diff options
author | Julia Reynolds <juliacr@google.com> | 2014-08-28 19:41:41 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-08-28 19:41:42 +0000 |
commit | a8528c642090525f0e5f3c35dc3ba5a50ff17093 (patch) | |
tree | c953dde5077e810fcac88897b5c47afab77204ad /services/devicepolicy | |
parent | 2db754ac6e2cddf01801c450bb8200b01cddf410 (diff) | |
parent | b53453fae037d67e421011936c8fdffe7ba43922 (diff) | |
download | frameworks_base-a8528c642090525f0e5f3c35dc3ba5a50ff17093.zip frameworks_base-a8528c642090525f0e5f3c35dc3ba5a50ff17093.tar.gz frameworks_base-a8528c642090525f0e5f3c35dc3ba5a50ff17093.tar.bz2 |
Merge "Audio/Micrphone user restriction/multiuser updates." into lmp-dev
Diffstat (limited to 'services/devicepolicy')
-rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 28cc99f..564a3df 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -4600,7 +4600,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { @Override public void setUserRestriction(ComponentName who, String key, boolean enabled) { final UserHandle userHandle = new UserHandle(UserHandle.getCallingUserId()); - synchronized (this) { if (who == null) { throw new NullPointerException("ComponentName is null"); @@ -4611,13 +4610,28 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (!isDeviceOwner && DEVICE_OWNER_USER_RESTRICTIONS.contains(key)) { throw new SecurityException("Profile owners cannot set user restriction " + key); } + boolean alreadyRestricted = mUserManager.hasUserRestriction(key, userHandle); + + IAudioService iAudioService = null; + if (UserManager.DISALLOW_UNMUTE_MICROPHONE.equals(key) + || UserManager.DISALLOW_ADJUST_VOLUME.equals(key)) { + iAudioService = IAudioService.Stub.asInterface( + ServiceManager.getService(Context.AUDIO_SERVICE)); + } + if (enabled && !alreadyRestricted) { + try { + if (UserManager.DISALLOW_UNMUTE_MICROPHONE.equals(key)) { + iAudioService.setMicrophoneMute(true, who.getPackageName()); + } else if (UserManager.DISALLOW_ADJUST_VOLUME.equals(key)) { + iAudioService.setMasterMute(true, 0, who.getPackageName(), null); + } + } catch (RemoteException re) { + Slog.e(LOG_TAG, "Failed to talk to AudioService.", re); + } + } long id = Binder.clearCallingIdentity(); try { - AudioManager audioManager = - (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); - boolean alreadyRestricted = mUserManager.hasUserRestriction(key); - if (enabled && !alreadyRestricted) { if (UserManager.DISALLOW_CONFIG_WIFI.equals(key)) { Settings.Secure.putIntForUser(mContext.getContentResolver(), @@ -4648,25 +4662,22 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { Settings.Secure.putIntForUser(mContext.getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS, 0, userHandle.getIdentifier()); - } else if (UserManager.DISALLOW_UNMUTE_MICROPHONE.equals(key)) { - audioManager.setMicrophoneMute(true); - } else if (UserManager.DISALLOW_ADJUST_VOLUME.equals(key)) { - audioManager.setMasterMute(true); } } - mUserManager.setUserRestriction(key, enabled, userHandle); - - if (!enabled && alreadyRestricted) { + } finally { + restoreCallingIdentity(id); + } + if (!enabled && alreadyRestricted) { + try { if (UserManager.DISALLOW_UNMUTE_MICROPHONE.equals(key)) { - audioManager.setMicrophoneMute(false); + iAudioService.setMicrophoneMute(false, who.getPackageName()); } else if (UserManager.DISALLOW_ADJUST_VOLUME.equals(key)) { - audioManager.setMasterMute(false); + iAudioService.setMasterMute(false, 0, who.getPackageName(), null); } + } catch (RemoteException re) { + Slog.e(LOG_TAG, "Failed to talk to AudioService.", re); } - - } finally { - restoreCallingIdentity(id); } } } |