Merge "[Carrier text] add debug location to logs" into udc-dev

This commit is contained in:
Evan Laird
2023-05-15 19:10:19 +00:00
committed by Android (Google) Code Review
9 changed files with 40 additions and 6 deletions

View File

@@ -39,7 +39,8 @@
android:ellipsize="marquee"
android:visibility="gone"
android:gravity="center"
androidprv:allCaps="@bool/kg_use_all_caps" />
androidprv:allCaps="@bool/kg_use_all_caps"
androidprv:debugLocation="Emergency" />
<com.android.keyguard.EmergencyButton
android:id="@+id/emergency_call_button"

View File

@@ -78,6 +78,7 @@
android:textColor="?attr/wallpaperTextColorSecondary"
android:singleLine="true"
systemui:showMissingSim="true"
systemui:showAirplaneMode="true" />
systemui:showAirplaneMode="true"
systemui:debugLocation="Keyguard" />
</com.android.systemui.statusbar.phone.KeyguardStatusBarView>

View File

@@ -146,6 +146,7 @@
<attr name="allCaps" format="boolean" />
<attr name="showMissingSim" format="boolean" />
<attr name="showAirplaneMode" format="boolean" />
<attr name="debugLocation" format="string" />
</declare-styleable>
<declare-styleable name="IlluminationDrawable">

View File

@@ -33,6 +33,8 @@ public class CarrierText extends TextView {
private final boolean mShowAirplaneMode;
private final String mDebugLocation;
public CarrierText(Context context) {
this(context, null);
}
@@ -46,6 +48,7 @@ public class CarrierText extends TextView {
useAllCaps = a.getBoolean(R.styleable.CarrierText_allCaps, false);
mShowAirplaneMode = a.getBoolean(R.styleable.CarrierText_showAirplaneMode, false);
mShowMissingSim = a.getBoolean(R.styleable.CarrierText_showMissingSim, false);
mDebugLocation = a.getString(R.styleable.CarrierText_debugLocation);
} finally {
a.recycle();
}
@@ -70,6 +73,10 @@ public class CarrierText extends TextView {
return mShowMissingSim;
}
public String getDebugLocation() {
return mDebugLocation;
}
private static class CarrierTextTransformationMethod extends SingleLineTransformationMethod {
private final Locale mLocale;
private final boolean mAllCaps;

View File

@@ -53,6 +53,7 @@ public class CarrierTextController extends ViewController<CarrierText> {
mCarrierTextManager = carrierTextManagerBuilder
.setShowAirplaneMode(mView.getShowAirplaneMode())
.setShowMissingSim(mView.getShowMissingSim())
.setDebugLocationString(mView.getDebugLocation())
.build();
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
}

View File

@@ -651,6 +651,7 @@ public class CarrierTextManager {
private final CarrierTextManagerLogger mLogger;
private boolean mShowAirplaneMode;
private boolean mShowMissingSim;
private String mDebugLocation;
@Inject
public Builder(
@@ -689,14 +690,25 @@ public class CarrierTextManager {
return this;
}
/**
* To help disambiguate logs, set a location to be used in the LogBuffer calls, e.g.:
* "keyguard" or "keyguard emergency status bar"
*/
public Builder setDebugLocationString(String debugLocationString) {
mDebugLocation = debugLocationString;
return this;
}
/** Create a CarrierTextManager. */
public CarrierTextManager build() {
mLogger.setLocation(mDebugLocation);
return new CarrierTextManager(
mContext, mSeparator, mShowAirplaneMode, mShowMissingSim, mWifiRepository,
mTelephonyManager, mTelephonyListenerManager, mWakefulnessLifecycle,
mMainExecutor, mBgExecutor, mKeyguardUpdateMonitor, mLogger);
}
}
/**
* Data structure for passing information to CarrierTextController subscribers
*/

View File

@@ -18,15 +18,19 @@ 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) {
/**
* To help disambiguate carrier text manager instances, set a location string here which will
* propagate to [logUpdate] and [logUpdateCarrierTextForReason]
*/
var location: String? = null
/**
* This method and the methods below trace the execution of CarrierTextManager.updateCarrierText
*/
@@ -35,7 +39,7 @@ class CarrierTextManagerLogger @Inject constructor(@CarrierTextManagerLog val bu
TAG,
LogLevel.VERBOSE,
{ int1 = numSubs },
{ "updateCarrierText: numSubs=$int1" },
{ "updateCarrierText: location=${location ?: "(unknown)"} numSubs=$int1" },
)
}
@@ -99,7 +103,10 @@ class CarrierTextManagerLogger @Inject constructor(@CarrierTextManagerLog val bu
TAG,
LogLevel.DEBUG,
{ int1 = reason },
{ "refreshing carrier info for reason: ${reason.reasonMessage()}" }
{
"refreshing carrier info for reason: ${reason.reasonMessage()}" +
" location=${location ?: "(unknown)"}"
}
)
}

View File

@@ -141,6 +141,7 @@ public class ShadeCarrierGroupController {
mCarrierTextManager = carrierTextManagerBuilder
.setShowAirplaneMode(false)
.setShowMissingSim(false)
.setDebugLocationString("Shade")
.build();
mCarrierConfigTracker = carrierConfigTracker;
mSlotIndexResolver = slotIndexResolver;

View File

@@ -23,6 +23,7 @@ import static org.junit.Assert.assertFalse;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -109,6 +110,8 @@ public class ShadeCarrierGroupControllerTest extends LeakCheckedTest {
.thenReturn(mCarrierTextControllerBuilder);
when(mCarrierTextControllerBuilder.setShowMissingSim(anyBoolean()))
.thenReturn(mCarrierTextControllerBuilder);
when(mCarrierTextControllerBuilder.setDebugLocationString(anyString()))
.thenReturn(mCarrierTextControllerBuilder);
when(mCarrierTextControllerBuilder.build()).thenReturn(mCarrierTextManager);
doAnswer(invocation -> mCallback = invocation.getArgument(0))