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

Commit 681f269d authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge changes from topic "global_to_secure" into sc-dev

* changes:
  Fix bubbles for workprofile
  Sysui bubbles multiuser fixes: persistence / overflow
  Move bubble setting to secure table & support multiuser
parents dd9d4ff9 26d22630
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2115,7 +2115,7 @@ package android.provider {
    field public static final String LOCATION_IGNORE_SETTINGS_PACKAGE_WHITELIST = "location_ignore_settings_package_whitelist";
    field public static final String LOW_POWER_MODE = "low_power";
    field public static final String LOW_POWER_MODE_STICKY = "low_power_sticky";
    field public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
    field @Deprecated public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
    field public static final String OVERLAY_DISPLAY_DEVICES = "overlay_display_devices";
    field public static final String SHOW_FIRST_CRASH_DIALOG = "show_first_crash_dialog";
    field public static final String USER_DISABLED_HDR_FORMATS = "user_disabled_hdr_formats";
@@ -2139,6 +2139,7 @@ package android.provider {
    field public static final String IMMERSIVE_MODE_CONFIRMATIONS = "immersive_mode_confirmations";
    field public static final String NFC_PAYMENT_DEFAULT_COMPONENT = "nfc_payment_default_component";
    field public static final String NOTIFICATION_BADGING = "notification_badging";
    field public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
    field public static final String POWER_MENU_LOCKED_SHOW_CONTENT = "power_menu_locked_show_content";
    field public static final String SELECTED_SPELL_CHECKER = "selected_spell_checker";
    field public static final String SELECTED_SPELL_CHECKER_SUBTYPE = "selected_spell_checker_subtype";
+16 −1
Original line number Diff line number Diff line
@@ -9497,6 +9497,18 @@ public final class Settings {
        public static final String BUBBLE_IMPORTANT_CONVERSATIONS
                = "bubble_important_conversations";
        /**
         * When enabled, notifications able to bubble will display an affordance allowing the user
         * to bubble them.
         * The value is boolean (1 to enable or 0 to disable).
         *
         * @hide
         */
        @TestApi
        @SuppressLint("NoSettingsProvider")
        @Readable
        public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
        /**
         * Whether notifications are dismissed by a right-to-left swipe (instead of a left-to-right
         * swipe).
@@ -9968,6 +9980,7 @@ public final class Settings {
            CLONE_TO_MANAGED_PROFILE.add(LOCATION_CHANGER);
            CLONE_TO_MANAGED_PROFILE.add(LOCATION_MODE);
            CLONE_TO_MANAGED_PROFILE.add(SHOW_IME_WITH_HARD_KEYBOARD);
            CLONE_TO_MANAGED_PROFILE.add(NOTIFICATION_BUBBLES);
        }
        /** @hide */
@@ -10061,7 +10074,9 @@ public final class Settings {
         * Whether the notification bubbles are globally enabled
         * The value is boolean (1 or 0).
         * @hide
         * @deprecated moved to secure settings.
         */
        @Deprecated
        @TestApi
        @Readable
        public static final String NOTIFICATION_BUBBLES = "notification_bubbles";
@@ -14810,7 +14825,7 @@ public final class Settings {
            MOVED_TO_SECURE.add(Global.ZEN_SETTINGS_SUGGESTION_VIEWED);
            MOVED_TO_SECURE.add(Global.CHARGING_SOUNDS_ENABLED);
            MOVED_TO_SECURE.add(Global.CHARGING_VIBRATION_ENABLED);
            MOVED_TO_SECURE.add(Global.NOTIFICATION_BUBBLES);
        }
        /** @hide */
+5 −3
Original line number Diff line number Diff line
@@ -165,7 +165,8 @@ public class Bubble implements BubbleViewProvider {
     * Create a bubble with limited information based on given {@link ShortcutInfo}.
     * Note: Currently this is only being used when the bubble is persisted to disk.
     */
    Bubble(@NonNull final String key, @NonNull final ShortcutInfo shortcutInfo,
    @VisibleForTesting(visibility = PRIVATE)
    public Bubble(@NonNull final String key, @NonNull final ShortcutInfo shortcutInfo,
            final int desiredHeight, final int desiredHeightResId, @Nullable final String title,
            int taskId, @Nullable final String locus, Executor mainExecutor) {
        Objects.requireNonNull(key);
@@ -188,7 +189,7 @@ public class Bubble implements BubbleViewProvider {
    }

    @VisibleForTesting(visibility = PRIVATE)
    Bubble(@NonNull final BubbleEntry entry,
    public Bubble(@NonNull final BubbleEntry entry,
            @Nullable final Bubbles.SuppressionChangedListener listener,
            final Bubbles.PendingIntentCanceledListener intentCancelListener,
            Executor mainExecutor) {
@@ -718,7 +719,8 @@ public class Bubble implements BubbleViewProvider {

    private int getUid(final Context context) {
        if (mAppUid != -1) return mAppUid;
        final PackageManager pm = context.getPackageManager();
        final PackageManager pm = BubbleController.getPackageManagerForUser(context,
                mUser.getIdentifier());
        if (pm == null) return -1;
        try {
            final ApplicationInfo info = pm.getApplicationInfo(mShortcutInfo.getPackage(), 0);
+43 −8
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.LauncherApps;
import android.content.pm.PackageManager;
import android.content.pm.ShortcutInfo;
import android.content.pm.UserInfo;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.PointF;
@@ -64,6 +65,7 @@ import android.util.ArraySet;
import android.util.Log;
import android.util.Pair;
import android.util.Slog;
import android.util.SparseArray;
import android.util.SparseSetArray;
import android.view.View;
import android.view.ViewGroup;
@@ -144,6 +146,8 @@ public class BubbleController {

    // Tracks the id of the current (foreground) user.
    private int mCurrentUserId;
    // Current profiles of the user (e.g. user with a workprofile)
    private SparseArray<UserInfo> mCurrentProfiles;
    // Saves notification keys of active bubbles when users are switched.
    private final SparseSetArray<String> mSavedBubbleKeysPerUser;

@@ -153,8 +157,8 @@ public class BubbleController {
    // Callback that updates BubbleOverflowActivity on data change.
    @Nullable private BubbleData.Listener mOverflowListener = null;

    // Only load overflow data from disk once
    private boolean mOverflowDataLoaded = false;
    // Typically only load once & after user switches
    private boolean mOverflowDataLoadNeeded = true;

    /**
     * When the shade status changes to SHADE (from anything but SHADE, like LOCKED) we'll select
@@ -468,14 +472,31 @@ public class BubbleController {
        updateStack();
    }

    private void onUserChanged(int newUserId) {
    /** Called when the current user changes. */
    @VisibleForTesting
    public void onUserChanged(int newUserId) {
        saveBubbles(mCurrentUserId);
        mCurrentUserId = newUserId;

        mBubbleData.dismissAll(DISMISS_USER_CHANGED);
        mBubbleData.clearOverflow();
        mOverflowDataLoadNeeded = true;

        restoreBubbles(newUserId);
        mCurrentUserId = newUserId;
        mBubbleData.setCurrentUserId(newUserId);
    }

    /** Called when the profiles for the current user change. **/
    public void onCurrentProfilesChanged(SparseArray<UserInfo> currentProfiles) {
        mCurrentProfiles = currentProfiles;
    }

    /** Whether this userId belongs to the current user. */
    private boolean isCurrentProfile(int userId) {
        return userId == UserHandle.USER_ALL
                || (mCurrentProfiles != null && mCurrentProfiles.get(userId) != null);
    }

    /**
     * Sets whether to perform inflation on the same thread as the caller. This method should only
     * be used in tests, not in production.
@@ -556,6 +577,7 @@ public class BubbleController {
        mWmLayoutParams.setTitle("Bubbles!");
        mWmLayoutParams.packageName = mContext.getPackageName();
        mWmLayoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
        mWmLayoutParams.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS;

        try {
            mAddedToWindowManager = true;
@@ -639,7 +661,7 @@ public class BubbleController {
            });
        });
        // Finally, remove the entries for this user now that bubbles are restored.
        mSavedBubbleKeysPerUser.remove(mCurrentUserId);
        mSavedBubbleKeysPerUser.remove(userId);
    }

    private void updateForThemeChanges() {
@@ -804,12 +826,12 @@ public class BubbleController {
     * Fills the overflow bubbles by loading them from disk.
     */
    void loadOverflowBubblesFromDisk() {
        if (!mBubbleData.getOverflowBubbles().isEmpty() || mOverflowDataLoaded) {
        if (!mBubbleData.getOverflowBubbles().isEmpty() && !mOverflowDataLoadNeeded) {
            // we don't need to load overflow bubbles from disk if it is already in memory
            return;
        }
        mOverflowDataLoaded = true;
        mDataRepository.loadBubbles((bubbles) -> {
        mOverflowDataLoadNeeded = false;
        mDataRepository.loadBubbles(mCurrentUserId, (bubbles) -> {
            bubbles.forEach(bubble -> {
                if (mBubbleData.hasAnyBubbleWithKey(bubble.getKey())) {
                    // if the bubble is already active, there's no need to push it to overflow
@@ -911,6 +933,12 @@ public class BubbleController {
            Pair<BubbleEntry, Boolean> entryData = entryDataByKey.get(key);
            BubbleEntry entry = entryData.first;
            boolean shouldBubbleUp = entryData.second;

            if (entry != null && !isCurrentProfile(
                    entry.getStatusBarNotification().getUser().getIdentifier())) {
                return;
            }

            rankingMap.getRanking(key, mTmpRanking);
            boolean isActiveBubble = mBubbleData.hasAnyBubbleWithKey(key);
            if (isActiveBubble && !mTmpRanking.canBubble()) {
@@ -1427,6 +1455,13 @@ public class BubbleController {
            });
        }

        @Override
        public void onCurrentProfilesChanged(SparseArray<UserInfo> currentProfiles) {
            mMainExecutor.execute(() -> {
                BubbleController.this.onCurrentProfilesChanged(currentProfiles);
            });
        }

        @Override
        public void onConfigChanged(Configuration newConfig) {
            mMainExecutor.execute(() -> {
+12 −1
Original line number Diff line number Diff line
@@ -510,7 +510,8 @@ public class BubbleData {
                        || reason == Bubbles.DISMISS_NO_LONGER_BUBBLE
                        || reason == Bubbles.DISMISS_BLOCKED
                        || reason == Bubbles.DISMISS_SHORTCUT_REMOVED
                        || reason == Bubbles.DISMISS_PACKAGE_REMOVED)) {
                        || reason == Bubbles.DISMISS_PACKAGE_REMOVED
                        || reason == Bubbles.DISMISS_USER_CHANGED)) {

                Bubble b = getOverflowBubbleWithKey(key);
                if (DEBUG_BUBBLE_DATA) {
@@ -642,6 +643,16 @@ public class BubbleData {
        }
    }

    /**
     * Removes all bubbles from the overflow, called when the user changes.
     */
    public void clearOverflow() {
        while (!mOverflowBubbles.isEmpty()) {
            doRemove(mOverflowBubbles.get(0).getKey(), Bubbles.DISMISS_USER_CHANGED);
        }
        dispatchPendingChanges();
    }

    private void dispatchPendingChanges() {
        if (mListener != null && mStateChange.anythingChanged()) {
            mListener.applyUpdate(mStateChange);
Loading