Merge "Add the Call Strength for SysUI" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
342dfd44d7
@@ -0,0 +1,35 @@
|
||||
<!--
|
||||
Copyright (C) 2020 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.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M20.17,14.84l-3.26,-0.65c-0.33,-0.07 -0.67,0.04 -0.9,0.27l-2.62,2.62c-2.75,-1.49 -5.01,-3.75 -6.5,-6.5l2.62,-2.62c0.24,-0.24 0.34,-0.58 0.27,-0.9L9.13,3.8C9.04,3.34 8.63,3 8.15,3H4C3.44,3 2.97,3.47 3,4.03c0.17,2.91 1.04,5.63 2.43,8.01c1.57,2.69 3.81,4.93 6.5,6.5c2.38,1.39 5.1,2.26 8.01,2.43c0.56,0.03 1.03,-0.44 1.03,-1v-4.15C20.97,15.34 20.64,14.93 20.17,14.84z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M13,8h2v3h-2z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M16.5,5h2v6h-2z"
|
||||
android:fillAlpha="0.3"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M20,3h2v8h-2z"
|
||||
android:fillAlpha="0.3"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,34 @@
|
||||
<!--
|
||||
Copyright (C) 2020 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.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M20.17,14.84l-3.26,-0.65c-0.33,-0.07 -0.67,0.04 -0.9,0.27l-2.62,2.62c-2.75,-1.49 -5.01,-3.75 -6.5,-6.5l2.62,-2.62c0.24,-0.24 0.34,-0.58 0.27,-0.9L9.13,3.8C9.04,3.34 8.63,3 8.15,3H4C3.44,3 2.97,3.47 3,4.03c0.17,2.91 1.04,5.63 2.43,8.01c1.57,2.69 3.81,4.93 6.5,6.5c2.38,1.39 5.1,2.26 8.01,2.43c0.56,0.03 1.03,-0.44 1.03,-1v-4.15C20.97,15.34 20.64,14.93 20.17,14.84z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M13,8h2v3h-2z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M16.5,5h2v6h-2z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M20,3h2v8h-2z"
|
||||
android:fillAlpha="0.3"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,33 @@
|
||||
<!--
|
||||
Copyright (C) 2020 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.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M20.17,14.84l-3.26,-0.65c-0.33,-0.07 -0.67,0.04 -0.9,0.27l-2.62,2.62c-2.75,-1.49 -5.01,-3.75 -6.5,-6.5l2.62,-2.62c0.24,-0.24 0.34,-0.58 0.27,-0.9L9.13,3.8C9.04,3.34 8.63,3 8.15,3H4C3.44,3 2.97,3.47 3,4.03c0.17,2.91 1.04,5.63 2.43,8.01c1.57,2.69 3.81,4.93 6.5,6.5c2.38,1.39 5.1,2.26 8.01,2.43c0.56,0.03 1.03,-0.44 1.03,-1v-4.15C20.97,15.34 20.64,14.93 20.17,14.84z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M13,8h2v3h-2z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M16.5,5h2v6h-2z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M20,3h2v8h-2z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,35 @@
|
||||
<!--
|
||||
Copyright (C) 2020 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.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M20.17,14.84l-3.26,-0.65c-0.33,-0.07 -0.67,0.04 -0.9,0.27l-2.62,2.62c-2.75,-1.49 -5.01,-3.75 -6.5,-6.5l2.62,-2.62c0.24,-0.24 0.34,-0.58 0.27,-0.9L9.13,3.8C9.04,3.34 8.63,3 8.15,3H4C3.44,3 2.97,3.47 3,4.03c0.17,2.91 1.04,5.63 2.43,8.01c1.57,2.69 3.81,4.93 6.5,6.5c2.38,1.39 5.1,2.26 8.01,2.43c0.56,0.03 1.03,-0.44 1.03,-1v-4.15C20.97,15.34 20.64,14.93 20.17,14.84z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M18.05,9.59C17.69,9.22 17.19,9 16.64,9c-0.55,0 -1.05,0.22 -1.41,0.59L16.64,11L18.05,9.59z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M16.64,7.5c0.96,0 1.84,0.39 2.47,1.03l1.42,-1.42c-1,-1 -2.37,-1.61 -3.89,-1.61c-1.52,0 -2.89,0.62 -3.89,1.61l1.42,1.42C14.8,7.89 15.67,7.5 16.64,7.5z"
|
||||
android:fillAlpha="0.3"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M16.64,4c1.93,0 3.68,0.79 4.95,2.05L23,4.64C21.37,3.01 19.12,2 16.64,2c-2.49,0 -4.74,1.01 -6.36,2.64l1.42,1.42C12.96,4.79 14.71,4 16.64,4z"
|
||||
android:fillAlpha="0.3"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,34 @@
|
||||
<!--
|
||||
Copyright (C) 2020 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.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M20.17,14.84l-3.26,-0.65c-0.33,-0.07 -0.67,0.04 -0.9,0.27l-2.62,2.62c-2.75,-1.49 -5.01,-3.75 -6.5,-6.5l2.62,-2.62c0.24,-0.24 0.34,-0.58 0.27,-0.9L9.13,3.8C9.04,3.34 8.63,3 8.15,3H4C3.44,3 2.97,3.47 3,4.03c0.17,2.91 1.04,5.63 2.43,8.01c1.57,2.69 3.81,4.93 6.5,6.5c2.38,1.39 5.1,2.26 8.01,2.43c0.56,0.03 1.03,-0.44 1.03,-1v-4.15C20.97,15.34 20.64,14.93 20.17,14.84z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M18.05,9.59C17.69,9.22 17.19,9 16.64,9c-0.55,0 -1.05,0.22 -1.41,0.59L16.64,11L18.05,9.59z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M16.64,7.5c0.96,0 1.84,0.39 2.47,1.03l1.42,-1.42c-1,-1 -2.37,-1.61 -3.89,-1.61c-1.52,0 -2.89,0.62 -3.89,1.61l1.42,1.42C14.8,7.89 15.67,7.5 16.64,7.5z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M16.64,4c1.93,0 3.68,0.79 4.95,2.05L23,4.64C21.37,3.01 19.12,2 16.64,2c-2.49,0 -4.74,1.01 -6.36,2.64l1.42,1.42C12.96,4.79 14.71,4 16.64,4z"
|
||||
android:fillAlpha="0.3"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,33 @@
|
||||
<!--
|
||||
Copyright (C) 2020 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.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M20.17,14.84l-3.26,-0.65c-0.33,-0.07 -0.67,0.04 -0.9,0.27l-2.62,2.62c-2.75,-1.49 -5.01,-3.75 -6.5,-6.5l2.62,-2.62c0.24,-0.24 0.34,-0.58 0.27,-0.9L9.13,3.8C9.04,3.34 8.63,3 8.15,3H4C3.44,3 2.97,3.47 3,4.03c0.17,2.91 1.04,5.63 2.43,8.01c1.57,2.69 3.81,4.93 6.5,6.5c2.38,1.39 5.1,2.26 8.01,2.43c0.56,0.03 1.03,-0.44 1.03,-1v-4.15C20.97,15.34 20.64,14.93 20.17,14.84z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M18.05,9.59C17.69,9.22 17.19,9 16.64,9c-0.55,0 -1.05,0.22 -1.41,0.59L16.64,11L18.05,9.59z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M16.64,7.5c0.96,0 1.84,0.39 2.47,1.03l1.42,-1.42c-1,-1 -2.37,-1.61 -3.89,-1.61c-1.52,0 -2.89,0.62 -3.89,1.61l1.42,1.42C14.8,7.89 15.67,7.5 16.64,7.5z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M16.64,4c1.93,0 3.68,0.79 4.95,2.05L23,4.64C21.37,3.01 19.12,2 16.64,2c-2.49,0 -4.74,1.01 -6.36,2.64l1.42,1.42C12.96,4.79 14.71,4 16.64,4z"/>
|
||||
</vector>
|
||||
@@ -1485,4 +1485,7 @@
|
||||
<string name="accessibility_ethernet_disconnected">Ethernet disconnected.</string>
|
||||
<!-- Content description of the Ethernet connection when connected for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_ethernet_connected">Ethernet.</string>
|
||||
|
||||
<!-- Content description of the no calling for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_no_calling">No calling.</string>
|
||||
</resources>
|
||||
|
||||
@@ -48,6 +48,8 @@ public class AccessibilityContentDescriptions {
|
||||
|
||||
public static final int WIFI_NO_CONNECTION = R.string.accessibility_no_wifi;
|
||||
|
||||
public static final int NO_CALLING = R.string.accessibility_no_calling;
|
||||
|
||||
public static final int[] ETHERNET_CONNECTION_VALUES = {
|
||||
R.string.accessibility_ethernet_disconnected,
|
||||
R.string.accessibility_ethernet_connected,
|
||||
|
||||
@@ -266,7 +266,7 @@ public class MobileStatusTracker {
|
||||
serviceState.getDataRegState()) + ")")
|
||||
.append(',')
|
||||
.append("signalStrength=").append(signalStrength == null ? ""
|
||||
: signalStrength.toString()).append(',')
|
||||
: signalStrength.getLevel()).append(',')
|
||||
.append("telephonyDisplayInfo=").append(telephonyDisplayInfo == null ? ""
|
||||
: telephonyDisplayInfo.toString()).append(']').toString();
|
||||
}
|
||||
|
||||
@@ -317,5 +317,21 @@ public class TelephonyIcons {
|
||||
ICON_NAME_TO_ICON.put("datadisable", DATA_DISABLED);
|
||||
ICON_NAME_TO_ICON.put("notdefaultdata", NOT_DEFAULT_DATA);
|
||||
}
|
||||
|
||||
public static final int[] WIFI_CALL_STRENGTH_ICONS = {
|
||||
R.drawable.ic_wifi_call_strength_1,
|
||||
R.drawable.ic_wifi_call_strength_1,
|
||||
R.drawable.ic_wifi_call_strength_2,
|
||||
R.drawable.ic_wifi_call_strength_3,
|
||||
R.drawable.ic_wifi_call_strength_3
|
||||
};
|
||||
|
||||
public static final int[] MOBILE_CALL_STRENGTH_ICONS = {
|
||||
R.drawable.ic_mobile_call_strength_1,
|
||||
R.drawable.ic_mobile_call_strength_1,
|
||||
R.drawable.ic_mobile_call_strength_2,
|
||||
R.drawable.ic_mobile_call_strength_3,
|
||||
R.drawable.ic_mobile_call_strength_3
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ public class QSCarrier extends LinearLayout {
|
||||
private ImageView mMobileSignal;
|
||||
private ImageView mMobileRoaming;
|
||||
private CellSignalState mLastSignalState;
|
||||
private boolean mProviderModel;
|
||||
|
||||
public QSCarrier(Context context) {
|
||||
super(context);
|
||||
@@ -59,15 +60,20 @@ public class QSCarrier extends LinearLayout {
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mMobileGroup = findViewById(R.id.mobile_combo);
|
||||
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)) {
|
||||
mMobileRoaming = findViewById(R.id.mobile_roaming_large);
|
||||
mProviderModel = true;
|
||||
} else {
|
||||
mMobileRoaming = findViewById(R.id.mobile_roaming);
|
||||
mProviderModel = false;
|
||||
}
|
||||
mMobileGroup = findViewById(R.id.mobile_combo);
|
||||
mMobileRoaming = findViewById(R.id.mobile_roaming);
|
||||
mMobileSignal = findViewById(R.id.mobile_signal);
|
||||
mCarrierText = findViewById(R.id.qs_carrier_text);
|
||||
mMobileSignal.setImageDrawable(new SignalDrawable(mContext));
|
||||
if (mProviderModel) {
|
||||
mMobileSignal.setImageDrawable(mContext.getDrawable(R.drawable.ic_qs_no_calling_sms));
|
||||
} else {
|
||||
mMobileSignal.setImageDrawable(new SignalDrawable(mContext));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,22 +91,27 @@ public class QSCarrier extends LinearLayout {
|
||||
android.R.attr.textColorPrimary);
|
||||
mMobileRoaming.setImageTintList(colorStateList);
|
||||
mMobileSignal.setImageTintList(colorStateList);
|
||||
mMobileSignal.setImageLevel(state.mobileSignalIconId);
|
||||
|
||||
StringBuilder contentDescription = new StringBuilder();
|
||||
if (state.contentDescription != null) {
|
||||
contentDescription.append(state.contentDescription).append(", ");
|
||||
if (mProviderModel) {
|
||||
mMobileSignal.setImageDrawable(mContext.getDrawable(state.mobileSignalIconId));
|
||||
mMobileSignal.setContentDescription(state.contentDescription);
|
||||
} else {
|
||||
mMobileSignal.setImageLevel(state.mobileSignalIconId);
|
||||
StringBuilder contentDescription = new StringBuilder();
|
||||
if (state.contentDescription != null) {
|
||||
contentDescription.append(state.contentDescription).append(", ");
|
||||
}
|
||||
if (state.roaming) {
|
||||
contentDescription
|
||||
.append(mContext.getString(R.string.data_connection_roaming))
|
||||
.append(", ");
|
||||
}
|
||||
// TODO: show mobile data off/no internet text for 5 seconds before carrier text
|
||||
if (hasValidTypeContentDescription(state.typeContentDescription)) {
|
||||
contentDescription.append(state.typeContentDescription);
|
||||
}
|
||||
mMobileSignal.setContentDescription(contentDescription);
|
||||
}
|
||||
if (state.roaming) {
|
||||
contentDescription
|
||||
.append(mContext.getString(R.string.data_connection_roaming))
|
||||
.append(", ");
|
||||
}
|
||||
// TODO: show mobile data off/no internet text for 5 seconds before carrier text
|
||||
if (hasValidTypeContentDescription(state.typeContentDescription)) {
|
||||
contentDescription.append(state.typeContentDescription);
|
||||
}
|
||||
mMobileSignal.setContentDescription(contentDescription);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.systemui.qs.carrier;
|
||||
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_YES;
|
||||
|
||||
import android.annotation.MainThread;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@@ -26,6 +27,7 @@ import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
@@ -33,6 +35,9 @@ import android.widget.TextView;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.keyguard.CarrierTextController;
|
||||
import com.android.settingslib.AccessibilityContentDescriptions;
|
||||
import com.android.settingslib.mobile.TelephonyIcons;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.dagger.qualifiers.Background;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.plugins.ActivityStarter;
|
||||
@@ -62,6 +67,9 @@ public class QSCarrierGroupController {
|
||||
new CellSignalState[SIM_SLOTS];
|
||||
private View[] mCarrierDividers = new View[SIM_SLOTS - 1];
|
||||
private QSCarrier[] mCarrierGroups = new QSCarrier[SIM_SLOTS];
|
||||
private int[] mLastSignalLevel = new int[SIM_SLOTS];
|
||||
private String[] mLastSignalLevelDescription = new String[SIM_SLOTS];
|
||||
private final boolean mProviderModel;
|
||||
|
||||
private final NetworkController.SignalCallback mSignalCallback =
|
||||
new NetworkController.SignalCallback() {
|
||||
@@ -72,6 +80,9 @@ public class QSCarrierGroupController {
|
||||
CharSequence typeContentDescription,
|
||||
CharSequence typeContentDescriptionHtml, CharSequence description,
|
||||
boolean isWide, int subId, boolean roaming, boolean showTriangle) {
|
||||
if (mProviderModel) {
|
||||
return;
|
||||
}
|
||||
int slotIndex = getSlotIndex(subId);
|
||||
if (slotIndex >= SIM_SLOTS) {
|
||||
Log.w(TAG, "setMobileDataIndicators - slot: " + slotIndex);
|
||||
@@ -91,6 +102,46 @@ public class QSCarrierGroupController {
|
||||
mMainHandler.obtainMessage(H.MSG_UPDATE_STATE).sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCallIndicator(NetworkController.IconState statusIcon, int subId) {
|
||||
if (!mProviderModel) {
|
||||
return;
|
||||
}
|
||||
int slotIndex = getSlotIndex(subId);
|
||||
if (slotIndex >= SIM_SLOTS) {
|
||||
Log.w(TAG, "setMobileDataIndicators - slot: " + slotIndex);
|
||||
return;
|
||||
}
|
||||
if (slotIndex == SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
|
||||
Log.e(TAG, "Invalid SIM slot index for subscription: " + subId);
|
||||
return;
|
||||
}
|
||||
if (statusIcon.icon == R.drawable.ic_qs_no_calling_sms) {
|
||||
if (statusIcon.visible) {
|
||||
mInfos[slotIndex] = new CellSignalState(true,
|
||||
statusIcon.icon, statusIcon.contentDescription, "", false);
|
||||
} else {
|
||||
// Whenever the no Calling & SMS state is cleared, switched to the last
|
||||
// known call strength icon.
|
||||
mInfos[slotIndex] = new CellSignalState(
|
||||
true, mLastSignalLevel[slotIndex],
|
||||
mLastSignalLevelDescription[slotIndex], "", false);
|
||||
}
|
||||
mMainHandler.obtainMessage(H.MSG_UPDATE_STATE).sendToTarget();
|
||||
} else {
|
||||
mLastSignalLevel[slotIndex] = statusIcon.icon;
|
||||
mLastSignalLevelDescription[slotIndex] = statusIcon.contentDescription;
|
||||
// Only Shows the call strength icon when the no Calling & SMS icon is not
|
||||
// shown.
|
||||
if (mInfos[slotIndex].mobileSignalIconId
|
||||
!= R.drawable.ic_qs_no_calling_sms) {
|
||||
mInfos[slotIndex] = new CellSignalState(true, statusIcon.icon,
|
||||
statusIcon.contentDescription, "", false);
|
||||
mMainHandler.obtainMessage(H.MSG_UPDATE_STATE).sendToTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoSims(boolean hasNoSims, boolean simDetected) {
|
||||
if (hasNoSims) {
|
||||
@@ -118,7 +169,12 @@ public class QSCarrierGroupController {
|
||||
private QSCarrierGroupController(QSCarrierGroup view, ActivityStarter activityStarter,
|
||||
@Background Handler bgHandler, @Main Looper mainLooper,
|
||||
NetworkController networkController,
|
||||
CarrierTextController.Builder carrierTextControllerBuilder) {
|
||||
CarrierTextController.Builder carrierTextControllerBuilder, Context context) {
|
||||
if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)) {
|
||||
mProviderModel = true;
|
||||
} else {
|
||||
mProviderModel = false;
|
||||
}
|
||||
mActivityStarter = activityStarter;
|
||||
mBgHandler = bgHandler;
|
||||
mNetworkController = networkController;
|
||||
@@ -149,7 +205,13 @@ public class QSCarrierGroupController {
|
||||
mCarrierDividers[1] = view.getCarrierDivider2();
|
||||
|
||||
for (int i = 0; i < SIM_SLOTS; i++) {
|
||||
mInfos[i] = new CellSignalState();
|
||||
mInfos[i] = new CellSignalState(true, R.drawable.ic_qs_no_calling_sms,
|
||||
context.getText(AccessibilityContentDescriptions.NO_CALLING).toString(),
|
||||
"", false);
|
||||
mLastSignalLevel[i] = TelephonyIcons.MOBILE_CALL_STRENGTH_ICONS[0];
|
||||
mLastSignalLevelDescription[i] =
|
||||
context.getText(AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0])
|
||||
.toString();
|
||||
mCarrierGroups[i].setOnClickListener(onClickListener);
|
||||
}
|
||||
view.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
|
||||
@@ -305,16 +367,18 @@ public class QSCarrierGroupController {
|
||||
private final Looper mLooper;
|
||||
private final NetworkController mNetworkController;
|
||||
private final CarrierTextController.Builder mCarrierTextControllerBuilder;
|
||||
private final Context mContext;
|
||||
|
||||
@Inject
|
||||
public Builder(ActivityStarter activityStarter, @Background Handler handler,
|
||||
@Main Looper looper, NetworkController networkController,
|
||||
CarrierTextController.Builder carrierTextControllerBuilder) {
|
||||
CarrierTextController.Builder carrierTextControllerBuilder, Context context) {
|
||||
mActivityStarter = activityStarter;
|
||||
mHandler = handler;
|
||||
mLooper = looper;
|
||||
mNetworkController = networkController;
|
||||
mCarrierTextControllerBuilder = carrierTextControllerBuilder;
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public Builder setQSCarrierGroup(QSCarrierGroup view) {
|
||||
@@ -324,7 +388,7 @@ public class QSCarrierGroupController {
|
||||
|
||||
public QSCarrierGroupController build() {
|
||||
return new QSCarrierGroupController(mView, mActivityStarter, mHandler, mLooper,
|
||||
mNetworkController, mCarrierTextControllerBuilder);
|
||||
mNetworkController, mCarrierTextControllerBuilder, mContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ import com.android.systemui.statusbar.StatusBarIconView;
|
||||
import com.android.systemui.statusbar.StatusBarMobileView;
|
||||
import com.android.systemui.statusbar.StatusBarWifiView;
|
||||
import com.android.systemui.statusbar.StatusIconDisplayable;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.CallIndicatorIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.MobileIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.NoCallingIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.WifiIconState;
|
||||
|
||||
import java.util.List;
|
||||
@@ -66,7 +66,7 @@ public interface StatusBarIconController {
|
||||
/**
|
||||
* Display the no calling & SMS icons.
|
||||
*/
|
||||
void setNoCallingIcons(String slot, List<NoCallingIconState> states);
|
||||
void setCallIndicatorIcons(String slot, List<CallIndicatorIconState> states);
|
||||
public void setIconVisibility(String slot, boolean b);
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,8 +34,8 @@ import com.android.systemui.demomode.DemoMode;
|
||||
import com.android.systemui.demomode.DemoModeController;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
import com.android.systemui.statusbar.StatusIconDisplayable;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.CallIndicatorIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.MobileIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.NoCallingIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.WifiIconState;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
|
||||
@@ -206,6 +206,7 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu
|
||||
Collections.reverse(iconStates);
|
||||
|
||||
for (MobileIconState state : iconStates) {
|
||||
|
||||
StatusBarIconHolder holder = mobileSlot.getHolderForTag(state.subId);
|
||||
if (holder == null) {
|
||||
holder = StatusBarIconHolder.fromMobileIconState(state);
|
||||
@@ -218,23 +219,25 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept a list of NoCallingIconStates, and show them in the same slot
|
||||
* Accept a list of CallIndicatorIconStates, and show them in the same slot
|
||||
* @param slot StatusBar slot
|
||||
* @param states All of the no Calling & SMS icon states
|
||||
*/
|
||||
@Override
|
||||
public void setNoCallingIcons(String slot, List<NoCallingIconState> states) {
|
||||
public void setCallIndicatorIcons(String slot, List<CallIndicatorIconState> states) {
|
||||
Slot noCallingSlot = getSlot(slot);
|
||||
int slotIndex = getSlotIndex(slot);
|
||||
|
||||
for (NoCallingIconState state : states) {
|
||||
for (CallIndicatorIconState state : states) {
|
||||
StatusBarIconHolder holder = noCallingSlot.getHolderForTag(state.subId);
|
||||
if (holder == null) {
|
||||
holder = StatusBarIconHolder.fromNoCallingState(mContext, state);
|
||||
holder.setVisible(state.visible);
|
||||
holder = StatusBarIconHolder.fromCallIndicatorState(mContext, state);
|
||||
setIcon(slotIndex, holder);
|
||||
} else {
|
||||
holder.setVisible(state.visible);
|
||||
int resId = state.isNoCalling ? state.noCallingResId : state.callStrengthResId;
|
||||
String contentDescription = state.isNoCalling
|
||||
? state.noCallingDescription : state.callStrengthDescription;
|
||||
holder.setIcon(new StatusBarIcon(UserHandle.SYSTEM, mContext.getPackageName(),
|
||||
Icon.createWithResource(mContext, resId), 0, 0, contentDescription));
|
||||
setIcon(slotIndex, holder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ import android.graphics.drawable.Icon;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import com.android.internal.statusbar.StatusBarIcon;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.CallIndicatorIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.MobileIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.NoCallingIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.WifiIconState;
|
||||
|
||||
/**
|
||||
@@ -72,14 +72,18 @@ public class StatusBarIconHolder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new StatusBarIconHolder from a NoCallingIconState.
|
||||
* Creates a new StatusBarIconHolder from a CallIndicatorIconState.
|
||||
*/
|
||||
public static StatusBarIconHolder fromNoCallingState(
|
||||
Context context, NoCallingIconState state) {
|
||||
public static StatusBarIconHolder fromCallIndicatorState(
|
||||
Context context, CallIndicatorIconState state) {
|
||||
StatusBarIconHolder holder = new StatusBarIconHolder();
|
||||
int resId = state.isNoCalling ? state.noCallingResId : state.callStrengthResId;
|
||||
String contentDescription = state.isNoCalling
|
||||
? state.noCallingDescription : state.callStrengthDescription;
|
||||
holder.mIcon = new StatusBarIcon(UserHandle.SYSTEM, context.getPackageName(),
|
||||
Icon.createWithResource(context, state.resId), 0, 0, null);
|
||||
Icon.createWithResource(context, resId), 0, 0, contentDescription);
|
||||
holder.mTag = state.subId;
|
||||
holder.setVisible(true);
|
||||
return holder;
|
||||
}
|
||||
|
||||
@@ -92,6 +96,10 @@ public class StatusBarIconHolder {
|
||||
return mIcon;
|
||||
}
|
||||
|
||||
public void setIcon(StatusBarIcon icon) {
|
||||
mIcon = icon;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public WifiIconState getWifiState() {
|
||||
return mWifiState;
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.telephony.SubscriptionInfo;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settingslib.mobile.TelephonyIcons;
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.policy.NetworkController;
|
||||
@@ -39,7 +40,7 @@ import java.util.Objects;
|
||||
public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallback,
|
||||
SecurityController.SecurityControllerCallback, Tunable {
|
||||
private static final String TAG = "StatusBarSignalPolicy";
|
||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.INFO);
|
||||
|
||||
private final String mSlotAirplane;
|
||||
private final String mSlotMobile;
|
||||
@@ -67,7 +68,8 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
|
||||
private boolean mWifiVisible = false;
|
||||
|
||||
private ArrayList<MobileIconState> mMobileStates = new ArrayList<MobileIconState>();
|
||||
private ArrayList<NoCallingIconState> mNoCallingStates = new ArrayList<NoCallingIconState>();
|
||||
private ArrayList<CallIndicatorIconState> mCallIndicatorStates =
|
||||
new ArrayList<CallIndicatorIconState>();
|
||||
private WifiIconState mWifiIconState = new WifiIconState();
|
||||
|
||||
public StatusBarSignalPolicy(Context context, StatusBarIconController iconController) {
|
||||
@@ -201,19 +203,25 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoCallingStatus(boolean noCalling, int subId) {
|
||||
public void setCallIndicator(IconState statusIcon, int subId) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "setNoCallingStatus: "
|
||||
+ "noCalling = " + noCalling + ","
|
||||
Log.d(TAG, "setCallIndicator: "
|
||||
+ "statusIcon = " + statusIcon + ","
|
||||
+ "subId = " + subId);
|
||||
}
|
||||
NoCallingIconState state = getNoCallingState(subId);
|
||||
CallIndicatorIconState state = getNoCallingState(subId);
|
||||
if (state == null) {
|
||||
return;
|
||||
}
|
||||
state.visible = noCalling;
|
||||
mIconController.setNoCallingIcons(
|
||||
mSlotNoCalling, NoCallingIconState.copyStates(mNoCallingStates));
|
||||
if (statusIcon.icon == R.drawable.ic_qs_no_calling_sms) {
|
||||
state.isNoCalling = statusIcon.visible;
|
||||
state.noCallingDescription = statusIcon.contentDescription;
|
||||
} else {
|
||||
state.callStrengthResId = statusIcon.icon;
|
||||
state.callStrengthDescription = statusIcon.contentDescription;
|
||||
}
|
||||
mIconController.setCallIndicatorIcons(
|
||||
mSlotNoCalling, CallIndicatorIconState.copyStates(mCallIndicatorStates));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -273,8 +281,8 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
|
||||
}
|
||||
}
|
||||
|
||||
private NoCallingIconState getNoCallingState(int subId) {
|
||||
for (NoCallingIconState state : mNoCallingStates) {
|
||||
private CallIndicatorIconState getNoCallingState(int subId) {
|
||||
for (CallIndicatorIconState state : mCallIndicatorStates) {
|
||||
if (state.subId == subId) {
|
||||
return state;
|
||||
}
|
||||
@@ -315,23 +323,25 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
|
||||
}
|
||||
|
||||
mIconController.removeAllIconsForSlot(mSlotMobile);
|
||||
mIconController.removeAllIconsForSlot(mSlotNoCalling);
|
||||
mMobileStates.clear();
|
||||
List<NoCallingIconState> noCallingStates = new ArrayList<NoCallingIconState>();
|
||||
noCallingStates.addAll(mNoCallingStates);
|
||||
mNoCallingStates.clear();
|
||||
List<CallIndicatorIconState> noCallingStates = new ArrayList<CallIndicatorIconState>();
|
||||
noCallingStates.addAll(mCallIndicatorStates);
|
||||
mCallIndicatorStates.clear();
|
||||
final int n = subs.size();
|
||||
for (int i = 0; i < n; i++) {
|
||||
mMobileStates.add(new MobileIconState(subs.get(i).getSubscriptionId()));
|
||||
boolean isNewSub = true;
|
||||
for (NoCallingIconState state : noCallingStates) {
|
||||
for (CallIndicatorIconState state : noCallingStates) {
|
||||
if (state.subId == subs.get(i).getSubscriptionId()) {
|
||||
mNoCallingStates.add(state);
|
||||
mCallIndicatorStates.add(state);
|
||||
isNewSub = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isNewSub) {
|
||||
mNoCallingStates.add(new NoCallingIconState(subs.get(i).getSubscriptionId()));
|
||||
mCallIndicatorStates.add(
|
||||
new CallIndicatorIconState(subs.get(i).getSubscriptionId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -425,14 +435,18 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
|
||||
/**
|
||||
* Stores the StatusBar state for no Calling & SMS.
|
||||
*/
|
||||
public static class NoCallingIconState {
|
||||
public boolean visible;
|
||||
public int resId;
|
||||
public static class CallIndicatorIconState {
|
||||
public boolean isNoCalling;
|
||||
public int noCallingResId;
|
||||
public int callStrengthResId;
|
||||
public int subId;
|
||||
public String noCallingDescription;
|
||||
public String callStrengthDescription;
|
||||
|
||||
private NoCallingIconState(int subId) {
|
||||
private CallIndicatorIconState(int subId) {
|
||||
this.subId = subId;
|
||||
this.resId = R.drawable.ic_qs_no_calling_sms;
|
||||
this.noCallingResId = R.drawable.ic_qs_no_calling_sms;
|
||||
this.callStrengthResId = TelephonyIcons.MOBILE_CALL_STRENGTH_ICONS[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -441,27 +455,36 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
NoCallingIconState that = (NoCallingIconState) o;
|
||||
return visible == that.visible
|
||||
&& resId == that.resId
|
||||
&& subId == that.subId;
|
||||
CallIndicatorIconState that = (CallIndicatorIconState) o;
|
||||
return isNoCalling == that.isNoCalling
|
||||
&& noCallingResId == that.noCallingResId
|
||||
&& callStrengthResId == that.callStrengthResId
|
||||
&& subId == that.subId
|
||||
&& noCallingDescription == that.noCallingDescription
|
||||
&& callStrengthDescription == that.callStrengthDescription;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(visible, resId, subId);
|
||||
return Objects.hash(isNoCalling, noCallingResId,
|
||||
callStrengthResId, subId, noCallingDescription, callStrengthDescription);
|
||||
}
|
||||
|
||||
private void copyTo(NoCallingIconState other) {
|
||||
other.visible = visible;
|
||||
other.resId = resId;
|
||||
private void copyTo(CallIndicatorIconState other) {
|
||||
other.isNoCalling = isNoCalling;
|
||||
other.noCallingResId = noCallingResId;
|
||||
other.callStrengthResId = callStrengthResId;
|
||||
other.subId = subId;
|
||||
other.noCallingDescription = noCallingDescription;
|
||||
other.callStrengthDescription = callStrengthDescription;
|
||||
}
|
||||
|
||||
private static List<NoCallingIconState> copyStates(List<NoCallingIconState> inStates) {
|
||||
ArrayList<NoCallingIconState> outStates = new ArrayList<>();
|
||||
for (NoCallingIconState state : inStates) {
|
||||
NoCallingIconState copy = new NoCallingIconState(state.subId);
|
||||
private static List<CallIndicatorIconState> copyStates(
|
||||
List<CallIndicatorIconState> inStates) {
|
||||
ArrayList<CallIndicatorIconState> outStates = new ArrayList<>();
|
||||
for (CallIndicatorIconState state : inStates) {
|
||||
CallIndicatorIconState copy = new CallIndicatorIconState(state.subId);
|
||||
state.copyTo(copy);
|
||||
outStates.add(copy);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import java.util.List;
|
||||
* the current or specified Looper.
|
||||
*/
|
||||
public class CallbackHandler extends Handler implements EmergencyListener, SignalCallback {
|
||||
private static final String TAG = "CallbackHandler";
|
||||
private static final int MSG_EMERGENCE_CHANGED = 0;
|
||||
private static final int MSG_SUBS_CHANGED = 1;
|
||||
private static final int MSG_NO_SIM_VISIBLE_CHANGED = 2;
|
||||
@@ -198,17 +199,17 @@ public class CallbackHandler extends Handler implements EmergencyListener, Signa
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoCallingStatus(boolean noCalling, int subId) {
|
||||
public void setCallIndicator(IconState statusIcon, int subId) {
|
||||
String log = new StringBuilder()
|
||||
.append(SSDF.format(System.currentTimeMillis())).append(",")
|
||||
.append("setNoCallingStatus: ")
|
||||
.append("noCalling=").append(noCalling).append(",")
|
||||
.append("setCallIndicator: ")
|
||||
.append("statusIcon=").append(statusIcon).append(",")
|
||||
.append("subId=").append(subId)
|
||||
.toString();
|
||||
recordLastCallback(log);
|
||||
post(() -> {
|
||||
for (SignalCallback signalCluster : mSignalCallbacks) {
|
||||
signalCluster.setNoCallingStatus(noCalling, subId);
|
||||
signalCluster.setCallIndicator(statusIcon, subId);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -226,24 +227,11 @@ public class CallbackHandler extends Handler implements EmergencyListener, Signa
|
||||
|
||||
@Override
|
||||
public void setNoSims(boolean show, boolean simDetected) {
|
||||
String log = new StringBuilder()
|
||||
.append(SSDF.format(System.currentTimeMillis())).append(",")
|
||||
.append("setNoSims: ")
|
||||
.append("show=").append(show).append(",")
|
||||
.append("simDetected=").append(simDetected)
|
||||
.toString();
|
||||
recordLastCallback(log);
|
||||
obtainMessage(MSG_NO_SIM_VISIBLE_CHANGED, show ? 1 : 0, simDetected ? 1 : 0).sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMobileDataEnabled(boolean enabled) {
|
||||
String log = new StringBuilder()
|
||||
.append(SSDF.format(System.currentTimeMillis())).append(",")
|
||||
.append("setMobileDataEnabled: ")
|
||||
.append("enabled=").append(enabled)
|
||||
.toString();
|
||||
recordLastCallback(log);
|
||||
obtainMessage(MSG_MOBILE_DATA_ENABLED_CHANGED, enabled ? 1 : 0, 0).sendToTarget();
|
||||
}
|
||||
|
||||
@@ -283,7 +271,8 @@ public class CallbackHandler extends Handler implements EmergencyListener, Signa
|
||||
}
|
||||
|
||||
protected void recordLastCallback(String callback) {
|
||||
mHistory[mHistoryIndex++ & (HISTORY_SIZE - 1)] = callback;
|
||||
mHistory[mHistoryIndex] = callback;
|
||||
mHistoryIndex = (mHistoryIndex + 1) % HISTORY_SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -293,7 +282,9 @@ public class CallbackHandler extends Handler implements EmergencyListener, Signa
|
||||
pw.println(" - CallbackHandler -----");
|
||||
int size = 0;
|
||||
for (int i = 0; i < HISTORY_SIZE; i++) {
|
||||
if (mHistory[i] != null) size++;
|
||||
if (mHistory[i] != null) {
|
||||
size++;
|
||||
}
|
||||
}
|
||||
// Print out the previous states in ordered number.
|
||||
for (int i = mHistoryIndex + HISTORY_SIZE - 1;
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.net.NetworkCapabilities;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings.Global;
|
||||
import android.telephony.AccessNetworkConstants;
|
||||
import android.telephony.CellSignalStrength;
|
||||
import android.telephony.CellSignalStrengthCdma;
|
||||
import android.telephony.ServiceState;
|
||||
@@ -34,12 +35,18 @@ import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyDisplayInfo;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.ims.ImsException;
|
||||
import android.telephony.ims.ImsMmTelManager;
|
||||
import android.telephony.ims.ImsReasonInfo;
|
||||
import android.telephony.ims.ImsRegistrationAttributes;
|
||||
import android.telephony.ims.RegistrationManager.RegistrationCallback;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settingslib.AccessibilityContentDescriptions;
|
||||
import com.android.settingslib.SignalIcon.MobileIconGroup;
|
||||
import com.android.settingslib.SignalIcon.MobileState;
|
||||
import com.android.settingslib.Utils;
|
||||
@@ -65,13 +72,19 @@ import java.util.Map;
|
||||
*/
|
||||
public class MobileSignalController extends SignalController<MobileState, MobileIconGroup> {
|
||||
private static final SimpleDateFormat SSDF = new SimpleDateFormat("MM-dd HH:mm:ss.SSS");
|
||||
|
||||
private static final int STATUS_HISTORY_SIZE = 64;
|
||||
private static final int IMS_TYPE_WWAN = 1;
|
||||
private static final int IMS_TYPE_WLAN = 2;
|
||||
private static final int IMS_TYPE_WLAN_CROSS_SIM = 3;
|
||||
private final TelephonyManager mPhone;
|
||||
private final ImsMmTelManager mImsMmTelManager;
|
||||
private final SubscriptionDefaults mDefaults;
|
||||
private final String mNetworkNameDefault;
|
||||
private final String mNetworkNameSeparator;
|
||||
private final ContentObserver mObserver;
|
||||
private final boolean mProviderModel;
|
||||
private final Handler mReceiverHandler;
|
||||
private int mImsType = IMS_TYPE_WWAN;
|
||||
// Save entire info for logging, we only use the id.
|
||||
final SubscriptionInfo mSubscriptionInfo;
|
||||
// @VisibleForDemoMode
|
||||
@@ -86,16 +99,21 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
|
||||
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE);
|
||||
private ServiceState mServiceState;
|
||||
private SignalStrength mSignalStrength;
|
||||
private int mLastLevel;
|
||||
private MobileIconGroup mDefaultIcons;
|
||||
private Config mConfig;
|
||||
@VisibleForTesting
|
||||
boolean mInflateSignalStrengths = false;
|
||||
private MobileStatusTracker.Callback mCallback;
|
||||
private RegistrationCallback mRegistrationCallback;
|
||||
private int mLastWwanLevel;
|
||||
private int mLastWlanLevel;
|
||||
private int mLastWlanCrossSimLevel;
|
||||
@VisibleForTesting
|
||||
MobileStatusTracker mMobileStatusTracker;
|
||||
|
||||
// Save the previous HISTORY_SIZE states for logging.
|
||||
private final String[] mMobileStatusHistory = new String[HISTORY_SIZE];
|
||||
// Save the previous STATUS_HISTORY_SIZE states for logging.
|
||||
private final String[] mMobileStatusHistory = new String[STATUS_HISTORY_SIZE];
|
||||
// Where to copy the next state into.
|
||||
private int mMobileStatusHistoryIndex;
|
||||
|
||||
@@ -116,6 +134,7 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
|
||||
.toString();
|
||||
mNetworkNameDefault = getTextIfExists(
|
||||
com.android.internal.R.string.lockscreen_carrier_default).toString();
|
||||
mReceiverHandler = new Handler(receiverLooper);
|
||||
|
||||
mNetworkToIconLookup = mapIconSets(mConfig);
|
||||
mDefaultIcons = getDefaultIcons(mConfig);
|
||||
@@ -133,6 +152,8 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
|
||||
}
|
||||
};
|
||||
mCallback = new MobileStatusTracker.Callback() {
|
||||
private String mLastStatus;
|
||||
|
||||
@Override
|
||||
public void onMobileStatusChanged(boolean updateTelephony,
|
||||
MobileStatus mobileStatus) {
|
||||
@@ -141,11 +162,15 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
|
||||
+ " updateTelephony=" + updateTelephony
|
||||
+ " mobileStatus=" + mobileStatus.toString());
|
||||
}
|
||||
String status = new StringBuilder()
|
||||
.append(SSDF.format(System.currentTimeMillis())).append(",")
|
||||
.append(mobileStatus.toString())
|
||||
.toString();
|
||||
recordLastMobileStatus(status);
|
||||
String currentStatus = mobileStatus.toString();
|
||||
if (!currentStatus.equals(mLastStatus)) {
|
||||
mLastStatus = currentStatus;
|
||||
String status = new StringBuilder()
|
||||
.append(SSDF.format(System.currentTimeMillis())).append(",")
|
||||
.append(currentStatus)
|
||||
.toString();
|
||||
recordLastMobileStatus(status);
|
||||
}
|
||||
updateMobileStatus(mobileStatus);
|
||||
if (updateTelephony) {
|
||||
updateTelephony();
|
||||
@@ -154,6 +179,53 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
mRegistrationCallback = new RegistrationCallback() {
|
||||
@Override
|
||||
public void onRegistered(ImsRegistrationAttributes attributes) {
|
||||
Log.d(mTag, "onRegistered: " + "attributes=" + attributes);
|
||||
int imsTransportType = attributes.getTransportType();
|
||||
int registrationAttributes = attributes.getAttributeFlags();
|
||||
if (imsTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) {
|
||||
mImsType = IMS_TYPE_WWAN;
|
||||
IconState statusIcon = new IconState(
|
||||
true,
|
||||
getCallStrengthIcon(mLastWwanLevel, /* isWifi= */false),
|
||||
getCallStrengthDescription(mLastWwanLevel, /* isWifi= */false));
|
||||
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
|
||||
} else if (imsTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WLAN) {
|
||||
if (registrationAttributes == 0) {
|
||||
mImsType = IMS_TYPE_WLAN;
|
||||
IconState statusIcon = new IconState(
|
||||
true,
|
||||
getCallStrengthIcon(mLastWlanLevel, /* isWifi= */true),
|
||||
getCallStrengthDescription(mLastWlanLevel, /* isWifi= */true));
|
||||
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
|
||||
} else if (registrationAttributes
|
||||
== ImsRegistrationAttributes.ATTR_EPDG_OVER_CELL_INTERNET) {
|
||||
mImsType = IMS_TYPE_WLAN_CROSS_SIM;
|
||||
IconState statusIcon = new IconState(
|
||||
true,
|
||||
getCallStrengthIcon(mLastWlanCrossSimLevel, /* isWifi= */false),
|
||||
getCallStrengthDescription(
|
||||
mLastWlanCrossSimLevel, /* isWifi= */false));
|
||||
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnregistered(ImsReasonInfo info) {
|
||||
Log.d(mTag, "onDeregistered: " + "info=" + info);
|
||||
mImsType = IMS_TYPE_WWAN;
|
||||
IconState statusIcon = new IconState(
|
||||
true,
|
||||
getCallStrengthIcon(mLastWwanLevel, /* isWifi= */false),
|
||||
getCallStrengthDescription(mLastWwanLevel, /* isWifi= */false));
|
||||
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
|
||||
}
|
||||
};
|
||||
mImsMmTelManager = ImsMmTelManager.createForSubscriptionId(info.getSubscriptionId());
|
||||
mMobileStatusTracker = new MobileStatusTracker(mPhone, receiverLooper,
|
||||
info, mDefaults, mCallback);
|
||||
mProviderModel = FeatureFlagUtils.isEnabled(
|
||||
@@ -202,14 +274,41 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
|
||||
mContext.getContentResolver().registerContentObserver(Global.getUriFor(
|
||||
Global.MOBILE_DATA + mSubscriptionInfo.getSubscriptionId()),
|
||||
true, mObserver);
|
||||
if (mProviderModel) {
|
||||
mReceiverHandler.post(mTryRegisterIms);
|
||||
}
|
||||
}
|
||||
|
||||
// There is no listener to monitor whether the IMS service is ready, so we have to retry the
|
||||
// IMS registration.
|
||||
private final Runnable mTryRegisterIms = new Runnable() {
|
||||
private static final int MAX_RETRY = 12;
|
||||
private int mRetryCount;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
mRetryCount++;
|
||||
mImsMmTelManager.registerImsRegistrationCallback(
|
||||
mReceiverHandler::post, mRegistrationCallback);
|
||||
Log.d(mTag, "registerImsRegistrationCallback succeeded");
|
||||
} catch (RuntimeException | ImsException e) {
|
||||
if (mRetryCount < MAX_RETRY) {
|
||||
Log.e(mTag, mRetryCount + " registerImsRegistrationCallback failed", e);
|
||||
// Wait for 5 seconds to retry
|
||||
mReceiverHandler.postDelayed(mTryRegisterIms, 5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop listening for phone state changes.
|
||||
*/
|
||||
public void unregisterListener() {
|
||||
mMobileStatusTracker.setListening(false);
|
||||
mContext.getContentResolver().unregisterContentObserver(mObserver);
|
||||
mImsMmTelManager.unregisterImsRegistrationCallback(mRegistrationCallback);
|
||||
}
|
||||
|
||||
private void updateInflateSignalStrength() {
|
||||
@@ -452,9 +551,9 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
|
||||
/**
|
||||
* Extracts the CellSignalStrengthCdma from SignalStrength then returns the level
|
||||
*/
|
||||
private final int getCdmaLevel() {
|
||||
private int getCdmaLevel(SignalStrength signalStrength) {
|
||||
List<CellSignalStrengthCdma> signalStrengthCdma =
|
||||
mSignalStrength.getCellSignalStrengths(CellSignalStrengthCdma.class);
|
||||
signalStrength.getCellSignalStrengths(CellSignalStrengthCdma.class);
|
||||
if (!signalStrengthCdma.isEmpty()) {
|
||||
return signalStrengthCdma.get(0).getLevel();
|
||||
}
|
||||
@@ -467,6 +566,7 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
|
||||
mCurrentState.dataSim = mobileStatus.dataSim;
|
||||
mCurrentState.carrierNetworkChangeMode = mobileStatus.carrierNetworkChangeMode;
|
||||
mDataState = mobileStatus.dataState;
|
||||
notifyMobileLevelChangeIfNecessary(mobileStatus.signalStrength);
|
||||
mSignalStrength = mobileStatus.signalStrength;
|
||||
mTelephonyDisplayInfo = mobileStatus.telephonyDisplayInfo;
|
||||
int lastVoiceState = mServiceState != null ? mServiceState.getState() : -1;
|
||||
@@ -481,9 +581,117 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
|
||||
&& (lastVoiceState == -1
|
||||
|| (lastVoiceState == ServiceState.STATE_IN_SERVICE
|
||||
|| currentVoiceState == ServiceState.STATE_IN_SERVICE))) {
|
||||
notifyNoCallingStatusChange(
|
||||
currentVoiceState != ServiceState.STATE_IN_SERVICE,
|
||||
mSubscriptionInfo.getSubscriptionId());
|
||||
boolean isNoCalling = currentVoiceState != ServiceState.STATE_IN_SERVICE;
|
||||
IconState statusIcon = new IconState(isNoCalling, R.drawable.ic_qs_no_calling_sms,
|
||||
getTextIfExists(AccessibilityContentDescriptions.NO_CALLING).toString());
|
||||
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
|
||||
}
|
||||
}
|
||||
|
||||
private int getCallStrengthIcon(int level, boolean isWifi) {
|
||||
return isWifi ? TelephonyIcons.WIFI_CALL_STRENGTH_ICONS[level]
|
||||
: TelephonyIcons.MOBILE_CALL_STRENGTH_ICONS[level];
|
||||
}
|
||||
|
||||
private String getCallStrengthDescription(int level, boolean isWifi) {
|
||||
return isWifi
|
||||
? getTextIfExists(AccessibilityContentDescriptions.WIFI_CONNECTION_STRENGTH[level])
|
||||
.toString()
|
||||
: getTextIfExists(AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[level])
|
||||
.toString();
|
||||
}
|
||||
|
||||
void refreshCallIndicator(SignalCallback callback) {
|
||||
boolean isNoCalling = mServiceState != null
|
||||
&& mServiceState.getState() != ServiceState.STATE_IN_SERVICE;
|
||||
IconState statusIcon = new IconState(isNoCalling, R.drawable.ic_qs_no_calling_sms,
|
||||
getTextIfExists(AccessibilityContentDescriptions.NO_CALLING).toString());
|
||||
callback.setCallIndicator(statusIcon, mSubscriptionInfo.getSubscriptionId());
|
||||
|
||||
switch (mImsType) {
|
||||
case IMS_TYPE_WWAN:
|
||||
statusIcon = new IconState(
|
||||
true,
|
||||
getCallStrengthIcon(mLastWwanLevel, /* isWifi= */false),
|
||||
getCallStrengthDescription(mLastWwanLevel, /* isWifi= */false));
|
||||
break;
|
||||
case IMS_TYPE_WLAN:
|
||||
statusIcon = new IconState(
|
||||
true,
|
||||
getCallStrengthIcon(mLastWlanLevel, /* isWifi= */true),
|
||||
getCallStrengthDescription(mLastWlanLevel, /* isWifi= */true));
|
||||
break;
|
||||
case IMS_TYPE_WLAN_CROSS_SIM:
|
||||
statusIcon = new IconState(
|
||||
true,
|
||||
getCallStrengthIcon(mLastWlanCrossSimLevel, /* isWifi= */false),
|
||||
getCallStrengthDescription(mLastWlanCrossSimLevel, /* isWifi= */false));
|
||||
}
|
||||
callback.setCallIndicator(statusIcon, mSubscriptionInfo.getSubscriptionId());
|
||||
}
|
||||
|
||||
void notifyWifiLevelChange(int level) {
|
||||
if (!mProviderModel) {
|
||||
return;
|
||||
}
|
||||
Log.d("mTag", "notifyWifiLevelChange " + mImsType);
|
||||
mLastWlanLevel = level;
|
||||
if (mImsType != IMS_TYPE_WLAN) {
|
||||
return;
|
||||
}
|
||||
IconState statusIcon = new IconState(
|
||||
true,
|
||||
getCallStrengthIcon(level, /* isWifi= */true),
|
||||
getCallStrengthDescription(level, /* isWifi= */true));
|
||||
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
|
||||
}
|
||||
|
||||
void notifyDefaultMobileLevelChange(int level) {
|
||||
if (!mProviderModel) {
|
||||
return;
|
||||
}
|
||||
Log.d("mTag", "notifyDefaultMobileLevelChange " + mImsType);
|
||||
mLastWlanCrossSimLevel = level;
|
||||
if (mImsType != IMS_TYPE_WLAN_CROSS_SIM) {
|
||||
return;
|
||||
}
|
||||
IconState statusIcon = new IconState(
|
||||
true,
|
||||
getCallStrengthIcon(level, /* isWifi= */false),
|
||||
getCallStrengthDescription(level, /* isWifi= */false));
|
||||
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
|
||||
}
|
||||
|
||||
void notifyMobileLevelChangeIfNecessary(SignalStrength signalStrength) {
|
||||
if (!mProviderModel) {
|
||||
return;
|
||||
}
|
||||
int newLevel = getSignalLevel(signalStrength);
|
||||
if (newLevel != mLastLevel) {
|
||||
mLastLevel = newLevel;
|
||||
Log.d("mTag", "notifyMobileLevelChangeIfNecessary " + mImsType);
|
||||
mLastWwanLevel = newLevel;
|
||||
if (mImsType == IMS_TYPE_WWAN) {
|
||||
IconState statusIcon = new IconState(
|
||||
true,
|
||||
getCallStrengthIcon(newLevel, /* isWifi= */false),
|
||||
getCallStrengthDescription(newLevel, /* isWifi= */false));
|
||||
notifyCallStateChange(statusIcon, mSubscriptionInfo.getSubscriptionId());
|
||||
}
|
||||
if (mCurrentState.dataSim) {
|
||||
mNetworkController.notifyDefaultMobileLevelChange(newLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int getSignalLevel(SignalStrength signalStrength) {
|
||||
if (signalStrength == null) {
|
||||
return 0;
|
||||
}
|
||||
if (!signalStrength.isGsm() && mConfig.alwaysShowCdmaRssi) {
|
||||
return getCdmaLevel(signalStrength);
|
||||
} else {
|
||||
return signalStrength.getLevel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,11 +709,7 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
|
||||
checkDefaultData();
|
||||
mCurrentState.connected = Utils.isInService(mServiceState) && mSignalStrength != null;
|
||||
if (mCurrentState.connected) {
|
||||
if (!mSignalStrength.isGsm() && mConfig.alwaysShowCdmaRssi) {
|
||||
mCurrentState.level = getCdmaLevel();
|
||||
} else {
|
||||
mCurrentState.level = mSignalStrength.getLevel();
|
||||
}
|
||||
mCurrentState.level = getSignalLevel(mSignalStrength);
|
||||
}
|
||||
|
||||
String iconKey = getIconKey(mTelephonyDisplayInfo);
|
||||
@@ -577,7 +781,13 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
|
||||
}
|
||||
|
||||
private void recordLastMobileStatus(String mobileStatus) {
|
||||
mMobileStatusHistory[mMobileStatusHistoryIndex++ & (HISTORY_SIZE - 1)] = mobileStatus;
|
||||
mMobileStatusHistory[mMobileStatusHistoryIndex] = mobileStatus;
|
||||
mMobileStatusHistoryIndex = (mMobileStatusHistoryIndex + 1) % STATUS_HISTORY_SIZE;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setImsType(int imsType) {
|
||||
mImsType = imsType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -592,15 +802,17 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
|
||||
pw.println(" isDataDisabled=" + isDataDisabled() + ",");
|
||||
pw.println(" MobileStatusHistory");
|
||||
int size = 0;
|
||||
for (int i = 0; i < HISTORY_SIZE; i++) {
|
||||
if (mMobileStatusHistory[i] != null) size++;
|
||||
for (int i = 0; i < STATUS_HISTORY_SIZE; i++) {
|
||||
if (mMobileStatusHistory[i] != null) {
|
||||
size++;
|
||||
}
|
||||
}
|
||||
// Print out the previous states in ordered number.
|
||||
for (int i = mMobileStatusHistoryIndex + HISTORY_SIZE - 1;
|
||||
i >= mMobileStatusHistoryIndex + HISTORY_SIZE - size; i--) {
|
||||
for (int i = mMobileStatusHistoryIndex + STATUS_HISTORY_SIZE - 1;
|
||||
i >= mMobileStatusHistoryIndex + STATUS_HISTORY_SIZE - size; i--) {
|
||||
pw.println(" Previous MobileStatus("
|
||||
+ (mMobileStatusHistoryIndex + HISTORY_SIZE - i) + "): "
|
||||
+ mMobileStatusHistory[i & (HISTORY_SIZE - 1)]);
|
||||
+ (mMobileStatusHistoryIndex + STATUS_HISTORY_SIZE - i) + "): "
|
||||
+ mMobileStatusHistory[i & (STATUS_HISTORY_SIZE - 1)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
|
||||
|
||||
/**
|
||||
* Callback for listeners to be able to update the state of any UI tracking connectivity
|
||||
* @param statusIcon the icon that should be shown in the status bar
|
||||
* @param statusIcon the icon that should be shown in the status bar
|
||||
* @param qsIcon the icon to show in Quick Settings
|
||||
* @param statusType the resId of the data type icon (e.g. LTE) to show in the status bar
|
||||
* @param qsType similar to above, the resId of the data type icon to show in Quick Settings
|
||||
@@ -95,11 +95,11 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
|
||||
boolean noNetworksAvailable) {}
|
||||
|
||||
/**
|
||||
* Callback for listeners to be able to update the no calling & SMS status
|
||||
* @param noCalling whether the calling and SMS is not working.
|
||||
* Callback for listeners to be able to update the call indicator
|
||||
* @param statusIcon the icon for the call indicator
|
||||
* @param subId subscription ID for which to update the UI
|
||||
*/
|
||||
default void setNoCallingStatus(boolean noCalling, int subId) {}
|
||||
default void setCallIndicator(IconState statusIcon, int subId) {}
|
||||
}
|
||||
|
||||
public interface EmergencyListener {
|
||||
|
||||
@@ -554,6 +554,20 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
||||
return controller != null ? controller.getNetworkNameForCarrierWiFi() : "";
|
||||
}
|
||||
|
||||
void notifyWifiLevelChange(int level) {
|
||||
for (int i = 0; i < mMobileSignalControllers.size(); i++) {
|
||||
MobileSignalController mobileSignalController = mMobileSignalControllers.valueAt(i);
|
||||
mobileSignalController.notifyWifiLevelChange(level);
|
||||
}
|
||||
}
|
||||
|
||||
void notifyDefaultMobileLevelChange(int level) {
|
||||
for (int i = 0; i < mMobileSignalControllers.size(); i++) {
|
||||
MobileSignalController mobileSignalController = mMobileSignalControllers.valueAt(i);
|
||||
mobileSignalController.notifyDefaultMobileLevelChange(level);
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyControllersMobileDataChanged() {
|
||||
for (int i = 0; i < mMobileSignalControllers.size(); i++) {
|
||||
MobileSignalController mobileSignalController = mMobileSignalControllers.valueAt(i);
|
||||
@@ -623,6 +637,9 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
||||
for (int i = 0; i < mMobileSignalControllers.size(); i++) {
|
||||
MobileSignalController mobileSignalController = mMobileSignalControllers.valueAt(i);
|
||||
mobileSignalController.notifyListeners(cb);
|
||||
if (mProviderModel) {
|
||||
mobileSignalController.refreshCallIndicator(cb);
|
||||
}
|
||||
}
|
||||
mCallbackHandler.setListening(cb, true);
|
||||
}
|
||||
@@ -1272,7 +1289,8 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
||||
}
|
||||
|
||||
private void recordLastNetworkCallback(String callback) {
|
||||
mHistory[mHistoryIndex++ & (HISTORY_SIZE - 1)] = callback;
|
||||
mHistory[mHistoryIndex] = callback;
|
||||
mHistoryIndex = (mHistoryIndex + 1) % HISTORY_SIZE;
|
||||
}
|
||||
|
||||
private SubscriptionInfo addSignalController(int id, int simSlotIndex) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.util.Log;
|
||||
|
||||
import com.android.settingslib.SignalIcon.IconGroup;
|
||||
import com.android.settingslib.SignalIcon.State;
|
||||
import com.android.systemui.statusbar.policy.NetworkController.IconState;
|
||||
import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
@@ -167,8 +168,8 @@ public abstract class SignalController<T extends State, I extends IconGroup> {
|
||||
}
|
||||
}
|
||||
|
||||
protected final void notifyNoCallingStatusChange(boolean noCalling, int subId) {
|
||||
mCallbackHandler.setNoCallingStatus(noCalling, subId);
|
||||
protected final void notifyCallStateChange(IconState statusIcon, int subId) {
|
||||
mCallbackHandler.setCallIndicator(statusIcon, subId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,7 +188,8 @@ public abstract class SignalController<T extends State, I extends IconGroup> {
|
||||
* and last value of any state data.
|
||||
*/
|
||||
protected void recordLastState() {
|
||||
mHistory[mHistoryIndex++ & (HISTORY_SIZE - 1)].copyFrom(mLastState);
|
||||
mHistory[mHistoryIndex].copyFrom(mLastState);
|
||||
mHistoryIndex = (mHistoryIndex + 1) % HISTORY_SIZE;
|
||||
}
|
||||
|
||||
public void dump(PrintWriter pw) {
|
||||
|
||||
@@ -202,6 +202,7 @@ public class WifiSignalController extends
|
||||
mCurrentState.connected = mWifiTracker.connected;
|
||||
mCurrentState.ssid = mWifiTracker.ssid;
|
||||
mCurrentState.rssi = mWifiTracker.rssi;
|
||||
notifyWifiLevelChangeIfNecessary(mWifiTracker.level);
|
||||
mCurrentState.level = mWifiTracker.level;
|
||||
mCurrentState.statusLabel = mWifiTracker.statusLabel;
|
||||
mCurrentState.isCarrierMerged = mWifiTracker.isCarrierMerged;
|
||||
@@ -211,6 +212,12 @@ public class WifiSignalController extends
|
||||
: mUnmergedWifiIconGroup;
|
||||
}
|
||||
|
||||
void notifyWifiLevelChangeIfNecessary(int level) {
|
||||
if (level != mCurrentState.level) {
|
||||
mNetworkController.notifyWifiLevelChange(level);
|
||||
}
|
||||
}
|
||||
|
||||
boolean isCarrierMergedWifi(int subId) {
|
||||
return mCurrentState.isDefault
|
||||
&& mCurrentState.isCarrierMerged && (mCurrentState.subId == subId);
|
||||
|
||||
@@ -98,7 +98,7 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
||||
|
||||
mQSCarrierGroupController = new QSCarrierGroupController.Builder(
|
||||
mActivityStarter, handler, TestableLooper.get(this).getLooper(),
|
||||
mNetworkController, mCarrierTextControllerBuilder)
|
||||
mNetworkController, mCarrierTextControllerBuilder, mContext)
|
||||
.setQSCarrierGroup(mQSCarrierGroup)
|
||||
.build();
|
||||
|
||||
|
||||
@@ -430,6 +430,10 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
|
||||
updateSignalStrength();
|
||||
}
|
||||
|
||||
public void setImsType(int imsType) {
|
||||
mMobileSignalController.setImsType(imsType);
|
||||
}
|
||||
|
||||
public void setIsGsm(boolean gsm) {
|
||||
when(mSignalStrength.isGsm()).thenReturn(gsm);
|
||||
updateSignalStrength();
|
||||
@@ -632,6 +636,14 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
protected void verifyLastCallStrength(int icon) {
|
||||
ArgumentCaptor<IconState> iconArg = ArgumentCaptor.forClass(IconState.class);
|
||||
verify(mCallbackHandler, Mockito.atLeastOnce()).setCallIndicator(
|
||||
iconArg.capture(),
|
||||
anyInt());
|
||||
assertEquals("Call strength, in status bar", icon, (int) iconArg.getValue().icon);
|
||||
}
|
||||
|
||||
protected void assertNetworkNameEquals(String expected) {
|
||||
assertEquals("Network name", expected, mMobileSignalController.getState().networkName);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import android.net.NetworkInfo;
|
||||
import android.net.vcn.VcnTransportInfo;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.telephony.CellSignalStrength;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableLooper.RunWithLooper;
|
||||
@@ -243,6 +244,28 @@ public class NetworkControllerWifiTest extends NetworkControllerBaseTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCallStrengh() {
|
||||
String testSsid = "Test SSID";
|
||||
setWifiEnabled(true);
|
||||
setWifiState(true, testSsid);
|
||||
// Set the ImsType to be IMS_TYPE_WLAN
|
||||
setImsType(2);
|
||||
setWifiLevel(1);
|
||||
for (int testLevel = 0; testLevel < WifiIcons.WIFI_LEVEL_COUNT; testLevel++) {
|
||||
setWifiLevel(testLevel);
|
||||
verifyLastCallStrength(TelephonyIcons.WIFI_CALL_STRENGTH_ICONS[testLevel]);
|
||||
}
|
||||
// Set the ImsType to be IMS_TYPE_WWAN
|
||||
setImsType(1);
|
||||
for (int testStrength = 0;
|
||||
testStrength < CellSignalStrength.getNumSignalStrengthLevels(); testStrength++) {
|
||||
setupDefaultSignal();
|
||||
setLevel(testStrength);
|
||||
verifyLastCallStrength(TelephonyIcons.MOBILE_CALL_STRENGTH_ICONS[testStrength]);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setWifiActivity(int activity) {
|
||||
// TODO: Not this, because this variable probably isn't sticking around.
|
||||
mNetworkController.mWifiSignalController.setActivity(activity);
|
||||
|
||||
@@ -19,8 +19,8 @@ import android.testing.LeakCheck;
|
||||
import com.android.internal.statusbar.StatusBarIcon;
|
||||
import com.android.systemui.statusbar.phone.StatusBarIconController;
|
||||
import com.android.systemui.statusbar.phone.StatusBarIconController.IconManager;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.CallIndicatorIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.MobileIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.NoCallingIconState;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.WifiIconState;
|
||||
|
||||
import java.util.List;
|
||||
@@ -66,7 +66,7 @@ public class FakeStatusBarIconController extends BaseLeakChecker<IconManager>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoCallingIcons(String slot, List<NoCallingIconState> states) {
|
||||
public void setCallIndicatorIcons(String slot, List<CallIndicatorIconState> states) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user