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

Commit c56192c1 authored by Zimuzo's avatar Zimuzo
Browse files

Fix system settings not cleared when package data is cleared

System settings written by an app were not cleared when app
data was cleared. Apps were thus unable to recover from a bad
state caused by writing a system setting.

BUG: 80134777
Test: Manually tested with test app that writes to system settings.
Verified that the system setting got cleared after clearing app data.

Change-Id: Ibdff885db3e45ea04be845bf06c2d53045115155
parent 16391f94
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -816,7 +816,7 @@ public class SettingsProvider extends ContentProvider {
            @Override
            public void onPackageRemoved(String packageName, int uid) {
                synchronized (mLock) {
                    mSettingsRegistry.onPackageRemovedLocked(packageName,
                    mSettingsRegistry.removeSettingsForPackageLocked(packageName,
                            UserHandle.getUserId(uid));
                }
            }
@@ -827,6 +827,14 @@ public class SettingsProvider extends ContentProvider {
                    mSettingsRegistry.onUidRemovedLocked(uid);
                }
            }

            @Override
            public void onPackageDataCleared(String packageName, int uid) {
                synchronized (mLock) {
                    mSettingsRegistry.removeSettingsForPackageLocked(packageName,
                            UserHandle.getUserId(uid));
                }
            }
        };

        // package changes
@@ -2547,7 +2555,7 @@ public class SettingsProvider extends ContentProvider {
            }
        }

        public void onPackageRemovedLocked(String packageName, int userId) {
        public void removeSettingsForPackageLocked(String packageName, int userId) {
            // Global and secure settings are signature protected. Apps signed
            // by the platform certificate are generally not uninstalled  and
            // the main exception is tests. We trust components signed
@@ -2556,7 +2564,7 @@ public class SettingsProvider extends ContentProvider {
            final int systemKey = makeKey(SETTINGS_TYPE_SYSTEM, userId);
            SettingsState systemSettings = mSettingsStates.get(systemKey);
            if (systemSettings != null) {
                systemSettings.onPackageRemovedLocked(packageName);
                systemSettings.removeSettingsForPackageLocked(packageName);
            }
        }

+1 −1
Original line number Diff line number Diff line
@@ -293,7 +293,7 @@ final class SettingsState {
    }

    // The settings provider must hold its lock when calling here.
    public void onPackageRemovedLocked(String packageName) {
    public void removeSettingsForPackageLocked(String packageName) {
        boolean removedSomething = false;

        final int settingCount = mSettings.size();