When the FalsingManager gets reloaded (due to plugins) it can
leak its listeners and callbacks. This change fixes that.
Bug:
136351609
Test: manual
Change-Id: I2b52d018d478dbcad4ecb7d8a5b361638d5c5877
Merged-In: I2b52d018d478dbcad4ecb7d8a5b361638d5c5877
*/
@ProvidesInterface(version = FalsingManager.VERSION)
public interface FalsingManager {
- int VERSION = 1;
+ int VERSION = 2;
void onSucccessfulUnlock();
void onTouchEvent(MotionEvent ev, int width, int height);
void dump(PrintWriter pw);
+
+ void cleanup();
}
.append("enabled=").append(isEnabled() ? 1 : 0)
.append(" mScreenOn=").append(mScreenOn ? 1 : 0)
.append(" mState=").append(StatusBarState.toShortString(mState))
+ .append(" mShowingAod=").append(mShowingAod ? 1 : 0)
.toString()
);
}
pw.println();
}
+ @Override
+ public void cleanup() {
+ mSensorManager.unregisterListener(mSensorEventListener);
+ mContext.getContentResolver().unregisterContentObserver(mSettingsObserver);
+ Dependency.get(StatusBarStateController.class).removeCallback(mStatusBarStateListener);
+ KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mKeyguardUpdateCallback);
+ }
+
public Uri reportRejectedTouch() {
if (mDataCollector.isEnabled()) {
return mDataCollector.reportRejectedTouch();
public void onPluginConnected(FalsingPlugin plugin, Context context) {
FalsingManager pluginFalsingManager = plugin.getFalsingManager(context);
if (pluginFalsingManager != null) {
+ mInternalFalsingManager.cleanup();
mInternalFalsingManager = pluginFalsingManager;
}
}
public void dump(PrintWriter pw) {
mInternalFalsingManager.dump(pw);
}
+
+ @Override
+ public void cleanup() {
+ mInternalFalsingManager.cleanup();
+ }
}
public void dump(PrintWriter printWriter) {
}
+ @Override
+ public void cleanup() {
+ unregisterSensors();
+ }
+
static void logDebug(String msg) {
logDebug(msg, null);
}