MediaSessionManager: Prevent volume keys from being ignored
When the volume key is pressed and the foreground activity doesn't handle the event, the foreground activity tells the MediaSessionService for adjusting system volume with its package name returned by Context#getPackageName(). However, if the foreground process runs on another application's process by specifying android:process in the AndroidManifest.xml. (e.g. ApnSettingsActivity in the Settings), its package name wouldn't match with the UID returned by the Binder.getCallingUid(). Because of the mismatch, the app ops check in the AudioService will fail and SecurityException will be thrown. This fixes the issue by two ways 1. Use Context#getOpPackageName() for sending package name. 2. Use system service's package name and UID when adjusting volume with the hardware volume key presses. Bug: 110525559 Test: Verified manually that the issue doesn't happen. And run all media CTS Change-Id: I8bba691a36cbe442212aab3f0b23c97533009052
Loading
Please register or sign in to comment