Skip to content

Commit 4c95059

Browse files
jaewan-githubgitbuildkicker
authored andcommitted
DO NOT MERGE Check caller for sending media key to global priority session
Prevent sending media key events from the non-system app to the global priority session through the MediaSessionManager.dispatchMediaKeyEvent(). Note that any app can use the API indirectly with the public API AudioManager.dispatchMediaKeyEvent(). Bug: 29833954 Tested: Installed malicious apps and confirmed that they don't work. Tested: Run CtsTelecomTestCases and CtsMediaTestCases Change-Id: I2a9e78196ba7455324e485f098f095d03b47ee15 (cherry picked from commit c282c4f)
1 parent 4f0dec2 commit 4c95059

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

services/core/java/com/android/server/media/MediaSessionService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import android.os.IBinder;
4848
import android.os.Message;
4949
import android.os.PowerManager;
50+
import android.os.Process;
5051
import android.os.RemoteException;
5152
import android.os.ResultReceiver;
5253
import android.os.ServiceManager;
@@ -760,6 +761,13 @@ public void dispatchMediaKeyEvent(KeyEvent keyEvent, boolean needWakeLock) {
760761
+ "setup is in progress.");
761762
return;
762763
}
764+
if (isGlobalPriorityActive() && uid != Process.SYSTEM_UID) {
765+
// Prevent dispatching key event through reflection while the global priority
766+
// session is active.
767+
Slog.i(TAG, "Only the system can dispatch media key event "
768+
+ "to the global priority session.");
769+
return;
770+
}
763771

764772
synchronized (mLock) {
765773
// If we don't have a media button receiver to fall back on

0 commit comments

Comments
 (0)