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

Commit 5745b057 authored by Julius D'souza's avatar Julius D'souza
Browse files

Add background thread notes for package restriction serialisation.



Serialising package restrictions uses synchronous disk access; callers
of these methods should probably use background threads for this.

Bug: 149216360
Test: TreeHugger
Change-Id: I6607a7225bf7daaad8a78e4d1e4c585ba5ac3efc
Signed-off-by: default avatarJulius D'souza <jdsouza@google.com>
parent 5ea95b84
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -979,7 +979,8 @@ public abstract class PackageManager {
     * Flag parameter for
     * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
     * that the given user's package restrictions state will be serialised to disk after the
     * component state has been updated.
     * component state has been updated. Note that this is synchronous disk access, so calls using
     * this flag should be run on a background thread.
     */
    public static final int SYNCHRONOUS = 0x00000002;

+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.annotation.WorkerThread;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Intent;
@@ -261,6 +262,7 @@ public abstract class PackageManagerInternal {
    /**
     * Flushes package restrictions for the given user immediately to disk.
     */
    @WorkerThread
    public abstract void flushPackageRestrictions(int userId);

    /**
+4 −1
Original line number Diff line number Diff line
@@ -130,6 +130,7 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.annotation.WorkerThread;
import android.app.ActivityManager;
import android.app.AppOpsManager;
import android.app.ApplicationPackageManager;
@@ -213,7 +214,6 @@ import android.content.pm.dex.ArtManager;
import android.content.pm.dex.DexMetadataHelper;
import android.content.pm.dex.IArtManager;
import android.content.pm.parsing.PackageInfoWithoutStateUtils;
import android.content.pm.parsing.ParsingPackageRead;
import android.content.pm.parsing.ParsingPackageUtils;
import android.content.pm.parsing.component.ParsedActivity;
import android.content.pm.parsing.component.ParsedInstrumentation;
@@ -20169,6 +20169,7 @@ public class PackageManagerService extends IPackageManager.Stub
        }
    }
    @WorkerThread
    @Override
    public void flushPackageRestrictionsAsUser(int userId) {
        if (getInstantAppPackageName(Binder.getCallingUid()) != null) {
@@ -20186,6 +20187,8 @@ public class PackageManagerService extends IPackageManager.Stub
    @GuardedBy("mLock")
    private void flushPackageRestrictionsAsUserInternalLocked(int userId) {
        // NOTE: this invokes synchronous disk access, so callers using this
        // method should consider running on a background thread
        mSettings.writePackageRestrictionsLPr(userId);
        mDirtyUsers.remove(userId);
        if (mDirtyUsers.isEmpty()) {