summaryrefslogtreecommitdiffstats
path: root/services/java
diff options
context:
space:
mode:
Diffstat (limited to 'services/java')
-rw-r--r--services/java/com/android/server/AppWidgetServiceImpl.java3
-rw-r--r--services/java/com/android/server/DeviceStorageMonitorService.java8
-rw-r--r--services/java/com/android/server/LocationManagerService.java42
-rwxr-xr-xservices/java/com/android/server/NotificationManagerService.java7
-rw-r--r--services/java/com/android/server/SystemServer.java12
-rw-r--r--services/java/com/android/server/ThrottleService.java9
-rw-r--r--services/java/com/android/server/UiModeManagerService.java9
-rw-r--r--services/java/com/android/server/WifiService.java10
-rw-r--r--services/java/com/android/server/accessibility/AccessibilityManagerService.java38
-rw-r--r--services/java/com/android/server/am/ActiveServices.java2
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java82
-rw-r--r--services/java/com/android/server/am/PendingIntentRecord.java13
-rw-r--r--services/java/com/android/server/connectivity/Tethering.java9
-rw-r--r--services/java/com/android/server/connectivity/Vpn.java5
-rw-r--r--services/java/com/android/server/display/WifiDisplayController.java2
-rw-r--r--services/java/com/android/server/input/InputManagerService.java13
-rw-r--r--services/java/com/android/server/pm/PackageManagerService.java100
-rw-r--r--services/java/com/android/server/pm/Settings.java39
-rw-r--r--services/java/com/android/server/usb/UsbDeviceManager.java19
19 files changed, 196 insertions, 226 deletions
diff --git a/services/java/com/android/server/AppWidgetServiceImpl.java b/services/java/com/android/server/AppWidgetServiceImpl.java
index fcc8a06..fa8f4b4 100644
--- a/services/java/com/android/server/AppWidgetServiceImpl.java
+++ b/services/java/com/android/server/AppWidgetServiceImpl.java
@@ -1398,8 +1398,7 @@ class AppWidgetServiceImpl {
int enforceSystemOrCallingUid(String packageName) throws IllegalArgumentException {
int callingUid = Binder.getCallingUid();
- int uid = Process.myUid();
- if (UserHandle.getAppId(uid) == Process.SYSTEM_UID || uid == 0) {
+ if (UserHandle.getAppId(callingUid) == Process.SYSTEM_UID || callingUid == 0) {
return callingUid;
}
return enforceCallingUid(packageName);
diff --git a/services/java/com/android/server/DeviceStorageMonitorService.java b/services/java/com/android/server/DeviceStorageMonitorService.java
index c919595..750a2fb 100644
--- a/services/java/com/android/server/DeviceStorageMonitorService.java
+++ b/services/java/com/android/server/DeviceStorageMonitorService.java
@@ -396,13 +396,15 @@ public class DeviceStorageMonitorService extends Binder {
com.android.internal.R.string.low_internal_storage_view_title);
CharSequence details = mContext.getText(
com.android.internal.R.string.low_internal_storage_view_text);
- PendingIntent intent = PendingIntent.getActivity(mContext, 0, lowMemIntent, 0);
+ PendingIntent intent = PendingIntent.getActivityAsUser(mContext, 0, lowMemIntent, 0,
+ null, UserHandle.CURRENT);
Notification notification = new Notification();
notification.icon = com.android.internal.R.drawable.stat_notify_disk_full;
notification.tickerText = title;
notification.flags |= Notification.FLAG_NO_CLEAR;
notification.setLatestEventInfo(mContext, title, details, intent);
- mNotificationMgr.notify(LOW_MEMORY_NOTIFICATION_ID, notification);
+ mNotificationMgr.notifyAsUser(null, LOW_MEMORY_NOTIFICATION_ID, notification,
+ UserHandle.ALL);
mContext.sendStickyBroadcast(mStorageLowIntent);
}
@@ -415,7 +417,7 @@ public class DeviceStorageMonitorService extends Binder {
(NotificationManager)mContext.getSystemService(
Context.NOTIFICATION_SERVICE);
//cancel notification since memory has been freed
- mNotificationMgr.cancel(LOW_MEMORY_NOTIFICATION_ID);
+ mNotificationMgr.cancelAsUser(null, LOW_MEMORY_NOTIFICATION_ID, UserHandle.ALL);
mContext.removeStickyBroadcastAsUser(mStorageLowIntent, UserHandle.ALL);
mContext.sendBroadcastAsUser(mStorageOkIntent, UserHandle.ALL);
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java
index 840d432..b834a84 100644
--- a/services/java/com/android/server/LocationManagerService.java
+++ b/services/java/com/android/server/LocationManagerService.java
@@ -601,6 +601,23 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
}
}
+ private boolean isAllowedProviderSafe(String provider) {
+ if (LocationManager.GPS_PROVIDER.equals(provider) ||
+ LocationManager.PASSIVE_PROVIDER.equals(provider)) {
+ // gps and passive providers require FINE permission
+ return mContext.checkCallingOrSelfPermission(ACCESS_FINE_LOCATION)
+ == PackageManager.PERMISSION_GRANTED;
+ } else if (LocationManager.NETWORK_PROVIDER.equals(provider) ||
+ LocationManager.FUSED_PROVIDER.equals(provider)) {
+ // network and fused providers are ok with COARSE or FINE
+ return (mContext.checkCallingOrSelfPermission(ACCESS_FINE_LOCATION)
+ == PackageManager.PERMISSION_GRANTED) ||
+ (mContext.checkCallingOrSelfPermission(ACCESS_COARSE_LOCATION)
+ == PackageManager.PERMISSION_GRANTED);
+ }
+ return false;
+ }
+
/**
* Returns all providers by name, including passive, but excluding
* fused.
@@ -632,8 +649,6 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
*/
@Override
public List<String> getProviders(Criteria criteria, boolean enabledOnly) {
- checkPermission();
-
ArrayList<String> out;
synchronized (mLock) {
out = new ArrayList<String>(mProviders.size());
@@ -642,14 +657,16 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
if (LocationManager.FUSED_PROVIDER.equals(name)) {
continue;
}
- if (enabledOnly && !isAllowedBySettingsLocked(name)) {
- continue;
- }
- if (criteria != null && !LocationProvider.propertiesMeetCriteria(
- name, provider.getProperties(), criteria)) {
- continue;
+ if (isAllowedProviderSafe(name)) {
+ if (enabledOnly && !isAllowedBySettingsLocked(name)) {
+ continue;
+ }
+ if (criteria != null && !LocationProvider.propertiesMeetCriteria(
+ name, provider.getProperties(), criteria)) {
+ continue;
+ }
+ out.add(name);
}
- out.add(name);
}
}
@@ -660,23 +677,22 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
/**
* Return the name of the best provider given a Criteria object.
* This method has been deprecated from the public API,
- * and the whole LoactionProvider (including #meetsCriteria)
+ * and the whole LocationProvider (including #meetsCriteria)
* has been deprecated as well. So this method now uses
* some simplified logic.
*/
@Override
public String getBestProvider(Criteria criteria, boolean enabledOnly) {
String result = null;
- checkPermission();
List<String> providers = getProviders(criteria, enabledOnly);
- if (providers.size() < 1) {
+ if (!providers.isEmpty()) {
result = pickBest(providers);
if (D) Log.d(TAG, "getBestProvider(" + criteria + ", " + enabledOnly + ")=" + result);
return result;
}
providers = getProviders(null, enabledOnly);
- if (providers.size() >= 1) {
+ if (!providers.isEmpty()) {
result = pickBest(providers);
if (D) Log.d(TAG, "getBestProvider(" + criteria + ", " + enabledOnly + ")=" + result);
return result;
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index 71e6e66..bab4f7a 100755
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -53,7 +53,6 @@ import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.Vibrator;
import android.provider.Settings;
-import android.service.dreams.IDreamManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.AtomicFile;
@@ -890,7 +889,7 @@ public class NotificationManagerService extends INotificationManager.Stub
final boolean isSystemNotification = ("android".equals(pkg));
userId = ActivityManager.handleIncomingUser(callingPid,
- callingUid, userId, false, true, "enqueueNotification", pkg);
+ callingUid, userId, true, true, "enqueueNotification", pkg);
// Limit the number of notifications that any given package except the android
// package can enqueue. Prevents DOS attacks and deals with leaks.
@@ -900,7 +899,7 @@ public class NotificationManagerService extends INotificationManager.Stub
final int N = mNotificationList.size();
for (int i=0; i<N; i++) {
final NotificationRecord r = mNotificationList.get(i);
- if (r.pkg.equals(pkg)) {
+ if (r.pkg.equals(pkg) && r.userId == userId) {
count++;
if (count >= MAX_PACKAGE_NOTIFICATIONS) {
Slog.e(TAG, "Package has already posted " + count
@@ -1261,7 +1260,7 @@ public class NotificationManagerService extends INotificationManager.Stub
public void cancelNotificationWithTag(String pkg, String tag, int id, int userId) {
checkCallerIsSystemOrSameApp(pkg);
userId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
- Binder.getCallingUid(), userId, false, true, "cancelNotificationWithTag", pkg);
+ Binder.getCallingUid(), userId, true, true, "cancelNotificationWithTag", pkg);
// Don't allow client applications to cancel foreground service notis.
cancelNotification(pkg, tag, id, 0,
Binder.getCallingUid() == Process.SYSTEM_UID
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index fb1d530..eeab757 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -768,6 +768,12 @@ class ServerThread extends Thread {
reportWtf("making Vibrator Service ready", e);
}
+ try {
+ lockSettings.systemReady();
+ } catch (Throwable e) {
+ reportWtf("making Lock Settings Service ready", e);
+ }
+
if (devicePolicy != null) {
try {
devicePolicy.systemReady();
@@ -785,12 +791,6 @@ class ServerThread extends Thread {
}
try {
- lockSettings.systemReady();
- } catch (Throwable e) {
- reportWtf("making Lock Settings Service ready", e);
- }
-
- try {
wm.systemReady();
} catch (Throwable e) {
reportWtf("making Window Manager Service ready", e);
diff --git a/services/java/com/android/server/ThrottleService.java b/services/java/com/android/server/ThrottleService.java
index 49f39fe..f36d73a 100644
--- a/services/java/com/android/server/ThrottleService.java
+++ b/services/java/com/android/server/ThrottleService.java
@@ -670,7 +670,8 @@ public class ThrottleService extends IThrottleManager.Stub {
intent.setClassName("com.android.phone", "com.android.phone.DataUsage");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
- PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);
+ PendingIntent pi = PendingIntent.getActivityAsUser(mContext, 0, intent, 0,
+ null, UserHandle.CURRENT);
Resources r = Resources.getSystem();
CharSequence title = r.getText(titleInt);
@@ -686,7 +687,8 @@ public class ThrottleService extends IThrottleManager.Stub {
mThrottlingNotification.tickerText = title;
mThrottlingNotification.setLatestEventInfo(mContext, title, message, pi);
- mNotificationManager.notify(mThrottlingNotification.icon, mThrottlingNotification);
+ mNotificationManager.notifyAsUser(null, mThrottlingNotification.icon,
+ mThrottlingNotification, UserHandle.ALL);
}
@@ -701,7 +703,8 @@ public class ThrottleService extends IThrottleManager.Stub {
Intent broadcast = new Intent(ThrottleManager.THROTTLE_ACTION);
broadcast.putExtra(ThrottleManager.EXTRA_THROTTLE_LEVEL, -1);
mContext.sendStickyBroadcastAsUser(broadcast, UserHandle.ALL);
- mNotificationManager.cancel(R.drawable.stat_sys_throttled);
+ mNotificationManager.cancelAsUser(null, R.drawable.stat_sys_throttled,
+ UserHandle.ALL);
mWarningNotificationSent = false;
}
}
diff --git a/services/java/com/android/server/UiModeManagerService.java b/services/java/com/android/server/UiModeManagerService.java
index 3e83baa..85a6e41 100644
--- a/services/java/com/android/server/UiModeManagerService.java
+++ b/services/java/com/android/server/UiModeManagerService.java
@@ -521,10 +521,13 @@ class UiModeManagerService extends IUiModeManager.Stub {
mContext,
mContext.getString(R.string.car_mode_disable_notification_title),
mContext.getString(R.string.car_mode_disable_notification_message),
- PendingIntent.getActivity(mContext, 0, carModeOffIntent, 0));
- mNotificationManager.notify(0, n);
+ PendingIntent.getActivityAsUser(mContext, 0, carModeOffIntent, 0,
+ null, UserHandle.CURRENT));
+ mNotificationManager.notifyAsUser(null,
+ R.string.car_mode_disable_notification_title, n, UserHandle.ALL);
} else {
- mNotificationManager.cancel(0);
+ mNotificationManager.cancelAsUser(null,
+ R.string.car_mode_disable_notification_title, UserHandle.ALL);
}
}
}
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java
index 5c38e63..024c8fd 100644
--- a/services/java/com/android/server/WifiService.java
+++ b/services/java/com/android/server/WifiService.java
@@ -1766,8 +1766,9 @@ public class WifiService extends IWifiManager.Stub {
mNotification.when = 0;
mNotification.icon = ICON_NETWORKS_AVAILABLE;
mNotification.flags = Notification.FLAG_AUTO_CANCEL;
- mNotification.contentIntent = PendingIntent.getActivity(mContext, 0,
- new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK), 0);
+ mNotification.contentIntent = PendingIntent.getActivityAsUser(mContext, 0,
+ new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK), 0,
+ null, UserHandle.CURRENT);
}
CharSequence title = mContext.getResources().getQuantityText(
@@ -1779,9 +1780,10 @@ public class WifiService extends IWifiManager.Stub {
mNotificationRepeatTime = System.currentTimeMillis() + NOTIFICATION_REPEAT_DELAY_MS;
- notificationManager.notify(ICON_NETWORKS_AVAILABLE, mNotification);
+ notificationManager.notifyAsUser(null, ICON_NETWORKS_AVAILABLE, mNotification,
+ UserHandle.ALL);
} else {
- notificationManager.cancel(ICON_NETWORKS_AVAILABLE);
+ notificationManager.cancelAsUser(null, ICON_NETWORKS_AVAILABLE, UserHandle.ALL);
}
mNotificationShown = visible;
diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
index 20c89ad..0e101e1 100644
--- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -79,7 +79,6 @@ import android.view.accessibility.IAccessibilityManagerClient;
import com.android.internal.R;
import com.android.internal.content.PackageMonitor;
-import com.android.internal.os.SomeArgs;
import com.android.internal.statusbar.IStatusBarService;
import org.xmlpull.v1.XmlPullParserException;
@@ -472,13 +471,18 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
// If necessary enable accessibility and announce that.
if (!userState.mIsAccessibilityEnabled) {
userState.mIsAccessibilityEnabled = true;
- scheduleSendStateToClientsLocked(userState);
}
+ // No touch exploration.
+ userState.mIsTouchExplorationEnabled = false;
+
+ // Hook the automation service up.
+ mUiAutomationService = new Service(mCurrentUserId, componentName,
+ accessibilityServiceInfo, true);
+ mUiAutomationService.onServiceConnected(componentName, serviceClient.asBinder());
+
+ updateInputFilterLocked(userState);
+ scheduleSendStateToClientsLocked(userState);
}
- // Hook the automation service up.
- mUiAutomationService = new Service(mCurrentUserId, componentName,
- accessibilityServiceInfo, true);
- mUiAutomationService.onServiceConnected(componentName, serviceClient.asBinder());
}
public void unregisterUiTestAutomationService(IAccessibilityServiceClient serviceClient) {
@@ -591,16 +595,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
// Recreate the internal state for the new user.
mMainHandler.obtainMessage(MainHandler.MSG_SEND_RECREATE_INTERNAL_STATE,
mCurrentUserId, 0).sendToTarget();
-
- // Re-register the test automation service after the new state is recreated.
- if (mUiAutomationService != null) {
- unregisterUiTestAutomationService(mUiAutomationService.mServiceInterface);
- SomeArgs args = SomeArgs.obtain();
- args.arg1 = mUiAutomationService.mServiceInterface;
- args.arg2 = mUiAutomationService.mAccessibilityServiceInfo;
- mMainHandler.obtainMessage(MainHandler.MSG_REGISTER_UI_TEST_AUTOMATION_SERVICE,
- args).sendToTarget();
- }
}
}
@@ -1166,7 +1160,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
public static final int MSG_SEND_STATE_TO_CLIENTS = 2;
public static final int MSG_SEND_CLEARED_STATE_TO_CLIENTS_FOR_USER = 3;
public static final int MSG_SEND_RECREATE_INTERNAL_STATE = 4;
- public static final int MSG_REGISTER_UI_TEST_AUTOMATION_SERVICE = 5;
public MainHandler(Looper looper) {
super(looper);
@@ -1202,17 +1195,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
recreateInternalStateLocked(userState);
}
} break;
- case MSG_REGISTER_UI_TEST_AUTOMATION_SERVICE: {
- SomeArgs args = (SomeArgs) msg.obj;
- try {
- IAccessibilityServiceClient client =
- (IAccessibilityServiceClient) args.arg1;
- AccessibilityServiceInfo info = (AccessibilityServiceInfo) args.arg2;
- registerUiTestAutomationService(client, info);
- } finally {
- args.recycle();
- }
- } break;
}
}
diff --git a/services/java/com/android/server/am/ActiveServices.java b/services/java/com/android/server/am/ActiveServices.java
index aefc264..0c0f00c 100644
--- a/services/java/com/android/server/am/ActiveServices.java
+++ b/services/java/com/android/server/am/ActiveServices.java
@@ -706,7 +706,7 @@ public class ActiveServices {
if (DEBUG_SERVICE) Slog.v(TAG, "retrieveServiceLocked: " + service
+ " type=" + resolvedType + " callingUid=" + callingUid);
- userId = mAm.handleIncomingUserLocked(callingPid, callingUid, userId,
+ userId = mAm.handleIncomingUser(callingPid, callingUid, userId,
false, true, "service", null);
if (service.getComponent() != null) {
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index a6f2974..904c98e 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -2448,7 +2448,7 @@ public final class ActivityManagerService extends ActivityManagerNative
String resultWho, int requestCode, int startFlags,
String profileFile, ParcelFileDescriptor profileFd, Bundle options, int userId) {
enforceNotIsolatedCaller("startActivity");
- userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(), userId,
+ userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "startActivity", null);
return mMainStack.startActivityMayWait(caller, -1, intent, resolvedType,
resultTo, resultWho, requestCode, startFlags, profileFile, profileFd,
@@ -2460,7 +2460,7 @@ public final class ActivityManagerService extends ActivityManagerNative
String resultWho, int requestCode, int startFlags, String profileFile,
ParcelFileDescriptor profileFd, Bundle options, int userId) {
enforceNotIsolatedCaller("startActivityAndWait");
- userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(), userId,
+ userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "startActivityAndWait", null);
WaitResult res = new WaitResult();
mMainStack.startActivityMayWait(caller, -1, intent, resolvedType,
@@ -2474,7 +2474,7 @@ public final class ActivityManagerService extends ActivityManagerNative
String resultWho, int requestCode, int startFlags, Configuration config,
Bundle options, int userId) {
enforceNotIsolatedCaller("startActivityWithConfig");
- userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(), userId,
+ userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "startActivityWithConfig", null);
int ret = mMainStack.startActivityMayWait(caller, -1, intent, resolvedType,
resultTo, resultWho, requestCode, startFlags,
@@ -2613,7 +2613,7 @@ public final class ActivityManagerService extends ActivityManagerNative
Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, int startFlags, Bundle options, int userId) {
- userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(), userId,
+ userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "startActivityInPackage", null);
int ret = mMainStack.startActivityMayWait(null, uid, intent, resolvedType,
@@ -2634,7 +2634,7 @@ public final class ActivityManagerService extends ActivityManagerNative
Intent[] intents, String[] resolvedTypes, IBinder resultTo,
Bundle options, int userId) {
- userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(), userId,
+ userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "startActivityInPackage", null);
int ret = mMainStack.startActivities(null, uid, intents, resolvedTypes, resultTo,
options, userId);
@@ -3460,7 +3460,7 @@ public final class ActivityManagerService extends ActivityManagerNative
enforceNotIsolatedCaller("clearApplicationUserData");
int uid = Binder.getCallingUid();
int pid = Binder.getCallingPid();
- userId = handleIncomingUserLocked(pid, uid,
+ userId = handleIncomingUser(pid, uid,
userId, false, true, "clearApplicationUserData", null);
long callingId = Binder.clearCallingIdentity();
try {
@@ -3516,7 +3516,7 @@ public final class ActivityManagerService extends ActivityManagerNative
throw new SecurityException(msg);
}
- userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(),
+ userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
userId, true, true, "killBackgroundProcesses", null);
long callingId = Binder.clearCallingIdentity();
try {
@@ -3591,7 +3591,7 @@ public final class ActivityManagerService extends ActivityManagerNative
Slog.w(TAG, msg);
throw new SecurityException(msg);
}
- userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(),
+ userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
userId, true, true, "forceStopPackage", null);
long callingId = Binder.clearCallingIdentity();
try {
@@ -4595,8 +4595,16 @@ public final class ActivityManagerService extends ActivityManagerNative
synchronized(this) {
int callingUid = Binder.getCallingUid();
- userId = handleIncomingUserLocked(Binder.getCallingPid(), callingUid, userId,
- false, true, "getIntentSender", null);
+ int origUserId = userId;
+ userId = handleIncomingUser(Binder.getCallingPid(), callingUid, userId,
+ type == ActivityManager.INTENT_SENDER_BROADCAST, true,
+ "getIntentSender", null);
+ if (origUserId == UserHandle.USER_CURRENT) {
+ // We don't want to evaluate this until the pending intent is
+ // actually executed. However, we do want to always do the
+ // security checking for it above.
+ userId = UserHandle.USER_CURRENT;
+ }
try {
if (callingUid != 0 && callingUid != Process.SYSTEM_UID) {
int uid = AppGlobals.getPackageManager()
@@ -5748,26 +5756,8 @@ public final class ActivityManagerService extends ActivityManagerNative
public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
int flags, int userId) {
- final int callingUid = Binder.getCallingUid();
- if (userId != UserHandle.getCallingUserId()) {
- // Check if the caller is holding permissions for cross-user requests.
- if (checkComponentPermission(
- android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
- Binder.getCallingPid(), callingUid, -1, true)
- != PackageManager.PERMISSION_GRANTED) {
- String msg = "Permission Denial: "
- + "Request to get recent tasks for user " + userId
- + " but is calling from user " + UserHandle.getUserId(callingUid)
- + "; this requires "
- + android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
- Slog.w(TAG, msg);
- throw new SecurityException(msg);
- } else {
- if (userId == UserHandle.USER_CURRENT) {
- userId = mCurrentUserId;
- }
- }
- }
+ userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
+ false, true, "getRecentTasks", null);
synchronized (this) {
enforceCallingPermission(android.Manifest.permission.GET_TASKS,
@@ -6671,7 +6661,7 @@ public final class ActivityManagerService extends ActivityManagerNative
throw new SecurityException(msg);
}
- userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(), userId,
+ userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "getContentProvider", null);
return getContentProviderImpl(caller, name, null, stable, userId);
}
@@ -6680,7 +6670,7 @@ public final class ActivityManagerService extends ActivityManagerNative
String name, int userId, IBinder token) {
enforceCallingPermission(android.Manifest.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY,
"Do not have permission in call getContentProviderExternal()");
- userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(), userId,
+ userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(), userId,
false, true, "getContentProvider", null);
return getContentProviderExternalUnchecked(name, token, userId);
}
@@ -6945,7 +6935,7 @@ public final class ActivityManagerService extends ActivityManagerNative
*/
public String getProviderMimeType(Uri uri, int userId) {
enforceNotIsolatedCaller("getProviderMimeType");
- userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(),
+ userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
userId, false, true, "getProviderMimeType", null);
final String name = uri.getAuthority();
final long ident = Binder.clearCallingIdentity();
@@ -10918,14 +10908,6 @@ public final class ActivityManagerService extends ActivityManagerNative
public int handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll,
boolean requireFull, String name, String callerPackage) {
- synchronized(this) {
- return handleIncomingUserLocked(callingPid, callingUid, userId, allowAll,
- requireFull, name, callerPackage);
- }
- }
-
- int handleIncomingUserLocked(int callingPid, int callingUid, int userId, boolean allowAll,
- boolean requireFull, String name, String callerPackage) {
final int callingUserId = UserHandle.getUserId(callingUid);
if (callingUserId != userId) {
if (callingUid != 0 && callingUid != Process.SYSTEM_UID) {
@@ -10966,6 +10948,10 @@ public final class ActivityManagerService extends ActivityManagerNative
}
if (userId == UserHandle.USER_CURRENT
|| userId == UserHandle.USER_CURRENT_OR_SELF) {
+ // Note that we may be accessing this outside of a lock...
+ // shouldn't be a big deal, if this is being called outside
+ // of a locked context there is intrinsically a race with
+ // the value the caller will receive and someone else changing it.
userId = mCurrentUserId;
}
if (!allowAll && userId < 0) {
@@ -11272,7 +11258,7 @@ public final class ActivityManagerService extends ActivityManagerNative
callingPid = Binder.getCallingPid();
}
- userId = this.handleIncomingUserLocked(callingPid, callingUid, userId,
+ userId = this.handleIncomingUser(callingPid, callingUid, userId,
true, true, "registerReceiver", callerPackage);
List allSticky = null;
@@ -11507,7 +11493,7 @@ public final class ActivityManagerService extends ActivityManagerNative
Slog.w(TAG, "Broadcast " + intent + " not ordered but result callback requested!");
}
- userId = handleIncomingUserLocked(callingPid, callingUid, userId,
+ userId = handleIncomingUser(callingPid, callingUid, userId,
true, false, "broadcast", callerPackage);
// Make sure that the user who is receiving this broadcast is started.
@@ -11920,7 +11906,7 @@ public final class ActivityManagerService extends ActivityManagerNative
throw new IllegalArgumentException("File descriptors passed in Intent");
}
- userId = handleIncomingUserLocked(Binder.getCallingPid(),
+ userId = handleIncomingUser(Binder.getCallingPid(),
Binder.getCallingUid(), userId, true, false, "removeStickyBroadcast", null);
synchronized(this) {
@@ -12008,7 +11994,7 @@ public final class ActivityManagerService extends ActivityManagerNative
String profileFile, int flags, Bundle arguments,
IInstrumentationWatcher watcher, int userId) {
enforceNotIsolatedCaller("startInstrumentation");
- userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(),
+ userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
userId, false, true, "startInstrumentation", null);
// Refuse possible leaked file descriptors
if (arguments != null && arguments.hasFileDescriptors()) {
@@ -13854,7 +13840,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
private ProcessRecord findProcessLocked(String process, int userId, String callName) {
- userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(),
+ userId = handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
userId, true, true, callName, null);
ProcessRecord proc = null;
try {
@@ -14303,6 +14289,10 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
+ int getCurrentUserIdLocked() {
+ return mCurrentUserId;
+ }
+
@Override
public boolean isUserRunning(int userId) {
if (checkCallingPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
diff --git a/services/java/com/android/server/am/PendingIntentRecord.java b/services/java/com/android/server/am/PendingIntentRecord.java
index c61f13c..8ee303f 100644
--- a/services/java/com/android/server/am/PendingIntentRecord.java
+++ b/services/java/com/android/server/am/PendingIntentRecord.java
@@ -25,6 +25,7 @@ import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
+import android.os.UserHandle;
import android.util.Slog;
import java.io.PrintWriter;
@@ -220,6 +221,10 @@ class PendingIntentRecord extends IIntentSender.Stub {
final long origId = Binder.clearCallingIdentity();
boolean sendFinish = finishedReceiver != null;
+ int userId = key.userId;
+ if (userId == UserHandle.USER_CURRENT) {
+ userId = owner.getCurrentUserIdLocked();
+ }
switch (key.type) {
case ActivityManager.INTENT_SENDER_ACTIVITY:
if (options == null) {
@@ -242,10 +247,10 @@ class PendingIntentRecord extends IIntentSender.Stub {
allIntents[allIntents.length-1] = finalIntent;
allResolvedTypes[allResolvedTypes.length-1] = resolvedType;
owner.startActivitiesInPackage(uid, allIntents,
- allResolvedTypes, resultTo, options, key.userId);
+ allResolvedTypes, resultTo, options, userId);
} else {
owner.startActivityInPackage(uid, finalIntent, resolvedType,
- resultTo, resultWho, requestCode, 0, options, key.userId);
+ resultTo, resultWho, requestCode, 0, options, userId);
}
} catch (RuntimeException e) {
Slog.w(ActivityManagerService.TAG,
@@ -263,7 +268,7 @@ class PendingIntentRecord extends IIntentSender.Stub {
owner.broadcastIntentInPackage(key.packageName, uid,
finalIntent, resolvedType,
finishedReceiver, code, null, null,
- requiredPermission, (finishedReceiver != null), false, key.userId);
+ requiredPermission, (finishedReceiver != null), false, userId);
sendFinish = false;
} catch (RuntimeException e) {
Slog.w(ActivityManagerService.TAG,
@@ -273,7 +278,7 @@ class PendingIntentRecord extends IIntentSender.Stub {
case ActivityManager.INTENT_SENDER_SERVICE:
try {
owner.startServiceInPackage(uid,
- finalIntent, resolvedType, key.userId);
+ finalIntent, resolvedType, userId);
} catch (RuntimeException e) {
Slog.w(ActivityManagerService.TAG,
"Unable to send startService intent", e);
diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java
index 79fb458..d8f3546 100644
--- a/services/java/com/android/server/connectivity/Tethering.java
+++ b/services/java/com/android/server/connectivity/Tethering.java
@@ -461,7 +461,8 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
intent.setClassName("com.android.settings", "com.android.settings.TetherSettings");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
- PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);
+ PendingIntent pi = PendingIntent.getActivityAsUser(mContext, 0, intent, 0,
+ null, UserHandle.CURRENT);
Resources r = Resources.getSystem();
CharSequence title = r.getText(com.android.internal.R.string.tethered_notification_title);
@@ -478,14 +479,16 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
mTetheredNotification.tickerText = title;
mTetheredNotification.setLatestEventInfo(mContext, title, message, pi);
- notificationManager.notify(mTetheredNotification.icon, mTetheredNotification);
+ notificationManager.notifyAsUser(null, mTetheredNotification.icon,
+ mTetheredNotification, UserHandle.ALL);
}
private void clearTetheredNotification() {
NotificationManager notificationManager =
(NotificationManager)mContext.getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null && mTetheredNotification != null) {
- notificationManager.cancel(mTetheredNotification.icon);
+ notificationManager.cancelAsUser(null, mTetheredNotification.icon,
+ UserHandle.ALL);
mTetheredNotification = null;
}
}
diff --git a/services/java/com/android/server/connectivity/Vpn.java b/services/java/com/android/server/connectivity/Vpn.java
index b3cbb84..03ff21f 100644
--- a/services/java/com/android/server/connectivity/Vpn.java
+++ b/services/java/com/android/server/connectivity/Vpn.java
@@ -50,6 +50,7 @@ import android.os.Process;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemService;
+import android.os.UserHandle;
import android.security.Credentials;
import android.security.KeyStore;
import android.util.Log;
@@ -421,7 +422,7 @@ public class Vpn extends BaseNetworkStateTracker {
.setDefaults(0)
.setOngoing(true)
.build();
- nm.notify(R.drawable.vpn_connected, notification);
+ nm.notifyAsUser(null, R.drawable.vpn_connected, notification, UserHandle.ALL);
}
}
@@ -433,7 +434,7 @@ public class Vpn extends BaseNetworkStateTracker {
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
if (nm != null) {
- nm.cancel(R.drawable.vpn_connected);
+ nm.cancelAsUser(null, R.drawable.vpn_connected, UserHandle.ALL);
}
}
diff --git a/services/java/com/android/server/display/WifiDisplayController.java b/services/java/com/android/server/display/WifiDisplayController.java
index 58f0445..d533c94 100644
--- a/services/java/com/android/server/display/WifiDisplayController.java
+++ b/services/java/com/android/server/display/WifiDisplayController.java
@@ -73,7 +73,7 @@ final class WifiDisplayController implements DumpUtils.Dump {
private static final int DEFAULT_CONTROL_PORT = 7236;
private static final int MAX_THROUGHPUT = 50;
- private static final int CONNECTION_TIMEOUT_SECONDS = 30;
+ private static final int CONNECTION_TIMEOUT_SECONDS = 60;
private static final int RTSP_TIMEOUT_SECONDS = 15;
private static final int DISCOVER_PEERS_MAX_RETRIES = 10;
diff --git a/services/java/com/android/server/input/InputManagerService.java b/services/java/com/android/server/input/InputManagerService.java
index 3709314..948c0e0 100644
--- a/services/java/com/android/server/input/InputManagerService.java
+++ b/services/java/com/android/server/input/InputManagerService.java
@@ -58,6 +58,7 @@ import android.os.Message;
import android.os.MessageQueue;
import android.os.Process;
import android.os.RemoteException;
+import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.util.Log;
@@ -660,7 +661,8 @@ public class InputManagerService extends IInputManager.Stub
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
- mKeyboardLayoutIntent = PendingIntent.getActivity(mContext, 0, intent, 0);
+ mKeyboardLayoutIntent = PendingIntent.getActivityAsUser(mContext, 0,
+ intent, 0, null, UserHandle.CURRENT);
}
Resources r = mContext.getResources();
@@ -673,8 +675,9 @@ public class InputManagerService extends IInputManager.Stub
.setSmallIcon(R.drawable.ic_settings_language)
.setPriority(Notification.PRIORITY_LOW)
.build();
- mNotificationManager.notify(R.string.select_keyboard_layout_notification_title,
- notification);
+ mNotificationManager.notifyAsUser(null,
+ R.string.select_keyboard_layout_notification_title,
+ notification, UserHandle.ALL);
mKeyboardLayoutNotificationShown = true;
}
}
@@ -683,7 +686,9 @@ public class InputManagerService extends IInputManager.Stub
private void hideMissingKeyboardLayoutNotification() {
if (mKeyboardLayoutNotificationShown) {
mKeyboardLayoutNotificationShown = false;
- mNotificationManager.cancel(R.string.select_keyboard_layout_notification_title);
+ mNotificationManager.cancelAsUser(null,
+ R.string.select_keyboard_layout_notification_title,
+ UserHandle.ALL);
}
}
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index 4b4febd..4800e7db 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -413,7 +413,6 @@ public class PackageManagerService extends IPackageManager.Stub {
// package uri's from external media onto secure containers
// or internal storage.
private IMediaContainerService mContainerService = null;
- private int mContainerServiceUserId;
static final int SEND_PENDING_BROADCAST = 1;
static final int MCS_BOUND = 3;
@@ -482,15 +481,8 @@ public class PackageManagerService extends IPackageManager.Stub {
" DefaultContainerService");
Intent service = new Intent().setComponent(DEFAULT_CONTAINER_COMPONENT);
Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
- mContainerServiceUserId = 0;
- if (mPendingInstalls.size() > 0) {
- mContainerServiceUserId = mPendingInstalls.get(0).getUser().getIdentifier();
- if (mContainerServiceUserId == UserHandle.USER_ALL) {
- mContainerServiceUserId = 0;
- }
- }
if (mContext.bindService(service, mDefContainerConn,
- Context.BIND_AUTO_CREATE, mContainerServiceUserId)) {
+ Context.BIND_AUTO_CREATE, UserHandle.USER_OWNER)) {
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
mBound = true;
return true;
@@ -567,15 +559,6 @@ public class PackageManagerService extends IPackageManager.Stub {
} else if (mPendingInstalls.size() > 0) {
HandlerParams params = mPendingInstalls.get(0);
if (params != null) {
- // Check if we're connected to the correct service, if it's an install
- // request.
- final int installFor = params.getUser().getIdentifier();
- if (installFor != mContainerServiceUserId
- && (installFor == UserHandle.USER_ALL
- && mContainerServiceUserId != 0)) {
- mHandler.sendEmptyMessage(MCS_RECONNECT);
- return;
- }
if (params.startCopy()) {
// We are done... look for more work or to
// go idle.
@@ -693,20 +676,23 @@ public class PackageManagerService extends IPackageManager.Stub {
}
case START_CLEANING_PACKAGE: {
Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
- PackageCleanItem item = new PackageCleanItem((String)msg.obj,
- msg.arg2 != 0);
+ final String packageName = (String)msg.obj;
+ final int userId = msg.arg1;
+ final boolean andCode = msg.arg2 != 0;
synchronized (mPackages) {
- if (msg.arg1 == UserHandle.USER_ALL) {
+ if (userId == UserHandle.USER_ALL) {
int[] users = sUserManager.getUserIds();
for (int user : users) {
- mSettings.addPackageToCleanLPw(user, item);
+ mSettings.addPackageToCleanLPw(
+ new PackageCleanItem(user, packageName, andCode));
}
} else {
- mSettings.addPackageToCleanLPw(msg.arg1, item);
+ mSettings.addPackageToCleanLPw(
+ new PackageCleanItem(userId, packageName, andCode));
}
}
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
- startCleaningPackages(-1);
+ startCleaningPackages();
} break;
case POST_INSTALL: {
if (DEBUG_INSTALL) Log.v(TAG, "Handling post-install for " + msg.arg1);
@@ -4193,10 +4179,14 @@ public class PackageManagerService extends IPackageManager.Stub {
// Add the new setting to mPackages
mPackages.put(pkg.applicationInfo.packageName, pkg);
// Make sure we don't accidentally delete its data.
- for (int i=0; i<mSettings.mPackagesToBeCleaned.size(); i++) {
- mSettings.mPackagesToBeCleaned.valueAt(i).remove(pkgName);
+ final Iterator<PackageCleanItem> iter = mSettings.mPackagesToBeCleaned.iterator();
+ while (iter.hasNext()) {
+ PackageCleanItem item = iter.next();
+ if (pkgName.equals(item.packageName)) {
+ iter.remove();
+ }
}
-
+
// Take care of first install / last update times.
if (currentTime != 0) {
if (pkgSetting.firstInstallTime == 0) {
@@ -5443,7 +5433,6 @@ public class PackageManagerService extends IPackageManager.Stub {
public PackageCleanItem nextPackageToClean(PackageCleanItem lastPackage) {
// writer
- final int userId = UserHandle.getCallingUserId();
synchronized (mPackages) {
if (!isExternalMediaAvailable()) {
// If the external storage is no longer mounted at this point,
@@ -5451,23 +5440,13 @@ public class PackageManagerService extends IPackageManager.Stub {
// packages files and can not delete any more. Bail.
return null;
}
- ArrayList<PackageCleanItem> pkgs = mSettings.mPackagesToBeCleaned.get(userId);
- if (pkgs != null) {
- if (lastPackage != null) {
- pkgs.remove(lastPackage);
- }
- if (pkgs.size() > 0) {
- return pkgs.get(0);
- }
+ final ArrayList<PackageCleanItem> pkgs = mSettings.mPackagesToBeCleaned;
+ if (lastPackage != null) {
+ pkgs.remove(lastPackage);
+ }
+ if (pkgs.size() > 0) {
+ return pkgs.get(0);
}
- mSettings.mPackagesToBeCleaned.remove(userId);
- }
- // Move on to the next user to clean.
- long ident = Binder.clearCallingIdentity();
- try {
- startCleaningPackages(userId);
- } finally {
- Binder.restoreCallingIdentity(ident);
}
return null;
}
@@ -5483,34 +5462,22 @@ public class PackageManagerService extends IPackageManager.Stub {
userId, andCode ? 1 : 0, packageName));
}
- void startCleaningPackages(int lastUser) {
+ void startCleaningPackages() {
// reader
- int nextUser = -1;
synchronized (mPackages) {
if (!isExternalMediaAvailable()) {
return;
}
- final int N = mSettings.mPackagesToBeCleaned.size();
- if (N <= 0) {
+ if (mSettings.mPackagesToBeCleaned.isEmpty()) {
return;
}
- for (int i=0; i<N; i++) {
- int user = mSettings.mPackagesToBeCleaned.keyAt(i);
- if (user > lastUser) {
- nextUser = user;
- break;
- }
- }
- if (nextUser < 0) {
- nextUser = mSettings.mPackagesToBeCleaned.keyAt(0);
- }
}
Intent intent = new Intent(PackageManager.ACTION_CLEAN_EXTERNAL_STORAGE);
intent.setComponent(DEFAULT_CONTAINER_COMPONENT);
IActivityManager am = ActivityManagerNative.getDefault();
if (am != null) {
try {
- am.startService(null, intent, null, nextUser);
+ am.startService(null, intent, null, UserHandle.USER_OWNER);
} catch (RemoteException e) {
}
}
@@ -8399,10 +8366,11 @@ public class PackageManagerService extends IPackageManager.Stub {
} else {
users = new int[] { userId };
}
- for (int curUser : users) {
- ClearStorageConnection conn = new ClearStorageConnection();
- if (mContext.bindService(containerIntent, conn, Context.BIND_AUTO_CREATE, curUser)) {
- try {
+ final ClearStorageConnection conn = new ClearStorageConnection();
+ if (mContext.bindService(
+ containerIntent, conn, Context.BIND_AUTO_CREATE, UserHandle.USER_OWNER)) {
+ try {
+ for (int curUser : users) {
long timeout = SystemClock.uptimeMillis() + 5000;
synchronized (conn) {
long now = SystemClock.uptimeMillis();
@@ -8438,9 +8406,9 @@ public class PackageManagerService extends IPackageManager.Stub {
} catch (RemoteException e) {
}
}
- } finally {
- mContext.unbindService(conn);
}
+ } finally {
+ mContext.unbindService(conn);
}
}
}
@@ -9596,7 +9564,7 @@ public class PackageManagerService extends IPackageManager.Stub {
if (DEBUG_SD_INSTALL)
Log.i(TAG, "Loading packages");
loadMediaPackages(processCids, uidArr, removeCids);
- startCleaningPackages(-1);
+ startCleaningPackages();
} else {
if (DEBUG_SD_INSTALL)
Log.i(TAG, "Unloading packages");
diff --git a/services/java/com/android/server/pm/Settings.java b/services/java/com/android/server/pm/Settings.java
index 23e54678..2fb853a 100644
--- a/services/java/com/android/server/pm/Settings.java
+++ b/services/java/com/android/server/pm/Settings.java
@@ -159,8 +159,7 @@ final class Settings {
// Packages that have been uninstalled and still need their external
// storage data deleted.
- final SparseArray<ArrayList<PackageCleanItem>> mPackagesToBeCleaned
- = new SparseArray<ArrayList<PackageCleanItem>>();
+ final ArrayList<PackageCleanItem> mPackagesToBeCleaned = new ArrayList<PackageCleanItem>();
// Packages that have been renamed since they were first installed.
// Keys are the new names of the packages, values are the original
@@ -1257,18 +1256,13 @@ final class Settings {
}
if (mPackagesToBeCleaned.size() > 0) {
- for (int i=0; i<mPackagesToBeCleaned.size(); i++) {
- final int userId = mPackagesToBeCleaned.keyAt(i);
- final String userStr = Integer.toString(userId);
- final ArrayList<PackageCleanItem> pkgs = mPackagesToBeCleaned.valueAt(i);
- for (int j=0; j<pkgs.size(); j++) {
- serializer.startTag(null, "cleaning-package");
- PackageCleanItem item = pkgs.get(j);
- serializer.attribute(null, ATTR_NAME, item.packageName);
- serializer.attribute(null, ATTR_CODE, item.andCode ? "true" : "false");
- serializer.attribute(null, ATTR_USER, userStr);
- serializer.endTag(null, "cleaning-package");
- }
+ for (PackageCleanItem item : mPackagesToBeCleaned) {
+ final String userStr = Integer.toString(item.userId);
+ serializer.startTag(null, "cleaning-package");
+ serializer.attribute(null, ATTR_NAME, item.packageName);
+ serializer.attribute(null, ATTR_CODE, item.andCode ? "true" : "false");
+ serializer.attribute(null, ATTR_USER, userStr);
+ serializer.endTag(null, "cleaning-package");
}
}
@@ -1524,14 +1518,9 @@ final class Settings {
return ret;
}
- void addPackageToCleanLPw(int userId, PackageCleanItem pkg) {
- ArrayList<PackageCleanItem> pkgs = mPackagesToBeCleaned.get(userId);
- if (pkgs == null) {
- pkgs = new ArrayList<PackageCleanItem>();
- mPackagesToBeCleaned.put(userId, pkgs);
- }
- if (!pkgs.contains(pkg)) {
- pkgs.add(pkg);
+ void addPackageToCleanLPw(PackageCleanItem pkg) {
+ if (!mPackagesToBeCleaned.contains(pkg)) {
+ mPackagesToBeCleaned.add(pkg);
}
}
@@ -1615,18 +1604,18 @@ final class Settings {
String userStr = parser.getAttributeValue(null, ATTR_USER);
String codeStr = parser.getAttributeValue(null, ATTR_CODE);
if (name != null) {
- int user = 0;
+ int userId = 0;
boolean andCode = true;
try {
if (userStr != null) {
- user = Integer.parseInt(userStr);
+ userId = Integer.parseInt(userStr);
}
} catch (NumberFormatException e) {
}
if (codeStr != null) {
andCode = Boolean.parseBoolean(codeStr);
}
- addPackageToCleanLPw(user, new PackageCleanItem(name, andCode));
+ addPackageToCleanLPw(new PackageCleanItem(userId, name, andCode));
}
} else if (tagName.equals("renamed-package")) {
String nname = parser.getAttributeValue(null, "new");
diff --git a/services/java/com/android/server/usb/UsbDeviceManager.java b/services/java/com/android/server/usb/UsbDeviceManager.java
index 392d5e7..8f13501 100644
--- a/services/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/java/com/android/server/usb/UsbDeviceManager.java
@@ -667,7 +667,8 @@ public class UsbDeviceManager {
if (id != mUsbNotificationId) {
// clear notification if title needs changing
if (mUsbNotificationId != 0) {
- mNotificationManager.cancel(mUsbNotificationId);
+ mNotificationManager.cancelAsUser(null, mUsbNotificationId,
+ UserHandle.ALL);
mUsbNotificationId = 0;
}
if (id != 0) {
@@ -688,10 +689,11 @@ public class UsbDeviceManager {
Intent intent = Intent.makeRestartActivityTask(
new ComponentName("com.android.settings",
"com.android.settings.UsbSettings"));
- PendingIntent pi = PendingIntent.getActivity(mContext, 0,
- intent, 0);
+ PendingIntent pi = PendingIntent.getActivityAsUser(mContext, 0,
+ intent, 0, null, UserHandle.CURRENT);
notification.setLatestEventInfo(mContext, title, message, pi);
- mNotificationManager.notify(id, notification);
+ mNotificationManager.notifyAsUser(null, id, notification,
+ UserHandle.ALL);
mUsbNotificationId = id;
}
}
@@ -722,15 +724,16 @@ public class UsbDeviceManager {
Intent intent = Intent.makeRestartActivityTask(
new ComponentName("com.android.settings",
"com.android.settings.DevelopmentSettings"));
- PendingIntent pi = PendingIntent.getActivity(mContext, 0,
- intent, 0);
+ PendingIntent pi = PendingIntent.getActivityAsUser(mContext, 0,
+ intent, 0, null, UserHandle.CURRENT);
notification.setLatestEventInfo(mContext, title, message, pi);
mAdbNotificationShown = true;
- mNotificationManager.notify(id, notification);
+ mNotificationManager.notifyAsUser(null, id, notification,
+ UserHandle.ALL);
}
} else if (mAdbNotificationShown) {
mAdbNotificationShown = false;
- mNotificationManager.cancel(id);
+ mNotificationManager.cancelAsUser(null, id, UserHandle.ALL);
}
}