Move handling of package changes to a background thread.
Helps get rid of some jank when installing applications.
Change-Id: I97d0022f82d67796e334d37086e5911dd6ca6b62
diff --git a/services/java/com/android/server/DevicePolicyManagerService.java b/services/java/com/android/server/DevicePolicyManagerService.java
index d8e3d59..eb33060 100644
--- a/services/java/com/android/server/DevicePolicyManagerService.java
+++ b/services/java/com/android/server/DevicePolicyManagerService.java
@@ -451,7 +451,7 @@
public DevicePolicyManagerService(Context context) {
mContext = context;
mMonitor = new MyPackageMonitor();
- mMonitor.register(context, true);
+ mMonitor.register(context, null, true);
mWakeLock = ((PowerManager)context.getSystemService(Context.POWER_SERVICE))
.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "DPM");
IntentFilter filter = new IntentFilter();
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index a474cec..43c2292 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -594,7 +594,7 @@
}
mImListManager = new InputMethodAndSubtypeListManager(context, this);
- (new MyPackageMonitor()).register(mContext, true);
+ (new MyPackageMonitor()).register(mContext, null, true);
IntentFilter screenOnOffFilt = new IntentFilter();
screenOnOffFilt.addAction(Intent.ACTION_SCREEN_ON);
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java
index 8cb9d99b..d651111 100644
--- a/services/java/com/android/server/LocationManagerService.java
+++ b/services/java/com/android/server/LocationManagerService.java
@@ -511,7 +511,7 @@
com.android.internal.R.string.config_networkLocationProvider);
mGeocodeProviderPackageName = resources.getString(
com.android.internal.R.string.config_geocodeProvider);
- mPackageMonitor.register(context, true);
+ mPackageMonitor.register(context, null, true);
if (LOCAL_LOGV) {
Slog.v(TAG, "Constructed LocationManager Service");
diff --git a/services/java/com/android/server/RecognitionManagerService.java b/services/java/com/android/server/RecognitionManagerService.java
index 85224d8..3567cfc 100644
--- a/services/java/com/android/server/RecognitionManagerService.java
+++ b/services/java/com/android/server/RecognitionManagerService.java
@@ -65,7 +65,7 @@
RecognitionManagerService(Context context) {
mContext = context;
mMonitor = new MyPackageMonitor();
- mMonitor.register(context, true);
+ mMonitor.register(context, null, true);
}
public void systemReady() {
diff --git a/services/java/com/android/server/TextServicesManagerService.java b/services/java/com/android/server/TextServicesManagerService.java
index 106bb3e..499ff7a 100644
--- a/services/java/com/android/server/TextServicesManagerService.java
+++ b/services/java/com/android/server/TextServicesManagerService.java
@@ -77,7 +77,7 @@
mSystemReady = false;
mContext = context;
mMonitor = new TextServicesMonitor();
- mMonitor.register(context, true);
+ mMonitor.register(context, null, true);
synchronized (mSpellCheckerMap) {
buildSpellCheckerMapLocked(context, mSpellCheckerList, mSpellCheckerMap);
}
diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java
index 6d83f30..d97d335 100644
--- a/services/java/com/android/server/WallpaperManagerService.java
+++ b/services/java/com/android/server/WallpaperManagerService.java
@@ -295,7 +295,7 @@
|| !wallpaper.wallpaperComponent.getPackageName().equals(packageName)) {
continue;
}
- doPackagesChanged(true, wallpaper);
+ doPackagesChangedLocked(true, wallpaper);
}
}
}
@@ -315,66 +315,68 @@
@Override
public boolean onHandleForceStop(Intent intent, String[] packages, int uid, boolean doit) {
- boolean changed = false;
- for (int i = 0; i < mWallpaperMap.size(); i++) {
- WallpaperData wallpaper = mWallpaperMap.valueAt(i);
- boolean res = doPackagesChanged(doit, wallpaper);
- changed |= res;
+ synchronized (mLock) {
+ boolean changed = false;
+ for (int i = 0; i < mWallpaperMap.size(); i++) {
+ WallpaperData wallpaper = mWallpaperMap.valueAt(i);
+ boolean res = doPackagesChangedLocked(doit, wallpaper);
+ changed |= res;
+ }
+ return changed;
}
- return changed;
}
@Override
public void onSomePackagesChanged() {
- for (int i = 0; i < mWallpaperMap.size(); i++) {
- WallpaperData wallpaper = mWallpaperMap.valueAt(i);
- doPackagesChanged(true, wallpaper);
+ synchronized (mLock) {
+ for (int i = 0; i < mWallpaperMap.size(); i++) {
+ WallpaperData wallpaper = mWallpaperMap.valueAt(i);
+ doPackagesChangedLocked(true, wallpaper);
+ }
}
}
- boolean doPackagesChanged(boolean doit, WallpaperData wallpaper) {
+ boolean doPackagesChangedLocked(boolean doit, WallpaperData wallpaper) {
boolean changed = false;
- synchronized (mLock) {
- if (wallpaper.wallpaperComponent != null) {
- int change = isPackageDisappearing(wallpaper.wallpaperComponent
- .getPackageName());
- if (change == PACKAGE_PERMANENT_CHANGE
- || change == PACKAGE_TEMPORARY_CHANGE) {
- changed = true;
- if (doit) {
- Slog.w(TAG, "Wallpaper uninstalled, removing: "
- + wallpaper.wallpaperComponent);
- clearWallpaperLocked(false, wallpaper.userId);
- }
- }
- }
- if (wallpaper.nextWallpaperComponent != null) {
- int change = isPackageDisappearing(wallpaper.nextWallpaperComponent
- .getPackageName());
- if (change == PACKAGE_PERMANENT_CHANGE
- || change == PACKAGE_TEMPORARY_CHANGE) {
- wallpaper.nextWallpaperComponent = null;
- }
- }
- if (wallpaper.wallpaperComponent != null
- && isPackageModified(wallpaper.wallpaperComponent.getPackageName())) {
- try {
- mContext.getPackageManager().getServiceInfo(
- wallpaper.wallpaperComponent, 0);
- } catch (NameNotFoundException e) {
- Slog.w(TAG, "Wallpaper component gone, removing: "
+ if (wallpaper.wallpaperComponent != null) {
+ int change = isPackageDisappearing(wallpaper.wallpaperComponent
+ .getPackageName());
+ if (change == PACKAGE_PERMANENT_CHANGE
+ || change == PACKAGE_TEMPORARY_CHANGE) {
+ changed = true;
+ if (doit) {
+ Slog.w(TAG, "Wallpaper uninstalled, removing: "
+ wallpaper.wallpaperComponent);
clearWallpaperLocked(false, wallpaper.userId);
}
}
- if (wallpaper.nextWallpaperComponent != null
- && isPackageModified(wallpaper.nextWallpaperComponent.getPackageName())) {
- try {
- mContext.getPackageManager().getServiceInfo(
- wallpaper.nextWallpaperComponent, 0);
- } catch (NameNotFoundException e) {
- wallpaper.nextWallpaperComponent = null;
- }
+ }
+ if (wallpaper.nextWallpaperComponent != null) {
+ int change = isPackageDisappearing(wallpaper.nextWallpaperComponent
+ .getPackageName());
+ if (change == PACKAGE_PERMANENT_CHANGE
+ || change == PACKAGE_TEMPORARY_CHANGE) {
+ wallpaper.nextWallpaperComponent = null;
+ }
+ }
+ if (wallpaper.wallpaperComponent != null
+ && isPackageModified(wallpaper.wallpaperComponent.getPackageName())) {
+ try {
+ mContext.getPackageManager().getServiceInfo(
+ wallpaper.wallpaperComponent, 0);
+ } catch (NameNotFoundException e) {
+ Slog.w(TAG, "Wallpaper component gone, removing: "
+ + wallpaper.wallpaperComponent);
+ clearWallpaperLocked(false, wallpaper.userId);
+ }
+ }
+ if (wallpaper.nextWallpaperComponent != null
+ && isPackageModified(wallpaper.nextWallpaperComponent.getPackageName())) {
+ try {
+ mContext.getPackageManager().getServiceInfo(
+ wallpaper.nextWallpaperComponent, 0);
+ } catch (NameNotFoundException e) {
+ wallpaper.nextWallpaperComponent = null;
}
}
return changed;
@@ -387,7 +389,7 @@
mIWindowManager = IWindowManager.Stub.asInterface(
ServiceManager.getService(Context.WINDOW_SERVICE));
mMonitor = new MyPackageMonitor();
- mMonitor.register(context, true);
+ mMonitor.register(context, null, true);
WALLPAPER_BASE_DIR.mkdirs();
loadSettingsLocked(0);
}
diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
index 6675816..a50db67 100644
--- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -269,11 +269,11 @@
};
// package changes
- monitor.register(context, true);
+ monitor.register(context, null, true);
// boot completed
IntentFilter bootFiler = new IntentFilter(Intent.ACTION_BOOT_COMPLETED);
- mContext.registerReceiver(monitor, bootFiler);
+ mContext.registerReceiver(monitor, bootFiler, null, monitor.getRegisteredHandler());
}
/**
diff --git a/services/java/com/android/server/am/UsageStatsService.java b/services/java/com/android/server/am/UsageStatsService.java
index e810e3c..ba65f39 100644
--- a/services/java/com/android/server/am/UsageStatsService.java
+++ b/services/java/com/android/server/am/UsageStatsService.java
@@ -656,7 +656,7 @@
}
}
};
- mPackageMonitor.register(mContext, true);
+ mPackageMonitor.register(mContext, null, true);
filterHistoryStats();
}
diff --git a/services/java/com/android/server/usb/UsbSettingsManager.java b/services/java/com/android/server/usb/UsbSettingsManager.java
index 0baafbb..7dde340 100644
--- a/services/java/com/android/server/usb/UsbSettingsManager.java
+++ b/services/java/com/android/server/usb/UsbSettingsManager.java
@@ -370,7 +370,7 @@
synchronized (mLock) {
readSettingsLocked();
}
- mPackageMonitor.register(context, true);
+ mPackageMonitor.register(context, null, true);
}
private void readPreference(XmlPullParser parser)