Defer writes to runtime-permissions.xml

In grantPermissionsLPw, use async version of writeRuntimePermissionsForUserLPr
to defer writes to runtime-permissions.xml.

Change-Id: I9dcae74199d26b6a988e35dff97b038d435e1e16
Bug: 21849928
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index a24bd52..5188fbe 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -7726,7 +7726,7 @@
                 }
             }
         }
-        
+
         if (pkgInfo != null) {
             grantPermissionsLPw(pkgInfo, (flags&UPDATE_PERMISSIONS_REPLACE_PKG) != 0, changingPkg);
         }
@@ -8006,7 +8006,7 @@
 
         // Persist the runtime permissions state for users with changes.
         for (int userId : changedRuntimePermissionUserIds) {
-            mSettings.writeRuntimePermissionsForUserLPr(userId, true);
+            mSettings.writeRuntimePermissionsForUserLPr(userId, false);
         }
     }