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

Commit cac31846 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Iaf91e560,Ib40dcf0a into udc-qpr-dev

* changes:
  [2/2] Migrating ShadeCarrierGroup mobile icons to modern status bar data pipeline
  [1/2] Update new status bar data pipeline to support names for multiple sims
parents 183c5b02 062fbc45
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2023, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<com.android.systemui.statusbar.pipeline.mobile.ui.view.ModernShadeCarrierGroupMobileView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/carrier_combo"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:gravity="center_vertical"
    android:orientation="horizontal" >

    <com.android.systemui.util.AutoMarqueeTextView
        android:id="@+id/mobile_carrier_text"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginEnd="@dimen/qs_carrier_margin_width"
        android:visibility="gone"
        android:textDirection="locale"
        android:marqueeRepeatLimit="marquee_forever"
        android:singleLine="true"
        android:maxEms="7"/>

    <include layout="@layout/status_bar_mobile_signal_group_new" />

</com.android.systemui.statusbar.pipeline.mobile.ui.view.ModernShadeCarrierGroupMobileView>
+4 −0
Original line number Diff line number Diff line
@@ -398,6 +398,10 @@ object Flags {
    // TODO(b/294588085): Tracking Bug
    val WIFI_SECONDARY_NETWORKS = releasedFlag("wifi_secondary_networks")

    // TODO(b/290676905): Tracking Bug
    val NEW_SHADE_CARRIER_GROUP_MOBILE_ICONS =
        unreleasedFlag("new_shade_carrier_group_mobile_icons")

    // 700 - dialer/calls
    // TODO(b/254512734): Tracking Bug
    val ONGOING_CALL_STATUS_BAR_CHIP = releasedFlag("ongoing_call_status_bar_chip")
+19 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.settingslib.Utils;
import com.android.settingslib.graph.SignalDrawable;
import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
import com.android.systemui.statusbar.pipeline.mobile.ui.view.ModernShadeCarrierGroupMobileView;
import com.android.systemui.util.LargeScreenUtils;

import java.util.Objects;
@@ -44,6 +45,7 @@ public class ShadeCarrier extends LinearLayout {
    private TextView mCarrierText;
    private ImageView mMobileSignal;
    private ImageView mMobileRoaming;
    private ModernShadeCarrierGroupMobileView mModernMobileView;
    private View mSpacer;
    @Nullable
    private CellSignalState mLastSignalState;
@@ -77,6 +79,23 @@ public class ShadeCarrier extends LinearLayout {
        updateResources();
    }

    /** Removes a ModernStatusBarMobileView from the ViewGroup. */
    public void removeModernMobileView() {
        if (mModernMobileView != null) {
            removeView(mModernMobileView);
            mModernMobileView = null;
        }
    }

    /** Adds a ModernStatusBarMobileView to the ViewGroup. */
    public void addModernMobileView(ModernShadeCarrierGroupMobileView mobileView) {
        mModernMobileView = mobileView;
        mMobileGroup.setVisibility(View.GONE);
        mSpacer.setVisibility(View.GONE);
        mCarrierText.setVisibility(View.GONE);
        addView(mobileView);
    }

    /**
     * Update the state of this view
     * @param state the current state of the signal for this view
+133 −16
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.shade.carrier;

import static android.telephony.SubscriptionManager.INVALID_SIM_SLOT_INDEX;
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_YES;

import android.annotation.MainThread;
@@ -46,8 +47,17 @@ import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.statusbar.connectivity.MobileDataIndicators;
import com.android.systemui.statusbar.connectivity.NetworkController;
import com.android.systemui.statusbar.connectivity.SignalCallback;
import com.android.systemui.statusbar.connectivity.ui.MobileContextProvider;
import com.android.systemui.statusbar.phone.StatusBarLocation;
import com.android.systemui.statusbar.pipeline.StatusBarPipelineFlags;
import com.android.systemui.statusbar.pipeline.mobile.ui.MobileUiAdapter;
import com.android.systemui.statusbar.pipeline.mobile.ui.binder.MobileIconsBinder;
import com.android.systemui.statusbar.pipeline.mobile.ui.view.ModernShadeCarrierGroupMobileView;
import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.MobileIconsViewModel;
import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.ShadeCarrierGroupMobileIconViewModel;
import com.android.systemui.util.CarrierConfigTracker;

import java.util.List;
import java.util.function.Consumer;

import javax.inject.Inject;
@@ -62,12 +72,16 @@ public class ShadeCarrierGroupController {

    private final ActivityStarter mActivityStarter;
    private final Handler mBgHandler;
    private final Context mContext;
    private final NetworkController mNetworkController;
    private final CarrierTextManager mCarrierTextManager;
    private final TextView mNoSimTextView;
    // Non final for testing
    private H mMainHandler;
    private final Callback mCallback;
    private final MobileIconsViewModel mMobileIconsViewModel;
    private final MobileContextProvider mMobileContextProvider;
    private final StatusBarPipelineFlags mStatusBarPipelineFlags;
    private boolean mListening;
    private final CellSignalState[] mInfos =
            new CellSignalState[SIM_SLOTS];
@@ -91,7 +105,7 @@ public class ShadeCarrierGroupController {
                        Log.w(TAG, "setMobileDataIndicators - slot: " + slotIndex);
                        return;
                    }
                    if (slotIndex == SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
                    if (slotIndex == INVALID_SIM_SLOT_INDEX) {
                        Log.e(TAG, "Invalid SIM slot index for subscription: " + indicators.subId);
                        return;
                    }
@@ -129,15 +143,25 @@ public class ShadeCarrierGroupController {
        }
    }

    private ShadeCarrierGroupController(ShadeCarrierGroup view, ActivityStarter activityStarter,
            @Background Handler bgHandler, @Main Looper mainLooper,
    private ShadeCarrierGroupController(
            ShadeCarrierGroup view,
            ActivityStarter activityStarter,
            @Background Handler bgHandler,
            @Main Looper mainLooper,
            NetworkController networkController,
            CarrierTextManager.Builder carrierTextManagerBuilder, Context context,
            CarrierConfigTracker carrierConfigTracker, SlotIndexResolver slotIndexResolver) {

            CarrierTextManager.Builder carrierTextManagerBuilder,
            Context context,
            CarrierConfigTracker carrierConfigTracker,
            SlotIndexResolver slotIndexResolver,
            MobileUiAdapter mobileUiAdapter,
            MobileContextProvider mobileContextProvider,
            StatusBarPipelineFlags statusBarPipelineFlags
    ) {
        mContext = context;
        mActivityStarter = activityStarter;
        mBgHandler = bgHandler;
        mNetworkController = networkController;
        mStatusBarPipelineFlags = statusBarPipelineFlags;
        mCarrierTextManager = carrierTextManagerBuilder
                .setShowAirplaneMode(false)
                .setShowMissingSim(false)
@@ -162,6 +186,14 @@ public class ShadeCarrierGroupController {
        mCarrierGroups[1] = view.getCarrier2View();
        mCarrierGroups[2] = view.getCarrier3View();

        mMobileContextProvider = mobileContextProvider;
        mMobileIconsViewModel = mobileUiAdapter.getMobileIconsViewModel();

        if (mStatusBarPipelineFlags.useNewShadeCarrierGroupMobileIcons()) {
            mobileUiAdapter.setShadeCarrierGroupController(this);
            MobileIconsBinder.bind(view, mMobileIconsViewModel);
        }

        mCarrierDividers[0] = view.getCarrierDivider1();
        mCarrierDividers[1] = view.getCarrierDivider2();

@@ -193,6 +225,50 @@ public class ShadeCarrierGroupController {
        });
    }

    /** Updates the number of visible mobile icons using the new pipeline. */
    public void updateModernMobileIcons(List<Integer> subIds) {
        if (!mStatusBarPipelineFlags.useNewShadeCarrierGroupMobileIcons()) {
            Log.d(TAG, "ignoring new pipeline callback because new mobile icon is disabled");
            return;
        }

        for (ShadeCarrier carrier : mCarrierGroups) {
            carrier.removeModernMobileView();
        }

        List<IconData> iconDataList = processSubIdList(subIds);

        for (IconData iconData : iconDataList) {
            ShadeCarrier carrier = mCarrierGroups[iconData.slotIndex];

            Context mobileContext =
                    mMobileContextProvider.getMobileContextForSub(iconData.subId, mContext);
            ModernShadeCarrierGroupMobileView modernMobileView = ModernShadeCarrierGroupMobileView
                    .constructAndBind(
                        mobileContext,
                        mMobileIconsViewModel.getLogger(),
                        "mobile_carrier_shade_group",
                        (ShadeCarrierGroupMobileIconViewModel) mMobileIconsViewModel
                                .viewModelForSub(iconData.subId,
                                    StatusBarLocation.SHADE_CARRIER_GROUP)
                    );
            carrier.addModernMobileView(modernMobileView);
        }
    }

    @VisibleForTesting
    List<IconData> processSubIdList(List<Integer> subIds) {
        return subIds
                .stream()
                .limit(SIM_SLOTS)
                .map(subId -> new IconData(subId, getSlotIndex(subId)))
                .filter(iconData ->
                        iconData.slotIndex < SIM_SLOTS
                                && iconData.slotIndex != INVALID_SIM_SLOT_INDEX
                )
                .toList();
    }

    @VisibleForTesting
    protected int getSlotIndex(int subscriptionId) {
        return mSlotIndexResolver.getSlotIndex(subscriptionId);
@@ -269,9 +345,13 @@ public class ShadeCarrierGroupController {
            }
        }

        if (mStatusBarPipelineFlags.useNewShadeCarrierGroupMobileIcons()) {
            Log.d(TAG, "ignoring old pipeline callback because new mobile icon is enabled");
        } else {
            for (int i = 0; i < SIM_SLOTS; i++) {
                mCarrierGroups[i].updateState(mInfos[i], singleCarrier);
            }
        }

        mCarrierDividers[0].setVisibility(
                mInfos[0].visible && mInfos[1].visible ? View.VISIBLE : View.GONE);
@@ -306,7 +386,7 @@ public class ShadeCarrierGroupController {
                        Log.w(TAG, "updateInfoCarrier - slot: " + slot);
                        continue;
                    }
                    if (slot == SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
                    if (slot == INVALID_SIM_SLOT_INDEX) {
                        Log.e(TAG,
                                "Invalid SIM slot index for subscription: "
                                        + info.subscriptionIds[i]);
@@ -385,12 +465,24 @@ public class ShadeCarrierGroupController {
        private final Context mContext;
        private final CarrierConfigTracker mCarrierConfigTracker;
        private final SlotIndexResolver mSlotIndexResolver;
        private final MobileUiAdapter mMobileUiAdapter;
        private final MobileContextProvider mMobileContextProvider;
        private final StatusBarPipelineFlags mStatusBarPipelineFlags;

        @Inject
        public Builder(ActivityStarter activityStarter, @Background Handler handler,
                @Main Looper looper, NetworkController networkController,
                CarrierTextManager.Builder carrierTextControllerBuilder, Context context,
                CarrierConfigTracker carrierConfigTracker, SlotIndexResolver slotIndexResolver) {
        public Builder(
                ActivityStarter activityStarter,
                @Background Handler handler,
                @Main Looper looper,
                NetworkController networkController,
                CarrierTextManager.Builder carrierTextControllerBuilder,
                Context context,
                CarrierConfigTracker carrierConfigTracker,
                SlotIndexResolver slotIndexResolver,
                MobileUiAdapter mobileUiAdapter,
                MobileContextProvider mobileContextProvider,
                StatusBarPipelineFlags statusBarPipelineFlags
        ) {
            mActivityStarter = activityStarter;
            mHandler = handler;
            mLooper = looper;
@@ -399,6 +491,9 @@ public class ShadeCarrierGroupController {
            mContext = context;
            mCarrierConfigTracker = carrierConfigTracker;
            mSlotIndexResolver = slotIndexResolver;
            mMobileUiAdapter = mobileUiAdapter;
            mMobileContextProvider = mobileContextProvider;
            mStatusBarPipelineFlags = statusBarPipelineFlags;
        }

        public Builder setShadeCarrierGroup(ShadeCarrierGroup view) {
@@ -407,9 +502,20 @@ public class ShadeCarrierGroupController {
        }

        public ShadeCarrierGroupController build() {
            return new ShadeCarrierGroupController(mView, mActivityStarter, mHandler, mLooper,
                    mNetworkController, mCarrierTextControllerBuilder, mContext,
                    mCarrierConfigTracker, mSlotIndexResolver);
            return new ShadeCarrierGroupController(
                    mView,
                    mActivityStarter,
                    mHandler,
                    mLooper,
                    mNetworkController,
                    mCarrierTextControllerBuilder,
                    mContext,
                    mCarrierConfigTracker,
                    mSlotIndexResolver,
                    mMobileUiAdapter,
                    mMobileContextProvider,
                    mStatusBarPipelineFlags
            );
        }
    }

@@ -448,4 +554,15 @@ public class ShadeCarrierGroupController {
            return SubscriptionManager.getSlotIndex(subscriptionId);
        }
    }

    @VisibleForTesting
    static class IconData {
        public final int subId;
        public final int slotIndex;

        IconData(int subId, int slotIndex) {
            this.subId = subId;
            this.slotIndex = slotIndex;
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -24,4 +24,6 @@ enum class StatusBarLocation {
    KEYGUARD,
    /** Quick settings (inside the shade). */
    QS,
    /** ShadeCarrierGroup (above QS status bar in expanded mode). */
    SHADE_CARRIER_GROUP,
}
Loading