Merge "Add cleanup method to FalsingManager to prevent memory leaks." into qt-dev
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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,6 +93,9 @@ public class FalsingManagerProxy implements FalsingManager {
|
|||||||
public void setupFalsingManager(Context context) {
|
public void setupFalsingManager(Context context) {
|
||||||
boolean brightlineEnabled = DeviceConfig.getBoolean(
|
boolean brightlineEnabled = DeviceConfig.getBoolean(
|
||||||
DeviceConfig.NAMESPACE_SYSTEMUI, BRIGHTLINE_FALSING_MANAGER_ENABLED, true);
|
DeviceConfig.NAMESPACE_SYSTEMUI, BRIGHTLINE_FALSING_MANAGER_ENABLED, true);
|
||||||
|
if (mInternalFalsingManager != null) {
|
||||||
|
mInternalFalsingManager.cleanup();
|
||||||
|
}
|
||||||
if (!brightlineEnabled) {
|
if (!brightlineEnabled) {
|
||||||
mInternalFalsingManager = new FalsingManagerImpl(context);
|
mInternalFalsingManager = new FalsingManagerImpl(context);
|
||||||
} else {
|
} else {
|
||||||
@@ -290,4 +294,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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -309,6 +309,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