diff options
author | Julia Reynolds <juliacr@google.com> | 2014-06-04 11:11:43 -0400 |
---|---|---|
committer | Julia Reynolds <juliacr@google.com> | 2014-06-09 14:18:01 -0400 |
commit | 4a21b25fad62e4f19d13ba814263841c931f56ef (patch) | |
tree | 99ae4989ab944facd6427dc1a109d57cef292ffd /services/devicepolicy/java | |
parent | f89fa8337466be97e40c3ae3cc37704e3f666b5e (diff) | |
download | frameworks_base-4a21b25fad62e4f19d13ba814263841c931f56ef.zip frameworks_base-4a21b25fad62e4f19d13ba814263841c931f56ef.tar.gz frameworks_base-4a21b25fad62e4f19d13ba814263841c931f56ef.tar.bz2 |
Allow profile and device owners to change and get the master volume mute state.
Also protect muting master volume with op code OP_AUDIO_MASTER_VOLUME.
Bug: 13585918
Change-Id: I91fe7ee60cd291cca15966b3127c0bb8a4828f6a
Diffstat (limited to 'services/devicepolicy/java')
-rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 14f14f4..5cfe0f1 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -51,6 +51,8 @@ import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; +import android.media.AudioManager; +import android.media.IAudioService; import android.net.ConnectivityManager; import android.content.pm.PackageManager.NameNotFoundException; import android.net.ProxyInfo; @@ -3775,4 +3777,40 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } } } + + @Override + public void setMasterVolumeMuted(ComponentName who, boolean on) { + final ContentResolver contentResolver = mContext.getContentResolver(); + + synchronized (this) { + if (who == null) { + throw new NullPointerException("ComponentName is null"); + } + getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); + + IAudioService iAudioService = IAudioService.Stub.asInterface( + ServiceManager.getService(Context.AUDIO_SERVICE)); + try{ + iAudioService.setMasterMute(on, 0, who.getPackageName(), null); + } catch (RemoteException re) { + Slog.e(LOG_TAG, "Failed to setMasterMute", re); + } + } + } + + @Override + public boolean isMasterVolumeMuted(ComponentName who) { + final ContentResolver contentResolver = mContext.getContentResolver(); + + synchronized (this) { + if (who == null) { + throw new NullPointerException("ComponentName is null"); + } + getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); + + AudioManager audioManager = + (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); + return audioManager.isMasterMute(); + } + } } |