Loading services/core/java/com/android/server/policy/AccessibilityShortcutController.java +11 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; import android.content.pm.PackageManager; import android.database.ContentObserver; import android.media.AudioAttributes; import android.media.Ringtone; Loading Loading @@ -138,13 +139,18 @@ public class AccessibilityShortcutController { final int userId = ActivityManager.getCurrentUser(); final int dialogAlreadyShown = Settings.Secure.getIntForUser( cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, 0, userId); // Use USAGE_ASSISTANCE_ACCESSIBILITY for TVs to ensure that TVs play the ringtone as they // have less ways of providing feedback like vibration. final int audioAttributesUsage = hasFeatureLeanback() ? AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY : AudioAttributes.USAGE_NOTIFICATION_EVENT; // Play a notification tone final Ringtone tone = RingtoneManager.getRingtone(mContext, Settings.System.DEFAULT_NOTIFICATION_URI); if (tone != null) { tone.setAudioAttributes(new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT) .setUsage(audioAttributesUsage) .build()); tone.play(); } Loading Loading @@ -254,6 +260,10 @@ public class AccessibilityShortcutController { AccessibilityServiceInfo.FEEDBACK_ALL_MASK).contains(serviceInfo); } private boolean hasFeatureLeanback() { return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK); } // Class to allow mocking of static framework calls public static class FrameworkObjectProvider { public AccessibilityManager getAccessibilityManagerInstance(Context context) { Loading services/core/java/com/android/server/policy/PhoneWindowManager.java +13 −20 Original line number Diff line number Diff line Loading @@ -3401,11 +3401,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (!down) { cancelPreloadRecentApps(); if (mHasFeatureLeanback) { // Clear flags mAccessibilityTvKey2Pressed = down; } mHomePressed = false; if (mHomeConsumed) { mHomeConsumed = false; Loading Loading @@ -3460,13 +3455,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { preloadRecentApps(); } } else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) { if (mHasFeatureLeanback) { mAccessibilityTvKey2Pressed = down; if (interceptAccessibilityGestureTv()) { return -1; } } if (!keyguardOn) { handleLongPressOnHome(event.getDeviceId()); } Loading Loading @@ -3633,12 +3621,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { return 0; } else if (mHasFeatureLeanback && interceptBugreportGestureTv(keyCode, down)) { return -1; } else if (mHasFeatureLeanback && keyCode == KeyEvent.KEYCODE_DPAD_CENTER) { mAccessibilityTvKey1Pressed = down; if (interceptAccessibilityGestureTv()) { } else if (mHasFeatureLeanback && interceptAccessibilityGestureTv(keyCode, down)) { return -1; } } // Toggle Caps Lock on META-ALT. boolean actionTriggered = false; Loading Loading @@ -3858,20 +3843,28 @@ public class PhoneWindowManager implements WindowManagerPolicy { /** * TV only: recognizes a remote control gesture as Accessibility shortcut. * Shortcut: Long press (HOME + DPAD_CENTER) * Shortcut: Long press (BACK + DPAD_DOWN) */ private boolean interceptAccessibilityGestureTv() { private boolean interceptAccessibilityGestureTv(int keyCode, boolean down) { if (keyCode == KeyEvent.KEYCODE_BACK) { mAccessibilityTvKey1Pressed = down; } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { mAccessibilityTvKey2Pressed = down; } if (mAccessibilityTvKey1Pressed && mAccessibilityTvKey2Pressed) { if (!mAccessibilityTvScheduled) { mAccessibilityTvScheduled = true; Message msg = Message.obtain(mHandler, MSG_ACCESSIBILITY_TV); msg.setAsynchronous(true); mHandler.sendMessage(msg); mHandler.sendMessageDelayed(msg, ViewConfiguration.get(mContext).getAccessibilityShortcutKeyTimeout()); } } else if (mAccessibilityTvScheduled) { mHandler.removeMessages(MSG_ACCESSIBILITY_TV); mAccessibilityTvScheduled = false; } return mAccessibilityTvScheduled; } Loading Loading
services/core/java/com/android/server/policy/AccessibilityShortcutController.java +11 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; import android.content.pm.PackageManager; import android.database.ContentObserver; import android.media.AudioAttributes; import android.media.Ringtone; Loading Loading @@ -138,13 +139,18 @@ public class AccessibilityShortcutController { final int userId = ActivityManager.getCurrentUser(); final int dialogAlreadyShown = Settings.Secure.getIntForUser( cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, 0, userId); // Use USAGE_ASSISTANCE_ACCESSIBILITY for TVs to ensure that TVs play the ringtone as they // have less ways of providing feedback like vibration. final int audioAttributesUsage = hasFeatureLeanback() ? AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY : AudioAttributes.USAGE_NOTIFICATION_EVENT; // Play a notification tone final Ringtone tone = RingtoneManager.getRingtone(mContext, Settings.System.DEFAULT_NOTIFICATION_URI); if (tone != null) { tone.setAudioAttributes(new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT) .setUsage(audioAttributesUsage) .build()); tone.play(); } Loading Loading @@ -254,6 +260,10 @@ public class AccessibilityShortcutController { AccessibilityServiceInfo.FEEDBACK_ALL_MASK).contains(serviceInfo); } private boolean hasFeatureLeanback() { return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK); } // Class to allow mocking of static framework calls public static class FrameworkObjectProvider { public AccessibilityManager getAccessibilityManagerInstance(Context context) { Loading
services/core/java/com/android/server/policy/PhoneWindowManager.java +13 −20 Original line number Diff line number Diff line Loading @@ -3401,11 +3401,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (!down) { cancelPreloadRecentApps(); if (mHasFeatureLeanback) { // Clear flags mAccessibilityTvKey2Pressed = down; } mHomePressed = false; if (mHomeConsumed) { mHomeConsumed = false; Loading Loading @@ -3460,13 +3455,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { preloadRecentApps(); } } else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) { if (mHasFeatureLeanback) { mAccessibilityTvKey2Pressed = down; if (interceptAccessibilityGestureTv()) { return -1; } } if (!keyguardOn) { handleLongPressOnHome(event.getDeviceId()); } Loading Loading @@ -3633,12 +3621,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { return 0; } else if (mHasFeatureLeanback && interceptBugreportGestureTv(keyCode, down)) { return -1; } else if (mHasFeatureLeanback && keyCode == KeyEvent.KEYCODE_DPAD_CENTER) { mAccessibilityTvKey1Pressed = down; if (interceptAccessibilityGestureTv()) { } else if (mHasFeatureLeanback && interceptAccessibilityGestureTv(keyCode, down)) { return -1; } } // Toggle Caps Lock on META-ALT. boolean actionTriggered = false; Loading Loading @@ -3858,20 +3843,28 @@ public class PhoneWindowManager implements WindowManagerPolicy { /** * TV only: recognizes a remote control gesture as Accessibility shortcut. * Shortcut: Long press (HOME + DPAD_CENTER) * Shortcut: Long press (BACK + DPAD_DOWN) */ private boolean interceptAccessibilityGestureTv() { private boolean interceptAccessibilityGestureTv(int keyCode, boolean down) { if (keyCode == KeyEvent.KEYCODE_BACK) { mAccessibilityTvKey1Pressed = down; } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { mAccessibilityTvKey2Pressed = down; } if (mAccessibilityTvKey1Pressed && mAccessibilityTvKey2Pressed) { if (!mAccessibilityTvScheduled) { mAccessibilityTvScheduled = true; Message msg = Message.obtain(mHandler, MSG_ACCESSIBILITY_TV); msg.setAsynchronous(true); mHandler.sendMessage(msg); mHandler.sendMessageDelayed(msg, ViewConfiguration.get(mContext).getAccessibilityShortcutKeyTimeout()); } } else if (mAccessibilityTvScheduled) { mHandler.removeMessages(MSG_ACCESSIBILITY_TV); mAccessibilityTvScheduled = false; } return mAccessibilityTvScheduled; } Loading