diff options
Diffstat (limited to 'services')
7 files changed, 170 insertions, 117 deletions
diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java index 7623514..da11dad 100644 --- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java +++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java @@ -2837,10 +2837,10 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku return providersUpdated; } - private boolean removeHostsAndProvidersForPackageLocked(String pkgName, int userId) { + private boolean removeProvidersForPackageLocked(String pkgName, int userId) { boolean removed = false; - int N = mProviders.size(); + final int N = mProviders.size(); for (int i = N - 1; i >= 0; i--) { Provider provider = mProviders.get(i); if (pkgName.equals(provider.info.provider.getPackageName()) @@ -2849,11 +2849,16 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku removed = true; } } + return removed; + } + + private boolean removeHostsAndProvidersForPackageLocked(String pkgName, int userId) { + boolean removed = removeProvidersForPackageLocked(pkgName, userId); // Delete the hosts for this package too // By now, we have removed any AppWidgets that were in any hosts here, // so we don't need to worry about sending DISABLE broadcasts to them. - N = mHosts.size(); + final int N = mHosts.size(); for (int i = N - 1; i >= 0; i--) { Host host = mHosts.get(i); if (pkgName.equals(host.id.packageName) @@ -2925,13 +2930,30 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku synchronized (mLock) { boolean providersChanged = false; + ArraySet<String> previousPackages = new ArraySet<String>(); + final int providerCount = mProviders.size(); + for (int i = 0; i < providerCount; ++i) { + Provider provider = mProviders.get(i); + if (provider.getUserId() == userId) { + previousPackages.add(provider.id.componentName.getPackageName()); + } + } + final int packageCount = packages.size(); for (int i = 0; i < packageCount; i++) { String packageName = packages.get(i); + previousPackages.remove(packageName); providersChanged |= updateProvidersForPackageLocked(packageName, userId, null); } + // Some packages are no longer whitelisted. + final int removedCount = previousPackages.size(); + for (int i = 0; i < removedCount; ++i) { + providersChanged |= removeProvidersForPackageLocked( + previousPackages.valueAt(i), userId); + } + if (providersChanged) { saveGroupStateAsync(userId); scheduleNotifyGroupHostsForProvidersChangedLocked(userId); @@ -3142,10 +3164,10 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku if (parentId != callerId) { return false; } - return isProviderWhitelListed(packageName, profileId); + return isProviderWhiteListed(packageName, profileId); } - public boolean isProviderWhitelListed(String packageName, int profileId) { + public boolean isProviderWhiteListed(String packageName, int profileId) { DevicePolicyManagerInternal devicePolicyManager = LocalServices.getService( DevicePolicyManagerInternal.class); diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 511347e..50820ff 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -57,6 +57,7 @@ import android.util.ArrayMap; import android.util.ArraySet; import android.util.SparseIntArray; +import android.view.Display; import com.android.internal.R; import com.android.internal.annotations.GuardedBy; import com.android.internal.app.IAppOpsService; @@ -8205,14 +8206,13 @@ public final class ActivityManagerService extends ActivityManagerNative } @Override - public IActivityContainer getEnclosingActivityContainer(IBinder activityToken) - throws RemoteException { + public int getActivityDisplayId(IBinder activityToken) throws RemoteException { synchronized (this) { ActivityStack stack = ActivityRecord.getStackLocked(activityToken); - if (stack != null) { - return stack.mActivityContainer; + if (stack != null && stack.mActivityContainer.isAttachedLocked()) { + return stack.mActivityContainer.getDisplayId(); } - return null; + return Display.DEFAULT_DISPLAY; } } diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java index 1a0f81d..06c154e 100644 --- a/services/core/java/com/android/server/media/MediaSessionService.java +++ b/services/core/java/com/android/server/media/MediaSessionService.java @@ -31,6 +31,7 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.database.ContentObserver; import android.media.AudioManager; +import android.media.AudioManagerInternal; import android.media.AudioSystem; import android.media.IAudioService; import android.media.IRemoteVolumeController; @@ -59,6 +60,7 @@ import android.util.Log; import android.util.SparseArray; import android.view.KeyEvent; +import com.android.server.LocalServices; import com.android.server.SystemService; import com.android.server.Watchdog; import com.android.server.Watchdog.Monitor; @@ -94,6 +96,7 @@ public class MediaSessionService extends SystemService implements Monitor { private KeyguardManager mKeyguardManager; private IAudioService mAudioService; private AudioManager mAudioManager; + private AudioManagerInternal mAudioManagerInternal; private ContentResolver mContentResolver; private SettingsObserver mSettingsObserver; @@ -121,6 +124,7 @@ public class MediaSessionService extends SystemService implements Monitor { (KeyguardManager) getContext().getSystemService(Context.KEYGUARD_SERVICE); mAudioService = getAudioService(); mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); + mAudioManagerInternal = LocalServices.getService(AudioManagerInternal.class); mContentResolver = getContext().getContentResolver(); mSettingsObserver = new SettingsObserver(); mSettingsObserver.observe(); @@ -343,7 +347,13 @@ public class MediaSessionService extends SystemService implements Monitor { } } - private void enforceStatusBarPermission(String action, int pid, int uid) { + private void enforceSystemUiPermission(String action, int pid, int uid) { + if (mAudioManagerInternal != null) { + final int vcuid = mAudioManagerInternal.getVolumeControllerUid(); + if (vcuid > 0 && uid == vcuid) { + return; + } + } if (getContext().checkPermission(android.Manifest.permission.STATUS_BAR_SERVICE, pid, uid) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Only system ui may " + action); @@ -789,7 +799,7 @@ public class MediaSessionService extends SystemService implements Monitor { final int uid = Binder.getCallingUid(); final long token = Binder.clearCallingIdentity(); try { - enforceStatusBarPermission("listen for volume changes", pid, uid); + enforceSystemUiPermission("listen for volume changes", pid, uid); mRvc = rvc; } finally { Binder.restoreCallingIdentity(token); diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index 69a1ac9..2729392 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -28,7 +28,6 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.UserInfo; import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.os.Binder; import android.os.Bundle; import android.os.Environment; @@ -36,6 +35,7 @@ import android.os.FileUtils; import android.os.Handler; import android.os.IUserManager; import android.os.Message; +import android.os.ParcelFileDescriptor; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; @@ -111,6 +111,7 @@ public class UserManagerService extends IUserManager.Stub { private static final String USER_INFO_DIR = "system" + File.separator + "users"; private static final String USER_LIST_FILENAME = "userlist.xml"; private static final String USER_PHOTO_FILENAME = "photo.png"; + private static final String USER_PHOTO_FILENAME_TMP = USER_PHOTO_FILENAME + ".tmp"; private static final String RESTRICTIONS_FILE_PREFIX = "res_"; private static final String XML_SUFFIX = ".xml"; @@ -433,7 +434,8 @@ public class UserManagerService extends IUserManager.Stub { } @Override - public Bitmap getUserIcon(int userId) { + public ParcelFileDescriptor getUserIcon(int userId) { + String iconPath; synchronized (mPackagesLock) { UserInfo info = mUsers.get(userId); if (info == null || info.partial) { @@ -448,8 +450,16 @@ public class UserManagerService extends IUserManager.Stub { if (info.iconPath == null) { return null; } - return BitmapFactory.decodeFile(info.iconPath); + iconPath = info.iconPath; } + + try { + return ParcelFileDescriptor.open( + new File(iconPath), ParcelFileDescriptor.MODE_READ_ONLY); + } catch (FileNotFoundException e) { + Log.e(LOG_TAG, "Couldn't find icon file", e); + } + return null; } public void makeInitialized(int userId) { @@ -572,6 +582,7 @@ public class UserManagerService extends IUserManager.Stub { try { File dir = new File(mUsersDir, Integer.toString(info.id)); File file = new File(dir, USER_PHOTO_FILENAME); + File tmp = new File(dir, USER_PHOTO_FILENAME_TMP); if (!dir.exists()) { dir.mkdir(); FileUtils.setPermissions( @@ -580,7 +591,8 @@ public class UserManagerService extends IUserManager.Stub { -1, -1); } FileOutputStream os; - if (bitmap.compress(Bitmap.CompressFormat.PNG, 100, os = new FileOutputStream(file))) { + if (bitmap.compress(Bitmap.CompressFormat.PNG, 100, os = new FileOutputStream(tmp)) + && tmp.renameTo(file)) { info.iconPath = file.getAbsolutePath(); } try { @@ -588,6 +600,7 @@ public class UserManagerService extends IUserManager.Stub { } catch (IOException ioe) { // What the ... ! } + tmp.delete(); } catch (FileNotFoundException e) { Slog.w(LOG_TAG, "Error setting photo for user ", e); } @@ -1787,7 +1800,8 @@ public class UserManagerService extends IUserManager.Stub { public int getUserHandle(int userSerialNumber) { synchronized (mPackagesLock) { for (int userId : mUserIds) { - if (getUserInfoLocked(userId).serialNumber == userSerialNumber) return userId; + UserInfo info = getUserInfoLocked(userId); + if (info != null && info.serialNumber == userSerialNumber) return userId; } // Not found return -1; diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 05f3473..f073c23 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -241,7 +241,9 @@ class DisplayContent { mTouchExcludeRegion.op(mTmpRect, Region.Op.DIFFERENCE); } } - mTapDetector.setTouchExcludeRegion(mTouchExcludeRegion); + if (mTapDetector != null) { + mTapDetector.setTouchExcludeRegion(mTouchExcludeRegion); + } } void switchUserStacks() { diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 9450d16..dd4bbb7 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -3663,14 +3663,12 @@ public class WindowManagerService extends IWindowManager.Stub // TODO(multidisplay): Change to the correct display. final WindowList windows = getDefaultWindowListLocked(); - int pos = windows.size() - 1; - while (pos >= 0) { + for (int pos = windows.size() - 1; pos >= 0; --pos) { WindowState win = windows.get(pos); - pos--; if (win.mAppToken != null) { // We hit an application window. so the orientation will be determined by the // app window. No point in continuing further. - return (mLastWindowForcedOrientation=ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); + return (mLastWindowForcedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } if (!win.isVisibleLw() || !win.mPolicyVisibilityAfterAnim) { continue; @@ -3682,9 +3680,9 @@ public class WindowManagerService extends IWindowManager.Stub } if (DEBUG_ORIENTATION) Slog.v(TAG, win + " forcing orientation to " + req); - return (mLastWindowForcedOrientation=req); + return (mLastWindowForcedOrientation = req); } - return (mLastWindowForcedOrientation=ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); + return (mLastWindowForcedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } public int getOrientationFromAppTokensLocked() { @@ -3742,14 +3740,12 @@ public class WindowManagerService extends IWindowManager.Stub // to use the orientation behind it, then just take whatever // orientation it has and ignores whatever is under it. lastFullscreen = atoken.appFullscreen; - if (lastFullscreen - && or != ActivityInfo.SCREEN_ORIENTATION_BEHIND) { + if (lastFullscreen && or != ActivityInfo.SCREEN_ORIENTATION_BEHIND) { if (DEBUG_ORIENTATION) Slog.v(TAG, "Done at " + atoken + " -- full screen, return " + or); return or; } - // If this application has requested an explicit orientation, - // then use it. + // If this application has requested an explicit orientation, then use it. if (or != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED && or != ActivityInfo.SCREEN_ORIENTATION_BEHIND) { if (DEBUG_ORIENTATION) Slog.v(TAG, "Done at " + atoken @@ -6367,13 +6363,12 @@ public class WindowManagerService extends IWindowManager.Stub screenRotationAnimation = mAnimator.getScreenRotationAnimationLocked(Display.DEFAULT_DISPLAY); - // We need to update our screen size information to match the new - // rotation. Note that this is redundant with the later call to - // sendNewConfiguration() that must be called after this function - // returns... however we need to do the screen size part of that - // before then so we have the correct size to use when initializing - // the rotation animation for the new rotation. - computeScreenConfigurationLocked(null); + // We need to update our screen size information to match the new rotation. If the rotation + // has actually changed then this method will return true and, according to the comment at + // the top of the method, the caller is obligated to call computeNewConfigurationLocked(). + // By updating the Display info here it will be available to + // computeScreenConfigurationLocked later. + updateDisplayAndOrientationLocked(); final DisplayInfo displayInfo = displayContent.getDisplayInfo(); if (!inTransaction) { @@ -7045,9 +7040,9 @@ public class WindowManagerService extends IWindowManager.Stub return sw; } - private boolean computeScreenConfigurationLocked(Configuration config) { + DisplayInfo updateDisplayAndOrientationLocked() { if (!mDisplayReady) { - return false; + return null; } // TODO(multidisplay): For now, apply Configuration to main screen only. @@ -7079,11 +7074,6 @@ public class WindowManagerService extends IWindowManager.Stub } } - if (config != null) { - config.orientation = (dw <= dh) ? Configuration.ORIENTATION_PORTRAIT : - Configuration.ORIENTATION_LANDSCAPE; - } - // Update application display metrics. final int appWidth = mPolicy.getNonDecorDisplayWidth(dw, dh, mRotation); final int appHeight = mPolicy.getNonDecorDisplayHeight(dw, dh, mRotation); @@ -7106,87 +7096,100 @@ public class WindowManagerService extends IWindowManager.Stub Slog.i(TAG, "Set app display size: " + appWidth + " x " + appHeight); } - final DisplayMetrics dm = mDisplayMetrics; - mCompatibleScreenScale = CompatibilityInfo.computeCompatibleScaling(dm, + mCompatibleScreenScale = CompatibilityInfo.computeCompatibleScaling(mDisplayMetrics, mCompatDisplayMetrics); + return displayInfo; + } - if (config != null) { - config.screenWidthDp = (int)(mPolicy.getConfigDisplayWidth(dw, dh, mRotation) - / dm.density); - config.screenHeightDp = (int)(mPolicy.getConfigDisplayHeight(dw, dh, mRotation) - / dm.density); - computeSizeRangesAndScreenLayout(displayInfo, rotated, dw, dh, dm.density, config); - - config.compatScreenWidthDp = (int)(config.screenWidthDp / mCompatibleScreenScale); - config.compatScreenHeightDp = (int)(config.screenHeightDp / mCompatibleScreenScale); - config.compatSmallestScreenWidthDp = computeCompatSmallestWidth(rotated, dm, dw, dh); - config.densityDpi = displayContent.mBaseDisplayDensity; - - // Update the configuration based on available input devices, lid switch, - // and platform configuration. - config.touchscreen = Configuration.TOUCHSCREEN_NOTOUCH; - config.keyboard = Configuration.KEYBOARD_NOKEYS; - config.navigation = Configuration.NAVIGATION_NONAV; - - int keyboardPresence = 0; - int navigationPresence = 0; - final InputDevice[] devices = mInputManager.getInputDevices(); - final int len = devices.length; - for (int i = 0; i < len; i++) { - InputDevice device = devices[i]; - if (!device.isVirtual()) { - final int sources = device.getSources(); - final int presenceFlag = device.isExternal() ? - WindowManagerPolicy.PRESENCE_EXTERNAL : - WindowManagerPolicy.PRESENCE_INTERNAL; - - if (mIsTouchDevice) { - if ((sources & InputDevice.SOURCE_TOUCHSCREEN) == - InputDevice.SOURCE_TOUCHSCREEN) { - config.touchscreen = Configuration.TOUCHSCREEN_FINGER; - } - } else { - config.touchscreen = Configuration.TOUCHSCREEN_NOTOUCH; - } + boolean computeScreenConfigurationLocked(Configuration config) { + final DisplayInfo displayInfo = updateDisplayAndOrientationLocked(); + if (displayInfo == null) { + return false; + } - if ((sources & InputDevice.SOURCE_TRACKBALL) == InputDevice.SOURCE_TRACKBALL) { - config.navigation = Configuration.NAVIGATION_TRACKBALL; - navigationPresence |= presenceFlag; - } else if ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD - && config.navigation == Configuration.NAVIGATION_NONAV) { - config.navigation = Configuration.NAVIGATION_DPAD; - navigationPresence |= presenceFlag; + final int dw = displayInfo.logicalWidth; + final int dh = displayInfo.logicalHeight; + config.orientation = (dw <= dh) ? Configuration.ORIENTATION_PORTRAIT : + Configuration.ORIENTATION_LANDSCAPE; + config.screenWidthDp = + (int)(mPolicy.getConfigDisplayWidth(dw, dh, mRotation) / mDisplayMetrics.density); + config.screenHeightDp = + (int)(mPolicy.getConfigDisplayHeight(dw, dh, mRotation) / mDisplayMetrics.density); + final boolean rotated = (mRotation == Surface.ROTATION_90 + || mRotation == Surface.ROTATION_270); + computeSizeRangesAndScreenLayout(displayInfo, rotated, dw, dh, mDisplayMetrics.density, + config); + + config.compatScreenWidthDp = (int)(config.screenWidthDp / mCompatibleScreenScale); + config.compatScreenHeightDp = (int)(config.screenHeightDp / mCompatibleScreenScale); + config.compatSmallestScreenWidthDp = computeCompatSmallestWidth(rotated, + mDisplayMetrics, dw, dh); + config.densityDpi = displayInfo.logicalDensityDpi; + + // Update the configuration based on available input devices, lid switch, + // and platform configuration. + config.touchscreen = Configuration.TOUCHSCREEN_NOTOUCH; + config.keyboard = Configuration.KEYBOARD_NOKEYS; + config.navigation = Configuration.NAVIGATION_NONAV; + + int keyboardPresence = 0; + int navigationPresence = 0; + final InputDevice[] devices = mInputManager.getInputDevices(); + final int len = devices.length; + for (int i = 0; i < len; i++) { + InputDevice device = devices[i]; + if (!device.isVirtual()) { + final int sources = device.getSources(); + final int presenceFlag = device.isExternal() ? + WindowManagerPolicy.PRESENCE_EXTERNAL : + WindowManagerPolicy.PRESENCE_INTERNAL; + + if (mIsTouchDevice) { + if ((sources & InputDevice.SOURCE_TOUCHSCREEN) == + InputDevice.SOURCE_TOUCHSCREEN) { + config.touchscreen = Configuration.TOUCHSCREEN_FINGER; } + } else { + config.touchscreen = Configuration.TOUCHSCREEN_NOTOUCH; + } - if (device.getKeyboardType() == InputDevice.KEYBOARD_TYPE_ALPHABETIC) { - config.keyboard = Configuration.KEYBOARD_QWERTY; - keyboardPresence |= presenceFlag; - } + if ((sources & InputDevice.SOURCE_TRACKBALL) == InputDevice.SOURCE_TRACKBALL) { + config.navigation = Configuration.NAVIGATION_TRACKBALL; + navigationPresence |= presenceFlag; + } else if ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD + && config.navigation == Configuration.NAVIGATION_NONAV) { + config.navigation = Configuration.NAVIGATION_DPAD; + navigationPresence |= presenceFlag; } - } - if (config.navigation == Configuration.NAVIGATION_NONAV && mHasPermanentDpad) { - config.navigation = Configuration.NAVIGATION_DPAD; - navigationPresence |= WindowManagerPolicy.PRESENCE_INTERNAL; + if (device.getKeyboardType() == InputDevice.KEYBOARD_TYPE_ALPHABETIC) { + config.keyboard = Configuration.KEYBOARD_QWERTY; + keyboardPresence |= presenceFlag; + } } + } - // Determine whether a hard keyboard is available and enabled. - boolean hardKeyboardAvailable = config.keyboard != Configuration.KEYBOARD_NOKEYS; - if (hardKeyboardAvailable != mHardKeyboardAvailable) { - mHardKeyboardAvailable = hardKeyboardAvailable; - mH.removeMessages(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE); - mH.sendEmptyMessage(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE); - } - if (mShowImeWithHardKeyboard) { - config.keyboard = Configuration.KEYBOARD_NOKEYS; - } + if (config.navigation == Configuration.NAVIGATION_NONAV && mHasPermanentDpad) { + config.navigation = Configuration.NAVIGATION_DPAD; + navigationPresence |= WindowManagerPolicy.PRESENCE_INTERNAL; + } - // Let the policy update hidden states. - config.keyboardHidden = Configuration.KEYBOARDHIDDEN_NO; - config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_NO; - config.navigationHidden = Configuration.NAVIGATIONHIDDEN_NO; - mPolicy.adjustConfigurationLw(config, keyboardPresence, navigationPresence); + // Determine whether a hard keyboard is available and enabled. + boolean hardKeyboardAvailable = config.keyboard != Configuration.KEYBOARD_NOKEYS; + if (hardKeyboardAvailable != mHardKeyboardAvailable) { + mHardKeyboardAvailable = hardKeyboardAvailable; + mH.removeMessages(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE); + mH.sendEmptyMessage(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE); } + if (mShowImeWithHardKeyboard) { + config.keyboard = Configuration.KEYBOARD_NOKEYS; + } + + // Let the policy update hidden states. + config.keyboardHidden = Configuration.KEYBOARDHIDDEN_NO; + config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_NO; + config.navigationHidden = Configuration.NAVIGATIONHIDDEN_NO; + mPolicy.adjustConfigurationLw(config, keyboardPresence, navigationPresence); return true; } diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 1e372ab..7ff7827 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -1580,15 +1580,16 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { void syncDeviceCapabilitiesLocked(DevicePolicyData policy) { // Ensure the status of the camera is synced down to the system. Interested native services // should monitor this value and act accordingly. - boolean systemState = SystemProperties.getBoolean(SYSTEM_PROP_DISABLE_CAMERA, false); + String cameraPropertyForUser = SYSTEM_PROP_DISABLE_CAMERA_PREFIX + policy.mUserHandle; + boolean systemState = SystemProperties.getBoolean(cameraPropertyForUser, false); boolean cameraDisabled = getCameraDisabled(null, policy.mUserHandle); if (cameraDisabled != systemState) { long token = Binder.clearCallingIdentity(); try { String value = cameraDisabled ? "1" : "0"; if (DBG) Slog.v(LOG_TAG, "Change in camera state [" - + SYSTEM_PROP_DISABLE_CAMERA + "] = " + value); - SystemProperties.set(SYSTEM_PROP_DISABLE_CAMERA, value); + + cameraPropertyForUser + "] = " + value); + SystemProperties.set(cameraPropertyForUser, value); } finally { Binder.restoreCallingIdentity(token); } @@ -3669,9 +3670,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { /** * The system property used to share the state of the camera. The native camera service - * is expected to read this property and act accordingly. + * is expected to read this property and act accordingly. The userId should be appended + * to this key. */ - public static final String SYSTEM_PROP_DISABLE_CAMERA = "sys.secpolicy.camera.disabled"; + public static final String SYSTEM_PROP_DISABLE_CAMERA_PREFIX = "sys.secpolicy.camera.off_"; /** * Disables all device cameras according to the specified admin. |