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

Commit 02ef064e authored by Guojing Yuan's avatar Guojing Yuan Committed by Android (Google) Code Review
Browse files

Merge "[CDM] Remove SharePreferences logic in onUserUnlocked" into main

parents 4c922b1d 35d432f4
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -239,11 +239,9 @@ public class CompanionDeviceManagerService extends SystemService {
        // Notify and bind the app after the phone is unlocked.
        mDevicePresenceProcessor.sendDevicePresenceEventOnUnlocked(user.getUserIdentifier());

        Binder.withCleanCallingIdentity(() -> {
        ExecutorService executor = Executors.newSingleThreadExecutor();
        executor.execute(() -> mCompanionExemptionProcessor.updateAutoRevokeExemptions(
                user.getUserIdentifier()));
        });
    }

    private void onPackageRemoveOrDataClearedInternal(
+12 −26
Original line number Diff line number Diff line
@@ -27,13 +27,11 @@ import android.app.ActivityManagerInternal;
import android.app.AppOpsManager;
import android.companion.AssociationInfo;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.net.NetworkPolicyManager;
import android.os.Binder;
import android.os.Environment;
import android.os.PowerExemptionManager;
import android.util.ArraySet;
import android.util.Pair;
@@ -43,7 +41,6 @@ import com.android.internal.util.ArrayUtils;
import com.android.server.companion.association.AssociationStore;
import com.android.server.wm.ActivityTaskManagerInternal;

import java.io.File;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -175,14 +172,6 @@ public class CompanionExemptionProcessor {
        Slog.d(TAG, "maybeGrantAutoRevokeExemptions()");

        PackageManager pm = mContext.getPackageManager();
        SharedPreferences pref = mContext.getSharedPreferences(
                new File(Environment.getUserSystemDirectory(userId), PREF_FILE_NAME),
                Context.MODE_PRIVATE);
        if (pref.getBoolean(PREF_KEY_AUTO_REVOKE_GRANTS_DONE, false)) {
            return;
        }

        try {
        final List<AssociationInfo> associations =
                mAssociationStore.getActiveAssociationsByUser(userId);
        Set<Pair<String, Integer>> exemptedPackages = new HashSet<>();
@@ -197,9 +186,6 @@ public class CompanionExemptionProcessor {
        for (Pair<String, Integer> exemptedPackage : exemptedPackages) {
            updateAutoRevokeExemption(exemptedPackage.first, exemptedPackage.second, true);
        }
        } finally {
            pref.edit().putBoolean(PREF_KEY_AUTO_REVOKE_GRANTS_DONE, true).apply();
        }
    }

    @SuppressLint("MissingPermission")