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

Commit 1b0691b3 authored by Danny Baumann's avatar Danny Baumann
Browse files

Move broadcast actions from service to ProfileManager so all API is

there.

Change-Id: Ic8a8ad8f86f01864a30963457687f5be70e99ef4
parent d8bfdb9d
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -45,6 +45,24 @@ public class ProfileManager {

    private static final String SYSTEM_PROFILES_ENABLED = "system_profiles_enabled";

    /**
     * <p>Broadcast Action: A new profile has been selected. This can be triggered by the user
     * or by calls to the ProfileManagerService / Profile.</p>
     * @hide
     */
    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";

    /**
     * Activity Action: Shows a profile picker.
     * <p>
+2 −3
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.view.View;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;

import com.android.server.ProfileManagerService;
import com.android.systemui.R;
import com.android.systemui.statusbar.phone.QuickSettingsContainerView;
import com.android.systemui.statusbar.phone.QuickSettingsController;
@@ -43,8 +42,8 @@ public class ProfileTile extends QuickSettingsTile {
            QuickSettingsController qsc) {
        super(context, qsc);

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

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

+4 −19
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.app.IProfileManager;
import android.app.NotificationGroup;
import android.app.Profile;
import android.app.ProfileGroup;
import android.app.ProfileManager;
import android.app.backup.BackupManager;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
@@ -53,31 +54,15 @@ import java.util.UUID;

/** {@hide} */
public class ProfileManagerService extends IProfileManager.Stub {
    private static final String TAG = "ProfileService";
    // Enable the below for detailed logging of this class
    private static final boolean LOCAL_LOGV = false;
    /**
     * <p>Broadcast Action: A new profile has been selected. This can be triggered by the user
     * or by calls to the ProfileManagerService / Profile.</p>
     * @hide
     */
    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";

    /* package */ static final File PROFILE_FILE =
            new File(Environment.getSystemSecureDirectory(), "profiles.xml");

    private static final String TAG = "ProfileService";

    private Map<UUID, Profile> mProfiles;

    // Match UUIDs and names, used for reverse compatibility
@@ -281,7 +266,7 @@ public class ProfileManagerService extends IProfileManager.Stub {
                mActiveProfile.doSelect(mContext);

                // Notify other applications of newly selected profile.
                Intent broadcast = new Intent(INTENT_ACTION_PROFILE_SELECTED);
                Intent broadcast = new Intent(ProfileManager.INTENT_ACTION_PROFILE_SELECTED);
                broadcast.putExtra("name", mActiveProfile.getName());
                broadcast.putExtra("uuid", mActiveProfile.getUuid().toString());
                broadcast.putExtra("lastName", lastProfile.getName());
@@ -294,7 +279,7 @@ public class ProfileManagerService extends IProfileManager.Stub {
                    ActivityManagerNative.isSystemReady()) {
                // Something definitely changed: notify.
                long token = clearCallingIdentity();
                Intent broadcast = new Intent(INTENT_ACTION_PROFILE_UPDATED);
                Intent broadcast = new Intent(ProfileManager.INTENT_ACTION_PROFILE_UPDATED);
                broadcast.putExtra("name", mActiveProfile.getName());
                broadcast.putExtra("uuid", mActiveProfile.getUuid().toString());
                mContext.sendBroadcastAsUser(broadcast, UserHandle.ALL);