Merge "Handle volume keys to apps in Vr mode" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a58589bdc1
@@ -2872,4 +2872,8 @@
|
|||||||
|
|
||||||
<!-- Additional non-platform defined secure settings exposed to Instant Apps -->
|
<!-- Additional non-platform defined secure settings exposed to Instant Apps -->
|
||||||
<string-array name="config_allowedSecureInstantAppSettings"></string-array>
|
<string-array name="config_allowedSecureInstantAppSettings"></string-array>
|
||||||
|
|
||||||
|
<!-- Handle volume keys directly in Window Manager without passing them to the foreground app -->
|
||||||
|
<bool name="config_handleVolumeKeysInWindowManager">false</bool>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -3010,4 +3010,5 @@
|
|||||||
<java-symbol type="array" name="config_allowedSystemInstantAppSettings" />
|
<java-symbol type="array" name="config_allowedSystemInstantAppSettings" />
|
||||||
<java-symbol type="array" name="config_allowedSecureInstantAppSettings" />
|
<java-symbol type="array" name="config_allowedSecureInstantAppSettings" />
|
||||||
|
|
||||||
|
<java-symbol type="bool" name="config_handleVolumeKeysInWindowManager" />
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -584,6 +584,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
boolean mTranslucentDecorEnabled = true;
|
boolean mTranslucentDecorEnabled = true;
|
||||||
boolean mUseTvRouting;
|
boolean mUseTvRouting;
|
||||||
|
|
||||||
|
private boolean mHandleVolumeKeysInWM;
|
||||||
|
|
||||||
int mPointerLocationMode = 0; // guarded by mLock
|
int mPointerLocationMode = 0; // guarded by mLock
|
||||||
|
|
||||||
// The last window we were told about in focusChanged.
|
// The last window we were told about in focusChanged.
|
||||||
@@ -1938,6 +1940,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
|
|
||||||
mUseTvRouting = AudioSystem.getPlatformType(mContext) == AudioSystem.PLATFORM_TELEVISION;
|
mUseTvRouting = AudioSystem.getPlatformType(mContext) == AudioSystem.PLATFORM_TELEVISION;
|
||||||
|
|
||||||
|
mHandleVolumeKeysInWM = mContext.getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.config_handleVolumeKeysInWindowManager);
|
||||||
|
|
||||||
readConfigurationDependentBehaviors();
|
readConfigurationDependentBehaviors();
|
||||||
|
|
||||||
mAccessibilityManager = (AccessibilityManager) context.getSystemService(
|
mAccessibilityManager = (AccessibilityManager) context.getSystemService(
|
||||||
@@ -3544,11 +3549,18 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP
|
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP
|
||||||
|| keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
|
|| keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
|
||||||
|| keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) {
|
|| keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) {
|
||||||
if (mUseTvRouting) {
|
if (mUseTvRouting || mHandleVolumeKeysInWM) {
|
||||||
// On TVs volume keys never go to the foreground app.
|
// On TVs or when the configuration is enabled, volume keys never
|
||||||
|
// go to the foreground app.
|
||||||
dispatchDirectAudioEvent(event);
|
dispatchDirectAudioEvent(event);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the device is in Vr mode, drop the volume keys and don't
|
||||||
|
// forward it to the application/dispatch the audio event.
|
||||||
|
if (mPersistentVrModeEnabled) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_TAB && event.isMetaPressed()) {
|
} else if (keyCode == KeyEvent.KEYCODE_TAB && event.isMetaPressed()) {
|
||||||
// Pass through keyboard navigation keys.
|
// Pass through keyboard navigation keys.
|
||||||
return 0;
|
return 0;
|
||||||
@@ -5957,8 +5969,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mUseTvRouting) {
|
if (mUseTvRouting || mHandleVolumeKeysInWM) {
|
||||||
// On TVs, defer special key handlings to
|
// Defer special key handlings to
|
||||||
// {@link interceptKeyBeforeDispatching()}.
|
// {@link interceptKeyBeforeDispatching()}.
|
||||||
result |= ACTION_PASS_TO_USER;
|
result |= ACTION_PASS_TO_USER;
|
||||||
} else if ((result & ACTION_PASS_TO_USER) == 0) {
|
} else if ((result & ACTION_PASS_TO_USER) == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user