Merge "Format Japanese numbers using national format when in Japan." am: 050e5ddb4f
am: 8ac499fbe6
Change-Id: Ied615fbaf689a931a2b93785d944f2a8bd7f49dd
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index df7c660..43a5eba 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -2533,7 +2533,6 @@
final int userId = ActivityManager.handleIncomingUser(callingPid,
callingUid, incomingUserId, true, false, "enqueueNotification", pkg);
final UserHandle user = new UserHandle(userId);
-
// Fix the notification as best we can.
try {
final ApplicationInfo ai = getContext().getPackageManager().getApplicationInfoAsUser(
@@ -2547,13 +2546,16 @@
mUsageStats.registerEnqueuedByApp(pkg);
-
if (pkg == null || notification == null) {
throw new IllegalArgumentException("null not allowed: pkg=" + pkg
+ " id=" + id + " notification=" + notification);
}
+
+ // The system can post notifications for any package, let us resolve that.
+ final int notificationUid = resolveNotificationUid(opPkg, callingUid, userId);
+
final StatusBarNotification n = new StatusBarNotification(
- pkg, opPkg, id, tag, callingUid, callingPid, 0, notification,
+ pkg, opPkg, id, tag, notificationUid, callingPid, 0, notification,
user);
// Limit the number of notifications that any given package except the android
@@ -2623,6 +2625,19 @@
idOut[0] = id;
}
+ private int resolveNotificationUid(String opPackageName, int callingUid, int userId) {
+ // The system can post notifications on behalf of any package it wants
+ if (isCallerSystem() && opPackageName != null && !"android".equals(opPackageName)) {
+ try {
+ return getContext().getPackageManager()
+ .getPackageUidAsUser(opPackageName, userId);
+ } catch (NameNotFoundException e) {
+ /* ignore */
+ }
+ }
+ return callingUid;
+ }
+
private class EnqueueNotificationRunnable implements Runnable {
private final NotificationRecord r;
private final int userId;
diff --git a/services/core/java/com/android/server/storage/AppCollector.java b/services/core/java/com/android/server/storage/AppCollector.java
index cf05e9f..ee9c5bf 100644
--- a/services/core/java/com/android/server/storage/AppCollector.java
+++ b/services/core/java/com/android/server/storage/AppCollector.java
@@ -16,6 +16,7 @@
package com.android.server.storage;
+import android.annotation.NonNull;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageStatsObserver;
@@ -32,6 +33,7 @@
import android.os.storage.VolumeInfo;
import android.util.Log;
import com.android.internal.os.BackgroundThread;
+import com.android.internal.util.Preconditions;
import java.util.ArrayList;
import java.util.List;
@@ -56,7 +58,9 @@
* @param context Android context used to get
* @param volume Volume to check for apps.
*/
- public AppCollector(Context context, VolumeInfo volume) {
+ public AppCollector(Context context, @NonNull VolumeInfo volume) {
+ Preconditions.checkNotNull(volume);
+
mBackgroundHandler = new BackgroundHandler(BackgroundThread.get().getLooper(),
volume,
context.getPackageManager(),
@@ -117,7 +121,7 @@
private final PackageManager mPm;
private final UserManager mUm;
- BackgroundHandler(Looper looper, VolumeInfo volume, PackageManager pm, UserManager um) {
+ BackgroundHandler(Looper looper, @NonNull VolumeInfo volume, PackageManager pm, UserManager um) {
super(looper);
mVolume = volume;
mPm = pm;
diff --git a/services/core/java/com/android/server/storage/DiskStatsLoggingService.java b/services/core/java/com/android/server/storage/DiskStatsLoggingService.java
index 7c43162..4035ade 100644
--- a/services/core/java/com/android/server/storage/DiskStatsLoggingService.java
+++ b/services/core/java/com/android/server/storage/DiskStatsLoggingService.java
@@ -29,6 +29,7 @@
import android.os.Environment;
import android.os.Environment.UserEnvironment;
import android.os.UserHandle;
+import android.os.storage.VolumeInfo;
import android.provider.Settings;
import android.util.Log;
@@ -61,10 +62,16 @@
return false;
}
+
+ VolumeInfo volume = getPackageManager().getPrimaryStorageCurrentVolume();
+ // volume is null if the primary storage is not yet mounted.
+ if (volume == null) {
+ return false;
+ }
+ AppCollector collector = new AppCollector(this, volume);
+
final int userId = UserHandle.myUserId();
UserEnvironment environment = new UserEnvironment(userId);
- AppCollector collector = new AppCollector(this,
- getPackageManager().getPrimaryStorageCurrentVolume());
LogRunnable task = new LogRunnable();
task.setRootDirectory(environment.getExternalStorageDirectory());
task.setDownloadsDirectory(
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index f0d5549..92830f4 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -159,10 +159,8 @@
"com.google.android.clockwork.ThermalObserver";
private static final String WEAR_BLUETOOTH_SERVICE_CLASS =
"com.google.android.clockwork.bluetooth.WearBluetoothService";
- private static final String WEAR_WIFI_MEDIATOR_SERVICE_CLASS =
- "com.google.android.clockwork.wifi.WearWifiMediatorService";
- private static final String WEAR_CELLULAR_MEDIATOR_SERVICE_CLASS =
- "com.google.android.clockwork.cellular.WearCellularMediatorService";
+ private static final String WEAR_CONNECTIVITY_SERVICE_CLASS =
+ "com.google.android.clockwork.connectivity.WearConnectivityService";
private static final String WEAR_TIME_SERVICE_CLASS =
"com.google.android.clockwork.time.WearTimeService";
private static final String ACCOUNT_SERVICE_CLASS =
@@ -1193,10 +1191,7 @@
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) {
mSystemServiceManager.startService(WEAR_BLUETOOTH_SERVICE_CLASS);
- mSystemServiceManager.startService(WEAR_WIFI_MEDIATOR_SERVICE_CLASS);
- if (SystemProperties.getBoolean("config.enable_cellmediator", false)) {
- mSystemServiceManager.startService(WEAR_CELLULAR_MEDIATOR_SERVICE_CLASS);
- }
+ mSystemServiceManager.startService(WEAR_CONNECTIVITY_SERVICE_CLASS);
if (!disableNonCoreServices) {
mSystemServiceManager.startService(WEAR_TIME_SERVICE_CLASS);
}
diff --git a/services/tests/servicestests/src/com/android/server/storage/AppCollectorTest.java b/services/tests/servicestests/src/com/android/server/storage/AppCollectorTest.java
index da22e77..29185e9 100644
--- a/services/tests/servicestests/src/com/android/server/storage/AppCollectorTest.java
+++ b/services/tests/servicestests/src/com/android/server/storage/AppCollectorTest.java
@@ -187,10 +187,14 @@
}).start();
latch.await();
- // This should
assertThat(myStats).containsAllOf(stats, otherStats);
}
+ @Test(expected=NullPointerException.class)
+ public void testNullVolumeShouldCauseNPE() throws Exception {
+ AppCollector collector = new AppCollector(mContext, null);
+ }
+
private void addApplication(String packageName, String uuid) {
ApplicationInfo info = new ApplicationInfo();
info.packageName = packageName;