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

Commit 578a10ba authored by Ladios Jonquil's avatar Ladios Jonquil Committed by Steve Kondik
Browse files

profile: Add an option to reset everything (1/2)

For user to reset all profiles and groups by one click, without
deleting /data/system/profiles.xml and reboot.

This is alternative of http://review.cyanogenmod.com/7624

Change-Id: I61e24de0d5853a66aa63713200dff2eae2a04513
parent 2195675e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -44,4 +44,6 @@ interface IProfileManager
    void updateNotificationGroup(in NotificationGroup group);
    NotificationGroup getNotificationGroupForPackage(in String pkg);
    NotificationGroup getNotificationGroup(in ParcelUuid groupParcelUuid);

    void resetAll();
}
+11 −0
Original line number Diff line number Diff line
@@ -231,4 +231,15 @@ public class ProfileManager
        }
        return getActiveProfile().getProfileGroup(notificationGroup.getUuid());
    }

    /** @hide */
    public void resetAll() {
        try {
            getService().resetAll();
        } catch (RemoteException e) {
            Log.e(TAG, e.getLocalizedMessage(), e);
        } catch (SecurityException e) {
            Log.e(TAG, e.getLocalizedMessage(), e);
        }
    }
}
+23 −9
Original line number Diff line number Diff line
@@ -105,22 +105,30 @@ public class ProfileManagerService extends IProfileManager.Stub {
    }

    private void initialize() {
        initialize(false);
    }

    private void initialize(boolean skipFile) {
        mProfiles = new HashMap<UUID, Profile>();
        mProfileNames = new HashMap<String, UUID>();
        mGroups = new HashMap<UUID, NotificationGroup>();
        mDirty = false;

        boolean init = skipFile;

        if (! skipFile) {
            try {
                loadFromFile();
            } catch (RemoteException e) {
                e.printStackTrace();
            } catch (XmlPullParserException e) {
            try {
                initialiseStructure();
            } catch (Throwable ex) {
                Log.e(TAG, "Error loading xml from resource: ", ex);
            }
                init = true;
            } catch (IOException e) {
                init = true;
            }
        }

        if (init) {
            try {
                initialiseStructure();
            } catch (Throwable ex) {
@@ -129,6 +137,12 @@ public class ProfileManagerService extends IProfileManager.Stub {
        }
    }

    @Override
    public void resetAll() {
        enforceChangePermissions();
        initialize(true);
    }

    @Override
    @Deprecated
    public boolean setActiveProfileByName(String profileName) throws RemoteException, SecurityException {