Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 80abed8c authored by Jeff Sharkey's avatar Jeff Sharkey Committed by The Android Automerger
Browse files

Reduce PackageInstaller Binder memory pressure.

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
parent e7091f95
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.pm.IPackageDeleteObserver2;
import android.content.pm.IPackageInstallerCallback;
import android.content.pm.IPackageInstallerCallback;
import android.content.pm.IPackageInstallerSession;
import android.content.pm.IPackageInstallerSession;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageInstaller;
import android.content.pm.ParceledListSlice;
import android.content.IntentSender;
import android.content.IntentSender;


import android.graphics.Bitmap;
import android.graphics.Bitmap;
@@ -37,8 +38,8 @@ interface IPackageInstaller {


    PackageInstaller.SessionInfo getSessionInfo(int sessionId);
    PackageInstaller.SessionInfo getSessionInfo(int sessionId);


    List<PackageInstaller.SessionInfo> getAllSessions(int userId);
    ParceledListSlice getAllSessions(int userId);
    List<PackageInstaller.SessionInfo> getMySessions(String installerPackageName, int userId);
    ParceledListSlice getMySessions(String installerPackageName, int userId);


    void registerCallback(IPackageInstallerCallback callback, int userId);
    void registerCallback(IPackageInstallerCallback callback, int userId);
    void unregisterCallback(IPackageInstallerCallback callback);
    void unregisterCallback(IPackageInstallerCallback callback);
+2 −2
Original line number Original line Diff line number Diff line
@@ -399,7 +399,7 @@ public class PackageInstaller {
        }
        }


        try {
        try {
            return mInstaller.getAllSessions(mUserId);
            return mInstaller.getAllSessions(mUserId).getList();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
            throw e.rethrowAsRuntimeException();
        }
        }
@@ -410,7 +410,7 @@ public class PackageInstaller {
     */
     */
    public @NonNull List<SessionInfo> getMySessions() {
    public @NonNull List<SessionInfo> getMySessions() {
        try {
        try {
            return mInstaller.getMySessions(mInstallerPackageName, mUserId);
            return mInstaller.getMySessions(mInstallerPackageName, mUserId).getList();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
            throw e.rethrowAsRuntimeException();
        }
        }
+5 −4
Original line number Original line Diff line number Diff line
@@ -45,6 +45,7 @@ import android.content.pm.PackageInstaller;
import android.content.pm.PackageInstaller.SessionInfo;
import android.content.pm.PackageInstaller.SessionInfo;
import android.content.pm.PackageInstaller.SessionParams;
import android.content.pm.PackageInstaller.SessionParams;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.content.pm.ParceledListSlice;
import android.graphics.Bitmap;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory;
@@ -714,7 +715,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
    }
    }


    @Override
    @Override
    public List<SessionInfo> getAllSessions(int userId) {
    public ParceledListSlice<SessionInfo> getAllSessions(int userId) {
        mPm.enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false, "getAllSessions");
        mPm.enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false, "getAllSessions");


        final List<SessionInfo> result = new ArrayList<>();
        final List<SessionInfo> result = new ArrayList<>();
@@ -726,11 +727,11 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
                }
                }
            }
            }
        }
        }
        return result;
        return new ParceledListSlice<>(result);
    }
    }


    @Override
    @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");
        mPm.enforceCrossUserPermission(Binder.getCallingUid(), userId, true, false, "getMySessions");
        mAppOps.checkPackage(Binder.getCallingUid(), installerPackageName);
        mAppOps.checkPackage(Binder.getCallingUid(), installerPackageName);


@@ -744,7 +745,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
                }
                }
            }
            }
        }
        }
        return result;
        return new ParceledListSlice<>(result);
    }
    }


    @Override
    @Override