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

Commit 5ba8d5c6 authored by Evan Laird's avatar Evan Laird Committed by Automerger Merge Worker
Browse files

Merge changes I4977aa47,I87686213,If4bd3e31,I727ad3ca,Ib02a1eb6 into...

Merge changes I4977aa47,I87686213,If4bd3e31,I727ad3ca,Ib02a1eb6 into tm-qpr-dev am: 18917a18 am: e6a924a6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20665129



Change-Id: Ia34e7515b0274e7fabb5168ce14aa4b44642ea91
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents e4945ce9 e6a924a6
Loading
Loading
Loading
Loading
+46 −2
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ import com.android.systemui.statusbar.StatusIconDisplayable;
import com.android.systemui.statusbar.connectivity.ui.MobileContextProvider;
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.MobileIconState;
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.WifiIconState;
import com.android.systemui.statusbar.pipeline.mobile.ui.view.ModernStatusBarMobileView;
import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.MobileIconsViewModel;

import java.util.ArrayList;
import java.util.List;
@@ -50,20 +52,25 @@ public class DemoStatusIcons extends StatusIconContainer implements DemoMode, Da

    private final LinearLayout mStatusIcons;
    private final ArrayList<StatusBarMobileView> mMobileViews = new ArrayList<>();
    private final ArrayList<ModernStatusBarMobileView> mModernMobileViews = new ArrayList<>();
    private final int mIconSize;

    private StatusBarWifiView mWifiView;
    private boolean mDemoMode;
    private int mColor;

    private final MobileIconsViewModel mMobileIconsViewModel;

    public DemoStatusIcons(
            LinearLayout statusIcons,
            MobileIconsViewModel mobileIconsViewModel,
            int iconSize
    ) {
        super(statusIcons.getContext());
        mStatusIcons = statusIcons;
        mIconSize = iconSize;
        mColor = DarkIconDispatcher.DEFAULT_ICON_TINT;
        mMobileIconsViewModel = mobileIconsViewModel;

        if (statusIcons instanceof StatusIconContainer) {
            setShouldRestrictIcons(((StatusIconContainer) statusIcons).isRestrictingIcons());
@@ -115,6 +122,8 @@ public class DemoStatusIcons extends StatusIconContainer implements DemoMode, Da
    public void onDemoModeFinished() {
        mDemoMode = false;
        mStatusIcons.setVisibility(View.VISIBLE);
        mModernMobileViews.clear();
        mMobileViews.clear();
        setVisibility(View.GONE);
    }

@@ -268,6 +277,24 @@ public class DemoStatusIcons extends StatusIconContainer implements DemoMode, Da
        addView(view, getChildCount(), createLayoutParams());
    }

    /**
     * Add a {@link ModernStatusBarMobileView}
     * @param mobileContext possibly mcc/mnc overridden mobile context
     * @param subId the subscriptionId for this mobile view
     */
    public void addModernMobileView(Context mobileContext, int subId) {
        Log.d(TAG, "addModernMobileView (subId=" + subId + ")");
        ModernStatusBarMobileView view = ModernStatusBarMobileView.constructAndBind(
                mobileContext,
                "mobile",
                mMobileIconsViewModel.viewModelForSub(subId)
        );

        // mobile always goes at the end
        mModernMobileViews.add(view);
        addView(view, getChildCount(), createLayoutParams());
    }

    /**
     * Apply an update to a mobile icon view for the given {@link MobileIconState}. For
     * compatibility with {@link MobileContextProvider}, we have to recreate the view every time we
@@ -292,12 +319,19 @@ public class DemoStatusIcons extends StatusIconContainer implements DemoMode, Da
        if (view.getSlot().equals("wifi")) {
            removeView(mWifiView);
            mWifiView = null;
        } else {
        } else if (view instanceof StatusBarMobileView) {
            StatusBarMobileView mobileView = matchingMobileView(view);
            if (mobileView != null) {
                removeView(mobileView);
                mMobileViews.remove(mobileView);
            }
        } else if (view instanceof ModernStatusBarMobileView) {
            ModernStatusBarMobileView mobileView = matchingModernMobileView(
                    (ModernStatusBarMobileView) view);
            if (mobileView != null) {
                removeView(mobileView);
                mModernMobileViews.remove(mobileView);
            }
        }
    }

@@ -316,6 +350,16 @@ public class DemoStatusIcons extends StatusIconContainer implements DemoMode, Da
        return null;
    }

    private ModernStatusBarMobileView matchingModernMobileView(ModernStatusBarMobileView other) {
        for (ModernStatusBarMobileView v : mModernMobileViews) {
            if (v.getSubId() == other.getSubId()) {
                return v;
            }
        }

        return null;
    }

    private LayoutParams createLayoutParams() {
        return new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, mIconSize);
    }
+6 −5
Original line number Diff line number Diff line
@@ -536,8 +536,7 @@ public interface StatusBarIconController {
            mGroup.addView(view, index, onCreateLayoutParams());

            if (mIsInDemoMode) {
                // TODO (b/249790009): demo mode should be handled at the data layer in the
                //  new pipeline
                mDemoStatusIcons.addModernMobileView(mContext, subId);
            }

            return view;
@@ -565,11 +564,13 @@ public interface StatusBarIconController {

        private ModernStatusBarMobileView onCreateModernStatusBarMobileView(
                String slot, int subId) {
            Context mobileContext = mMobileContextProvider.getMobileContextForSub(subId, mContext);
            return ModernStatusBarMobileView
                    .constructAndBind(
                            mContext,
                            mobileContext,
                            slot,
                            mMobileIconsViewModel.viewModelForSub(subId));
                            mMobileIconsViewModel.viewModelForSub(subId)
                        );
        }

        protected LinearLayout.LayoutParams onCreateLayoutParams() {
@@ -704,7 +705,7 @@ public interface StatusBarIconController {
        }

        protected DemoStatusIcons createDemoStatusIcons() {
            return new DemoStatusIcons((LinearLayout) mGroup, mIconSize);
            return new DemoStatusIcons((LinearLayout) mGroup, mMobileIconsViewModel, mIconSize);
        }
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -276,6 +276,11 @@ public class StatusBarIconControllerImpl implements Tunable,
        String slotName = mContext.getString(com.android.internal.R.string.status_bar_mobile);
        Slot mobileSlot = mStatusBarIconList.getSlot(slotName);

        // Because of the way we cache the icon holders, we need to remove everything any time
        // we get a new set of subscriptions. This might change in the future, but is required
        // to support demo mode for now
        removeAllIconsForSlot(slotName);

        Collections.reverse(subIds);

        for (Integer subId : subIds) {
+2 −3
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.telephony.TelephonyCallback.ServiceStateListener
import android.telephony.TelephonyCallback.SignalStrengthsListener
import android.telephony.TelephonyDisplayInfo
import android.telephony.TelephonyManager
import android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN
import com.android.systemui.statusbar.pipeline.mobile.data.model.DataConnectionState.Disconnected

/**
@@ -39,7 +38,7 @@ import com.android.systemui.statusbar.pipeline.mobile.data.model.DataConnectionS
 * any new field that needs to be tracked should be copied into this data class rather than
 * threading complex system objects through the pipeline.
 */
data class MobileSubscriptionModel(
data class MobileConnectionModel(
    /** From [ServiceStateListener.onServiceStateChanged] */
    val isEmergencyOnly: Boolean = false,

@@ -65,5 +64,5 @@ data class MobileSubscriptionModel(
     * [resolvedNetworkType] is the [TelephonyDisplayInfo.getOverrideNetworkType] if it exists or
     * [TelephonyDisplayInfo.getNetworkType]. This is used to look up the proper network type icon
     */
    val resolvedNetworkType: ResolvedNetworkType = DefaultNetworkType(NETWORK_TYPE_UNKNOWN),
    val resolvedNetworkType: ResolvedNetworkType = ResolvedNetworkType.UnknownNetworkType,
)
+16 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.pipeline.mobile.data.model

import android.telephony.Annotation.NetworkType
import android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN
import com.android.systemui.statusbar.pipeline.mobile.util.MobileMappingsProxy

/**
@@ -26,8 +27,20 @@ import com.android.systemui.statusbar.pipeline.mobile.util.MobileMappingsProxy
 */
sealed interface ResolvedNetworkType {
    @NetworkType val type: Int
    val lookupKey: String

    object UnknownNetworkType : ResolvedNetworkType {
        override val type: Int = NETWORK_TYPE_UNKNOWN
        override val lookupKey: String = "unknown"
    }

data class DefaultNetworkType(@NetworkType override val type: Int) : ResolvedNetworkType
    data class DefaultNetworkType(
        @NetworkType override val type: Int,
        override val lookupKey: String,
    ) : ResolvedNetworkType

data class OverrideNetworkType(@NetworkType override val type: Int) : ResolvedNetworkType
    data class OverrideNetworkType(
        @NetworkType override val type: Int,
        override val lookupKey: String,
    ) : ResolvedNetworkType
}
Loading