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

Commit cdcd587f authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB][Sat] Add demo repo for device-based satellite.

Fixes: 323522792
Test: See below:
1) `adb shell am broadcast -a com.android.systemui.demo -e command
   enter` -> starts demo mode
2) `adb shell am broadcast -a com.android.systemui.demo -e command
   network -e mobile show -e level 0` -> sets mobile to be
   out-of-service
3) Wait 10s
4) Verify dimmed satellite icon appears
5) `adb shell am broadcast -a com.android.systemui.demo -e command
network -e satellite show -e level 4 -e connection connected` -> Verify
full satellite icon appears with level
6) Update the `level` value or `connection` value in the satellite
   command -> Verify satellite icon adjusts appropriately
7) `adb shell am broadcast -a com.android.systemui.demo -e command
   network -e mobile show -e level 1` -> sets mobile to be in-service,
   so verify satellite icon disappears
Test: all unit tests in the statusbar.pipeline.satellite directory
Flag: ACONFIG com.android.internal.telephony.flags.oem_enabled_satellite_flag
NEXTFOOD

Change-Id: I43622852763f6ac1d28446e0afd77a8cb92d26e0
parent 8e1ad154
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.systemui.statusbar.StatusIconDisplayable;
import com.android.systemui.statusbar.pipeline.mobile.ui.MobileViewLogger;
import com.android.systemui.statusbar.pipeline.mobile.ui.view.ModernStatusBarMobileView;
import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.MobileIconsViewModel;
import com.android.systemui.statusbar.pipeline.shared.ui.view.ModernStatusBarView;
import com.android.systemui.statusbar.pipeline.wifi.ui.view.ModernStatusBarWifiView;
import com.android.systemui.statusbar.pipeline.wifi.ui.viewmodel.LocationBasedWifiViewModel;

