Skip to content

Commit f702e7c

Browse files
jmtriviandi34
authored andcommitted
Do not persist and restore the media button event receiver
Do not persist the media button event receiver. Do not restore the media button event receiver on behalf of the application that registered. Prevents reported vulnerability. Bug 15428797 Change-Id: I7ca3e7fccb165c55b23f471c00e0ed77436f7dc1
1 parent f225754 commit f702e7c

File tree

2 files changed

+0
-59
lines changed

2 files changed

+0
-59
lines changed

media/java/android/media/AudioService.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,6 @@ private void readPersistedSettings() {
745745
// Broadcast vibrate settings
746746
broadcastVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);
747747
broadcastVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION);
748-
749-
// Restore the default media button receiver from the system settings
750-
mMediaFocusControl.restoreMediaButtonReceiver();
751748
}
752749

753750
private int rescaleIndex(int index, int srcStream, int dstStream) {

media/java/android/media/MediaFocusControl.java

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@ private boolean isComponentInStringArray(ComponentName comp, String[] enabledArr
318318
//==========================================================================================
319319

320320
// event handler messages
321-
private static final int MSG_PERSIST_MEDIABUTTONRECEIVER = 0;
322321
private static final int MSG_RCDISPLAY_CLEAR = 1;
323322
private static final int MSG_RCDISPLAY_UPDATE = 2;
324323
private static final int MSG_REEVALUATE_REMOTE = 3;
@@ -359,9 +358,6 @@ private class MediaEventHandler extends Handler {
359358
@Override
360359
public void handleMessage(Message msg) {
361360
switch(msg.what) {
362-
case MSG_PERSIST_MEDIABUTTONRECEIVER:
363-
onHandlePersistMediaButtonReceiver( (ComponentName) msg.obj );
364-
break;
365361

366362
case MSG_RCDISPLAY_CLEAR:
367363
onRcDisplayClear();
@@ -1427,47 +1423,7 @@ private void cleanupMediaButtonReceiverForPackage(String packageName, boolean re
14271423
}
14281424
}
14291425
}
1430-
if (mRCStack.empty()) {
1431-
// no saved media button receiver
1432-
mEventHandler.sendMessage(
1433-
mEventHandler.obtainMessage(MSG_PERSIST_MEDIABUTTONRECEIVER, 0, 0,
1434-
null));
1435-
} else if (oldTop != mRCStack.peek()) {
1436-
// the top of the stack has changed, save it in the system settings
1437-
// by posting a message to persist it; only do this however if it has
1438-
// a concrete component name (is not a transient registration)
1439-
RemoteControlStackEntry rcse = mRCStack.peek();
1440-
if (rcse.mReceiverComponent != null) {
1441-
mEventHandler.sendMessage(
1442-
mEventHandler.obtainMessage(MSG_PERSIST_MEDIABUTTONRECEIVER, 0, 0,
1443-
rcse.mReceiverComponent));
1444-
}
1445-
}
1446-
}
1447-
}
1448-
}
1449-
1450-
/**
1451-
* Helper function:
1452-
* Restore remote control receiver from the system settings.
1453-
*/
1454-
protected void restoreMediaButtonReceiver() {
1455-
String receiverName = Settings.System.getStringForUser(mContentResolver,
1456-
Settings.System.MEDIA_BUTTON_RECEIVER, UserHandle.USER_CURRENT);
1457-
if ((null != receiverName) && !receiverName.isEmpty()) {
1458-
ComponentName eventReceiver = ComponentName.unflattenFromString(receiverName);
1459-
if (eventReceiver == null) {
1460-
// an invalid name was persisted
1461-
return;
14621426
}
1463-
// construct a PendingIntent targeted to the restored component name
1464-
// for the media button and register it
1465-
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
1466-
// the associated intent will be handled by the component being registered
1467-
mediaButtonIntent.setComponent(eventReceiver);
1468-
PendingIntent pi = PendingIntent.getBroadcast(mContext,
1469-
0/*requestCode, ignored*/, mediaButtonIntent, 0/*flags*/);
1470-
registerMediaButtonIntent(pi, eventReceiver, null);
14711427
}
14721428
}
14731429

@@ -1509,12 +1465,6 @@ private boolean pushMediaButtonReceiver_syncAfRcs(PendingIntent mediaIntent,
15091465
}
15101466
mRCStack.push(rcse); // rcse is never null
15111467

1512-
// post message to persist the default media button receiver
1513-
if (target != null) {
1514-
mEventHandler.sendMessage( mEventHandler.obtainMessage(
1515-
MSG_PERSIST_MEDIABUTTONRECEIVER, 0, 0, target/*obj*/) );
1516-
}
1517-
15181468
// RC stack was modified
15191469
return true;
15201470
}
@@ -1553,12 +1503,6 @@ private boolean isCurrentRcController(PendingIntent pi) {
15531503
return false;
15541504
}
15551505

1556-
private void onHandlePersistMediaButtonReceiver(ComponentName receiver) {
1557-
Settings.System.putStringForUser(mContentResolver,
1558-
Settings.System.MEDIA_BUTTON_RECEIVER,
1559-
receiver == null ? "" : receiver.flattenToString(),
1560-
UserHandle.USER_CURRENT);
1561-
}
15621506

15631507
//==========================================================================================
15641508
// Remote control display / client

0 commit comments

Comments
 (0)