summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server/PackageManagerService.java
diff options
context:
space:
mode:
authorSuchi Amalapurapu <asuchitra@google.com>2010-02-22 16:03:53 -0800
committerSuchi Amalapurapu <asuchitra@google.com>2010-02-24 20:30:03 -0800
commitc42e29e0a58d07a95d470780216cdf1d67476bd6 (patch)
treebb2a39fe7ddaf416a3a67a98eb12b661c7070d6d /services/java/com/android/server/PackageManagerService.java
parent406b09bbd117446814a05aabc5971fd55c6afa5d (diff)
downloadframeworks_base-c42e29e0a58d07a95d470780216cdf1d67476bd6.zip
frameworks_base-c42e29e0a58d07a95d470780216cdf1d67476bd6.tar.gz
frameworks_base-c42e29e0a58d07a95d470780216cdf1d67476bd6.tar.bz2
Add new handler mechanism in MountService to make unmount api asynchronous.
MountService updates state on PackageManager and then tries to kill processes holding file references to media about to be unmounted by invoking api on ACtivityManager. This is retried upto 4 times to make sure all processes holding file references are killed before unmounting the media at specified path. Also changed PackageManger api to return boolean value to indicate if MountService is likely to receive broadcasts related to apps on sd.
Diffstat (limited to 'services/java/com/android/server/PackageManagerService.java')
-rw-r--r--services/java/com/android/server/PackageManagerService.java25
1 files changed, 18 insertions, 7 deletions
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 9e0d623..a23fac4 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -8877,6 +8877,9 @@ class PackageManagerService extends IPackageManager.Stub {
return prefix + tmpIdx;
}
+ /*
+ * Return true if PackageManager does have packages to be updated.
+ */
public boolean updateExternalMediaStatus(final boolean mediaStatus) {
synchronized (mPackages) {
if (DEBUG_SD_INSTALL) Log.i(TAG, "updateExternalMediaStatus:: mediaStatus=" +
@@ -8885,16 +8888,24 @@ class PackageManagerService extends IPackageManager.Stub {
return false;
}
mMediaMounted = mediaStatus;
- final HashMap<SdInstallArgs, String> processCids =
- new HashMap<SdInstallArgs, String>();
- final int[] uidArr = getExternalMediaPackages(mediaStatus, processCids);
- if (processCids.size() == 0) {
+ boolean ret = false;
+ synchronized (mPackages) {
+ Set<String> appList = mSettings.findPackagesWithFlag(ApplicationInfo.FLAG_ON_SDCARD);
+ ret = appList != null && appList.size() > 0;
+ }
+ if (!ret) {
+ // No packages will be effected by the sdcard update. Just return.
return false;
}
// Queue up an async operation since the package installation may take a little while.
mHandler.post(new Runnable() {
public void run() {
mHandler.removeCallbacks(this);
+ // If we are up here that means there are packages to be
+ // enabled or disabled.
+ final HashMap<SdInstallArgs, String> processCids =
+ new HashMap<SdInstallArgs, String>();
+ final int[] uidArr = getExternalMediaPackages(mediaStatus, processCids);
if (mediaStatus) {
if (DEBUG_SD_INSTALL) Log.i(TAG, "Loading packages");
loadMediaPackages(processCids, uidArr);
@@ -9019,9 +9030,9 @@ class PackageManagerService extends IPackageManager.Stub {
}
args.doPostInstall(retCode);
}
- // Send broadcasts first
+ // Send a broadcast to let everyone know we are done processing
+ sendResourcesChangedBroadcast(true, pkgList, uidArr);
if (pkgList.size() > 0) {
- sendResourcesChangedBroadcast(true, pkgList, uidArr);
Runtime.getRuntime().gc();
// If something failed do we clean up here or next install?
}
@@ -9049,9 +9060,9 @@ class PackageManagerService extends IPackageManager.Stub {
}
}
}
+ sendResourcesChangedBroadcast(false, pkgList, uidArr);
// Send broadcasts
if (pkgList.size() > 0) {
- sendResourcesChangedBroadcast(false, pkgList, uidArr);
Runtime.getRuntime().gc();
}
// Do clean up. Just unmount