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

Commit 0da64913 authored by Kevin Han's avatar Kevin Han
Browse files

Add OEM-configurable flag for OAT artifact deletion

As per feedback from OEM partners, we are adding a configurable build
time flag that determines whether hibernation performs OAT artifact
deletion. This flag is only for this specific sub-optimization the other
parts of hibernation would occur regardless of the flag.

Bug: 183563260
Test: atest AppHibernationServiceTest
Change-Id: Ic798f3ed4c340b84f4c97f118e07767d36211a97
parent aa029a25
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -4838,4 +4838,7 @@
    <bool name="config_cecRcProfileSourceMediaContextSensitiveMenuHandled_default">false</bool>
    <bool name="config_cecRcProfileSourceMediaContextSensitiveMenuNotHandled_allowed">true</bool>
    <bool name="config_cecRcProfileSourceMediaContextSensitiveMenuNotHandled_default">true</bool>

    <!-- Whether app hibernation deletes OAT artifact files as part of global hibernation. -->
    <bool name="config_hibernationDeletesOatArtifactsEnabled">true</bool>
</resources>
+1 −0
Original line number Diff line number Diff line
@@ -480,6 +480,7 @@
  <java-symbol type="string" name="config_bandwidthEstimateSource" />
  <java-symbol type="integer" name="config_smartSelectionInitializedTimeoutMillis" />
  <java-symbol type="integer" name="config_smartSelectionInitializingTimeoutMillis" />
  <java-symbol type="bool" name="config_hibernationDeletesOatArtifactsEnabled"/>

  <java-symbol type="color" name="tab_indicator_text_v4" />

+13 −1
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ public final class AppHibernationService extends SystemService {
    private final HibernationStateDiskStore<GlobalLevelState> mGlobalLevelHibernationDiskStore;
    private final Injector mInjector;
    private final Executor mBackgroundExecutor;
    private final boolean mOatArtifactDeletionEnabled;

    @VisibleForTesting
    boolean mIsServiceEnabled;
@@ -133,6 +134,7 @@ public final class AppHibernationService extends SystemService {
        mUserManager = injector.getUserManager();
        mGlobalLevelHibernationDiskStore = injector.getGlobalLevelDiskStore();
        mBackgroundExecutor = injector.getBackgroundExecutor();
        mOatArtifactDeletionEnabled = injector.isOatArtifactDeletionEnabled();
        mInjector = injector;

        final Context userAllContext = mContext.createContextAsUser(UserHandle.ALL, 0 /* flags */);
@@ -371,7 +373,9 @@ public final class AppHibernationService extends SystemService {
    @GuardedBy("mLock")
    private void hibernatePackageGlobally(@NonNull String packageName, GlobalLevelState state) {
        Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, "hibernatePackageGlobally");
        if (mOatArtifactDeletionEnabled) {
            mPackageManagerInternal.deleteOatArtifactsOfPackage(packageName);
        }
        state.hibernated = true;
        Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
    }
@@ -744,6 +748,8 @@ public final class AppHibernationService extends SystemService {
        HibernationStateDiskStore<GlobalLevelState> getGlobalLevelDiskStore();

        HibernationStateDiskStore<UserLevelState> getUserLevelDiskStore(int userId);

        boolean isOatArtifactDeletionEnabled();
    }

    private static final class InjectorImpl implements Injector {
@@ -801,5 +807,11 @@ public final class AppHibernationService extends SystemService {
            return new HibernationStateDiskStore<>(
                    dir, mUserLevelHibernationProto, mScheduledExecutorService);
        }

        @Override
        public boolean isOatArtifactDeletionEnabled() {
            return mContext.getResources().getBoolean(
                    com.android.internal.R.bool.config_hibernationDeletesOatArtifactsEnabled);
        }
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -282,5 +282,10 @@ public final class AppHibernationServiceTest {
        public HibernationStateDiskStore<UserLevelState> getUserLevelDiskStore(int userId) {
            return mock(HibernationStateDiskStore.class);
        }

        @Override
        public boolean isOatArtifactDeletionEnabled() {
            return true;
        }
    }
}