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

Commit 676e76e4 authored by Ying Xu's avatar Ying Xu Committed by Automerger Merge Worker
Browse files

Merge "Implement the CarrierConfig for call indicators" into sc-dev am: 11cbeca7

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

Change-Id: I495d120acc2b933c22d9e7fa4843360bbe5e6ea4
parents 57b77c44 11cbeca7
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
<!--
Copyright (C) 2021 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="16dp"
        android:height="16dp"
        android:viewportWidth="16.0"
        android:viewportHeight="16.0">
  <path/>
</vector>
+47 −0
Original line number Diff line number Diff line
<!--
Copyright (C) 2021 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24"
    android:tint="?android:attr/colorControlNormal"
    >

    <path
        android:fillColor="#FF000000"
        android:pathData="M18,2h-8L4,8v12c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V4C20,2.9,19.1,2,18,2z M18,4v16H6V8.83L10.83,4L18,4L18,4z" />
    <path
        android:fillColor="#FF000000"
        android:pathData="M 7 17 H 9 V 19 H 7 V 17 Z" />
    <path
        android:fillColor="#FF000000"
        android:pathData="M 15 17 H 17 V 19 H 15 V 17 Z" />
    <path
        android:fillColor="#FF000000"
        android:pathData="M 7 11 H 9 V 15 H 7 V 11 Z" />
    <path
        android:fillColor="#FF000000"
        android:pathData="M 11 15 H 13 V 19 H 11 V 15 Z" />
    <path
        android:fillColor="#FF000000"
        android:pathData="M 11 11 H 13 V 13 H 11 V 11 Z" />
    <path
        android:fillColor="#FF000000"
        android:pathData="M 15 11 H 17 V 15 H 15 V 11 Z" />
    <path
        android:pathData="M0,0h24v24H0V0z" />
</vector>
+50 −9
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NetworkController.MobileDataIndicators;
import com.android.systemui.util.CarrierConfigTracker;

import java.util.function.Consumer;

