OSDN Git Service

Reduce PackageInstaller Binder memory pressure.
authorJeff Sharkey <jsharkey@android.com>
Wed, 15 Oct 2014 16:19:47 +0000 (09:19 -0700)
committerJeff Sharkey <jsharkey@android.com>
Wed, 15 Oct 2014 16:19:54 +0000 (09:19 -0700)
When restoring hundreds of apps on low-DPI devices, we end up sending
icon Bitmaps inline in the response instead of splitting into ashmem
regions.  To avoid triggering TransactionTooLargeException, switch to
using ParceledListSlice under the hood.

Bug: 17926122
Change-Id: Ib4da6775e79d2fcb4aaea15f58ed998df203a5f9

core/java/android/content/pm/IPackageInstaller.aidl
core/java/android/content/pm/PackageInstaller.java
services/core/java/com/android/server/pm/PackageInstallerService.java

index 6daefc8..ba62cd6 100644 (file)
@@ -20,6 +20,7 @@ import android.content.pm.IPackageDeleteObserver2;
 import android.content.pm.IPackageInstallerCallback;
 import android.content.pm.IPackageInstallerSession;
 import android.content.pm.PackageInstaller;
+import android.content.pm.ParceledListSlice;
 import android.content.IntentSender;
 
 import android.graphics.Bitmap;
@@ -37,8 +38,8 @@ interface IPackageInstaller {
 
     PackageInstaller.SessionInfo getSessionInfo(int sessionId);
 
-    List<PackageInstaller.SessionInfo> getAllSessions(int userId);
-    List<PackageInstaller.SessionInfo> getMySessions(String installerPackageName, int userId);
+    ParceledListSlice getAllSessions(int userId);
+    ParceledListSlice getMySessions(String installerPackageName, int userId);
 
     void registerCallback(IPackageInstallerCallback callback, int userId);
     void unregisterCallback(IPackageInstallerCallback callback);
index f249c5f..80efd0b 100644 (file)
@@ -399,7 +399,7 @@ public class PackageInstaller {
         }
 
         try {
-            return mInstaller.getAllSessions(mUserId);
+            return mInstaller.getAllSessions(mUserId).getList();
         } catch (RemoteException e) {
             throw e.rethrowAsRuntimeException();
         }
@@ -410,7 +410,7 @@ public class PackageInstaller {
      */
     public @NonNull List<SessionInfo> getMySessions() {
         try {
-            return mInstaller.getMySessions(mInstallerPackageName, mUserId);
+            return mInstaller.getMySessions(mInstallerPackageName, mUserId).getList();
         } catch (RemoteException e) {
             throw e.rethrowAsRuntimeException();
         }
index 9db3fba..2150e9a 100644 (file)
@@ -45,6 +45,7 @@ import android.content.pm.PackageInstaller;
 import android.content.pm.PackageInstaller.SessionInfo;
 import android.content.pm.PackageInstaller.SessionParams;
 import android.content.pm.PackageManager;
+import android.content.pm.ParceledListSlice;
 import android.graphics.Bitmap;
 import android.graphics.Bitmap.CompressFormat;
 import android.graphics.BitmapFactory;
@@ -714,7 +715,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
     }
 
     @Override
-    public List<SessionInfo> getAllSessions(int userId) {
+    public ParceledListSlice<SessionInfo> getAllSessions(int userId) {
         mPm.enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false, "getAllSessions");
 
         final List<SessionInfo> result = new ArrayList<>();
@@ -726,11 +727,11 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
                 }
             }
         }
-        return result;
+        return new ParceledListSlice<>(result);
     }
 
     @Override
-    public List<SessionInfo> getMySessions(String installerPackageName, int userId) {
+    public ParceledListSlice<SessionInfo> getMySessions(String installerPackageName, int userId) {
         mPm.enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false, "getMySessions");
         mAppOps.checkPackage(Binder.getCallingUid(), installerPackageName);
 
@@ -744,7 +745,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
                 }
             }
         }
-        return result;
+        return new ParceledListSlice<>(result);
     }
 
     @Override