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

Commit 6715c6ab authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Clean up zen rules and permissions immediately on uninstall." into nyc-mr1-dev

parents 6529ab20 6434eb2e
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package com.android.server.notification;

import android.annotation.NonNull;
import android.app.INotificationManager;
import android.app.NotificationManager;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -161,6 +163,25 @@ public class ConditionProviders extends ManagedServices {
        }
    }

    @Override
    public void onPackagesChanged(boolean removingPackage, String[] pkgList) {
        if (removingPackage) {
            INotificationManager inm = NotificationManager.getService();

            if (pkgList != null && (pkgList.length > 0)) {
                for (String pkgName : pkgList) {
                    try {
                        inm.removeAutomaticZenRules(pkgName);
                        inm.setNotificationPolicyAccessGranted(pkgName, false);
                    } catch (Exception e) {
                        Slog.e(TAG, "Failed to clean up rules for " + pkgName, e);
                    }
                }
            }
        }
        super.onPackagesChanged(removingPackage, pkgList);
    }

    public ManagedServiceInfo checkServiceToken(IConditionProvider provider) {
        synchronized(mMutex) {
            return checkServiceTokenLocked(provider);
+3 −3
Original line number Diff line number Diff line
@@ -217,8 +217,8 @@ abstract public class ManagedServices {
        return mEnabledServicesPackageNames.contains(pkg);
    }

    public void onPackagesChanged(boolean queryReplace, String[] pkgList) {
        if (DEBUG) Slog.d(TAG, "onPackagesChanged queryReplace=" + queryReplace
    public void onPackagesChanged(boolean removingPackage, String[] pkgList) {
        if (DEBUG) Slog.d(TAG, "onPackagesChanged removingPackage=" + removingPackage
                + " pkgList=" + (pkgList == null ? null : Arrays.asList(pkgList))
                + " mEnabledServicesPackageNames=" + mEnabledServicesPackageNames);
        boolean anyServicesInvolved = false;
@@ -234,7 +234,7 @@ abstract public class ManagedServices {

        if (anyServicesInvolved) {
            // if we're not replacing a package, clean up orphaned bits
            if (!queryReplace) {
            if (removingPackage) {
                updateSettingsAccordingToInstalledServices();
                rebuildRestoredPackages();
            }
+10 −10
Original line number Diff line number Diff line
@@ -696,9 +696,9 @@ public class NotificationManagerService extends SystemService {
                int changeUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
                        UserHandle.USER_ALL);
                String pkgList[] = null;
                boolean queryReplace = queryRemove &&
                        intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
                if (DBG) Slog.i(TAG, "action=" + action + " queryReplace=" + queryReplace);
                boolean removingPackage = queryRemove &&
                        !intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
                if (DBG) Slog.i(TAG, "action=" + action + " removing=" + removingPackage);
                if (action.equals(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE)) {
                    pkgList = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
                } else if (action.equals(Intent.ACTION_PACKAGES_SUSPENDED)) {
@@ -747,10 +747,10 @@ public class NotificationManagerService extends SystemService {
                        }
                    }
                }
                mListeners.onPackagesChanged(queryReplace, pkgList);
                mRankerServices.onPackagesChanged(queryReplace, pkgList);
                mConditionProviders.onPackagesChanged(queryReplace, pkgList);
                mRankingHelper.onPackagesChanged(queryReplace, pkgList);
                mListeners.onPackagesChanged(removingPackage, pkgList);
                mRankerServices.onPackagesChanged(removingPackage, pkgList);
                mConditionProviders.onPackagesChanged(removingPackage, pkgList);
                mRankingHelper.onPackagesChanged(removingPackage, pkgList);
            }
        }
    };
@@ -3894,14 +3894,14 @@ public class NotificationManagerService extends SystemService {
        }

        @Override
        public void onPackagesChanged(boolean queryReplace, String[] pkgList) {
            if (DEBUG) Slog.d(TAG, "onPackagesChanged queryReplace=" + queryReplace
        public void onPackagesChanged(boolean removingPackage, String[] pkgList) {
            if (DEBUG) Slog.d(TAG, "onPackagesChanged removingPackage=" + removingPackage
                    + " pkgList=" + (pkgList == null ? null : Arrays.asList(pkgList)));
            if (mRankerServicePackageName == null) {
                return;
            }

            if (pkgList != null && (pkgList.length > 0)) {
            if (pkgList != null && (pkgList.length > 0) && !removingPackage) {
                for (String pkgName : pkgList) {
                    if (mRankerServicePackageName.equals(pkgName)) {
                        registerRanker();
+2 −2
Original line number Diff line number Diff line
@@ -504,8 +504,8 @@ public class RankingHelper implements RankingConfig {
        return packageBans;
    }

    public void onPackagesChanged(boolean queryReplace, String[] pkgList) {
        if (queryReplace || pkgList == null || pkgList.length == 0
    public void onPackagesChanged(boolean removingPackage, String[] pkgList) {
        if (!removingPackage || pkgList == null || pkgList.length == 0
                || mRestoredWithoutUids.isEmpty()) {
            return; // nothing to do
        }
+1 −0
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ public class ZenModeConditions implements ConditionProviders.Callback {
            if (mConditionProviders.subscribeIfNecessary(rule.component, rule.conditionId)) {
                mSubscriptions.put(rule.conditionId, rule.component);
            } else {
                rule.condition = null;
                if (DEBUG) Log.d(TAG, "zmc failed to subscribe");
            }
        }