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

Commit beaf4d86 authored by Samiul Islam's avatar Samiul Islam Committed by Mohammad Samiul Islam
Browse files

Create sdk directory for an app only if app consumes sdk

Currently, we create sdk directories for all apps. This means during
boot time, when we create app data directory for system apps, we are now
creating twice the amount of directories as before. This has significant
impact on boot time.

In order to avoid the regression, we are now limiting the creation to
only when app actually consumes an sdk and needs these directories. We
have introduced a new installd flag: FLAG_STORAGE_SDK, which needs to be
passed to installd when sdk directory should be created for the app.

Bug: 220095381
Bug: 217543371
Test: atest SupplementalProcessStorageHostTest
Change-Id: I72af7c9460892bf7ac6d908a6a7ca6912167b894
parent 598ddd81
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -273,12 +273,15 @@ public class StorageManager {
    public static final int FLAG_STORAGE_CE = IInstalld.FLAG_STORAGE_CE;
    /** {@hide} */
    public static final int FLAG_STORAGE_EXTERNAL = IInstalld.FLAG_STORAGE_EXTERNAL;
    /** @hide */
    public static final int FLAG_STORAGE_SDK = IInstalld.FLAG_STORAGE_SDK;

    /** {@hide} */
    @IntDef(prefix = "FLAG_STORAGE_",  value = {
            FLAG_STORAGE_DE,
            FLAG_STORAGE_CE,
            FLAG_STORAGE_EXTERNAL
            FLAG_STORAGE_EXTERNAL,
            FLAG_STORAGE_SDK,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface StorageFlags {}
+2 −1
Original line number Diff line number Diff line
@@ -218,8 +218,9 @@ final class AppDataHelper {

        final String seInfo = pkgSeInfo + seInfoUser;
        final int targetSdkVersion = pkg.getTargetSdkVersion();
        final boolean usesSdk = !pkg.getUsesSdkLibraries().isEmpty();
        final CreateAppDataArgs args = Installer.buildCreateAppDataArgs(volumeUuid, packageName,
                userId, flags, appId, seInfo, targetSdkVersion);
                userId, flags, appId, seInfo, targetSdkVersion, usesSdk);
        args.previousAppId = previousAppId;

        return batch.createAppData(args).whenComplete((ceDataInode, e) -> {
+6 −1
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ public class Installer extends SystemService {
    public static final int FLAG_STORAGE_DE = IInstalld.FLAG_STORAGE_DE;
    public static final int FLAG_STORAGE_CE = IInstalld.FLAG_STORAGE_CE;
    public static final int FLAG_STORAGE_EXTERNAL = IInstalld.FLAG_STORAGE_EXTERNAL;
    public static final int FLAG_STORAGE_SDK = IInstalld.FLAG_STORAGE_SDK;

    public static final int FLAG_CLEAR_CACHE_ONLY = IInstalld.FLAG_CLEAR_CACHE_ONLY;
    public static final int FLAG_CLEAR_CODE_CACHE_ONLY = IInstalld.FLAG_CLEAR_CODE_CACHE_ONLY;
@@ -190,12 +191,16 @@ public class Installer extends SystemService {
    // We explicitly do NOT set previousAppId because the default value should always be 0.
    // Manually override previousAppId after building CreateAppDataArgs for specific behaviors.
    static CreateAppDataArgs buildCreateAppDataArgs(String uuid, String packageName,
            int userId, int flags, int appId, String seInfo, int targetSdkVersion) {
            int userId, int flags, int appId, String seInfo, int targetSdkVersion,
            boolean usesSdk) {
        final CreateAppDataArgs args = new CreateAppDataArgs();
        args.uuid = uuid;
        args.packageName = packageName;
        args.userId = userId;
        args.flags = flags;
        if (usesSdk) {
            args.flags |= FLAG_STORAGE_SDK;
        }
        args.appId = appId;
        args.seInfo = seInfo;
        args.targetSdkVersion = targetSdkVersion;
+2 −1
Original line number Diff line number Diff line
@@ -4190,10 +4190,11 @@ public final class Settings implements Watchable, Snappable {
                    // Accumulate all required args and call the installer after mPackages lock
                    // has been released
                    final String seInfo = AndroidPackageUtils.getSeInfo(ps.getPkg(), ps);
                    final boolean usesSdk = !ps.getPkg().getUsesSdkLibraries().isEmpty();
                    final CreateAppDataArgs args = Installer.buildCreateAppDataArgs(
                            ps.getVolumeUuid(), ps.getPackageName(), userHandle,
                            StorageManager.FLAG_STORAGE_CE | StorageManager.FLAG_STORAGE_DE,
                            ps.getAppId(), seInfo, ps.getPkg().getTargetSdkVersion());
                            ps.getAppId(), seInfo, ps.getPkg().getTargetSdkVersion(), usesSdk);
                    batch.createAppData(args);
                } else {
                    // Make sure the app is excluded from storage mapping for this user