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

Commit db87b2da authored by Tony Huang's avatar Tony Huang Committed by Android (Google) Code Review
Browse files

Merge "Migrate Bubbles to wm-shell (3/n)"

parents 168d7918 56273e65
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -72,8 +72,6 @@ public final class Prefs {
            Key.QS_HAS_TURNED_OFF_MOBILE_DATA,
            Key.TOUCHED_RINGER_TOGGLE,
            Key.HAS_SEEN_ODI_CAPTIONS_TOOLTIP,
            Key.HAS_SEEN_BUBBLES_EDUCATION,
            Key.HAS_SEEN_BUBBLES_MANAGE_EDUCATION,
            Key.HAS_SEEN_REVERSE_BOTTOM_SHEET,
            Key.CONTROLS_STRUCTURE_SWIPE_TOOLTIP_COUNT,
            Key.HAS_SEEN_PRIORITY_ONBOARDING
@@ -123,8 +121,6 @@ public final class Prefs {
        String QS_HAS_TURNED_OFF_MOBILE_DATA = "QsHasTurnedOffMobileData";
        String TOUCHED_RINGER_TOGGLE = "TouchedRingerToggle";
        String HAS_SEEN_ODI_CAPTIONS_TOOLTIP = "HasSeenODICaptionsTooltip";
        String HAS_SEEN_BUBBLES_EDUCATION = "HasSeenBubblesOnboarding";
        String HAS_SEEN_BUBBLES_MANAGE_EDUCATION = "HasSeenBubblesManageOnboarding";
        String HAS_SEEN_REVERSE_BOTTOM_SHEET = "HasSeenReverseBottomSheet";
        String CONTROLS_STRUCTURE_SWIPE_TOOLTIP_COUNT = "ControlsStructureSwipeTooltipCount";
        /** Tracks whether the user has seen the onboarding screen for priority conversations */
+22 −11
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ import androidx.annotation.MainThread;
import androidx.annotation.Nullable;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.UiEventLogger;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.Dumpable;
@@ -87,6 +88,7 @@ import com.android.systemui.bubbles.dagger.BubbleModule;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.model.SysUiState;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.shared.system.TaskStackChangeListeners;
import com.android.systemui.statusbar.FeatureFlags;
@@ -168,7 +170,7 @@ public class BubbleController implements Bubbles, ConfigurationController.Config
    private final ShadeController mShadeController;
    private final FloatingContentCoordinator mFloatingContentCoordinator;
    private final BubbleDataRepository mDataRepository;
    private BubbleLogger mLogger = new BubbleLoggerImpl();
    private BubbleLogger mLogger;

    private BubbleData mBubbleData;
    private ScrimView mBubbleScrim;
@@ -365,20 +367,21 @@ public class BubbleController implements Bubbles, ConfigurationController.Config
            FeatureFlags featureFlags,
            DumpManager dumpManager,
            FloatingContentCoordinator floatingContentCoordinator,
            BubbleDataRepository dataRepository,
            SysUiState sysUiState,
            INotificationManager notificationManager,
            @Nullable IStatusBarService statusBarService,
            WindowManager windowManager,
            WindowManagerShellWrapper windowManagerShellWrapper,
            LauncherApps launcherApps) {
            LauncherApps launcherApps,
            UiEventLogger uiEventLogger) {
        BubbleLogger logger = new BubbleLogger(uiEventLogger);
        return new BubbleController(context, notificationShadeWindowController,
                statusBarStateController, shadeController, new BubbleData(context), synchronizer,
                configurationController, interruptionStateProvider, zenModeController,
                statusBarStateController, shadeController, new BubbleData(context, logger),
                synchronizer, configurationController, interruptionStateProvider, zenModeController,
                notifUserManager, groupManager, entryManager, notifPipeline, featureFlags,
                dumpManager, floatingContentCoordinator, dataRepository, sysUiState,
                notificationManager, statusBarService, windowManager, windowManagerShellWrapper,
                launcherApps);
                dumpManager, floatingContentCoordinator,
                new BubbleDataRepository(context, launcherApps), sysUiState, notificationManager,
                statusBarService, windowManager, windowManagerShellWrapper, launcherApps, logger);
    }

    /**
@@ -407,7 +410,8 @@ public class BubbleController implements Bubbles, ConfigurationController.Config
            @Nullable IStatusBarService statusBarService,
            WindowManager windowManager,
            WindowManagerShellWrapper windowManagerShellWrapper,
            LauncherApps launcherApps) {
            LauncherApps launcherApps,
            BubbleLogger bubbleLogger) {
        dumpManager.registerDumpable(TAG, this);
        mContext = context;
        mShadeController = shadeController;
@@ -417,6 +421,7 @@ public class BubbleController implements Bubbles, ConfigurationController.Config
        mFloatingContentCoordinator = floatingContentCoordinator;
        mDataRepository = dataRepository;
        mINotificationManager = notificationManager;
        mLogger = bubbleLogger;
        mZenModeController.addCallback(new ZenModeController.Callback() {
            @Override
            public void onZenChanged(int zen) {
@@ -577,6 +582,12 @@ public class BubbleController implements Bubbles, ConfigurationController.Config
        }
    }

    private void onBubbleExpandChanged(boolean shouldExpand) {
        mSysUiState
                .setFlag(QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED, shouldExpand)
                .commitUpdate(mContext.getDisplayId());
    }

    private void setupNEM() {
        mNotificationEntryManager.addNotificationEntryListener(
                new NotificationEntryListener() {
@@ -791,8 +802,8 @@ public class BubbleController implements Bubbles, ConfigurationController.Config
        if (mStackView == null) {
            mStackView = new BubbleStackView(
                    mContext, mBubbleData, mSurfaceSynchronizer, mFloatingContentCoordinator,
                    mSysUiState, this::onAllBubblesAnimatedOut, this::onImeVisibilityChanged,
                    this::hideCurrentInputMethod);
                    this::onAllBubblesAnimatedOut, this::onImeVisibilityChanged,
                    this::hideCurrentInputMethod, this::onBubbleExpandChanged);
            mStackView.setStackStartPosition(mPositionFromRemovedStack);
            mStackView.addView(mBubbleScrim);
            if (mExpandListener != null) {
+6 −7
Original line number Diff line number Diff line
@@ -32,10 +32,9 @@ import android.view.View;
import androidx.annotation.Nullable;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.FrameworkStatsLog;
import com.android.systemui.R;
import com.android.systemui.bubbles.BubbleController.DismissReason;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.shared.system.SysUiStatsLog;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -53,10 +52,9 @@ import java.util.function.Predicate;
/**
 * Keeps track of active bubbles.
 */
