Loading packages/SystemUI/src/com/android/systemui/onehanded/OneHandedUI.java +17 −6 Original line number Diff line number Diff line Loading @@ -29,7 +29,9 @@ import android.os.IBinder; import android.os.Looper; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; import android.provider.Settings; import android.util.Log; import androidx.annotation.VisibleForTesting; Loading @@ -56,6 +58,7 @@ public class OneHandedUI extends SystemUI implements CommandQueue.Callbacks, Dum private static final String TAG = "OneHandedUI"; private static final String ONE_HANDED_MODE_GESTURAL_OVERLAY = "com.android.internal.systemui.onehanded.gestural"; private static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode"; private final OneHandedManagerImpl mOneHandedManager; private final CommandQueue mCommandQueue; Loading Loading @@ -136,10 +139,18 @@ public class OneHandedUI extends SystemUI implements CommandQueue.Callbacks, Dum ScreenLifecycle screenLifecycle) { super(context); if (!SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false)) { Log.i(TAG, "Device config SUPPORT_ONE_HANDED_MODE off"); mCommandQueue = null; mOneHandedManager = null; mOverlayManager = null; mSettingUtil = null; mTimeoutHandler = null; mScreenLifecycle = null; return; } mCommandQueue = commandQueue; /* TODO(b/154290458) define a boolean system properties "support_one_handed_mode" boolean supportOneHanded = SystemProperties.getBoolean("support_one_handed_mode"); if (!supportOneHanded) return; */ mOneHandedManager = oneHandedManager; mSettingUtil = settingsUtil; mTimeoutHandler = OneHandedTimeoutHandler.get(); Loading @@ -150,9 +161,9 @@ public class OneHandedUI extends SystemUI implements CommandQueue.Callbacks, Dum @Override public void start() { /* TODO(b/154290458) define a boolean system properties "support_one_handed_mode" boolean supportOneHanded = SystemProperties.getBoolean("support_one_handed_mode"); if (!supportOneHanded) return; */ if (!SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false)) { return; } mCommandQueue.addCallback(this); setupKeyguardUpdateMonitor(); setupScreenObserver(); Loading packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedUITest.java +45 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static org.mockito.Mockito.any; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import android.os.SystemProperties; import android.provider.Settings; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; Loading @@ -42,6 +43,9 @@ import org.mockito.MockitoAnnotations; @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper public class OneHandedUITest extends OneHandedTestCase { private static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode"; boolean mIsSupportOneHandedMode; CommandQueue mCommandQueue; KeyguardUpdateMonitor mKeyguardUpdateMonitor; OneHandedUI mOneHandedUI; Loading @@ -58,6 +62,7 @@ public class OneHandedUITest extends OneHandedTestCase { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mIsSupportOneHandedMode = SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false); mCommandQueue = new CommandQueue(mContext); mScreenLifecycle = new ScreenLifecycle(); mOneHandedUI = new OneHandedUI(mContext, Loading @@ -72,6 +77,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void testStartOneHanded() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } mOneHandedUI.startOneHanded(); verify(mMockOneHandedManagerImpl, times(1)).startOneHanded(); Loading @@ -79,6 +88,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void testStopOneHanded() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } mOneHandedUI.stopOneHanded(); verify(mMockOneHandedManagerImpl, times(1)).stopOneHanded(); Loading @@ -86,6 +99,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void testRegisterSettingsObserver_forEnabled() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } final String key = Settings.Secure.ONE_HANDED_MODE_ENABLED; verify(mMockSettingsUtil, times(1)).registerSettingsKeyObserver(key, any(), any()); Loading @@ -93,6 +110,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void testRegisterSettingsObserver_forTimeout() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } final String key = Settings.Secure.ONE_HANDED_MODE_TIMEOUT; verify(mMockSettingsUtil, times(1)).registerSettingsKeyObserver(key, any(), any()); Loading @@ -100,6 +121,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void testRegisterSettingsObserver_forTapAppExit() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } final String key = Settings.Secure.TAPS_APP_TO_EXIT; verify(mMockSettingsUtil, times(1)).registerSettingsKeyObserver(key, any(), any()); Loading @@ -107,6 +132,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void tesSettingsObserver_updateTapAppToExit() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.TAPS_APP_TO_EXIT, 1); Loading @@ -115,6 +144,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void tesSettingsObserver_updateEnabled() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.ONE_HANDED_MODE_ENABLED, 1); Loading @@ -123,6 +156,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void tesSettingsObserver_updateTimeout() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.ONE_HANDED_MODE_TIMEOUT, OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_MEDIUM_IN_SECONDS); Loading @@ -134,6 +171,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Ignore("Clarifying do not receive callback") @Test public void testKeyguardBouncerShowing_shouldStopOneHanded() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } mKeyguardUpdateMonitor.sendKeyguardBouncerChanged(true); verify(mMockOneHandedManagerImpl, times(1)).stopOneHanded(); Loading @@ -141,6 +182,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void testScreenTurningOff_shouldStopOneHanded() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } mScreenLifecycle.dispatchScreenTurningOff(); verify(mMockOneHandedManagerImpl, times(1)).stopOneHanded(); Loading Loading
packages/SystemUI/src/com/android/systemui/onehanded/OneHandedUI.java +17 −6 Original line number Diff line number Diff line Loading @@ -29,7 +29,9 @@ import android.os.IBinder; import android.os.Looper; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; import android.provider.Settings; import android.util.Log; import androidx.annotation.VisibleForTesting; Loading @@ -56,6 +58,7 @@ public class OneHandedUI extends SystemUI implements CommandQueue.Callbacks, Dum private static final String TAG = "OneHandedUI"; private static final String ONE_HANDED_MODE_GESTURAL_OVERLAY = "com.android.internal.systemui.onehanded.gestural"; private static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode"; private final OneHandedManagerImpl mOneHandedManager; private final CommandQueue mCommandQueue; Loading Loading @@ -136,10 +139,18 @@ public class OneHandedUI extends SystemUI implements CommandQueue.Callbacks, Dum ScreenLifecycle screenLifecycle) { super(context); if (!SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false)) { Log.i(TAG, "Device config SUPPORT_ONE_HANDED_MODE off"); mCommandQueue = null; mOneHandedManager = null; mOverlayManager = null; mSettingUtil = null; mTimeoutHandler = null; mScreenLifecycle = null; return; } mCommandQueue = commandQueue; /* TODO(b/154290458) define a boolean system properties "support_one_handed_mode" boolean supportOneHanded = SystemProperties.getBoolean("support_one_handed_mode"); if (!supportOneHanded) return; */ mOneHandedManager = oneHandedManager; mSettingUtil = settingsUtil; mTimeoutHandler = OneHandedTimeoutHandler.get(); Loading @@ -150,9 +161,9 @@ public class OneHandedUI extends SystemUI implements CommandQueue.Callbacks, Dum @Override public void start() { /* TODO(b/154290458) define a boolean system properties "support_one_handed_mode" boolean supportOneHanded = SystemProperties.getBoolean("support_one_handed_mode"); if (!supportOneHanded) return; */ if (!SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false)) { return; } mCommandQueue.addCallback(this); setupKeyguardUpdateMonitor(); setupScreenObserver(); Loading
packages/SystemUI/tests/src/com/android/systemui/onehanded/OneHandedUITest.java +45 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static org.mockito.Mockito.any; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import android.os.SystemProperties; import android.provider.Settings; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; Loading @@ -42,6 +43,9 @@ import org.mockito.MockitoAnnotations; @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper public class OneHandedUITest extends OneHandedTestCase { private static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode"; boolean mIsSupportOneHandedMode; CommandQueue mCommandQueue; KeyguardUpdateMonitor mKeyguardUpdateMonitor; OneHandedUI mOneHandedUI; Loading @@ -58,6 +62,7 @@ public class OneHandedUITest extends OneHandedTestCase { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mIsSupportOneHandedMode = SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false); mCommandQueue = new CommandQueue(mContext); mScreenLifecycle = new ScreenLifecycle(); mOneHandedUI = new OneHandedUI(mContext, Loading @@ -72,6 +77,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void testStartOneHanded() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } mOneHandedUI.startOneHanded(); verify(mMockOneHandedManagerImpl, times(1)).startOneHanded(); Loading @@ -79,6 +88,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void testStopOneHanded() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } mOneHandedUI.stopOneHanded(); verify(mMockOneHandedManagerImpl, times(1)).stopOneHanded(); Loading @@ -86,6 +99,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void testRegisterSettingsObserver_forEnabled() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } final String key = Settings.Secure.ONE_HANDED_MODE_ENABLED; verify(mMockSettingsUtil, times(1)).registerSettingsKeyObserver(key, any(), any()); Loading @@ -93,6 +110,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void testRegisterSettingsObserver_forTimeout() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } final String key = Settings.Secure.ONE_HANDED_MODE_TIMEOUT; verify(mMockSettingsUtil, times(1)).registerSettingsKeyObserver(key, any(), any()); Loading @@ -100,6 +121,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void testRegisterSettingsObserver_forTapAppExit() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } final String key = Settings.Secure.TAPS_APP_TO_EXIT; verify(mMockSettingsUtil, times(1)).registerSettingsKeyObserver(key, any(), any()); Loading @@ -107,6 +132,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void tesSettingsObserver_updateTapAppToExit() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.TAPS_APP_TO_EXIT, 1); Loading @@ -115,6 +144,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void tesSettingsObserver_updateEnabled() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.ONE_HANDED_MODE_ENABLED, 1); Loading @@ -123,6 +156,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void tesSettingsObserver_updateTimeout() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.ONE_HANDED_MODE_TIMEOUT, OneHandedSettingsUtil.ONE_HANDED_TIMEOUT_MEDIUM_IN_SECONDS); Loading @@ -134,6 +171,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Ignore("Clarifying do not receive callback") @Test public void testKeyguardBouncerShowing_shouldStopOneHanded() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } mKeyguardUpdateMonitor.sendKeyguardBouncerChanged(true); verify(mMockOneHandedManagerImpl, times(1)).stopOneHanded(); Loading @@ -141,6 +182,10 @@ public class OneHandedUITest extends OneHandedTestCase { @Test public void testScreenTurningOff_shouldStopOneHanded() { // Bypass test if device not support one-handed mode if (!mIsSupportOneHandedMode) { return; } mScreenLifecycle.dispatchScreenTurningOff(); verify(mMockOneHandedManagerImpl, times(1)).stopOneHanded(); Loading