Merge changes from topic "revert-23118164-revert-23033485-WUUYRIDOOG-NYHTCROJNY" into udc-dev
* changes: Revert^2 "Add @SysUISingleton to repository switcher classes" Revert^2 "Carrier text: add LogBuffer debug logs"
This commit is contained in:
@@ -16,6 +16,11 @@
|
|||||||
|
|
||||||
package com.android.keyguard;
|
package com.android.keyguard;
|
||||||
|
|
||||||
|
import static com.android.keyguard.logging.CarrierTextManagerLogger.REASON_ACTIVE_DATA_SUB_CHANGED;
|
||||||
|
import static com.android.keyguard.logging.CarrierTextManagerLogger.REASON_ON_SIM_STATE_CHANGED;
|
||||||
|
import static com.android.keyguard.logging.CarrierTextManagerLogger.REASON_ON_TELEPHONY_CAPABLE;
|
||||||
|
import static com.android.keyguard.logging.CarrierTextManagerLogger.REASON_REFRESH_CARRIER_INFO;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
@@ -32,6 +37,7 @@ import android.util.Log;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
|
import com.android.keyguard.logging.CarrierTextManagerLogger;
|
||||||
import com.android.settingslib.WirelessUtils;
|
import com.android.settingslib.WirelessUtils;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.dagger.qualifiers.Background;
|
import com.android.systemui.dagger.qualifiers.Background;
|
||||||
@@ -40,6 +46,7 @@ import com.android.systemui.keyguard.WakefulnessLifecycle;
|
|||||||
import com.android.systemui.statusbar.pipeline.wifi.data.repository.WifiRepository;
|
import com.android.systemui.statusbar.pipeline.wifi.data.repository.WifiRepository;
|
||||||
import com.android.systemui.telephony.TelephonyListenerManager;
|
import com.android.systemui.telephony.TelephonyListenerManager;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
@@ -68,6 +75,7 @@ public class CarrierTextManager {
|
|||||||
private final AtomicBoolean mNetworkSupported = new AtomicBoolean();
|
private final AtomicBoolean mNetworkSupported = new AtomicBoolean();
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
protected KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||||
|
private final CarrierTextManagerLogger mLogger;
|
||||||
private final WifiRepository mWifiRepository;
|
private final WifiRepository mWifiRepository;
|
||||||
private final boolean[] mSimErrorState;
|
private final boolean[] mSimErrorState;
|
||||||
private final int mSimSlotsNumber;
|
private final int mSimSlotsNumber;
|
||||||
@@ -97,19 +105,13 @@ public class CarrierTextManager {
|
|||||||
protected final KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
|
protected final KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onRefreshCarrierInfo() {
|
public void onRefreshCarrierInfo() {
|
||||||
if (DEBUG) {
|
mLogger.logUpdateCarrierTextForReason(REASON_REFRESH_CARRIER_INFO);
|
||||||
Log.d(TAG, "onRefreshCarrierInfo(), mTelephonyCapable: "
|
|
||||||
+ Boolean.toString(mTelephonyCapable));
|
|
||||||
}
|
|
||||||
updateCarrierText();
|
updateCarrierText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTelephonyCapable(boolean capable) {
|
public void onTelephonyCapable(boolean capable) {
|
||||||
if (DEBUG) {
|
mLogger.logUpdateCarrierTextForReason(REASON_ON_TELEPHONY_CAPABLE);
|
||||||
Log.d(TAG, "onTelephonyCapable() mTelephonyCapable: "
|
|
||||||
+ Boolean.toString(capable));
|
|
||||||
}
|
|
||||||
mTelephonyCapable = capable;
|
mTelephonyCapable = capable;
|
||||||
updateCarrierText();
|
updateCarrierText();
|
||||||
}
|
}
|
||||||
@@ -121,7 +123,7 @@ public class CarrierTextManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG) Log.d(TAG, "onSimStateChanged: " + getStatusForIccState(simState));
|
mLogger.logUpdateCarrierTextForReason(REASON_ON_SIM_STATE_CHANGED);
|
||||||
if (getStatusForIccState(simState) == CarrierTextManager.StatusMode.SimIoError) {
|
if (getStatusForIccState(simState) == CarrierTextManager.StatusMode.SimIoError) {
|
||||||
mSimErrorState[slotId] = true;
|
mSimErrorState[slotId] = true;
|
||||||
updateCarrierText();
|
updateCarrierText();
|
||||||
@@ -137,6 +139,7 @@ public class CarrierTextManager {
|
|||||||
@Override
|
@Override
|
||||||
public void onActiveDataSubscriptionIdChanged(int subId) {
|
public void onActiveDataSubscriptionIdChanged(int subId) {
|
||||||
if (mNetworkSupported.get() && mCarrierTextCallback != null) {
|
if (mNetworkSupported.get() && mCarrierTextCallback != null) {
|
||||||
|
mLogger.logUpdateCarrierTextForReason(REASON_ACTIVE_DATA_SUB_CHANGED);
|
||||||
updateCarrierText();
|
updateCarrierText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,7 +178,9 @@ public class CarrierTextManager {
|
|||||||
WakefulnessLifecycle wakefulnessLifecycle,
|
WakefulnessLifecycle wakefulnessLifecycle,
|
||||||
@Main Executor mainExecutor,
|
@Main Executor mainExecutor,
|
||||||
@Background Executor bgExecutor,
|
@Background Executor bgExecutor,
|
||||||
KeyguardUpdateMonitor keyguardUpdateMonitor) {
|
KeyguardUpdateMonitor keyguardUpdateMonitor,
|
||||||
|
CarrierTextManagerLogger logger) {
|
||||||
|
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mIsEmergencyCallCapable = telephonyManager.isVoiceCapable();
|
mIsEmergencyCallCapable = telephonyManager.isVoiceCapable();
|
||||||
|
|
||||||
@@ -191,6 +196,7 @@ public class CarrierTextManager {
|
|||||||
mMainExecutor = mainExecutor;
|
mMainExecutor = mainExecutor;
|
||||||
mBgExecutor = bgExecutor;
|
mBgExecutor = bgExecutor;
|
||||||
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
||||||
|
mLogger = logger;
|
||||||
mBgExecutor.execute(() -> {
|
mBgExecutor.execute(() -> {
|
||||||
boolean supported = mContext.getPackageManager()
|
boolean supported = mContext.getPackageManager()
|
||||||
.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
|
.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
|
||||||
@@ -315,7 +321,7 @@ public class CarrierTextManager {
|
|||||||
subOrderBySlot[i] = -1;
|
subOrderBySlot[i] = -1;
|
||||||
}
|
}
|
||||||
final CharSequence[] carrierNames = new CharSequence[numSubs];
|
final CharSequence[] carrierNames = new CharSequence[numSubs];
|
||||||
if (DEBUG) Log.d(TAG, "updateCarrierText(): " + numSubs);
|
mLogger.logUpdate(numSubs);
|
||||||
|
|
||||||
for (int i = 0; i < numSubs; i++) {
|
for (int i = 0; i < numSubs; i++) {
|
||||||
int subId = subs.get(i).getSubscriptionId();
|
int subId = subs.get(i).getSubscriptionId();
|
||||||
@@ -325,9 +331,7 @@ public class CarrierTextManager {
|
|||||||
int simState = mKeyguardUpdateMonitor.getSimState(subId);
|
int simState = mKeyguardUpdateMonitor.getSimState(subId);
|
||||||
CharSequence carrierName = subs.get(i).getCarrierName();
|
CharSequence carrierName = subs.get(i).getCarrierName();
|
||||||
CharSequence carrierTextForSimState = getCarrierTextForSimState(simState, carrierName);
|
CharSequence carrierTextForSimState = getCarrierTextForSimState(simState, carrierName);
|
||||||
if (DEBUG) {
|
mLogger.logUpdateLoopStart(subId, simState, String.valueOf(carrierName));
|
||||||
Log.d(TAG, "Handling (subId=" + subId + "): " + simState + " " + carrierName);
|
|
||||||
}
|
|
||||||
if (carrierTextForSimState != null) {
|
if (carrierTextForSimState != null) {
|
||||||
allSimsMissing = false;
|
allSimsMissing = false;
|
||||||
carrierNames[i] = carrierTextForSimState;
|
carrierNames[i] = carrierTextForSimState;
|
||||||
@@ -340,9 +344,7 @@ public class CarrierTextManager {
|
|||||||
// Wi-Fi is disassociated or disabled
|
// Wi-Fi is disassociated or disabled
|
||||||
if (ss.getRilDataRadioTechnology() != ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN
|
if (ss.getRilDataRadioTechnology() != ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN
|
||||||
|| mWifiRepository.isWifiConnectedWithValidSsid()) {
|
|| mWifiRepository.isWifiConnectedWithValidSsid()) {
|
||||||
if (DEBUG) {
|
mLogger.logUpdateWfcCheck();
|
||||||
Log.d(TAG, "SIM ready and in service: subId=" + subId + ", ss=" + ss);
|
|
||||||
}
|
|
||||||
anySimReadyAndInService = true;
|
anySimReadyAndInService = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -379,7 +381,7 @@ public class CarrierTextManager {
|
|||||||
if (i.getBooleanExtra(TelephonyManager.EXTRA_SHOW_PLMN, false)) {
|
if (i.getBooleanExtra(TelephonyManager.EXTRA_SHOW_PLMN, false)) {
|
||||||
plmn = i.getStringExtra(TelephonyManager.EXTRA_PLMN);
|
plmn = i.getStringExtra(TelephonyManager.EXTRA_PLMN);
|
||||||
}
|
}
|
||||||
if (DEBUG) Log.d(TAG, "Getting plmn/spn sticky brdcst " + plmn + "/" + spn);
|
mLogger.logUpdateFromStickyBroadcast(plmn, spn);
|
||||||
if (Objects.equals(plmn, spn)) {
|
if (Objects.equals(plmn, spn)) {
|
||||||
text = plmn;
|
text = plmn;
|
||||||
} else {
|
} else {
|
||||||
@@ -409,6 +411,7 @@ public class CarrierTextManager {
|
|||||||
!allSimsMissing,
|
!allSimsMissing,
|
||||||
subsIds,
|
subsIds,
|
||||||
airplaneMode);
|
airplaneMode);
|
||||||
|
mLogger.logCallbackSentFromUpdate(info);
|
||||||
postToCallback(info);
|
postToCallback(info);
|
||||||
Trace.endSection();
|
Trace.endSection();
|
||||||
}
|
}
|
||||||
@@ -645,6 +648,7 @@ public class CarrierTextManager {
|
|||||||
private final Executor mMainExecutor;
|
private final Executor mMainExecutor;
|
||||||
private final Executor mBgExecutor;
|
private final Executor mBgExecutor;
|
||||||
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||||
|
private final CarrierTextManagerLogger mLogger;
|
||||||
private boolean mShowAirplaneMode;
|
private boolean mShowAirplaneMode;
|
||||||
private boolean mShowMissingSim;
|
private boolean mShowMissingSim;
|
||||||
|
|
||||||
@@ -658,7 +662,8 @@ public class CarrierTextManager {
|
|||||||
WakefulnessLifecycle wakefulnessLifecycle,
|
WakefulnessLifecycle wakefulnessLifecycle,
|
||||||
@Main Executor mainExecutor,
|
@Main Executor mainExecutor,
|
||||||
@Background Executor bgExecutor,
|
@Background Executor bgExecutor,
|
||||||
KeyguardUpdateMonitor keyguardUpdateMonitor) {
|
KeyguardUpdateMonitor keyguardUpdateMonitor,
|
||||||
|
CarrierTextManagerLogger logger) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mSeparator = resources.getString(
|
mSeparator = resources.getString(
|
||||||
com.android.internal.R.string.kg_text_message_separator);
|
com.android.internal.R.string.kg_text_message_separator);
|
||||||
@@ -669,6 +674,7 @@ public class CarrierTextManager {
|
|||||||
mMainExecutor = mainExecutor;
|
mMainExecutor = mainExecutor;
|
||||||
mBgExecutor = bgExecutor;
|
mBgExecutor = bgExecutor;
|
||||||
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
||||||
|
mLogger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
@@ -688,7 +694,7 @@ public class CarrierTextManager {
|
|||||||
return new CarrierTextManager(
|
return new CarrierTextManager(
|
||||||
mContext, mSeparator, mShowAirplaneMode, mShowMissingSim, mWifiRepository,
|
mContext, mSeparator, mShowAirplaneMode, mShowMissingSim, mWifiRepository,
|
||||||
mTelephonyManager, mTelephonyListenerManager, mWakefulnessLifecycle,
|
mTelephonyManager, mTelephonyListenerManager, mWakefulnessLifecycle,
|
||||||
mMainExecutor, mBgExecutor, mKeyguardUpdateMonitor);
|
mMainExecutor, mBgExecutor, mKeyguardUpdateMonitor, mLogger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -716,6 +722,17 @@ public class CarrierTextManager {
|
|||||||
this.subscriptionIds = subscriptionIds;
|
this.subscriptionIds = subscriptionIds;
|
||||||
this.airplaneMode = airplaneMode;
|
this.airplaneMode = airplaneMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CarrierTextCallbackInfo{"
|
||||||
|
+ "carrierText=" + carrierText
|
||||||
|
+ ", listOfCarriers=" + Arrays.toString(listOfCarriers)
|
||||||
|
+ ", anySimReady=" + anySimReady
|
||||||
|
+ ", subscriptionIds=" + Arrays.toString(subscriptionIds)
|
||||||
|
+ ", airplaneMode=" + airplaneMode
|
||||||
|
+ '}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,135 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.keyguard.logging
|
||||||
|
|
||||||
|
import androidx.annotation.IntDef
|
||||||
|
import com.android.keyguard.CarrierTextManager.CarrierTextCallbackInfo
|
||||||
|
import com.android.systemui.dagger.SysUISingleton
|
||||||
|
import com.android.systemui.log.LogBuffer
|
||||||
|
import com.android.systemui.log.LogLevel
|
||||||
|
import com.android.systemui.log.dagger.CarrierTextManagerLog
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
/** Logger adapter for [CarrierTextManager] to add detailed messages in a [LogBuffer] */
|
||||||
|
@SysUISingleton
|
||||||
|
class CarrierTextManagerLogger @Inject constructor(@CarrierTextManagerLog val buffer: LogBuffer) {
|
||||||
|
/**
|
||||||
|
* This method and the methods below trace the execution of CarrierTextManager.updateCarrierText
|
||||||
|
*/
|
||||||
|
fun logUpdate(numSubs: Int) {
|
||||||
|
buffer.log(
|
||||||
|
TAG,
|
||||||
|
LogLevel.VERBOSE,
|
||||||
|
{ int1 = numSubs },
|
||||||
|
{ "updateCarrierText: numSubs=$int1" },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun logUpdateLoopStart(sub: Int, simState: Int, carrierName: String) {
|
||||||
|
buffer.log(
|
||||||
|
TAG,
|
||||||
|
LogLevel.VERBOSE,
|
||||||
|
{
|
||||||
|
int1 = sub
|
||||||
|
int2 = simState
|
||||||
|
str1 = carrierName
|
||||||
|
},
|
||||||
|
{ "┣ updateCarrierText: updating sub=$int1 simState=$int2 carrierName=$str1" },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun logUpdateWfcCheck() {
|
||||||
|
buffer.log(
|
||||||
|
TAG,
|
||||||
|
LogLevel.VERBOSE,
|
||||||
|
{},
|
||||||
|
{ "┣ updateCarrierText: found WFC state" },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun logUpdateFromStickyBroadcast(plmn: String?, spn: String?) {
|
||||||
|
buffer.log(
|
||||||
|
TAG,
|
||||||
|
LogLevel.VERBOSE,
|
||||||
|
{
|
||||||
|
str1 = plmn
|
||||||
|
str2 = spn
|
||||||
|
},
|
||||||
|
{ "┣ updateCarrierText: getting PLMN/SPN sticky brdcst. plmn=$str1, spn=$str1" },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** De-structures the info object so that we don't have to generate new strings */
|
||||||
|
fun logCallbackSentFromUpdate(info: CarrierTextCallbackInfo) {
|
||||||
|
buffer.log(
|
||||||
|
TAG,
|
||||||
|
LogLevel.VERBOSE,
|
||||||
|
{
|
||||||
|
str1 = "${info.carrierText}"
|
||||||
|
bool1 = info.anySimReady
|
||||||
|
bool2 = info.airplaneMode
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"┗ updateCarrierText: " +
|
||||||
|
"result=(carrierText=$str1, anySimReady=$bool1, airplaneMode=$bool2)"
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to log the starting point for _why_ the carrier text is updating. In order to keep us
|
||||||
|
* from holding on to too many objects, we'll just use simple ints for reasons here
|
||||||
|
*/
|
||||||
|
fun logUpdateCarrierTextForReason(@CarrierTextRefreshReason reason: Int) {
|
||||||
|
buffer.log(
|
||||||
|
TAG,
|
||||||
|
LogLevel.DEBUG,
|
||||||
|
{ int1 = reason },
|
||||||
|
{ "refreshing carrier info for reason: ${reason.reasonMessage()}" }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val REASON_REFRESH_CARRIER_INFO = 1
|
||||||
|
const val REASON_ON_TELEPHONY_CAPABLE = 2
|
||||||
|
const val REASON_ON_SIM_STATE_CHANGED = 3
|
||||||
|
const val REASON_ACTIVE_DATA_SUB_CHANGED = 4
|
||||||
|
|
||||||
|
@Retention(AnnotationRetention.SOURCE)
|
||||||
|
@IntDef(
|
||||||
|
value =
|
||||||
|
[
|
||||||
|
REASON_REFRESH_CARRIER_INFO,
|
||||||
|
REASON_ON_TELEPHONY_CAPABLE,
|
||||||
|
REASON_ON_SIM_STATE_CHANGED,
|
||||||
|
REASON_ACTIVE_DATA_SUB_CHANGED,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
annotation class CarrierTextRefreshReason
|
||||||
|
|
||||||
|
private fun @receiver:CarrierTextRefreshReason Int.reasonMessage() =
|
||||||
|
when (this) {
|
||||||
|
REASON_REFRESH_CARRIER_INFO -> "REFRESH_CARRIER_INFO"
|
||||||
|
REASON_ON_TELEPHONY_CAPABLE -> "ON_TELEPHONY_CAPABLE"
|
||||||
|
REASON_ON_SIM_STATE_CHANGED -> "SIM_STATE_CHANGED"
|
||||||
|
REASON_ACTIVE_DATA_SUB_CHANGED -> "ACTIVE_DATA_SUB_CHANGED"
|
||||||
|
else -> "unknown"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private const val TAG = "CarrierTextManagerLog"
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.android.systemui.log.dagger
|
||||||
|
|
||||||
|
import javax.inject.Qualifier
|
||||||
|
|
||||||
|
/** A [LogBuffer] for detailed carrier text logs. */
|
||||||
|
@Qualifier
|
||||||
|
@MustBeDocumented
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
annotation class CarrierTextManagerLog
|
||||||
@@ -372,6 +372,16 @@ public class LogModule {
|
|||||||
return factory.create("KeyguardUpdateMonitorLog", 400);
|
return factory.create("KeyguardUpdateMonitorLog", 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a {@link LogBuffer} for use by {@link com.android.keyguard.KeyguardUpdateMonitor}.
|
||||||
|
*/
|
||||||
|
@Provides
|
||||||
|
@SysUISingleton
|
||||||
|
@CarrierTextManagerLog
|
||||||
|
public static LogBuffer provideCarrierTextManagerLog(LogBufferFactory factory) {
|
||||||
|
return factory.create("CarrierTextManagerLog", 100);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a {@link LogBuffer} for use by {@link com.android.systemui.ScreenDecorations}.
|
* Provides a {@link LogBuffer} for use by {@link com.android.systemui.ScreenDecorations}.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import androidx.annotation.VisibleForTesting
|
|||||||
import com.android.settingslib.SignalIcon
|
import com.android.settingslib.SignalIcon
|
||||||
import com.android.settingslib.mobile.MobileMappings
|
import com.android.settingslib.mobile.MobileMappings
|
||||||
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
|
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
|
||||||
|
import com.android.systemui.dagger.SysUISingleton
|
||||||
import com.android.systemui.dagger.qualifiers.Application
|
import com.android.systemui.dagger.qualifiers.Application
|
||||||
import com.android.systemui.demomode.DemoMode
|
import com.android.systemui.demomode.DemoMode
|
||||||
import com.android.systemui.demomode.DemoModeController
|
import com.android.systemui.demomode.DemoModeController
|
||||||
@@ -62,6 +63,7 @@ import kotlinx.coroutines.flow.stateIn
|
|||||||
*/
|
*/
|
||||||
@Suppress("EXPERIMENTAL_IS_NOT_ENABLED")
|
@Suppress("EXPERIMENTAL_IS_NOT_ENABLED")
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
|
@SysUISingleton
|
||||||
class MobileRepositorySwitcher
|
class MobileRepositorySwitcher
|
||||||
@Inject
|
@Inject
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.pipeline.wifi.data.repository
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.annotation.VisibleForTesting
|
import androidx.annotation.VisibleForTesting
|
||||||
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
|
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
|
||||||
|
import com.android.systemui.dagger.SysUISingleton
|
||||||
import com.android.systemui.dagger.qualifiers.Application
|
import com.android.systemui.dagger.qualifiers.Application
|
||||||
import com.android.systemui.demomode.DemoMode
|
import com.android.systemui.demomode.DemoMode
|
||||||
import com.android.systemui.demomode.DemoModeController
|
import com.android.systemui.demomode.DemoModeController
|
||||||
@@ -54,6 +55,7 @@ import kotlinx.coroutines.flow.stateIn
|
|||||||
*/
|
*/
|
||||||
@Suppress("EXPERIMENTAL_IS_NOT_ENABLED")
|
@Suppress("EXPERIMENTAL_IS_NOT_ENABLED")
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
|
@SysUISingleton
|
||||||
class WifiRepositorySwitcher
|
class WifiRepositorySwitcher
|
||||||
@Inject
|
@Inject
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import static android.telephony.SubscriptionManager.DATA_ROAMING_DISABLE;
|
|||||||
import static android.telephony.SubscriptionManager.DATA_ROAMING_ENABLE;
|
import static android.telephony.SubscriptionManager.DATA_ROAMING_ENABLE;
|
||||||
import static android.telephony.SubscriptionManager.NAME_SOURCE_CARRIER_ID;
|
import static android.telephony.SubscriptionManager.NAME_SOURCE_CARRIER_ID;
|
||||||
|
|
||||||
|
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertTrue;
|
import static junit.framework.Assert.assertTrue;
|
||||||
@@ -30,13 +32,18 @@ import static org.junit.Assert.assertEquals;
|
|||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
import static org.mockito.Mockito.doAnswer;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.reset;
|
import static org.mockito.Mockito.reset;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
@@ -47,8 +54,10 @@ import android.test.suitebuilder.annotation.SmallTest;
|
|||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.android.keyguard.logging.CarrierTextManagerLogger;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
|
import com.android.systemui.dump.LogBufferHelperKt;
|
||||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||||
import com.android.systemui.statusbar.pipeline.wifi.data.repository.FakeWifiRepository;
|
import com.android.systemui.statusbar.pipeline.wifi.data.repository.FakeWifiRepository;
|
||||||
import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel;
|
import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel;
|
||||||
@@ -110,6 +119,10 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
private CarrierTextManager mCarrierTextManager;
|
private CarrierTextManager mCarrierTextManager;
|
||||||
|
|
||||||
|
private CarrierTextManagerLogger mLogger =
|
||||||
|
new CarrierTextManagerLogger(
|
||||||
|
LogBufferHelperKt.logcatLogBuffer("CarrierTextManagerLog"));
|
||||||
|
|
||||||
private Void checkMainThread(InvocationOnMock inv) {
|
private Void checkMainThread(InvocationOnMock inv) {
|
||||||
assertThat(mMainExecutor.isExecuting()).isTrue();
|
assertThat(mMainExecutor.isExecuting()).isTrue();
|
||||||
assertThat(mBgExecutor.isExecuting()).isFalse();
|
assertThat(mBgExecutor.isExecuting()).isFalse();
|
||||||
@@ -144,7 +157,7 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
|||||||
mCarrierTextManager = new CarrierTextManager.Builder(
|
mCarrierTextManager = new CarrierTextManager.Builder(
|
||||||
mContext, mContext.getResources(), mWifiRepository,
|
mContext, mContext.getResources(), mWifiRepository,
|
||||||
mTelephonyManager, mTelephonyListenerManager, mWakefulnessLifecycle, mMainExecutor,
|
mTelephonyManager, mTelephonyListenerManager, mWakefulnessLifecycle, mMainExecutor,
|
||||||
mBgExecutor, mKeyguardUpdateMonitor)
|
mBgExecutor, mKeyguardUpdateMonitor, mLogger)
|
||||||
.setShowAirplaneMode(true)
|
.setShowAirplaneMode(true)
|
||||||
.setShowMissingSim(true)
|
.setShowMissingSim(true)
|
||||||
.build();
|
.build();
|
||||||
@@ -183,6 +196,47 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
|||||||
assertEquals(AIRPLANE_MODE_TEXT, captor.getValue().carrierText);
|
assertEquals(AIRPLANE_MODE_TEXT, captor.getValue().carrierText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** regression test for b/281706473, caused by sending NULL plmn / spn to the logger */
|
||||||
|
@Test
|
||||||
|
public void testAirplaneMode_noSim_nullPlmn_nullSpn_doesNotCrash() {
|
||||||
|
// GIVEN - sticy broadcast that returns a null PLMN and null SPN
|
||||||
|
Intent stickyIntent = new Intent(TelephonyManager.ACTION_SERVICE_PROVIDERS_UPDATED);
|
||||||
|
stickyIntent.putExtra(TelephonyManager.EXTRA_SHOW_PLMN, true);
|
||||||
|
stickyIntent.removeExtra(TelephonyManager.EXTRA_PLMN);
|
||||||
|
stickyIntent.putExtra(TelephonyManager.EXTRA_SHOW_SPN, true);
|
||||||
|
stickyIntent.removeExtra(TelephonyManager.EXTRA_SPN);
|
||||||
|
|
||||||
|
mCarrierTextManager = new CarrierTextManager.Builder(
|
||||||
|
getContextSpyForStickyBroadcast(stickyIntent),
|
||||||
|
mContext.getResources(),
|
||||||
|
mWifiRepository,
|
||||||
|
mTelephonyManager,
|
||||||
|
mTelephonyListenerManager,
|
||||||
|
mWakefulnessLifecycle,
|
||||||
|
mMainExecutor,
|
||||||
|
mBgExecutor,
|
||||||
|
mKeyguardUpdateMonitor,
|
||||||
|
mLogger
|
||||||
|
)
|
||||||
|
.setShowAirplaneMode(true)
|
||||||
|
.setShowMissingSim(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// GIVEN - airplane mode is off (causing CTM to fetch the sticky broadcast)
|
||||||
|
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
|
||||||
|
reset(mCarrierTextCallback);
|
||||||
|
List<SubscriptionInfo> list = new ArrayList<>();
|
||||||
|
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo()).thenReturn(list);
|
||||||
|
when(mKeyguardUpdateMonitor.getSimState(0))
|
||||||
|
.thenReturn(TelephonyManager.SIM_STATE_NOT_READY);
|
||||||
|
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||||
|
|
||||||
|
// WHEN CTM fetches the broadcast and attempts to log the result, no crash results
|
||||||
|
mCarrierTextManager.updateCarrierText();
|
||||||
|
|
||||||
|
// No assert, this test should not crash
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCardIOError() {
|
public void testCardIOError() {
|
||||||
reset(mCarrierTextCallback);
|
reset(mCarrierTextCallback);
|
||||||
@@ -506,4 +560,10 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
|||||||
assertEquals(TEST_CARRIER + SEPARATOR + TEST_CARRIER,
|
assertEquals(TEST_CARRIER + SEPARATOR + TEST_CARRIER,
|
||||||
captor.getValue().carrierText);
|
captor.getValue().carrierText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Context getContextSpyForStickyBroadcast(Intent returnVal) {
|
||||||
|
Context contextSpy = spy(mContext);
|
||||||
|
doReturn(returnVal).when(contextSpy).registerReceiver(eq(null), any(IntentFilter.class));
|
||||||
|
return contextSpy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user