@SysUISingleton
public class BubbleData {

    private BubbleLoggerImpl mLogger = new BubbleLoggerImpl();
    private BubbleLogger mLogger;

    private int mCurrentUserId;

@@ -155,8 +153,9 @@ public class BubbleData {
     */
    private HashMap<String, String> mSuppressedGroupKeys = new HashMap<>();

    public BubbleData(Context context) {
    public BubbleData(Context context, BubbleLogger bubbleLogger) {
        mContext = context;
        mLogger = bubbleLogger;
        mBubbles = new ArrayList<>();
        mOverflowBubbles = new ArrayList<>();
        mPendingBubbles = new HashMap<>();
@@ -623,7 +622,7 @@ public class BubbleData {
        if (provider == null) {
            mLogger.logStackUiChanged(packageName, action, bubbleCount, normalX, normalY);
        } else if (provider.getKey().equals(BubbleOverflow.KEY)) {
            if (action == SysUiStatsLog.BUBBLE_UICHANGED__ACTION__EXPANDED) {
            if (action == FrameworkStatsLog.BUBBLE_UICHANGED__ACTION__EXPANDED) {
                mLogger.logShowOverflow(packageName, mCurrentUserId);
            }
        } else {
+4 −8
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.systemui.bubbles

import android.annotation.SuppressLint
import android.annotation.UserIdInt
import android.content.Context
import android.content.pm.LauncherApps
import android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_CACHED
import android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC
@@ -26,21 +27,16 @@ import android.util.Log
import com.android.systemui.bubbles.storage.BubbleEntity
import com.android.systemui.bubbles.storage.BubblePersistentRepository
import com.android.systemui.bubbles.storage.BubbleVolatileRepository
import com.android.systemui.dagger.SysUISingleton
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.launch
import kotlinx.coroutines.yield
import javax.inject.Inject

@SysUISingleton
internal class BubbleDataRepository @Inject constructor(
    private val volatileRepository: BubbleVolatileRepository,
    private val persistentRepository: BubblePersistentRepository,
    private val launcherApps: LauncherApps
) {
internal class BubbleDataRepository(context: Context, private val launcherApps: LauncherApps) {
    private val volatileRepository = BubbleVolatileRepository(launcherApps)
    private val persistentRepository = BubblePersistentRepository(context)

    private val ioScope = CoroutineScope(Dispatchers.IO)
    private val uiScope = CoroutineScope(Dispatchers.Main)
+72 −10
Original line number Diff line number Diff line
@@ -19,17 +19,22 @@ package com.android.systemui.bubbles;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;
import com.android.internal.util.FrameworkStatsLog;

/**
 * Interface for handling bubble-specific logging.
 * Implementation of UiEventLogger for logging bubble UI events.
 *
 * See UiEventReported atom in atoms.proto for more context.
 */
public interface BubbleLogger extends UiEventLogger {
public class BubbleLogger {

    private final UiEventLogger mUiEventLogger;

    /**
     * Bubble UI event.
     */
    @VisibleForTesting
    enum Event implements UiEventLogger.UiEventEnum {
    public enum Event implements UiEventLogger.UiEventEnum {

        @UiEvent(doc = "User dismissed the bubble via gesture, add bubble to overflow.")
        BUBBLE_OVERFLOW_ADD_USER_GESTURE(483),
@@ -70,23 +75,80 @@ public interface BubbleLogger extends UiEventLogger {
        }
    }

    public BubbleLogger(UiEventLogger uiEventLogger) {
        mUiEventLogger = uiEventLogger;
    }

    /**
     * @param b Bubble involved in this UI event
     * @param e UI event
     */
    void log(Bubble b, UiEventEnum e);
    public void log(Bubble b, UiEventLogger.UiEventEnum e) {
        mUiEventLogger.logWithInstanceId(e, b.getAppUid(), b.getPackageName(), b.getInstanceId());
    }

    /**
     *
     * @param b Bubble removed from overflow
     * @param r Reason that bubble was removed from overflow
     * @param r Reason that bubble was removed
     */
    void logOverflowRemove(Bubble b, @BubbleController.DismissReason int r);
    public void logOverflowRemove(Bubble b, @BubbleController.DismissReason int r) {
        if (r == BubbleController.DISMISS_NOTIF_CANCEL) {
            log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_CANCEL);
        } else if (r == BubbleController.DISMISS_GROUP_CANCELLED) {
            log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_GROUP_CANCEL);
        } else if (r == BubbleController.DISMISS_NO_LONGER_BUBBLE) {
            log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_NO_LONGER_BUBBLE);
        } else if (r == BubbleController.DISMISS_BLOCKED) {
            log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_BLOCKED);
        }
    }

    /**
     *
     * @param b Bubble added to overflow
     * @param r Reason that bubble was added to overflow
     */
    void logOverflowAdd(Bubble b, @BubbleController.DismissReason int r);
    public void logOverflowAdd(Bubble b, @BubbleController.DismissReason int r) {
        if (r == BubbleController.DISMISS_AGED) {
            log(b, Event.BUBBLE_OVERFLOW_ADD_AGED);
        } else if (r == BubbleController.DISMISS_USER_GESTURE) {
            log(b, Event.BUBBLE_OVERFLOW_ADD_USER_GESTURE);
        }
    }

    void logStackUiChanged(String packageName, int action, int bubbleCount, float normalX,
            float normalY) {
        FrameworkStatsLog.write(FrameworkStatsLog.BUBBLE_UI_CHANGED,
                packageName,
                null /* notification channel */,
                0 /* notification ID */,
                0 /* bubble position */,
                bubbleCount,
                action,
                normalX,
                normalY,
                false /* unread bubble */,
                false /* on-going bubble */,
                false /* isAppForeground (unused) */);
    }

    void logShowOverflow(String packageName, int currentUserId) {
        mUiEventLogger.log(BubbleLogger.Event.BUBBLE_OVERFLOW_SELECTED, currentUserId,
                packageName);
    }

    void logBubbleUiChanged(Bubble bubble, String packageName, int action, int bubbleCount,
            float normalX, float normalY, int index) {
        FrameworkStatsLog.write(FrameworkStatsLog.BUBBLE_UI_CHANGED,
                packageName,
                bubble.getChannelId() /* notification channel */,
                bubble.getNotificationId() /* notification ID */,
                index,
                bubbleCount,
                action,
                normalX,
                normalY,
                bubble.showInShade() /* isUnread */,
                false /* isOngoing (unused) */,
                false /* isAppForeground (unused) */);
    }
}
 No newline at end of file
Loading