summaryrefslogtreecommitdiffstats
path: root/packages/DefaultContainerService
diff options
context:
space:
mode:
authorSuchi Amalapurapu <asuchitra@google.com>2010-03-03 09:45:24 -0800
committerSuchi Amalapurapu <asuchitra@google.com>2010-03-03 14:06:10 -0800
commit9b10ef5fe85e9d29721ff0cd15161f960d38a8db (patch)
treea6830aad34d62273b02f0e3dbaa054dd7ec7c270 /packages/DefaultContainerService
parenta034cd3e15b6626be03e60f2d6a0f929dcb950d9 (diff)
downloadframeworks_base-9b10ef5fe85e9d29721ff0cd15161f960d38a8db.zip
frameworks_base-9b10ef5fe85e9d29721ff0cd15161f960d38a8db.tar.gz
frameworks_base-9b10ef5fe85e9d29721ff0cd15161f960d38a8db.tar.bz2
Rework the way PackageManager binds to default container service.
Clean up stale containers when enabling/disabling packages on sdcard. Check the path of packages which are being enabled. Make sure gc's are done prior to destroying containers when moving applicati as well as enabling/disabling packages for sdcard mount status changes. Some miscellaneous issues Remove hack to avoid renaming containers. Fix test with forward locked apps Remove adding container id to asec list when renaming Some cosmetic changes to DefaultContainerService
Diffstat (limited to 'packages/DefaultContainerService')
-rw-r--r--packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java79
1 files changed, 29 insertions, 50 deletions
diff --git a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
index a79f0cd..c826973 100644
--- a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
+++ b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
@@ -166,62 +166,41 @@ public class DefaultContainerService extends IntentService {
String codePath = packageURI.getPath();
File codeFile = new File(codePath);
String newCachePath = null;
- final int CREATE_FAILED = 1;
- final int COPY_FAILED = 2;
- final int FINALIZE_FAILED = 3;
- final int PASS = 4;
- int errCode = CREATE_FAILED;
// Create new container
if ((newCachePath = PackageHelper.createSdDir(codeFile,
- newCid, key, Process.myUid())) != null) {
- if (localLOGV) Log.i(TAG, "Created container for " + newCid
- + " at path : " + newCachePath);
- File resFile = new File(newCachePath, resFileName);
- errCode = COPY_FAILED;
- // Copy file from codePath
- if (FileUtils.copyFile(new File(codePath), resFile)) {
- if (localLOGV) Log.i(TAG, "Copied " + codePath + " to " + resFile);
- errCode = FINALIZE_FAILED;
- if (PackageHelper.finalizeSdDir(newCid)) {
- if (localLOGV) Log.i(TAG, "Finalized container " + newCid);
- errCode = PASS;
- }
- }
+ newCid, key, Process.myUid())) == null) {
+ Log.e(TAG, "Failed creating container " + newCid);
+ return null;
}
- // Print error based on errCode
- String errMsg = "";
- switch (errCode) {
- case CREATE_FAILED:
- errMsg = "CREATE_FAILED";
- break;
- case COPY_FAILED:
- errMsg = "COPY_FAILED";
- if (localLOGV) Log.i(TAG, "Destroying " + newCid +
- " at path " + newCachePath + " after " + errMsg);
- PackageHelper.destroySdDir(newCid);
- break;
- case FINALIZE_FAILED:
- errMsg = "FINALIZE_FAILED";
- if (localLOGV) Log.i(TAG, "Destroying " + newCid +
- " at path " + newCachePath + " after " + errMsg);
- PackageHelper.destroySdDir(newCid);
- break;
- default:
- errMsg = "PASS";
- if (PackageHelper.isContainerMounted(newCid)) {
- if (localLOGV) Log.i(TAG, "Unmounting " + newCid +
- " at path " + newCachePath + " after " + errMsg);
- // Force a gc to avoid being killed.
- Runtime.getRuntime().gc();
- PackageHelper.unMountSdDir(newCid);
- } else {
- if (localLOGV) Log.i(TAG, "Container " + newCid + " not mounted");
- }
- break;
+ if (localLOGV) Log.i(TAG, "Created container for " + newCid
+ + " at path : " + newCachePath);
+ File resFile = new File(newCachePath, resFileName);
+ // Copy file from codePath
+ if (!FileUtils.copyFile(new File(codePath), resFile)) {
+ Log.e(TAG, "Failed to copy " + codePath + " to " + resFile);
+ // Clean up created container
+ PackageHelper.destroySdDir(newCid);
+ return null;
}
- if (errCode != PASS) {
+ if (localLOGV) Log.i(TAG, "Copied " + codePath + " to " + resFile);
+ // Finalize container now
+ if (!PackageHelper.finalizeSdDir(newCid)) {
+ Log.e(TAG, "Failed to finalize " + newCid + " at cache path " + newCachePath);
+ // Clean up created container
+ PackageHelper.destroySdDir(newCid);
return null;
}
+ if (localLOGV) Log.i(TAG, "Finalized container " + newCid);
+ // Force a gc to avoid being killed.
+ Runtime.getRuntime().gc();
+ // Unmount container
+ if (PackageHelper.isContainerMounted(newCid)) {
+ if (localLOGV) Log.i(TAG, "Unmounting " + newCid +
+ " at path " + newCachePath);
+ PackageHelper.unMountSdDir(newCid);
+ } else {
+ if (localLOGV) Log.i(TAG, "Container " + newCid + " not mounted");
+ }
return newCachePath;
}