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

Commit 37f90751 authored by David van Tonder's avatar David van Tonder Committed by Gerrit Code Review
Browse files

Merge "profiles: Broadcast profile updates" into cm-10.1

parents 4c90669f 8d7d1899
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ public class ProfileTile extends QuickSettingsTile {
        super(context, qsc);

        qsc.registerAction(ProfileManagerService.INTENT_ACTION_PROFILE_SELECTED, this);
        qsc.registerAction(ProfileManagerService.INTENT_ACTION_PROFILE_UPDATED, this);

        mProfileManager = (ProfileManager) mContext.getSystemService(Context.PROFILE_SERVICE);

+17 −0
Original line number Diff line number Diff line
@@ -54,6 +54,15 @@ public class ProfileManagerService extends IProfileManager.Stub {
     */
    public static final String INTENT_ACTION_PROFILE_SELECTED = "android.intent.action.PROFILE_SELECTED";

    /**
    * <p>Broadcast Action: Current profile has been updated. This is triggered every time the
    * currently active profile is updated, instead of selected.</p>
    * <p> For instance, this includes profile updates caused by a locale change, which doesn't
    * trigger a profile selection, but causes its name to change.</p>
    * @hide
    */
    public static final String INTENT_ACTION_PROFILE_UPDATED = "android.intent.action.PROFILE_UPDATED";

    public static final String PERMISSION_CHANGE_SETTINGS = "android.permission.WRITE_SETTINGS";

    private static final String PROFILE_FILENAME = "/data/system/profiles.xml";
@@ -218,6 +227,14 @@ public class ProfileManagerService extends IProfileManager.Stub {

                restoreCallingIdentity(token);
                persistIfDirty();
            } else if (lastProfile != mActiveProfile) {
                // Something definitely changed: notify.
                long token = clearCallingIdentity();
                Intent broadcast = new Intent(INTENT_ACTION_PROFILE_UPDATED);
                broadcast.putExtra("name", mActiveProfile.getName());
                broadcast.putExtra("uuid", mActiveProfile.getUuid().toString());
                mContext.sendBroadcastAsUser(broadcast, UserHandle.ALL);
                restoreCallingIdentity(token);
            }
            return true;
        } catch (Exception ex) {