Merge "Refresh carrier info on SERVICE_PROVIDERS_UPDATED" into udc-dev

This commit is contained in:
Evan Laird
2023-05-25 18:36:53 +00:00
committed by Android (Google) Code Review
3 changed files with 52 additions and 0 deletions

View File

@@ -246,6 +246,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
private static final int MSG_TIME_FORMAT_UPDATE = 344; private static final int MSG_TIME_FORMAT_UPDATE = 344;
private static final int MSG_REQUIRE_NFC_UNLOCK = 345; private static final int MSG_REQUIRE_NFC_UNLOCK = 345;
private static final int MSG_KEYGUARD_DISMISS_ANIMATION_FINISHED = 346; private static final int MSG_KEYGUARD_DISMISS_ANIMATION_FINISHED = 346;
private static final int MSG_SERVICE_PROVIDERS_UPDATED = 347;
/** Biometric authentication state: Not listening. */ /** Biometric authentication state: Not listening. */
private static final int BIOMETRIC_STATE_STOPPED = 0; private static final int BIOMETRIC_STATE_STOPPED = 0;
@@ -1826,6 +1827,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
} else if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) { } else if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE); String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
mHandler.sendMessage(mHandler.obtainMessage(MSG_PHONE_STATE_CHANGED, state)); mHandler.sendMessage(mHandler.obtainMessage(MSG_PHONE_STATE_CHANGED, state));
} else if (TelephonyManager.ACTION_SERVICE_PROVIDERS_UPDATED.equals(action)) {
mHandler.obtainMessage(MSG_SERVICE_PROVIDERS_UPDATED, intent).sendToTarget();
} else if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(action)) { } else if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(action)) {
mHandler.sendEmptyMessage(MSG_AIRPLANE_MODE_CHANGED); mHandler.sendEmptyMessage(MSG_AIRPLANE_MODE_CHANGED);
} else if (Intent.ACTION_SERVICE_STATE.equals(action)) { } else if (Intent.ACTION_SERVICE_STATE.equals(action)) {
@@ -2402,6 +2405,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
case MSG_SERVICE_STATE_CHANGE: case MSG_SERVICE_STATE_CHANGE:
handleServiceStateChange(msg.arg1, (ServiceState) msg.obj); handleServiceStateChange(msg.arg1, (ServiceState) msg.obj);
break; break;
case MSG_SERVICE_PROVIDERS_UPDATED:
handleServiceProvidersUpdated((Intent) msg.obj);
break;
case MSG_SCREEN_TURNED_OFF: case MSG_SCREEN_TURNED_OFF:
Trace.beginSection("KeyguardUpdateMonitor#handler MSG_SCREEN_TURNED_OFF"); Trace.beginSection("KeyguardUpdateMonitor#handler MSG_SCREEN_TURNED_OFF");
handleScreenTurnedOff(); handleScreenTurnedOff();
@@ -2472,6 +2478,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
filter.addAction(Intent.ACTION_SERVICE_STATE); filter.addAction(Intent.ACTION_SERVICE_STATE);
filter.addAction(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED); filter.addAction(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED); filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
filter.addAction(TelephonyManager.ACTION_SERVICE_PROVIDERS_UPDATED);
filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED); filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
filter.addAction(UsbManager.ACTION_USB_PORT_COMPLIANCE_CHANGED); filter.addAction(UsbManager.ACTION_USB_PORT_COMPLIANCE_CHANGED);
mBroadcastDispatcher.registerReceiverWithHandler(mBroadcastReceiver, filter, mHandler); mBroadcastDispatcher.registerReceiverWithHandler(mBroadcastReceiver, filter, mHandler);
@@ -3726,6 +3733,14 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
callbacksRefreshCarrierInfo(); callbacksRefreshCarrierInfo();
} }
/**
* Handle {@link #MSG_SERVICE_PROVIDERS_UPDATED}
*/
private void handleServiceProvidersUpdated(Intent intent) {
mLogger.logServiceProvidersUpdated(intent);
callbacksRefreshCarrierInfo();
}
/** /**
* Whether the keyguard is showing and not occluded. * Whether the keyguard is showing and not occluded.
*/ */

View File

@@ -16,11 +16,15 @@
package com.android.keyguard.logging package com.android.keyguard.logging
import android.content.Intent
import android.hardware.biometrics.BiometricConstants.LockoutMode import android.hardware.biometrics.BiometricConstants.LockoutMode
import android.os.PowerManager import android.os.PowerManager
import android.os.PowerManager.WakeReason import android.os.PowerManager.WakeReason
import android.telephony.ServiceState import android.telephony.ServiceState
import android.telephony.SubscriptionInfo import android.telephony.SubscriptionInfo
import android.telephony.SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX
import android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID
import android.telephony.TelephonyManager
import com.android.keyguard.ActiveUnlockConfig import com.android.keyguard.ActiveUnlockConfig
import com.android.keyguard.FaceAuthUiEvent import com.android.keyguard.FaceAuthUiEvent
import com.android.keyguard.KeyguardListenModel import com.android.keyguard.KeyguardListenModel
@@ -363,6 +367,21 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
) )
} }
fun logServiceProvidersUpdated(intent: Intent) {
logBuffer.log(
TAG,
VERBOSE,
{
int1 = intent.getIntExtra(EXTRA_SUBSCRIPTION_INDEX, INVALID_SUBSCRIPTION_ID)
str1 = intent.getStringExtra(TelephonyManager.EXTRA_SPN)
str2 = intent.getStringExtra(TelephonyManager.EXTRA_PLMN)
},
{
"action SERVICE_PROVIDERS_UPDATED subId=$int1 spn=$str1 plmn=$str2"
}
)
}
fun logSimState(subId: Int, slotId: Int, state: Int) { fun logSimState(subId: Int, slotId: Int, state: Int) {
logBuffer.log( logBuffer.log(
TAG, TAG,

View File

@@ -653,6 +653,24 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
assertThat(mKeyguardUpdateMonitor.mTelephonyCapable).isTrue(); assertThat(mKeyguardUpdateMonitor.mTelephonyCapable).isTrue();
} }
@Test
public void serviceProvidersUpdated_broadcastTriggersInfoRefresh() {
// The callback is invoked once on init
verify(mTestCallback, times(1)).onRefreshCarrierInfo();
// WHEN the SERVICE_PROVIDERS_UPDATED broadcast is sent
Intent intent = new Intent(TelephonyManager.ACTION_SERVICE_PROVIDERS_UPDATED);
intent.putExtra(TelephonyManager.EXTRA_SPN, "spn");
intent.putExtra(TelephonyManager.EXTRA_PLMN, "plmn");
mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext(),
putPhoneInfo(intent, null, true));
mTestableLooper.processAllMessages();
// THEN verify keyguardUpdateMonitorCallback receives a refresh callback
// Note that we have times(2) here because it's been called once already
verify(mTestCallback, times(2)).onRefreshCarrierInfo();
}
@Test @Test
public void testTriesToAuthenticateFingerprint_whenKeyguard() { public void testTriesToAuthenticateFingerprint_whenKeyguard() {
mKeyguardUpdateMonitor.dispatchStartedGoingToSleep(0 /* why */); mKeyguardUpdateMonitor.dispatchStartedGoingToSleep(0 /* why */);