@@ -277,6 +278,15 @@ public class DemoStatusIcons extends StatusIconContainer implements DemoMode, Da
        addView(view, viewIndex, createLayoutParams());
    }

    /** Adds a bindable icon to the demo mode view. */
    public void addBindableIcon(StatusBarIconHolder.BindableIconHolder holder) {
        // This doesn't do any correct ordering, and also doesn't check if we already have an
        // existing icon for the slot. But since we hope to remove this class soon, we won't spend
        // the time adding that logic.
        ModernStatusBarView view = holder.getInitializer().createAndBind(mContext);
        addView(view, createLayoutParams());
    }

    public void onRemoveIcon(StatusIconDisplayable view) {
        if (view.getSlot().equals("wifi")) {
            if (view instanceof ModernStatusBarWifiView) {
+14 −1
Original line number Diff line number Diff line
@@ -54,7 +54,9 @@ import com.android.systemui.statusbar.pipeline.wifi.ui.viewmodel.LocationBasedWi
import com.android.systemui.util.Assert;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;

@@ -348,7 +350,11 @@ public interface StatusBarIconController {
        private final MobileContextProvider mMobileContextProvider;
        private final LocationBasedWifiViewModel mWifiViewModel;
        private final MobileIconsViewModel mMobileIconsViewModel;

        /**
         * Stores the list of bindable icons that have been added, keyed on slot name. This ensures
         * we don't accidentally add the same bindable icon twice.
         */
        private final Map<String, BindableIconHolder> mBindableIcons = new HashMap<>();
        protected final Context mContext;
        protected int mIconSize;
        // Whether or not these icons show up in dumpsys
@@ -460,8 +466,12 @@ public interface StatusBarIconController {
         * ViewBinder to control its visual state.
         */
        protected StatusIconDisplayable addBindableIcon(BindableIconHolder holder, int index) {
            mBindableIcons.put(holder.getSlot(), holder);
            ModernStatusBarView view = holder.getInitializer().createAndBind(mContext);
            mGroup.addView(view, index, onCreateLayoutParams());
            if (mIsInDemoMode) {
                mDemoStatusIcons.addBindableIcon(holder);
            }
            return view;
        }

@@ -572,6 +582,9 @@ public interface StatusBarIconController {
            if (mDemoStatusIcons == null) {
                mDemoStatusIcons = createDemoStatusIcons();
                mDemoStatusIcons.addModernWifiView(mWifiViewModel);
                for (BindableIconHolder holder : mBindableIcons.values()) {
                    mDemoStatusIcons.addBindableIcon(holder);
                }
            }
            mDemoStatusIcons.onDemoModeStarted();
        }
+2 −1
Original line number Diff line number Diff line
@@ -212,7 +212,8 @@ public class StatusBarIconControllerImpl implements Tunable,
        StatusBarIconHolder existingHolder = mStatusBarIconList.getIconHolder(icon.getSlot(), 0);
        // Expected to be null
        if (existingHolder == null) {
            BindableIconHolder bindableIcon = new BindableIconHolder(icon.getInitializer());
            BindableIconHolder bindableIcon =
                    new BindableIconHolder(icon.getInitializer(), icon.getSlot());
            setIcon(icon.getSlot(), bindableIcon);
        } else {
            Log.e(TAG, "addBindableIcon called, but icon has already been added. Ignoring");
+6 −3
Original line number Diff line number Diff line
@@ -169,16 +169,19 @@ open class StatusBarIconHolder private constructor() {
     * StatusBarIconController will register all available bindable icons on init (see
     * [BindableIconsRepository]), and will ignore any call to setIcon for these.
     *
     * [initializer] a view creator that can bind the relevant view models to the created view.
     * @property initializer a view creator that can bind the relevant view models to the created
     *   view.
     * @property slot the name of the slot that this holder is used for.
     */
    class BindableIconHolder(val initializer: ModernStatusBarViewCreator) : StatusBarIconHolder() {
    class BindableIconHolder(val initializer: ModernStatusBarViewCreator, val slot: String) :
        StatusBarIconHolder() {
        override var type: Int = TYPE_BINDABLE

        /** This is unused, as bindable icons use their own view binders to control visibility */
        override var isVisible: Boolean = true

        override fun toString(): String {
            return ("StatusBarIconHolder(type=BINDABLE)")
            return ("StatusBarIconHolder(type=BINDABLE, slot=$slot)")
        }
    }
}
+8 −1
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ import com.android.systemui.statusbar.pipeline.mobile.util.MobileMappingsProxyIm
import com.android.systemui.statusbar.pipeline.mobile.util.SubscriptionManagerProxy
import com.android.systemui.statusbar.pipeline.mobile.util.SubscriptionManagerProxyImpl
import com.android.systemui.statusbar.pipeline.satellite.data.DeviceBasedSatelliteRepository
import com.android.systemui.statusbar.pipeline.satellite.data.DeviceBasedSatelliteRepositorySwitcher
import com.android.systemui.statusbar.pipeline.satellite.data.RealDeviceBasedSatelliteRepository
import com.android.systemui.statusbar.pipeline.satellite.data.prod.DeviceBasedSatelliteRepositoryImpl
import com.android.systemui.statusbar.pipeline.shared.data.repository.ConnectivityRepository
import com.android.systemui.statusbar.pipeline.shared.data.repository.ConnectivityRepositoryImpl
@@ -81,8 +83,13 @@ abstract class StatusBarPipelineModule {
    abstract fun connectivityRepository(impl: ConnectivityRepositoryImpl): ConnectivityRepository

    @Binds
    abstract fun deviceBasedSatelliteRepository(
    abstract fun realDeviceBasedSatelliteRepository(
        impl: DeviceBasedSatelliteRepositoryImpl
    ): RealDeviceBasedSatelliteRepository

    @Binds
    abstract fun deviceBasedSatelliteRepository(
        impl: DeviceBasedSatelliteRepositorySwitcher
    ): DeviceBasedSatelliteRepository

    @Binds abstract fun wifiRepository(impl: WifiRepositorySwitcher): WifiRepository
Loading