Only create app data for installed apps for new user

Apps not being installed for a new user don't need
to have app folders created. They will be created
later when the app is installed.

Saved around 500ms for 140 apps that were
excluded.

Bug: 187985313
Test: Reboot, Create a new user and add existing apps

Change-Id: If629301b771466a0a07a8b4369687df80fd336c3
This commit is contained in:
Amith Yamasani
2021-06-04 22:24:49 -07:00
parent 8b6cc5fd2e
commit 6d2948b021

View File

@@ -3997,15 +3997,18 @@ public final class Settings implements Watchable, Snappable {
final int uninstallReason = (shouldMaybeInstall && !shouldReallyInstall) ?
UNINSTALL_REASON_USER_TYPE : UNINSTALL_REASON_UNKNOWN;
ps.setUninstallReason(uninstallReason, userHandle);
if (!shouldReallyInstall) {
if (shouldReallyInstall) {
// Need to create a data directory for all apps installed for this user.
// Accumulate all required args and call the installer after mPackages lock
// has been released
final String seInfo = AndroidPackageUtils.getSeInfo(ps.pkg, ps);
batch.createAppData(ps.volumeUuid, ps.name, userHandle,
StorageManager.FLAG_STORAGE_CE | StorageManager.FLAG_STORAGE_DE,
ps.appId, seInfo, ps.pkg.getTargetSdkVersion());
} else {
// Make sure the app is excluded from storage mapping for this user
writeKernelMappingLPr(ps);
}
// Need to create a data directory for all apps under this user. Accumulate all
// required args and call the installer after mPackages lock has been released
final String seInfo = AndroidPackageUtils.getSeInfo(ps.pkg, ps);
batch.createAppData(ps.volumeUuid, ps.name, userHandle,
StorageManager.FLAG_STORAGE_CE | StorageManager.FLAG_STORAGE_DE, ps.appId,
seInfo, ps.pkg.getTargetSdkVersion());
}
}
t.traceBegin("createAppData");