Add cleanup method to FalsingManager to prevent memory leaks.
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
This commit is contained in:
@@ -30,7 +30,7 @@ import java.io.PrintWriter;
|
|||||||
*/
|
*/
|
||||||
@ProvidesInterface(version = FalsingManager.VERSION)
|
@ProvidesInterface(version = FalsingManager.VERSION)
|
||||||
public interface FalsingManager {
|
public interface FalsingManager {
|
||||||
int VERSION = 1;
|
int VERSION = 2;
|
||||||
|
|
||||||
void onSucccessfulUnlock();
|
void onSucccessfulUnlock();
|
||||||
|
|
||||||
@@ -103,4 +103,6 @@ public interface FalsingManager {
|
|||||||
void onTouchEvent(MotionEvent ev, int width, int height);
|
void onTouchEvent(MotionEvent ev, int width, int height);
|
||||||
|
|
||||||
void dump(PrintWriter pw);
|
void dump(PrintWriter pw);
|
||||||
|
|
||||||
|
void cleanup();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,4 +239,8 @@ public class FalsingManagerFake implements FalsingManager {
|
|||||||
public void dump(PrintWriter pw) {
|
public void dump(PrintWriter pw) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cleanup() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ public class FalsingManagerImpl implements FalsingManager {
|
|||||||
.append("enabled=").append(isEnabled() ? 1 : 0)
|
.append("enabled=").append(isEnabled() ? 1 : 0)
|
||||||
.append(" mScreenOn=").append(mScreenOn ? 1 : 0)
|
.append(" mScreenOn=").append(mScreenOn ? 1 : 0)
|
||||||
.append(" mState=").append(StatusBarState.toShortString(mState))
|
.append(" mState=").append(StatusBarState.toShortString(mState))
|
||||||
|
.append(" mShowingAod=").append(mShowingAod ? 1 : 0)
|
||||||
.toString()
|
.toString()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -550,6 +551,14 @@ public class FalsingManagerImpl implements FalsingManager {
|
|||||||
pw.println();
|
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() {
|
public Uri reportRejectedTouch() {
|
||||||
if (mDataCollector.isEnabled()) {
|
if (mDataCollector.isEnabled()) {
|
||||||
return mDataCollector.reportRejectedTouch();
|
return mDataCollector.reportRejectedTouch();
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public class FalsingManagerProxy implements FalsingManager {
|
|||||||
public void onPluginConnected(FalsingPlugin plugin, Context context) {
|
public void onPluginConnected(FalsingPlugin plugin, Context context) {
|
||||||
FalsingManager pluginFalsingManager = plugin.getFalsingManager(context);
|
FalsingManager pluginFalsingManager = plugin.getFalsingManager(context);
|
||||||
if (pluginFalsingManager != null) {
|
if (pluginFalsingManager != null) {
|
||||||
|
mInternalFalsingManager.cleanup();
|
||||||
mInternalFalsingManager = pluginFalsingManager;
|
mInternalFalsingManager = pluginFalsingManager;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -290,4 +291,9 @@ public class FalsingManagerProxy implements FalsingManager {
|
|||||||
public void dump(PrintWriter pw) {
|
public void dump(PrintWriter pw) {
|
||||||
mInternalFalsingManager.dump(pw);
|
mInternalFalsingManager.dump(pw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cleanup() {
|
||||||
|
mInternalFalsingManager.cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -324,6 +324,11 @@ public class BrightLineFalsingManager implements FalsingManager {
|
|||||||
public void dump(PrintWriter printWriter) {
|
public void dump(PrintWriter printWriter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cleanup() {
|
||||||
|
unregisterSensors();
|
||||||
|
}
|
||||||
|
|
||||||
static void logDebug(String msg) {
|
static void logDebug(String msg) {
|
||||||
logDebug(msg, null);
|
logDebug(msg, null);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user