diff options
author | Kenny Root <kroot@google.com> | 2010-07-28 14:48:40 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-07-28 14:48:40 -0700 |
commit | 56c02dc3d325bab8549ec34b9d6aa7c62ef742d0 (patch) | |
tree | b465b8f43821db74dc7c27afc2b214d882f82978 /services | |
parent | b1bb7180ec3446208ea717d96f6a507ea9955a13 (diff) | |
parent | c78a8079740bfcad2e4439ccd74da52f6dc7fae2 (diff) | |
download | frameworks_base-56c02dc3d325bab8549ec34b9d6aa7c62ef742d0.zip frameworks_base-56c02dc3d325bab8549ec34b9d6aa7c62ef742d0.tar.gz frameworks_base-56c02dc3d325bab8549ec34b9d6aa7c62ef742d0.tar.bz2 |
Merge "Fix getTempContainerId()" into gingerbread
Diffstat (limited to 'services')
-rw-r--r-- | services/java/com/android/server/PackageManagerService.java | 68 |
1 files changed, 25 insertions, 43 deletions
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java index 9d8c072..17ad9e3 100644 --- a/services/java/com/android/server/PackageManagerService.java +++ b/services/java/com/android/server/PackageManagerService.java @@ -187,7 +187,9 @@ class PackageManagerService extends IPackageManager.Stub { static final ComponentName DEFAULT_CONTAINER_COMPONENT = new ComponentName( "com.android.defcontainer", "com.android.defcontainer.DefaultContainerService"); - + + static final String mTempContainerPrefix = "smdl2tmp"; + final HandlerThread mHandlerThread = new HandlerThread("PackageManager", Process.THREAD_PRIORITY_BACKGROUND); final PackageHandler mHandler; @@ -9549,48 +9551,28 @@ class PackageManagerService extends IPackageManager.Stub { } } - static String getTempContainerId() { - String prefix = "smdl2tmp"; - int tmpIdx = 1; - String list[] = PackageHelper.getSecureContainerList(); - if (list != null) { - int idx = 0; - int idList[] = new int[MAX_CONTAINERS]; - boolean neverFound = true; - for (String name : list) { - // Ignore null entries - if (name == null) { - continue; - } - int sidx = name.indexOf(prefix); - if (sidx == -1) { - // Not a temp file. just ignore - continue; - } - String subStr = name.substring(sidx + prefix.length()); - idList[idx] = -1; - if (subStr != null) { - try { - int cid = Integer.parseInt(subStr); - idList[idx++] = cid; - neverFound = false; - } catch (NumberFormatException e) { - } - } - } - if (!neverFound) { - // Sort idList - Arrays.sort(idList); - for (int j = 1; j <= idList.length; j++) { - if (idList[j-1] != j) { - tmpIdx = j; - break; - } - } - } - } - return prefix + tmpIdx; - } + /* package */ static String getTempContainerId() { + int tmpIdx = 1; + String list[] = PackageHelper.getSecureContainerList(); + if (list != null) { + for (final String name : list) { + // Ignore null and non-temporary container entries + if (name == null || !name.startsWith(mTempContainerPrefix)) { + continue; + } + + String subStr = name.substring(mTempContainerPrefix.length()); + try { + int cid = Integer.parseInt(subStr); + if (cid >= tmpIdx) { + tmpIdx = cid + 1; + } + } catch (NumberFormatException e) { + } + } + } + return mTempContainerPrefix + tmpIdx; + } /* * Update media status on PackageManager. |