diff options
author | Jeff Sharkey <jsharkey@android.com> | 2014-07-13 17:33:07 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2014-07-14 10:57:04 -0700 |
commit | ad11eb52fe62b6696df2194cb9e176f7d799e844 (patch) | |
tree | 440f9699b759d4b14b20a9280234d352faf2b0ce | |
parent | 5c6a8e322227354acbded5c49f44c0b289021bf5 (diff) | |
download | frameworks_base-ad11eb52fe62b6696df2194cb9e176f7d799e844.zip frameworks_base-ad11eb52fe62b6696df2194cb9e176f7d799e844.tar.gz frameworks_base-ad11eb52fe62b6696df2194cb9e176f7d799e844.tar.bz2 |
Pass install result message; path selection.
Oops, forgot to include message argument to invoke the new-style
callback. Also use more robust way of generating cluster APK
directory names, and add more logging details on rename failure.
Change-Id: Ifa8abdd1db58b73e13b9a8077ec126cf20a0d90e
4 files changed, 39 insertions, 26 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java index 3d0eec4..3a2ca30 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -50,6 +50,7 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.os.UserManager; +import android.text.TextUtils; import android.util.Log; import com.android.internal.content.PackageHelper; @@ -923,33 +924,13 @@ public final class Pm { return; } } else if (opt.equals("--abi")) { - abi = nextOptionData(); - if (abi == null) { - System.err.println("Error: must supply argument for --abi"); - return; - } + abi = checkAbiArgument(nextOptionData()); } else { System.err.println("Error: Unknown option: " + opt); return; } } - if (abi != null) { - final String[] supportedAbis = Build.SUPPORTED_ABIS; - boolean matched = false; - for (String supportedAbi : supportedAbis) { - if (supportedAbi.equals(abi)) { - matched = true; - break; - } - } - - if (!matched) { - System.err.println("Error: abi " + abi + " not supported on this device."); - return; - } - } - final Uri verificationURI; final Uri originatingURI; final Uri referrerURI; @@ -1044,6 +1025,8 @@ public final class Pm { } else if (opt.equals("-S")) { params.deltaSize = Long.parseLong(nextOptionData()); params.progressMax = (int) params.deltaSize; + } else if (opt.equals("--abi")) { + params.abiOverride = checkAbiArgument(nextOptionData()); } else { throw new IllegalArgumentException("Unknown option " + opt); } @@ -1684,6 +1667,21 @@ public final class Pm { } } + private static String checkAbiArgument(String abi) { + if (TextUtils.isEmpty(abi)) { + throw new IllegalArgumentException("Missing ABI argument"); + } + + final String[] supportedAbis = Build.SUPPORTED_ABIS; + for (String supportedAbi : supportedAbis) { + if (supportedAbi.equals(abi)) { + return abi; + } + } + + throw new IllegalArgumentException("ABI " + abi + " not supported on this device"); + } + private String nextOption() { if (mNextArg >= mArgs.length) { return null; diff --git a/core/java/android/app/PackageInstallObserver.java b/core/java/android/app/PackageInstallObserver.java index 7117111..1b2504e 100644 --- a/core/java/android/app/PackageInstallObserver.java +++ b/core/java/android/app/PackageInstallObserver.java @@ -25,7 +25,7 @@ public class PackageInstallObserver { @Override public void packageInstalled(String basePackageName, Bundle extras, int returnCode, String msg) { - PackageInstallObserver.this.packageInstalled(basePackageName, extras, returnCode); + PackageInstallObserver.this.packageInstalled(basePackageName, extras, returnCode, msg); } }; diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java index c399fa2..41ab66a 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerSession.java +++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java @@ -177,7 +177,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { @Override public void setClientProgress(int progress) { mClientProgress = progress; - mProgress = MathUtils.constrain((mClientProgress * 8 * 100) / (params.progressMax * 10), 0, 80); + mProgress = MathUtils.constrain( + (int) (((float) mClientProgress) / ((float) params.progressMax)) * 80, 0, 80); mCallback.onSessionProgress(this, mProgress); } diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 101ef92..3708fbc 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -9331,14 +9331,18 @@ public class PackageManagerService extends IPackageManager.Stub { return false; } else { final File beforeCodeFile = codeFile; - final File afterCodeFile = new File(mAppInstallDir, - getNextCodePath(oldCodePath, pkg.packageName, null)); + final File afterCodeFile = getNextCodePath(pkg.packageName); Slog.d(TAG, "Renaming " + beforeCodeFile + " to " + afterCodeFile); - if (!beforeCodeFile.renameTo(afterCodeFile)) { + try { + Os.rename(beforeCodeFile.getAbsolutePath(), afterCodeFile.getAbsolutePath()); + } catch (ErrnoException e) { + Slog.d(TAG, "Failed to rename", e); return false; } + if (!SELinux.restoreconRecursive(afterCodeFile)) { + Slog.d(TAG, "Failed to restorecon"); return false; } @@ -9811,6 +9815,16 @@ public class PackageManagerService extends IPackageManager.Stub { return prefix + idxStr; } + private File getNextCodePath(String packageName) { + int suffix = 1; + File result; + do { + result = new File(mAppInstallDir, packageName + "-" + suffix); + suffix++; + } while (result.exists()); + return result; + } + // Utility method used to ignore ADD/REMOVE events // by directory observer. private static boolean ignoreCodePath(String fullPathStr) { |