resolve merge conflicts of e8c6801367 to cw-e-dev.

Change-Id: I9c5a0be4e18cc27e163da60ba9dd81ae71588bef
diff --git a/src/com/android/packageinstaller/wear/WearPackageInstallerService.java b/src/com/android/packageinstaller/wear/WearPackageInstallerService.java
index ba83ea2..d57236e 100644
--- a/src/com/android/packageinstaller/wear/WearPackageInstallerService.java
+++ b/src/com/android/packageinstaller/wear/WearPackageInstallerService.java
@@ -238,7 +238,7 @@
             PackageInfo existingPkgInfo = null;
             try {
                 existingPkgInfo = pm.getPackageInfo(packageName,
-                        PackageManager.GET_UNINSTALLED_PACKAGES);
+                        PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_PERMISSIONS);
                 if(existingPkgInfo != null) {
                     installFlags |= PackageManager.INSTALL_REPLACE_EXISTING;
                 }
@@ -298,6 +298,10 @@
                         // If the permission is granted, then we will not ask to request it again.
                         if ((existingPkgInfo.requestedPermissionsFlags[i] &
                                 PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0) {
+                            if (Log.isLoggable(TAG, Log.DEBUG)) {
+                                Log.d(TAG, existingPkgInfo.requestedPermissions[i] +
+                                        " is already granted for " + packageName);
+                            }
                             wearablePerms.remove(existingPkgInfo.requestedPermissions[i]);
                         }
                     }