summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rwxr-xr-xservices/core/java/com/android/server/am/ActivityManagerService.java27
-rwxr-xr-xservices/core/java/com/android/server/am/ActivityStack.java11
-rw-r--r--services/core/java/com/android/server/am/ActivityStackSupervisor.java96
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java80
-rw-r--r--services/core/java/com/android/server/notification/ZenModeHelper.java26
-rw-r--r--services/core/java/com/android/server/wm/WindowStateAnimator.java6
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java45
7 files changed, 210 insertions, 81 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 6ca536c..1367761 100755
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -1198,11 +1198,12 @@ public final class ActivityManagerService extends ActivityManagerNative
*/
private boolean mUserIsMonkey;
- /** Flag whether the device has a recents UI */
- final boolean mHasRecents;
+ /** Flag whether the device has a Recents UI */
+ boolean mHasRecents;
- final int mThumbnailWidth;
- final int mThumbnailHeight;
+ /** The dimensions of the thumbnails in the Recents UI. */
+ int mThumbnailWidth;
+ int mThumbnailHeight;
final ServiceThread mHandlerThread;
final MainHandler mHandler;
@@ -2257,11 +2258,6 @@ public final class ActivityManagerService extends ActivityManagerNative
mConfigurationSeq = mConfiguration.seq = 1;
mProcessCpuTracker.init();
- final Resources res = mContext.getResources();
- mHasRecents = res.getBoolean(com.android.internal.R.bool.config_hasRecents);
- mThumbnailWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_width);
- mThumbnailHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_height);
-
mCompatModePackages = new CompatModePackages(this, systemDir, mHandler);
mIntentFirewall = new IntentFirewall(new IntentFirewallInterface(), mHandler);
mStackSupervisor = new ActivityStackSupervisor(this);
@@ -10680,6 +10676,14 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
+ /** Loads resources after the current configuration has been set. */
+ private void loadResourcesOnSystemReady() {
+ final Resources res = mContext.getResources();
+ mHasRecents = res.getBoolean(com.android.internal.R.bool.config_hasRecents);
+ mThumbnailWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_width);
+ mThumbnailHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_height);
+ }
+
public boolean testIsSystemReady() {
// no need to synchronize(this) just to read & return the value
return mSystemReady;
@@ -10961,6 +10965,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
retrieveSettings();
+ loadResourcesOnSystemReady();
synchronized (this) {
readGrantedUriPermissionsLocked();
@@ -15208,6 +15213,10 @@ public final class ActivityManagerService extends ActivityManagerNative
final int is24Hour = intent.getBooleanExtra(
Intent.EXTRA_TIME_PREF_24_HOUR_FORMAT, false) ? 1 : 0;
mHandler.sendMessage(mHandler.obtainMessage(UPDATE_TIME, is24Hour, 0));
+ BatteryStatsImpl stats = mBatteryStatsService.getActiveStatistics();
+ synchronized (stats) {
+ stats.noteCurrentTimeChangedLocked();
+ }
}
if (Intent.ACTION_CLEAR_DNS_CACHE.equals(intent.getAction())) {
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index d066940..3efd049 100755
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -229,9 +229,6 @@ final class ActivityStack {
private ActivityRecord mLastScreenshotActivity = null;
private Bitmap mLastScreenshotBitmap = null;
- int mThumbnailWidth = -1;
- int mThumbnailHeight = -1;
-
int mCurrentUser;
final int mStackId;
@@ -355,10 +352,6 @@ final class ActivityStack {
mWindowManager = mService.mWindowManager;
mStackId = activityContainer.mStackId;
mCurrentUser = mService.mCurrentUserId;
- // Get the activity screenshot thumbnail dimensions
- Resources res = mService.mContext.getResources();
- mThumbnailWidth = mService.mThumbnailWidth;
- mThumbnailHeight = mService.mThumbnailHeight;
}
/**
@@ -773,8 +766,8 @@ final class ActivityStack {
return null;
}
- int w = mThumbnailWidth;
- int h = mThumbnailHeight;
+ int w = mService.mThumbnailWidth;
+ int h = mService.mThumbnailHeight;
if (w > 0) {
if (who != mLastScreenshotActivity || mLastScreenshotBitmap == null
|| mLastScreenshotActivity.state == ActivityState.RESUMED
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 9b32b65..1d2f7a9 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -1543,6 +1543,15 @@ public final class ActivityStackSupervisor implements DisplayListener {
final Intent intent = r.intent;
final int callingUid = r.launchedFromUid;
+ // In some flows in to this function, we retrieve the task record and hold on to it
+ // without a lock before calling back in to here... so the task at this point may
+ // not actually be in recents. Check for that, and if it isn't in recents just
+ // consider it invalid.
+ if (inTask != null && !inTask.inRecents) {
+ Slog.w(TAG, "Starting activity in task not in recents: " + inTask);
+ inTask = null;
+ }
+
final boolean launchSingleTop = r.launchMode == ActivityInfo.LAUNCH_SINGLE_TOP;
final boolean launchSingleInstance = r.launchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE;
final boolean launchSingleTask = r.launchMode == ActivityInfo.LAUNCH_SINGLE_TASK;
@@ -1686,32 +1695,50 @@ public final class ActivityStackSupervisor implements DisplayListener {
// If the caller is not coming from another activity, but has given us an
// explicit task into which they would like us to launch the new activity,
// then let's see about doing that.
- if (sourceRecord == null && inTask != null && inTask.stack != null && inTask.inRecents) {
+ if (sourceRecord == null && inTask != null && inTask.stack != null) {
+ final Intent baseIntent = inTask.getBaseIntent();
+ final ActivityRecord root = inTask.getRootActivity();
+ if (baseIntent == null) {
+ ActivityOptions.abort(options);
+ throw new IllegalArgumentException("Launching into task without base intent: "
+ + inTask);
+ }
+
// If this task is empty, then we are adding the first activity -- it
// determines the root, and must be launching as a NEW_TASK.
- if (inTask.getRootActivity() == null) {
- if ((launchFlags & Intent.FLAG_ACTIVITY_NEW_TASK) == 0
- && !launchSingleInstance && !launchSingleTask) {
- throw new IllegalStateException("Caller has inTask " + inTask
- + " but target is not a new task");
- } else if (inTask.getBaseIntent() == null || !intent.getComponent().equals(
- inTask.getBaseIntent().getComponent())) {
- throw new IllegalStateException("Caller requested " + inTask + " is component "
- + inTask.getBaseIntent() + " but starting " + intent);
+ if (launchSingleInstance || launchSingleTask) {
+ if (!baseIntent.getComponent().equals(r.intent.getComponent())) {
+ ActivityOptions.abort(options);
+ throw new IllegalArgumentException("Trying to launch singleInstance/Task "
+ + r + " into different task " + inTask);
}
+ if (root != null) {
+ ActivityOptions.abort(options);
+ throw new IllegalArgumentException("Caller with inTask " + inTask
+ + " has root " + root + " but target is singleInstance/Task");
+ }
+ }
+
+ // If task is empty, then adopt the interesting intent launch flags in to the
+ // activity being started.
+ if (root == null) {
+ final int flagsOfInterest = Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT
+ | Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS;
+ launchFlags = (launchFlags&~flagsOfInterest)
+ | (baseIntent.getFlags()&flagsOfInterest);
+ intent.setFlags(launchFlags);
inTask.setIntent(r);
// If the task is not empty, then we are going to add the new activity on top
// of the task, so it can not be launching as a new task.
- } else {
- if ((launchFlags & Intent.FLAG_ACTIVITY_NEW_TASK) != 0
- || launchSingleInstance || launchSingleTask) {
- throw new IllegalStateException("Caller has inTask " + inTask
- + " but target is a new task");
- }
+ } else if ((launchFlags & Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
+ ActivityOptions.abort(options);
+ throw new IllegalStateException("Caller has inTask " + inTask
+ + " but target is a new task");
}
- sourceStack = inTask.stack;
reuseTask = inTask;
+ addingToTask = true;
} else {
inTask = null;
}
@@ -1724,10 +1751,11 @@ public final class ActivityStackSupervisor implements DisplayListener {
if (((launchFlags & Intent.FLAG_ACTIVITY_NEW_TASK) != 0 &&
(launchFlags & Intent.FLAG_ACTIVITY_MULTIPLE_TASK) == 0)
|| launchSingleInstance || launchSingleTask) {
- // If bring to front is requested, and no result is requested, and
+ // If bring to front is requested, and no result is requested and we have not
+ // been given an explicit task to launch in to, and
// we can find a task that was started with this same
// component, then instead of launching bring that one to the front.
- if (r.resultTo == null) {
+ if (inTask == null && r.resultTo == null) {
// See if there is a task to bring to the front. If this is
// a SINGLE_INSTANCE activity, there can be one and only one
// instance of it in the history, and it is always in its own
@@ -1957,13 +1985,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
Slog.e(TAG, "Attempted Lock Task Mode violation r=" + r);
return ActivityManager.START_RETURN_LOCK_TASK_MODE_VIOLATION;
}
- if (inTask == null) {
- // If we have an incoming task, we are just going to use that.
- newTask = true;
- targetStack = adjustStackFocus(r, newTask);
- } else {
- targetStack = inTask.stack;
- }
+ newTask = true;
+ targetStack = adjustStackFocus(r, newTask);
if (!launchTaskBehind) {
targetStack.moveToFront();
}
@@ -2048,8 +2071,27 @@ public final class ActivityStackSupervisor implements DisplayListener {
return ActivityManager.START_RETURN_LOCK_TASK_MODE_VIOLATION;
}
targetStack = inTask.stack;
- targetStack.moveToFront();
+ targetStack.moveTaskToFrontLocked(inTask, r, options);
mWindowManager.moveTaskToTop(targetStack.topTask().taskId);
+
+ // Check whether we should actually launch the new activity in to the task,
+ // or just reuse the current activity on top.
+ ActivityRecord top = inTask.getTopActivity();
+ if (top != null && top.realActivity.equals(r.realActivity) && top.userId == r.userId) {
+ if ((launchFlags & Intent.FLAG_ACTIVITY_SINGLE_TOP) != 0
+ || launchSingleTop || launchSingleTask) {
+ ActivityStack.logStartActivity(EventLogTags.AM_NEW_INTENT, top, top.task);
+ if ((startFlags&ActivityManager.START_FLAG_ONLY_IF_NEEDED) != 0) {
+ // We don't need to start a new activity, and
+ // the client said not to do anything if that
+ // is the case, so this is it!
+ return ActivityManager.START_RETURN_INTENT_TO_CALLER;
+ }
+ top.deliverNewIntentLocked(callingUid, r.intent);
+ return ActivityManager.START_DELIVERED_TO_TOP;
+ }
+ }
+
r.setTask(inTask, null);
if (DEBUG_TASKS) Slog.v(TAG, "Starting new activity " + r
+ " in explicit task " + r.task);
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 8c0d2c9..fc1b746 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -57,7 +57,6 @@ import android.os.IBinder;
import android.os.IInterface;
import android.os.Looper;
import android.os.Message;
-import android.os.PowerManager;
import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
@@ -127,6 +126,7 @@ public class NotificationManagerService extends SystemService {
static final int MESSAGE_RANKING_CONFIG_CHANGE = 5;
static final int MESSAGE_SEND_RANKING_UPDATE = 6;
static final int MESSAGE_LISTENER_HINTS_CHANGED = 7;
+ static final int MESSAGE_LISTENER_NOTIFICATION_FILTER_CHANGED = 8;
static final int LONG_DELAY = 3500; // 3.5 seconds
static final int SHORT_DELAY = 2000; // 2 seconds
@@ -178,6 +178,7 @@ public class NotificationManagerService extends SystemService {
private final ArraySet<ManagedServiceInfo> mListenersDisablingEffects = new ArraySet<>();
private ComponentName mEffectsSuppressor;
private int mListenerHints; // right now, all hints are global
+ private int mInterruptionFilter; // current ZEN mode as communicated to listeners
// for enabling and disabling notification pulse behavior
private boolean mScreenOn = true;
@@ -806,7 +807,7 @@ public class NotificationManagerService extends SystemService {
@Override
void onZenModeChanged() {
synchronized(mNotificationList) {
- updateListenerHintsLocked();
+ updateInterruptionFilterLocked();
}
}
});
@@ -938,8 +939,7 @@ public class NotificationManagerService extends SystemService {
}
private void updateListenerHintsLocked() {
- final int hints = (mListenersDisablingEffects.isEmpty() ? 0 : HINT_HOST_DISABLE_EFFECTS) |
- mZenModeHelper.getZenModeListenerHint();
+ final int hints = mListenersDisablingEffects.isEmpty() ? 0 : HINT_HOST_DISABLE_EFFECTS;
if (hints == mListenerHints) return;
mListenerHints = hints;
scheduleListenerHintsChanged(hints);
@@ -954,6 +954,13 @@ public class NotificationManagerService extends SystemService {
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY));
}
+ private void updateInterruptionFilterLocked() {
+ int interruptionFilter = mZenModeHelper.getZenModeListenerInterruptionFilter();
+ if (interruptionFilter == mInterruptionFilter) return;
+ mInterruptionFilter = interruptionFilter;
+ scheduleInterruptionFilterChanged(interruptionFilter);
+ }
+
private final IBinder mService = new INotificationManager.Stub() {
// Toasts
// ============================================================================
@@ -1318,7 +1325,6 @@ public class NotificationManagerService extends SystemService {
} else {
mListenersDisablingEffects.remove(info);
}
- mZenModeHelper.requestFromListener(hints);
updateListenerHintsLocked();
updateEffectsSuppressorLocked();
}
@@ -1335,6 +1341,29 @@ public class NotificationManagerService extends SystemService {
}
@Override
+ public void requestInterruptionFilterFromListener(INotificationListener token,
+ int interruptionFilter) throws RemoteException {
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ synchronized (mNotificationList) {
+ mListeners.checkServiceTokenLocked(token);
+ mZenModeHelper.requestFromListener(interruptionFilter);
+ updateInterruptionFilterLocked();
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ @Override
+ public int getInterruptionFilterFromListener(INotificationListener token)
+ throws RemoteException {
+ synchronized (mNotificationLight) {
+ return mInterruptionFilter;
+ }
+ }
+
+ @Override
public ZenModeConfig getZenModeConfig() {
enforceSystemOrSystemUI("INotificationManager.getZenModeConfig");
return mZenModeHelper.getConfig();
@@ -2058,12 +2087,26 @@ public class NotificationManagerService extends SystemService {
mHandler.obtainMessage(MESSAGE_LISTENER_HINTS_CHANGED, state, 0).sendToTarget();
}
+ private void scheduleInterruptionFilterChanged(int listenerInterruptionFilter) {
+ mHandler.removeMessages(MESSAGE_LISTENER_NOTIFICATION_FILTER_CHANGED);
+ mHandler.obtainMessage(
+ MESSAGE_LISTENER_NOTIFICATION_FILTER_CHANGED,
+ listenerInterruptionFilter,
+ 0).sendToTarget();
+ }
+
private void handleListenerHintsChanged(int hints) {
synchronized (mNotificationList) {
mListeners.notifyListenerHintsChangedLocked(hints);
}
}
+ private void handleListenerInterruptionFilterChanged(int interruptionFilter) {
+ synchronized (mNotificationList) {
+ mListeners.notifyInterruptionFilterChanged(interruptionFilter);
+ }
+ }
+
private final class WorkerHandler extends Handler
{
@Override
@@ -2083,6 +2126,9 @@ public class NotificationManagerService extends SystemService {
case MESSAGE_LISTENER_HINTS_CHANGED:
handleListenerHintsChanged(msg.arg1);
break;
+ case MESSAGE_LISTENER_NOTIFICATION_FILTER_CHANGED:
+ handleListenerInterruptionFilterChanged(msg.arg1);
+ break;
}
}
@@ -2701,6 +2747,20 @@ public class NotificationManagerService extends SystemService {
}
}
+ public void notifyInterruptionFilterChanged(final int interruptionFilter) {
+ for (final ManagedServiceInfo serviceInfo : mServices) {
+ if (!serviceInfo.isEnabledForCurrentProfiles()) {
+ continue;
+ }
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ notifyInterruptionFilterChanged(serviceInfo, interruptionFilter);
+ }
+ });
+ }
+ }
+
private void notifyPosted(final ManagedServiceInfo info,
final StatusBarNotification sbn, NotificationRankingUpdate rankingUpdate) {
final INotificationListener listener = (INotificationListener)info.service;
@@ -2743,6 +2803,16 @@ public class NotificationManagerService extends SystemService {
}
}
+ private void notifyInterruptionFilterChanged(ManagedServiceInfo info,
+ int interruptionFilter) {
+ final INotificationListener listener = (INotificationListener) info.service;
+ try {
+ listener.onInterruptionFilterChanged(interruptionFilter);
+ } catch (RemoteException ex) {
+ Log.e(TAG, "unable to notify listener (interruption filter): " + listener, ex);
+ }
+ }
+
private boolean isListenerPackage(String packageName) {
if (packageName == null) {
return false;
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index 0b93690..7a5336b 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -115,35 +115,35 @@ public class ZenModeHelper {
mAudioManager = audioManager;
}
- public int getZenModeListenerHint() {
- switch(mZenMode) {
+ public int getZenModeListenerInterruptionFilter() {
+ switch (mZenMode) {
case Global.ZEN_MODE_OFF:
- return NotificationListenerService.HINT_HOST_INTERRUPTION_LEVEL_ALL;
+ return NotificationListenerService.INTERRUPTION_FILTER_ALL;
case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
- return NotificationListenerService.HINT_HOST_INTERRUPTION_LEVEL_PRIORITY;
+ return NotificationListenerService.INTERRUPTION_FILTER_PRIORITY;
case Global.ZEN_MODE_NO_INTERRUPTIONS:
- return NotificationListenerService.HINT_HOST_INTERRUPTION_LEVEL_NONE;
+ return NotificationListenerService.INTERRUPTION_FILTER_NONE;
default:
return 0;
}
}
- private static int zenFromListenerHint(int hints, int defValue) {
- final int level = hints & NotificationListenerService.HOST_INTERRUPTION_LEVEL_MASK;
- switch(level) {
- case NotificationListenerService.HINT_HOST_INTERRUPTION_LEVEL_ALL:
+ private static int zenModeFromListenerInterruptionFilter(int listenerInterruptionFilter,
+ int defValue) {
+ switch (listenerInterruptionFilter) {
+ case NotificationListenerService.INTERRUPTION_FILTER_ALL:
return Global.ZEN_MODE_OFF;
- case NotificationListenerService.HINT_HOST_INTERRUPTION_LEVEL_PRIORITY:
+ case NotificationListenerService.INTERRUPTION_FILTER_PRIORITY:
return Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
- case NotificationListenerService.HINT_HOST_INTERRUPTION_LEVEL_NONE:
+ case NotificationListenerService.INTERRUPTION_FILTER_NONE:
return Global.ZEN_MODE_NO_INTERRUPTIONS;
default:
return defValue;
}
}
- public void requestFromListener(int hints) {
- final int newZen = zenFromListenerHint(hints, -1);
+ public void requestFromListener(int interruptionFilter) {
+ final int newZen = zenModeFromListenerInterruptionFilter(interruptionFilter, -1);
if (newZen != -1) {
setZenMode(newZen, "listener");
}
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 38433ae..4b7dd08 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -754,7 +754,11 @@ class WindowStateAnimator {
final boolean isHwAccelerated = (attrs.flags &
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0;
final int format = isHwAccelerated ? PixelFormat.TRANSLUCENT : attrs.format;
- if (!PixelFormat.formatHasAlpha(attrs.format)) {
+ if (!PixelFormat.formatHasAlpha(attrs.format)
+ && attrs.surfaceInsets.left == 0
+ && attrs.surfaceInsets.top == 0
+ && attrs.surfaceInsets.right == 0
+ && attrs.surfaceInsets.bottom == 0) {
flags |= SurfaceControl.OPAQUE;
}
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);
}
}
}