@@ -71,6 +72,7 @@ public class QSCarrierGroupController {
    private int[] mLastSignalLevel = new int[SIM_SLOTS];
    private String[] mLastSignalLevelDescription = new String[SIM_SLOTS];
    private final boolean mProviderModel;
    private final CarrierConfigTracker mCarrierConfigTracker;

    private final NetworkController.SignalCallback mSignalCallback =
            new NetworkController.SignalCallback() {
@@ -112,6 +114,10 @@ public class QSCarrierGroupController {
                        Log.e(TAG, "Invalid SIM slot index for subscription: " + subId);
                        return;
                    }

                    boolean displayCallStrengthIcon =
                            mCarrierConfigTracker.getCallStrengthConfig(subId);

                    if (statusIcon.icon == R.drawable.ic_qs_no_calling_sms) {
                        if (statusIcon.visible) {
                            mInfos[slotIndex] = new CellSignalState(true,
@@ -119,9 +125,14 @@ public class QSCarrierGroupController {
                        } else {
                            // Whenever the no Calling & SMS state is cleared, switched to the last
                            // known call strength icon.
                            if (displayCallStrengthIcon) {
                                mInfos[slotIndex] = new CellSignalState(
                                        true, mLastSignalLevel[slotIndex],
                                        mLastSignalLevelDescription[slotIndex], "", false);
                            } else {
                                mInfos[slotIndex] = new CellSignalState(
                                        true, R.drawable.ic_qs_sim_card, "", "", false);
                            }
                        }
                        mMainHandler.obtainMessage(H.MSG_UPDATE_STATE).sendToTarget();
                    } else {
@@ -131,8 +142,13 @@ public class QSCarrierGroupController {
                        // shown.
                        if (mInfos[slotIndex].mobileSignalIconId
                                != R.drawable.ic_qs_no_calling_sms) {
                            if (displayCallStrengthIcon) {
                                mInfos[slotIndex] = new CellSignalState(true, statusIcon.icon,
                                        statusIcon.contentDescription, "", false);
                            } else {
                                mInfos[slotIndex] = new CellSignalState(
                                        true, R.drawable.ic_qs_sim_card, "", "", false);
                            }
                            mMainHandler.obtainMessage(H.MSG_UPDATE_STATE).sendToTarget();
                        }
                    }
@@ -165,7 +181,8 @@ public class QSCarrierGroupController {
    private QSCarrierGroupController(QSCarrierGroup view, ActivityStarter activityStarter,
            @Background Handler bgHandler, @Main Looper mainLooper,
            NetworkController networkController,
            CarrierTextManager.Builder carrierTextManagerBuilder, Context context) {
            CarrierTextManager.Builder carrierTextManagerBuilder, Context context,
            CarrierConfigTracker carrierConfigTracker) {
        if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)) {
            mProviderModel = true;
        } else {
@@ -178,7 +195,7 @@ public class QSCarrierGroupController {
                .setShowAirplaneMode(false)
                .setShowMissingSim(false)
                .build();

        mCarrierConfigTracker = carrierConfigTracker;
        View.OnClickListener onClickListener = v -> {
            if (!v.isVisibleToUser()) {
                return;
@@ -228,6 +245,17 @@ public class QSCarrierGroupController {
        return SubscriptionManager.getSlotIndex(subscriptionId);
    }

    private boolean isSingleCarrier() {
        int carrierCount = 0;
        for (int i = 0; i < SIM_SLOTS; i++) {

            if (mInfos[i].visible) {
                carrierCount++;
            }
        }
        return carrierCount == 1;
    }

    public void setListening(boolean listening) {
        if (listening == mListening) {
            return;
@@ -257,6 +285,15 @@ public class QSCarrierGroupController {
            return;
        }

        if (isSingleCarrier()) {
            for (int i = 0; i < SIM_SLOTS; i++) {
                if (mInfos[i].visible
                        && mInfos[i].mobileSignalIconId == R.drawable.ic_qs_sim_card) {
                    mInfos[i] = new CellSignalState(true, R.drawable.ic_blank, "", "", false);
                }
            }
        }

        for (int i = 0; i < SIM_SLOTS; i++) {
            mCarrierGroups[i].updateState(mInfos[i]);
        }
@@ -363,17 +400,20 @@ public class QSCarrierGroupController {
        private final NetworkController mNetworkController;
        private final CarrierTextManager.Builder mCarrierTextControllerBuilder;
        private final Context mContext;
        private final CarrierConfigTracker mCarrierConfigTracker;

        @Inject
        public Builder(ActivityStarter activityStarter, @Background Handler handler,
                @Main Looper looper, NetworkController networkController,
                CarrierTextManager.Builder carrierTextControllerBuilder, Context context) {
                CarrierTextManager.Builder carrierTextControllerBuilder, Context context,
                CarrierConfigTracker carrierConfigTracker) {
            mActivityStarter = activityStarter;
            mHandler = handler;
            mLooper = looper;
            mNetworkController = networkController;
            mCarrierTextControllerBuilder = carrierTextControllerBuilder;
            mContext = context;
            mCarrierConfigTracker = carrierConfigTracker;
        }

        public Builder setQSCarrierGroup(QSCarrierGroup view) {
@@ -383,7 +423,8 @@ public class QSCarrierGroupController {

        public QSCarrierGroupController build() {
            return new QSCarrierGroupController(mView, mActivityStarter, mHandler, mLooper,
                    mNetworkController, mCarrierTextControllerBuilder, mContext);
                    mNetworkController, mCarrierTextControllerBuilder, mContext,
                    mCarrierConfigTracker);
        }
    }
}
+2 −4
Original line number Diff line number Diff line
@@ -393,7 +393,6 @@ public class StatusBar extends SystemUI implements DemoMode,

    private final Object mQueueLock = new Object();

    private final StatusBarIconController mIconController;
    private final PulseExpansionHandler mPulseExpansionHandler;
    private final NotificationWakeUpCoordinator mWakeUpCoordinator;
    private final KeyguardBypassController mKeyguardBypassController;
@@ -720,7 +719,7 @@ public class StatusBar extends SystemUI implements DemoMode,
            LightBarController lightBarController,
            AutoHideController autoHideController,
            KeyguardUpdateMonitor keyguardUpdateMonitor,
            StatusBarIconController statusBarIconController,
            StatusBarSignalPolicy signalPolicy,
            PulseExpansionHandler pulseExpansionHandler,
            NotificationWakeUpCoordinator notificationWakeUpCoordinator,
            KeyguardBypassController keyguardBypassController,
@@ -806,7 +805,7 @@ public class StatusBar extends SystemUI implements DemoMode,
        mLightBarController = lightBarController;
        mAutoHideController = autoHideController;
        mKeyguardUpdateMonitor = keyguardUpdateMonitor;
        mIconController = statusBarIconController;
        mSignalPolicy = signalPolicy;
        mPulseExpansionHandler = pulseExpansionHandler;
        mWakeUpCoordinator = notificationWakeUpCoordinator;
        mKeyguardBypassController = keyguardBypassController;
@@ -1015,7 +1014,6 @@ public class StatusBar extends SystemUI implements DemoMode,

        // Lastly, call to the icon policy to install/update all the icons.
        mIconPolicy.init();
        mSignalPolicy = new StatusBarSignalPolicy(mContext, mIconController);

        mKeyguardStateController.addCallback(this);
        startKeyguard();
+16 −3
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.util.Log;
import com.android.settingslib.mobile.TelephonyIcons;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NetworkController.IconState;
import com.android.systemui.statusbar.policy.NetworkController.MobileDataIndicators;
@@ -33,12 +34,16 @@ import com.android.systemui.statusbar.policy.NetworkControllerImpl;
import com.android.systemui.statusbar.policy.SecurityController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;
import com.android.systemui.util.CarrierConfigTracker;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import javax.inject.Inject;

/** Controls the signal policies for icons shown in the StatusBar. **/
@SysUISingleton
public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallback,
        SecurityController.SecurityControllerCallback, Tunable {
    private static final String TAG = "StatusBarSignalPolicy";
@@ -57,6 +62,7 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
    private final NetworkController mNetworkController;
    private final SecurityController mSecurityController;
    private final Handler mHandler = Handler.getMain();
    private final CarrierConfigTracker mCarrierConfigTracker;

    private boolean mHideAirplane;
    private boolean mHideMobile;
@@ -75,7 +81,9 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
            new ArrayList<CallIndicatorIconState>();
    private WifiIconState mWifiIconState = new WifiIconState();

    public StatusBarSignalPolicy(Context context, StatusBarIconController iconController) {
    @Inject
    public StatusBarSignalPolicy(Context context, StatusBarIconController iconController,
            CarrierConfigTracker carrierConfigTracker) {
        mContext = context;

        mSlotAirplane = mContext.getString(com.android.internal.R.string.status_bar_airplane);
@@ -95,6 +103,7 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
        Dependency.get(TunerService.class).addTunable(this, StatusBarIconController.ICON_HIDE_LIST);
        mNetworkController.addCallback(this);
        mSecurityController.addCallback(this);
        mCarrierConfigTracker = carrierConfigTracker;
    }

    public void destroy() {
@@ -215,8 +224,12 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
            state.callStrengthResId = statusIcon.icon;
            state.callStrengthDescription = statusIcon.contentDescription;
        }
        if (mCarrierConfigTracker.getCallStrengthConfig(subId)) {
            mIconController.setCallStrengthIcons(mSlotCallStrength,
                    CallIndicatorIconState.copyStates(mCallIndicatorStates));
        } else {
            mIconController.removeIcon(mSlotCallStrength, subId);
        }
        mIconController.setNoCallingIcons(mSlotNoCalling,
                CallIndicatorIconState.copyStates(mCallIndicatorStates));
    }
Loading