Loading packages/SystemUI/src/com/android/systemui/appops/AppOpsControllerImpl.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -100,6 +100,13 @@ public class AppOpsControllerImpl implements AppOpsController, } else { } else { mAppOps.stopWatchingActive(this); mAppOps.stopWatchingActive(this); mAppOps.stopWatchingNoted(this); mAppOps.stopWatchingNoted(this); mBGHandler.removeCallbacksAndMessages(null); // null removes all synchronized (mActiveItems) { mActiveItems.clear(); } synchronized (mNotedItems) { mNotedItems.clear(); } } } } } Loading packages/SystemUI/tests/src/com/android/systemui/appops/AppOpsControllerTest.java +20 −0 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,10 @@ package com.android.systemui.appops; package com.android.systemui.appops; import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt; Loading Loading @@ -189,4 +192,21 @@ public class AppOpsControllerTest extends SysuiTestCase { AppOpsManager.MODE_ALLOWED); AppOpsManager.MODE_ALLOWED); verify(mMockHandler).scheduleRemoval(any(AppOpItem.class), anyLong()); verify(mMockHandler).scheduleRemoval(any(AppOpItem.class), anyLong()); } } @Test public void noItemsAfterStopListening() { mController.setBGHandler(mMockHandler); mController.setListening(true); mController.onOpActiveChanged(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME, true); mController.onOpNoted(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME, AppOpsManager.MODE_ALLOWED); assertFalse(mController.getActiveAppOps().isEmpty()); mController.setListening(false); verify(mMockHandler).removeCallbacksAndMessages(null); assertTrue(mController.getActiveAppOps().isEmpty()); } } } Loading
packages/SystemUI/src/com/android/systemui/appops/AppOpsControllerImpl.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -100,6 +100,13 @@ public class AppOpsControllerImpl implements AppOpsController, } else { } else { mAppOps.stopWatchingActive(this); mAppOps.stopWatchingActive(this); mAppOps.stopWatchingNoted(this); mAppOps.stopWatchingNoted(this); mBGHandler.removeCallbacksAndMessages(null); // null removes all synchronized (mActiveItems) { mActiveItems.clear(); } synchronized (mNotedItems) { mNotedItems.clear(); } } } } } Loading
packages/SystemUI/tests/src/com/android/systemui/appops/AppOpsControllerTest.java +20 −0 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,10 @@ package com.android.systemui.appops; package com.android.systemui.appops; import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt; Loading Loading @@ -189,4 +192,21 @@ public class AppOpsControllerTest extends SysuiTestCase { AppOpsManager.MODE_ALLOWED); AppOpsManager.MODE_ALLOWED); verify(mMockHandler).scheduleRemoval(any(AppOpItem.class), anyLong()); verify(mMockHandler).scheduleRemoval(any(AppOpItem.class), anyLong()); } } @Test public void noItemsAfterStopListening() { mController.setBGHandler(mMockHandler); mController.setListening(true); mController.onOpActiveChanged(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME, true); mController.onOpNoted(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME, AppOpsManager.MODE_ALLOWED); assertFalse(mController.getActiveAppOps().isEmpty()); mController.setListening(false); verify(mMockHandler).removeCallbacksAndMessages(null); assertTrue(mController.getActiveAppOps().isEmpty()); } } }