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
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;
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);
}
try {
- return mInstaller.getAllSessions(mUserId);
+ return mInstaller.getAllSessions(mUserId).getList();
} catch (RemoteException e) {
throw e.rethrowAsRuntimeException();
}
*/
public @NonNull List<SessionInfo> getMySessions() {
try {
- return mInstaller.getMySessions(mInstallerPackageName, mUserId);
+ return mInstaller.getMySessions(mInstallerPackageName, mUserId).getList();
} catch (RemoteException e) {
throw e.rethrowAsRuntimeException();
}
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;
}
@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<>();
}
}
}
- 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);
}
}
}
- return result;
+ return new ParceledListSlice<>(result);
}
@Override