Loading packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java +4 −2 Original line number Diff line number Diff line Loading @@ -242,7 +242,8 @@ public class PipTouchHandler { this::updateMovementBounds, sysUiState); mTouchState = new PipTouchState(ViewConfiguration.get(context), mHandler, () -> mMenuController.showMenuWithDelay(MENU_STATE_FULL, mMotionHelper.getBounds(), true /* allowMenuTimeout */, willResizeMenu(), shouldShowResizeHandle())); true /* allowMenuTimeout */, willResizeMenu(), shouldShowResizeHandle()), menuController::hideMenu); Resources res = context.getResources(); mEnableDismissDragToEdge = res.getBoolean(R.bool.config_pipEnableDismissDragToEdge); Loading Loading @@ -708,6 +709,7 @@ public class PipTouchHandler { // on and changing MotionEvents into HoverEvents. // Let's not enable menu show/hide for a11y services. if (!mAccessibilityManager.isTouchExplorationEnabled()) { mTouchState.removeHoverExitTimeoutCallback(); mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(), false /* allowMenuTimeout */, false /* willResizeMenu */, shouldShowResizeHandle()); Loading @@ -725,7 +727,7 @@ public class PipTouchHandler { // Let's not enable menu show/hide for a11y services. if (!mAccessibilityManager.isTouchExplorationEnabled()) { mHideMenuAfterShown = true; mMenuController.hideMenu(); mTouchState.scheduleHoverExitTimeoutCallback(); } if (!shouldDeliverToMenu && mSendingHoverAccessibilityEvents) { sendAccessibilityHoverEvent(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT); Loading packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchState.java +17 −1 Original line number Diff line number Diff line Loading @@ -36,10 +36,12 @@ public class PipTouchState { @VisibleForTesting static final long DOUBLE_TAP_TIMEOUT = 200; static final long HOVER_EXIT_TIMEOUT = 50; private final Handler mHandler; private final ViewConfiguration mViewConfig; private final Runnable mDoubleTapTimeoutCallback; private final Runnable mHoverExitTimeoutCallback; private VelocityTracker mVelocityTracker; private long mDownTouchTime = 0; Loading @@ -64,10 +66,11 @@ public class PipTouchState { private int mActivePointerId; public PipTouchState(ViewConfiguration viewConfig, Handler handler, Runnable doubleTapTimeoutCallback) { Runnable doubleTapTimeoutCallback, Runnable hoverExitTimeoutCallback) { mViewConfig = viewConfig; mHandler = handler; mDoubleTapTimeoutCallback = doubleTapTimeoutCallback; mHoverExitTimeoutCallback = hoverExitTimeoutCallback; } /** Loading Loading @@ -197,6 +200,10 @@ public class PipTouchState { recycleVelocityTracker(); break; } case MotionEvent.ACTION_BUTTON_PRESS: { removeHoverExitTimeoutCallback(); break; } } } Loading Loading @@ -326,6 +333,15 @@ public class PipTouchState { mHandler.removeCallbacks(mDoubleTapTimeoutCallback); } void scheduleHoverExitTimeoutCallback() { mHandler.removeCallbacks(mHoverExitTimeoutCallback); mHandler.postDelayed(mHoverExitTimeoutCallback, HOVER_EXIT_TIMEOUT); } void removeHoverExitTimeoutCallback() { mHandler.removeCallbacks(mHoverExitTimeoutCallback); } void addMovementToVelocityTracker(MotionEvent event) { if (mVelocityTracker == null) { return; Loading packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java +21 −5 Original line number Diff line number Diff line Loading @@ -265,9 +265,13 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic private void createDialog() { final boolean isDeviceManaged = mSecurityController.isDeviceManaged(); boolean isProfileOwnerOfOrganizationOwnedDevice = mSecurityController.isProfileOwnerOfOrganizationOwnedDevice(); final boolean hasWorkProfile = mSecurityController.hasWorkProfile(); final CharSequence deviceOwnerOrganization = mSecurityController.getDeviceOwnerOrganizationName(); final CharSequence workProfileOrganizationName = mSecurityController.getWorkProfileOrganizationName(); final boolean hasCACerts = mSecurityController.hasCACertInCurrentUser(); final boolean hasCACertsInWorkProfile = mSecurityController.hasCACertInWorkProfile(); final boolean isNetworkLoggingEnabled = mSecurityController.isNetworkLoggingEnabled(); Loading @@ -284,7 +288,8 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic // device management section CharSequence managementMessage = getManagementMessage(isDeviceManaged, deviceOwnerOrganization); deviceOwnerOrganization, isProfileOwnerOfOrganizationOwnedDevice, workProfileOrganizationName); if (managementMessage == null) { dialogView.findViewById(R.id.device_management_disclosures).setVisibility(View.GONE); } else { Loading @@ -292,8 +297,12 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic TextView deviceManagementWarning = (TextView) dialogView.findViewById(R.id.device_management_warning); deviceManagementWarning.setText(managementMessage); // Don't show the policies button for profile owner of org owned device, because there // is no policies settings screen for it if (!isProfileOwnerOfOrganizationOwnedDevice) { mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getSettingsButton(), this); } } // ca certificate section CharSequence caCertsMessage = getCaCertsMessage(isDeviceManaged, hasCACerts, Loading Loading @@ -382,11 +391,18 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic } protected CharSequence getManagementMessage(boolean isDeviceManaged, CharSequence organizationName) { if (!isDeviceManaged) return null; if (organizationName != null) CharSequence organizationName, boolean isProfileOwnerOfOrganizationOwnedDevice, CharSequence workProfileOrganizationName) { if (!isDeviceManaged && !isProfileOwnerOfOrganizationOwnedDevice) { return null; } if (isDeviceManaged && organizationName != null) { return mContext.getString( R.string.monitoring_description_named_management, organizationName); } else if (isProfileOwnerOfOrganizationOwnedDevice && workProfileOrganizationName != null) { return mContext.getString( R.string.monitoring_description_named_management, workProfileOrganizationName); } return mContext.getString(R.string.monitoring_description_management); } Loading packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipTouchStateTest.java +34 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.pip.phone; import static android.view.MotionEvent.ACTION_BUTTON_PRESS; import static android.view.MotionEvent.ACTION_DOWN; import static android.view.MotionEvent.ACTION_MOVE; import static android.view.MotionEvent.ACTION_UP; Loading Loading @@ -49,13 +50,17 @@ public class PipTouchStateTest extends SysuiTestCase { private PipTouchState mTouchState; private CountDownLatch mDoubleTapCallbackTriggeredLatch; private CountDownLatch mHoverExitCallbackTriggeredLatch; @Before public void setUp() throws Exception { mDoubleTapCallbackTriggeredLatch = new CountDownLatch(1); mHoverExitCallbackTriggeredLatch = new CountDownLatch(1); mTouchState = new PipTouchState(ViewConfiguration.get(getContext()), Handler.createAsync(Looper.myLooper()), () -> { mDoubleTapCallbackTriggeredLatch.countDown(); }, () -> { mHoverExitCallbackTriggeredLatch.countDown(); }); assertFalse(mTouchState.isDoubleTap()); assertFalse(mTouchState.isWaitingForDoubleTap()); Loading Loading @@ -120,6 +125,35 @@ public class PipTouchStateTest extends SysuiTestCase { assertTrue(mTouchState.getDoubleTapTimeoutCallbackDelay() == -1); } @Test public void testHoverExitTimeout_timeoutCallbackCalled() throws Exception { mTouchState.scheduleHoverExitTimeoutCallback(); // TODO: Remove this sleep. Its only being added because it speeds up this test a bit. Thread.sleep(50); TestableLooper.get(this).processAllMessages(); assertTrue(mHoverExitCallbackTriggeredLatch.getCount() == 0); } @Test public void testHoverExitTimeout_timeoutCallbackNotCalled() throws Exception { mTouchState.scheduleHoverExitTimeoutCallback(); TestableLooper.get(this).processAllMessages(); assertTrue(mHoverExitCallbackTriggeredLatch.getCount() == 1); } @Test public void testHoverExitTimeout_timeoutCallbackNotCalled_ifButtonPress() throws Exception { mTouchState.scheduleHoverExitTimeoutCallback(); mTouchState.onTouchEvent(createMotionEvent(ACTION_BUTTON_PRESS, SystemClock.uptimeMillis(), 0, 0)); // TODO: Remove this sleep. Its only being added because it speeds up this test a bit. Thread.sleep(50); TestableLooper.get(this).processAllMessages(); assertTrue(mHoverExitCallbackTriggeredLatch.getCount() == 1); } private MotionEvent createMotionEvent(int action, long eventTime, float x, float y) { return MotionEvent.obtain(0, eventTime, action, x, y, 0); } Loading packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java +37 −4 Original line number Diff line number Diff line Loading @@ -367,13 +367,46 @@ public class QSSecurityFooterTest extends SysuiTestCase { } @Test public void testGetManagementMessage() { assertEquals(null, mFooter.getManagementMessage(false, MANAGING_ORGANIZATION)); public void testGetManagementMessage_noManagement() { assertEquals(null, mFooter.getManagementMessage( /* isDeviceManaged= */ false, MANAGING_ORGANIZATION, /* isProfileOwnerOfOrganizationOwnedDevice= */ false, MANAGING_ORGANIZATION)); } @Test public void testGetManagementMessage_deviceOwner() { assertEquals(mContext.getString(R.string.monitoring_description_named_management, MANAGING_ORGANIZATION), mFooter.getManagementMessage( /* isDeviceManaged= */ true, MANAGING_ORGANIZATION, /* isProfileOwnerOfOrganizationOwnedDevice= */ false, /* workProfileOrganizationName= */ null)); assertEquals(mContext.getString(R.string.monitoring_description_management), mFooter.getManagementMessage( /* isDeviceManaged= */ true, /* organizationName= */ null, /* isProfileOwnerOfOrganizationOwnedDevice= */ false, /* workProfileOrganizationName= */ null)); } @Test public void testGetManagementMessage_profileOwnerOfOrganizationOwnedDevice() { assertEquals(mContext.getString(R.string.monitoring_description_named_management, MANAGING_ORGANIZATION), mFooter.getManagementMessage(true, MANAGING_ORGANIZATION)); mFooter.getManagementMessage( /* isDeviceManaged= */ false, /* organizationName= */ null, /* isProfileOwnerOfOrganizationOwnedDevice= */ true, MANAGING_ORGANIZATION)); assertEquals(mContext.getString(R.string.monitoring_description_management), mFooter.getManagementMessage(true, null)); mFooter.getManagementMessage( /* isDeviceManaged= */ false, /* organizationName= */ null, /* isProfileOwnerOfOrganizationOwnedDevice= */ true, /* workProfileOrganizationName= */ null)); } @Test Loading Loading
packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java +4 −2 Original line number Diff line number Diff line Loading @@ -242,7 +242,8 @@ public class PipTouchHandler { this::updateMovementBounds, sysUiState); mTouchState = new PipTouchState(ViewConfiguration.get(context), mHandler, () -> mMenuController.showMenuWithDelay(MENU_STATE_FULL, mMotionHelper.getBounds(), true /* allowMenuTimeout */, willResizeMenu(), shouldShowResizeHandle())); true /* allowMenuTimeout */, willResizeMenu(), shouldShowResizeHandle()), menuController::hideMenu); Resources res = context.getResources(); mEnableDismissDragToEdge = res.getBoolean(R.bool.config_pipEnableDismissDragToEdge); Loading Loading @@ -708,6 +709,7 @@ public class PipTouchHandler { // on and changing MotionEvents into HoverEvents. // Let's not enable menu show/hide for a11y services. if (!mAccessibilityManager.isTouchExplorationEnabled()) { mTouchState.removeHoverExitTimeoutCallback(); mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(), false /* allowMenuTimeout */, false /* willResizeMenu */, shouldShowResizeHandle()); Loading @@ -725,7 +727,7 @@ public class PipTouchHandler { // Let's not enable menu show/hide for a11y services. if (!mAccessibilityManager.isTouchExplorationEnabled()) { mHideMenuAfterShown = true; mMenuController.hideMenu(); mTouchState.scheduleHoverExitTimeoutCallback(); } if (!shouldDeliverToMenu && mSendingHoverAccessibilityEvents) { sendAccessibilityHoverEvent(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT); Loading
packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchState.java +17 −1 Original line number Diff line number Diff line Loading @@ -36,10 +36,12 @@ public class PipTouchState { @VisibleForTesting static final long DOUBLE_TAP_TIMEOUT = 200; static final long HOVER_EXIT_TIMEOUT = 50; private final Handler mHandler; private final ViewConfiguration mViewConfig; private final Runnable mDoubleTapTimeoutCallback; private final Runnable mHoverExitTimeoutCallback; private VelocityTracker mVelocityTracker; private long mDownTouchTime = 0; Loading @@ -64,10 +66,11 @@ public class PipTouchState { private int mActivePointerId; public PipTouchState(ViewConfiguration viewConfig, Handler handler, Runnable doubleTapTimeoutCallback) { Runnable doubleTapTimeoutCallback, Runnable hoverExitTimeoutCallback) { mViewConfig = viewConfig; mHandler = handler; mDoubleTapTimeoutCallback = doubleTapTimeoutCallback; mHoverExitTimeoutCallback = hoverExitTimeoutCallback; } /** Loading Loading @@ -197,6 +200,10 @@ public class PipTouchState { recycleVelocityTracker(); break; } case MotionEvent.ACTION_BUTTON_PRESS: { removeHoverExitTimeoutCallback(); break; } } } Loading Loading @@ -326,6 +333,15 @@ public class PipTouchState { mHandler.removeCallbacks(mDoubleTapTimeoutCallback); } void scheduleHoverExitTimeoutCallback() { mHandler.removeCallbacks(mHoverExitTimeoutCallback); mHandler.postDelayed(mHoverExitTimeoutCallback, HOVER_EXIT_TIMEOUT); } void removeHoverExitTimeoutCallback() { mHandler.removeCallbacks(mHoverExitTimeoutCallback); } void addMovementToVelocityTracker(MotionEvent event) { if (mVelocityTracker == null) { return; Loading
packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java +21 −5 Original line number Diff line number Diff line Loading @@ -265,9 +265,13 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic private void createDialog() { final boolean isDeviceManaged = mSecurityController.isDeviceManaged(); boolean isProfileOwnerOfOrganizationOwnedDevice = mSecurityController.isProfileOwnerOfOrganizationOwnedDevice(); final boolean hasWorkProfile = mSecurityController.hasWorkProfile(); final CharSequence deviceOwnerOrganization = mSecurityController.getDeviceOwnerOrganizationName(); final CharSequence workProfileOrganizationName = mSecurityController.getWorkProfileOrganizationName(); final boolean hasCACerts = mSecurityController.hasCACertInCurrentUser(); final boolean hasCACertsInWorkProfile = mSecurityController.hasCACertInWorkProfile(); final boolean isNetworkLoggingEnabled = mSecurityController.isNetworkLoggingEnabled(); Loading @@ -284,7 +288,8 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic // device management section CharSequence managementMessage = getManagementMessage(isDeviceManaged, deviceOwnerOrganization); deviceOwnerOrganization, isProfileOwnerOfOrganizationOwnedDevice, workProfileOrganizationName); if (managementMessage == null) { dialogView.findViewById(R.id.device_management_disclosures).setVisibility(View.GONE); } else { Loading @@ -292,8 +297,12 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic TextView deviceManagementWarning = (TextView) dialogView.findViewById(R.id.device_management_warning); deviceManagementWarning.setText(managementMessage); // Don't show the policies button for profile owner of org owned device, because there // is no policies settings screen for it if (!isProfileOwnerOfOrganizationOwnedDevice) { mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getSettingsButton(), this); } } // ca certificate section CharSequence caCertsMessage = getCaCertsMessage(isDeviceManaged, hasCACerts, Loading Loading @@ -382,11 +391,18 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic } protected CharSequence getManagementMessage(boolean isDeviceManaged, CharSequence organizationName) { if (!isDeviceManaged) return null; if (organizationName != null) CharSequence organizationName, boolean isProfileOwnerOfOrganizationOwnedDevice, CharSequence workProfileOrganizationName) { if (!isDeviceManaged && !isProfileOwnerOfOrganizationOwnedDevice) { return null; } if (isDeviceManaged && organizationName != null) { return mContext.getString( R.string.monitoring_description_named_management, organizationName); } else if (isProfileOwnerOfOrganizationOwnedDevice && workProfileOrganizationName != null) { return mContext.getString( R.string.monitoring_description_named_management, workProfileOrganizationName); } return mContext.getString(R.string.monitoring_description_management); } Loading
packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipTouchStateTest.java +34 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.pip.phone; import static android.view.MotionEvent.ACTION_BUTTON_PRESS; import static android.view.MotionEvent.ACTION_DOWN; import static android.view.MotionEvent.ACTION_MOVE; import static android.view.MotionEvent.ACTION_UP; Loading Loading @@ -49,13 +50,17 @@ public class PipTouchStateTest extends SysuiTestCase { private PipTouchState mTouchState; private CountDownLatch mDoubleTapCallbackTriggeredLatch; private CountDownLatch mHoverExitCallbackTriggeredLatch; @Before public void setUp() throws Exception { mDoubleTapCallbackTriggeredLatch = new CountDownLatch(1); mHoverExitCallbackTriggeredLatch = new CountDownLatch(1); mTouchState = new PipTouchState(ViewConfiguration.get(getContext()), Handler.createAsync(Looper.myLooper()), () -> { mDoubleTapCallbackTriggeredLatch.countDown(); }, () -> { mHoverExitCallbackTriggeredLatch.countDown(); }); assertFalse(mTouchState.isDoubleTap()); assertFalse(mTouchState.isWaitingForDoubleTap()); Loading Loading @@ -120,6 +125,35 @@ public class PipTouchStateTest extends SysuiTestCase { assertTrue(mTouchState.getDoubleTapTimeoutCallbackDelay() == -1); } @Test public void testHoverExitTimeout_timeoutCallbackCalled() throws Exception { mTouchState.scheduleHoverExitTimeoutCallback(); // TODO: Remove this sleep. Its only being added because it speeds up this test a bit. Thread.sleep(50); TestableLooper.get(this).processAllMessages(); assertTrue(mHoverExitCallbackTriggeredLatch.getCount() == 0); } @Test public void testHoverExitTimeout_timeoutCallbackNotCalled() throws Exception { mTouchState.scheduleHoverExitTimeoutCallback(); TestableLooper.get(this).processAllMessages(); assertTrue(mHoverExitCallbackTriggeredLatch.getCount() == 1); } @Test public void testHoverExitTimeout_timeoutCallbackNotCalled_ifButtonPress() throws Exception { mTouchState.scheduleHoverExitTimeoutCallback(); mTouchState.onTouchEvent(createMotionEvent(ACTION_BUTTON_PRESS, SystemClock.uptimeMillis(), 0, 0)); // TODO: Remove this sleep. Its only being added because it speeds up this test a bit. Thread.sleep(50); TestableLooper.get(this).processAllMessages(); assertTrue(mHoverExitCallbackTriggeredLatch.getCount() == 1); } private MotionEvent createMotionEvent(int action, long eventTime, float x, float y) { return MotionEvent.obtain(0, eventTime, action, x, y, 0); } Loading
packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java +37 −4 Original line number Diff line number Diff line Loading @@ -367,13 +367,46 @@ public class QSSecurityFooterTest extends SysuiTestCase { } @Test public void testGetManagementMessage() { assertEquals(null, mFooter.getManagementMessage(false, MANAGING_ORGANIZATION)); public void testGetManagementMessage_noManagement() { assertEquals(null, mFooter.getManagementMessage( /* isDeviceManaged= */ false, MANAGING_ORGANIZATION, /* isProfileOwnerOfOrganizationOwnedDevice= */ false, MANAGING_ORGANIZATION)); } @Test public void testGetManagementMessage_deviceOwner() { assertEquals(mContext.getString(R.string.monitoring_description_named_management, MANAGING_ORGANIZATION), mFooter.getManagementMessage( /* isDeviceManaged= */ true, MANAGING_ORGANIZATION, /* isProfileOwnerOfOrganizationOwnedDevice= */ false, /* workProfileOrganizationName= */ null)); assertEquals(mContext.getString(R.string.monitoring_description_management), mFooter.getManagementMessage( /* isDeviceManaged= */ true, /* organizationName= */ null, /* isProfileOwnerOfOrganizationOwnedDevice= */ false, /* workProfileOrganizationName= */ null)); } @Test public void testGetManagementMessage_profileOwnerOfOrganizationOwnedDevice() { assertEquals(mContext.getString(R.string.monitoring_description_named_management, MANAGING_ORGANIZATION), mFooter.getManagementMessage(true, MANAGING_ORGANIZATION)); mFooter.getManagementMessage( /* isDeviceManaged= */ false, /* organizationName= */ null, /* isProfileOwnerOfOrganizationOwnedDevice= */ true, MANAGING_ORGANIZATION)); assertEquals(mContext.getString(R.string.monitoring_description_management), mFooter.getManagementMessage(true, null)); mFooter.getManagementMessage( /* isDeviceManaged= */ false, /* organizationName= */ null, /* isProfileOwnerOfOrganizationOwnedDevice= */ true, /* workProfileOrganizationName= */ null)); } @Test Loading