summaryrefslogtreecommitdiffstats
path: root/src/com/android/packageinstaller/wear/WearPackageInstallerService.java
diff options
context:
space:
mode:
authorAnthony Hugh <ahugh@google.com>2015-11-11 15:06:17 -0800
committerAnthony Hugh <ahugh@google.com>2015-11-16 13:08:33 -0800
commit9c78316fe6baa4f7fd7d5108349ecf8a2532b047 (patch)
treebb6c4f49183ae800d830f17682cf72e7e8ed0b14 /src/com/android/packageinstaller/wear/WearPackageInstallerService.java
parent012a557f593bd2862756839eeade4b892b05422e (diff)
downloadandroid_packages_apps_PackageInstaller-9c78316fe6baa4f7fd7d5108349ecf8a2532b047.tar.gz
android_packages_apps_PackageInstaller-9c78316fe6baa4f7fd7d5108349ecf8a2532b047.tar.bz2
android_packages_apps_PackageInstaller-9c78316fe6baa4f7fd7d5108349ecf8a2532b047.zip
Remove app from "needs permission" state if installation failed
This adds code to remove an app that is in the "needs permission" state from the ShowPermStore if the app fails to install. b/25721625 tracks creating a new intent to handle this case for F. BUG: 25363020 Change-Id: Ifed00024d7e329fb3185a4607a347e972f697fcd
Diffstat (limited to 'src/com/android/packageinstaller/wear/WearPackageInstallerService.java')
-rw-r--r--src/com/android/packageinstaller/wear/WearPackageInstallerService.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/com/android/packageinstaller/wear/WearPackageInstallerService.java b/src/com/android/packageinstaller/wear/WearPackageInstallerService.java
index d57236e1..6dc5aa70 100644
--- a/src/com/android/packageinstaller/wear/WearPackageInstallerService.java
+++ b/src/com/android/packageinstaller/wear/WearPackageInstallerService.java
@@ -337,7 +337,8 @@ public class WearPackageInstallerService extends Service {
// Finally install the package.
pm.installPackage(Uri.fromFile(tempFile),
- new PackageInstallObserver(this, lock, startId), installFlags, packageName);
+ new PackageInstallObserver(this, lock, startId, packageName),
+ installFlags, packageName);
messageSent = true;
Log.i(TAG, "Sent installation request for " + packageName);
} catch (FileNotFoundException e) {
@@ -575,20 +576,26 @@ public class WearPackageInstallerService extends Service {
private Context mContext;
private PowerManager.WakeLock mWakeLock;
private int mStartId;
+ private String mApplicationPackageName;
private PackageInstallObserver(Context context, PowerManager.WakeLock wakeLock,
- int startId) {
+ int startId, String applicationPackageName) {
mContext = context;
mWakeLock = wakeLock;
mStartId = startId;
+ mApplicationPackageName = applicationPackageName;
}
public void packageInstalled(String packageName, int returnCode) {
- if (returnCode >= 0) {
- Log.i(TAG, "Package " + packageName + " was installed.");
- } else {
- Log.e(TAG, "Package install failed " + packageName + ", returnCode " + returnCode);
+ // If installation failed, bail out and remove the ShowPermsStore entry
+ if (returnCode < 0) {
+ Log.e(TAG, "Package install failed " + mApplicationPackageName
+ + ", returnCode " + returnCode);
+ WearPackageUtil.removeFromPermStore(mContext, mApplicationPackageName);
+ return;
}
+ Log.i(TAG, "Package " + packageName + " was installed.");
+
// Delete tempFile from the file system.
File tempFile = WearPackageUtil.getTemporaryFile(mContext, packageName);
if (tempFile != null) {