Loading packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java +12 −0 Original line number Original line Diff line number Diff line Loading @@ -159,6 +159,15 @@ public class DozeMachine { mDozeHost = dozeHost; mDozeHost = dozeHost; } } /** * Clean ourselves up. */ public void destroy() { for (Part part : mParts) { part.destroy(); } } /** Initializes the set of {@link Part}s. Must be called exactly once after construction. */ /** Initializes the set of {@link Part}s. Must be called exactly once after construction. */ public void setParts(Part[] parts) { public void setParts(Part[] parts) { Preconditions.checkState(mParts == null); Preconditions.checkState(mParts == null); Loading Loading @@ -411,6 +420,9 @@ public class DozeMachine { /** Dump current state. For debugging only. */ /** Dump current state. For debugging only. */ default void dump(PrintWriter pw) {} default void dump(PrintWriter pw) {} /** Give the Part a chance to clean itself up. */ default void destroy() {} } } /** A wrapper interface for {@link android.service.dreams.DreamService} */ /** A wrapper interface for {@link android.service.dreams.DreamService} */ Loading packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java +11 −0 Original line number Original line Diff line number Diff line Loading @@ -163,6 +163,17 @@ public class DozeSensors { }); }); } } /** * Unregister any sensors. */ public void destroy() { // Unregisters everything, which is enough to allow gc. for (TriggerSensor triggerSensor : mSensors) { triggerSensor.setListening(false); } mProximitySensor.pause(); } /** /** * Temporarily disable some sensors to avoid turning on the device while the user is * Temporarily disable some sensors to avoid turning on the device while the user is * turning it off. * turning it off. Loading packages/SystemUI/src/com/android/systemui/doze/DozeService.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -65,6 +65,7 @@ public class DozeService extends DreamService mPluginManager.removePluginListener(this); mPluginManager.removePluginListener(this); } } super.onDestroy(); super.onDestroy(); mDozeMachine.destroy(); mDozeMachine = null; mDozeMachine = null; } } Loading packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -111,6 +111,11 @@ public class DozeTriggers implements DozeMachine.Part { mBroadcastDispatcher = broadcastDispatcher; mBroadcastDispatcher = broadcastDispatcher; } } @Override public void destroy() { mDozeSensors.destroy(); } private void onNotification(Runnable onPulseSuppressedListener) { private void onNotification(Runnable onPulseSuppressedListener) { if (DozeMachine.DEBUG) { if (DozeMachine.DEBUG) { Log.d(TAG, "requestNotificationPulse"); Log.d(TAG, "requestNotificationPulse"); Loading packages/SystemUI/tests/src/com/android/systemui/doze/DozeSensorsTest.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -158,6 +158,13 @@ public class DozeSensorsTest extends SysuiTestCase { verify(mTriggerSensor).setListening(eq(false)); verify(mTriggerSensor).setListening(eq(false)); } } @Test public void testDestroy() { mDozeSensors.destroy(); verify(mTriggerSensor).setListening(false); } private class TestableDozeSensors extends DozeSensors { private class TestableDozeSensors extends DozeSensors { TestableDozeSensors() { TestableDozeSensors() { Loading Loading
packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java +12 −0 Original line number Original line Diff line number Diff line Loading @@ -159,6 +159,15 @@ public class DozeMachine { mDozeHost = dozeHost; mDozeHost = dozeHost; } } /** * Clean ourselves up. */ public void destroy() { for (Part part : mParts) { part.destroy(); } } /** Initializes the set of {@link Part}s. Must be called exactly once after construction. */ /** Initializes the set of {@link Part}s. Must be called exactly once after construction. */ public void setParts(Part[] parts) { public void setParts(Part[] parts) { Preconditions.checkState(mParts == null); Preconditions.checkState(mParts == null); Loading Loading @@ -411,6 +420,9 @@ public class DozeMachine { /** Dump current state. For debugging only. */ /** Dump current state. For debugging only. */ default void dump(PrintWriter pw) {} default void dump(PrintWriter pw) {} /** Give the Part a chance to clean itself up. */ default void destroy() {} } } /** A wrapper interface for {@link android.service.dreams.DreamService} */ /** A wrapper interface for {@link android.service.dreams.DreamService} */ Loading
packages/SystemUI/src/com/android/systemui/doze/DozeSensors.java +11 −0 Original line number Original line Diff line number Diff line Loading @@ -163,6 +163,17 @@ public class DozeSensors { }); }); } } /** * Unregister any sensors. */ public void destroy() { // Unregisters everything, which is enough to allow gc. for (TriggerSensor triggerSensor : mSensors) { triggerSensor.setListening(false); } mProximitySensor.pause(); } /** /** * Temporarily disable some sensors to avoid turning on the device while the user is * Temporarily disable some sensors to avoid turning on the device while the user is * turning it off. * turning it off. Loading
packages/SystemUI/src/com/android/systemui/doze/DozeService.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -65,6 +65,7 @@ public class DozeService extends DreamService mPluginManager.removePluginListener(this); mPluginManager.removePluginListener(this); } } super.onDestroy(); super.onDestroy(); mDozeMachine.destroy(); mDozeMachine = null; mDozeMachine = null; } } Loading
packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -111,6 +111,11 @@ public class DozeTriggers implements DozeMachine.Part { mBroadcastDispatcher = broadcastDispatcher; mBroadcastDispatcher = broadcastDispatcher; } } @Override public void destroy() { mDozeSensors.destroy(); } private void onNotification(Runnable onPulseSuppressedListener) { private void onNotification(Runnable onPulseSuppressedListener) { if (DozeMachine.DEBUG) { if (DozeMachine.DEBUG) { Log.d(TAG, "requestNotificationPulse"); Log.d(TAG, "requestNotificationPulse"); Loading
packages/SystemUI/tests/src/com/android/systemui/doze/DozeSensorsTest.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -158,6 +158,13 @@ public class DozeSensorsTest extends SysuiTestCase { verify(mTriggerSensor).setListening(eq(false)); verify(mTriggerSensor).setListening(eq(false)); } } @Test public void testDestroy() { mDozeSensors.destroy(); verify(mTriggerSensor).setListening(false); } private class TestableDozeSensors extends DozeSensors { private class TestableDozeSensors extends DozeSensors { TestableDozeSensors() { TestableDozeSensors() { Loading