Loading services/core/java/com/android/server/audio/AudioDeviceBroker.java +5 −3 Original line number Diff line number Diff line Loading @@ -500,8 +500,8 @@ import java.util.concurrent.atomic.AtomicBoolean; sendIIMsgNoDelay(MSG_II_SET_HEARING_AID_VOLUME, SENDMSG_REPLACE, index, streamType); } /*package*/ void postSetModeOwnerPid(int pid) { sendIMsgNoDelay(MSG_I_SET_MODE_OWNER_PID, SENDMSG_REPLACE, pid); /*package*/ void postSetModeOwnerPid(int pid, int mode) { sendIIMsgNoDelay(MSG_I_SET_MODE_OWNER_PID, SENDMSG_REPLACE, pid, mode); } /*package*/ void postBluetoothA2dpDeviceConfigChange(@NonNull BluetoothDevice device) { Loading Loading @@ -977,7 +977,9 @@ import java.util.concurrent.atomic.AtomicBoolean; synchronized (mDeviceStateLock) { if (mModeOwnerPid != msg.arg1) { mModeOwnerPid = msg.arg1; if (msg.arg2 != AudioSystem.MODE_RINGTONE) { updateSpeakerphoneOn("setNewModeOwner"); } if (mModeOwnerPid != 0) { mBtHelper.disconnectBluetoothSco(mModeOwnerPid); } Loading services/core/java/com/android/server/audio/AudioService.java +19 −10 Original line number Diff line number Diff line Loading @@ -3747,13 +3747,15 @@ public class AudioService extends IAudioService.Stub private final IBinder mCb; // To be notified of client's death private final int mPid; private final int mUid; private String mPackage; private final boolean mIsPrivileged; private final String mPackage; private int mMode = AudioSystem.MODE_NORMAL; // Current mode set by this client SetModeDeathHandler(IBinder cb, int pid, int uid, String caller) { SetModeDeathHandler(IBinder cb, int pid, int uid, boolean isPrivileged, String caller) { mCb = cb; mPid = pid; mUid = uid; mIsPrivileged = isPrivileged; mPackage = caller; } Loading @@ -3765,12 +3767,13 @@ public class AudioService extends IAudioService.Stub if (index < 0) { Log.w(TAG, "unregistered setMode() client died"); } else { newModeOwnerPid = setModeInt(AudioSystem.MODE_NORMAL, mCb, mPid, mUid, TAG); newModeOwnerPid = setModeInt( AudioSystem.MODE_NORMAL, mCb, mPid, mUid, mIsPrivileged, TAG); } } // when entering RINGTONE, IN_CALL or IN_COMMUNICATION mode, clear all // SCO connections not started by the application changing the mode when pid changes mDeviceBroker.postSetModeOwnerPid(newModeOwnerPid); mDeviceBroker.postSetModeOwnerPid(newModeOwnerPid, AudioService.this.getMode()); } public int getPid() { Loading @@ -3796,6 +3799,10 @@ public class AudioService extends IAudioService.Stub public String getPackage() { return mPackage; } public boolean isPrivileged() { return mIsPrivileged; } } /** @see AudioManager#setMode(int) */ Loading Loading @@ -3847,18 +3854,19 @@ public class AudioService extends IAudioService.Stub + " without permission or being mode owner"); return; } newModeOwnerPid = setModeInt( mode, cb, callingPid, Binder.getCallingUid(), callingPackage); newModeOwnerPid = setModeInt(mode, cb, callingPid, Binder.getCallingUid(), hasModifyPhoneStatePermission, callingPackage); } // when entering RINGTONE, IN_CALL or IN_COMMUNICATION mode, clear all // SCO connections not started by the application changing the mode when pid changes mDeviceBroker.postSetModeOwnerPid(newModeOwnerPid); mDeviceBroker.postSetModeOwnerPid(newModeOwnerPid, getMode()); } // setModeInt() returns a valid PID if the audio mode was successfully set to // any mode other than NORMAL. @GuardedBy("mDeviceBroker.mSetModeLock") private int setModeInt(int mode, IBinder cb, int pid, int uid, String caller) { private int setModeInt( int mode, IBinder cb, int pid, int uid, boolean isPrivileged, String caller) { if (DEBUG_MODE) { Log.v(TAG, "setModeInt(mode=" + mode + ", pid=" + pid + ", uid=" + uid + ", caller=" + caller + ")"); Loading Loading @@ -3910,7 +3918,7 @@ public class AudioService extends IAudioService.Stub } } else { if (hdlr == null) { hdlr = new SetModeDeathHandler(cb, pid, uid, caller); hdlr = new SetModeDeathHandler(cb, pid, uid, isPrivileged, caller); } // Register for client death notification try { Loading Loading @@ -3969,7 +3977,8 @@ public class AudioService extends IAudioService.Stub // change of mode may require volume to be re-applied on some devices updateAbsVolumeMultiModeDevices(oldMode, actualMode); if (actualMode == AudioSystem.MODE_IN_COMMUNICATION) { if (actualMode == AudioSystem.MODE_IN_COMMUNICATION && !hdlr.isPrivileged()) { sendMsg(mAudioHandler, MSG_CHECK_MODE_FOR_UID, SENDMSG_QUEUE, Loading Loading
services/core/java/com/android/server/audio/AudioDeviceBroker.java +5 −3 Original line number Diff line number Diff line Loading @@ -500,8 +500,8 @@ import java.util.concurrent.atomic.AtomicBoolean; sendIIMsgNoDelay(MSG_II_SET_HEARING_AID_VOLUME, SENDMSG_REPLACE, index, streamType); } /*package*/ void postSetModeOwnerPid(int pid) { sendIMsgNoDelay(MSG_I_SET_MODE_OWNER_PID, SENDMSG_REPLACE, pid); /*package*/ void postSetModeOwnerPid(int pid, int mode) { sendIIMsgNoDelay(MSG_I_SET_MODE_OWNER_PID, SENDMSG_REPLACE, pid, mode); } /*package*/ void postBluetoothA2dpDeviceConfigChange(@NonNull BluetoothDevice device) { Loading Loading @@ -977,7 +977,9 @@ import java.util.concurrent.atomic.AtomicBoolean; synchronized (mDeviceStateLock) { if (mModeOwnerPid != msg.arg1) { mModeOwnerPid = msg.arg1; if (msg.arg2 != AudioSystem.MODE_RINGTONE) { updateSpeakerphoneOn("setNewModeOwner"); } if (mModeOwnerPid != 0) { mBtHelper.disconnectBluetoothSco(mModeOwnerPid); } Loading
services/core/java/com/android/server/audio/AudioService.java +19 −10 Original line number Diff line number Diff line Loading @@ -3747,13 +3747,15 @@ public class AudioService extends IAudioService.Stub private final IBinder mCb; // To be notified of client's death private final int mPid; private final int mUid; private String mPackage; private final boolean mIsPrivileged; private final String mPackage; private int mMode = AudioSystem.MODE_NORMAL; // Current mode set by this client SetModeDeathHandler(IBinder cb, int pid, int uid, String caller) { SetModeDeathHandler(IBinder cb, int pid, int uid, boolean isPrivileged, String caller) { mCb = cb; mPid = pid; mUid = uid; mIsPrivileged = isPrivileged; mPackage = caller; } Loading @@ -3765,12 +3767,13 @@ public class AudioService extends IAudioService.Stub if (index < 0) { Log.w(TAG, "unregistered setMode() client died"); } else { newModeOwnerPid = setModeInt(AudioSystem.MODE_NORMAL, mCb, mPid, mUid, TAG); newModeOwnerPid = setModeInt( AudioSystem.MODE_NORMAL, mCb, mPid, mUid, mIsPrivileged, TAG); } } // when entering RINGTONE, IN_CALL or IN_COMMUNICATION mode, clear all // SCO connections not started by the application changing the mode when pid changes mDeviceBroker.postSetModeOwnerPid(newModeOwnerPid); mDeviceBroker.postSetModeOwnerPid(newModeOwnerPid, AudioService.this.getMode()); } public int getPid() { Loading @@ -3796,6 +3799,10 @@ public class AudioService extends IAudioService.Stub public String getPackage() { return mPackage; } public boolean isPrivileged() { return mIsPrivileged; } } /** @see AudioManager#setMode(int) */ Loading Loading @@ -3847,18 +3854,19 @@ public class AudioService extends IAudioService.Stub + " without permission or being mode owner"); return; } newModeOwnerPid = setModeInt( mode, cb, callingPid, Binder.getCallingUid(), callingPackage); newModeOwnerPid = setModeInt(mode, cb, callingPid, Binder.getCallingUid(), hasModifyPhoneStatePermission, callingPackage); } // when entering RINGTONE, IN_CALL or IN_COMMUNICATION mode, clear all // SCO connections not started by the application changing the mode when pid changes mDeviceBroker.postSetModeOwnerPid(newModeOwnerPid); mDeviceBroker.postSetModeOwnerPid(newModeOwnerPid, getMode()); } // setModeInt() returns a valid PID if the audio mode was successfully set to // any mode other than NORMAL. @GuardedBy("mDeviceBroker.mSetModeLock") private int setModeInt(int mode, IBinder cb, int pid, int uid, String caller) { private int setModeInt( int mode, IBinder cb, int pid, int uid, boolean isPrivileged, String caller) { if (DEBUG_MODE) { Log.v(TAG, "setModeInt(mode=" + mode + ", pid=" + pid + ", uid=" + uid + ", caller=" + caller + ")"); Loading Loading @@ -3910,7 +3918,7 @@ public class AudioService extends IAudioService.Stub } } else { if (hdlr == null) { hdlr = new SetModeDeathHandler(cb, pid, uid, caller); hdlr = new SetModeDeathHandler(cb, pid, uid, isPrivileged, caller); } // Register for client death notification try { Loading Loading @@ -3969,7 +3977,8 @@ public class AudioService extends IAudioService.Stub // change of mode may require volume to be re-applied on some devices updateAbsVolumeMultiModeDevices(oldMode, actualMode); if (actualMode == AudioSystem.MODE_IN_COMMUNICATION) { if (actualMode == AudioSystem.MODE_IN_COMMUNICATION && !hdlr.isPrivileged()) { sendMsg(mAudioHandler, MSG_CHECK_MODE_FOR_UID, SENDMSG_QUEUE, Loading