Merge "Fixed race condition while powering down" into main
diff --git a/flags/network.aconfig b/flags/network.aconfig
index 7c09ba3..be599ea 100644
--- a/flags/network.aconfig
+++ b/flags/network.aconfig
@@ -93,3 +93,20 @@
}
}
+# OWNER=yomna TARGET=25Q2
+flag {
+ name: "security_algorithms_update_indications"
+ is_exported: true
+ namespace: "telephony"
+ description: "guard system API onSecurityAlgorithmsChanged"
+ bug: "355062720"
+}
+
+# OWNER=yomna TARGET=25Q2
+flag {
+ name: "cellular_identifier_disclosure_indications"
+ is_exported: true
+ namespace: "telephony"
+ description: "guard system API onCellularIdentifierDisclosedChanged"
+ bug: "355062720"
+}
diff --git a/src/java/com/android/internal/telephony/DefaultPhoneNotifier.java b/src/java/com/android/internal/telephony/DefaultPhoneNotifier.java
index 732582f..dc05608 100644
--- a/src/java/com/android/internal/telephony/DefaultPhoneNotifier.java
+++ b/src/java/com/android/internal/telephony/DefaultPhoneNotifier.java
@@ -25,12 +25,14 @@
import android.telephony.CallQuality;
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
+import android.telephony.CellularIdentifierDisclosure;
import android.telephony.LinkCapacityEstimate;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.PhoneCapability;
import android.telephony.PhysicalChannelConfig;
import android.telephony.PreciseCallState;
import android.telephony.PreciseDataConnectionState;
+import android.telephony.SecurityAlgorithmUpdate;
import android.telephony.ServiceState;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager.DataEnabledReason;
@@ -356,6 +358,23 @@
sender.getSubId(), ntnSignalStrength);
}
+ @Override
+ public void notifySecurityAlgorithmsChanged(Phone sender, SecurityAlgorithmUpdate update) {
+ if (!mFeatureFlags.securityAlgorithmsUpdateIndications()) return;
+
+ mTelephonyRegistryMgr.notifySecurityAlgorithmsChanged(sender.getPhoneId(),
+ sender.getSubId(), update);
+ }
+
+ @Override
+ public void notifyCellularIdentifierDisclosedChanged(Phone sender,
+ CellularIdentifierDisclosure disclosure) {
+ if (!mFeatureFlags.cellularIdentifierDisclosureIndications()) return;
+
+ mTelephonyRegistryMgr.notifyCellularIdentifierDisclosedChanged(sender.getPhoneId(),
+ sender.getSubId(), disclosure);
+ }
+
/**
* Convert the {@link Call.State} enum into the PreciseCallState.PRECISE_CALL_STATE_* constants
* for the public API.
diff --git a/src/java/com/android/internal/telephony/PhoneNotifier.java b/src/java/com/android/internal/telephony/PhoneNotifier.java
index faf4fd1..6c8b222 100644
--- a/src/java/com/android/internal/telephony/PhoneNotifier.java
+++ b/src/java/com/android/internal/telephony/PhoneNotifier.java
@@ -25,11 +25,13 @@
import android.telephony.CallQuality;
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
+import android.telephony.CellularIdentifierDisclosure;
import android.telephony.LinkCapacityEstimate;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.PhoneCapability;
import android.telephony.PhysicalChannelConfig;
import android.telephony.PreciseDataConnectionState;
+import android.telephony.SecurityAlgorithmUpdate;
import android.telephony.ServiceState;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager.DataEnabledReason;
@@ -174,4 +176,11 @@
/** Notify carrier roaming non-terrestrial network signal strength changed. */
void notifyCarrierRoamingNtnSignalStrengthChanged(Phone sender,
@NonNull NtnSignalStrength ntnSignalStrength);
+
+ /** Notify of a cellular identifier disclosure change. */
+ void notifyCellularIdentifierDisclosedChanged(Phone sender,
+ CellularIdentifierDisclosure disclosure);
+
+ /** Notify of a security algorithm update change. */
+ void notifySecurityAlgorithmsChanged(Phone sender, SecurityAlgorithmUpdate update);
}
diff --git a/tests/telephonytests/src/com/android/internal/telephony/DefaultPhoneNotifierTest.java b/tests/telephonytests/src/com/android/internal/telephony/DefaultPhoneNotifierTest.java
index 8720171..522cdac 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/DefaultPhoneNotifierTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/DefaultPhoneNotifierTest.java
@@ -15,6 +15,12 @@
*/
package com.android.internal.telephony;
+import static android.telephony.CellularIdentifierDisclosure.CELLULAR_IDENTIFIER_IMSI;
+import static android.telephony.CellularIdentifierDisclosure.NAS_PROTOCOL_MESSAGE_ATTACH_REQUEST;
+import static android.telephony.SecurityAlgorithmUpdate.CONNECTION_EVENT_VOLTE_SIP;
+import static android.telephony.SecurityAlgorithmUpdate.SECURITY_ALGORITHM_EEA2;
+import static android.telephony.SecurityAlgorithmUpdate.SECURITY_ALGORITHM_HMAC_SHA1_96;
+
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq;
@@ -26,9 +32,11 @@
import android.telephony.CellIdentityGsm;
import android.telephony.CellInfo;
+import android.telephony.CellularIdentifierDisclosure;
import android.telephony.DisconnectCause;
import android.telephony.PreciseCallState;
import android.telephony.PreciseDisconnectCause;
+import android.telephony.SecurityAlgorithmUpdate;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsCallProfile;
@@ -449,4 +457,35 @@
verify(mTelephonyRegistryManager).notifyCarrierRoamingNtnAvailableServicesChanged(
eq(subId), eq(testServices));
}
+
+ @Test
+ @SmallTest
+ public void testSecurityAlgorithmsChanged() {
+ doReturn(true).when(mFeatureFlags).securityAlgorithmsUpdateIndications();
+ int phoneId = mPhone.getPhoneId();
+ int subId = mPhone.getSubId();
+ SecurityAlgorithmUpdate update =
+ new SecurityAlgorithmUpdate(
+ CONNECTION_EVENT_VOLTE_SIP, SECURITY_ALGORITHM_EEA2,
+ SECURITY_ALGORITHM_HMAC_SHA1_96, false);
+ mDefaultPhoneNotifierUT.notifySecurityAlgorithmsChanged(mPhone, update);
+ verify(mTelephonyRegistryManager).notifySecurityAlgorithmsChanged(
+ eq(phoneId), eq(subId), eq(update));
+ }
+
+ @Test
+ @SmallTest
+ public void testCellularIdentifierDisclosedChanged() {
+ doReturn(true).when(mFeatureFlags).cellularIdentifierDisclosureIndications();
+ int phoneId = mPhone.getPhoneId();
+ int subId = mPhone.getSubId();
+ CellularIdentifierDisclosure disclosure =
+ new CellularIdentifierDisclosure(NAS_PROTOCOL_MESSAGE_ATTACH_REQUEST,
+ CELLULAR_IDENTIFIER_IMSI,
+ "001001",
+ false);
+ mDefaultPhoneNotifierUT.notifyCellularIdentifierDisclosedChanged(mPhone, disclosure);
+ verify(mTelephonyRegistryManager).notifyCellularIdentifierDisclosedChanged(
+ eq(phoneId), eq(subId), eq(disclosure));
+ }
}
diff --git a/tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java b/tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java
index 2ff38b2..5dc4719 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java
@@ -15,7 +15,12 @@
*/
package com.android.internal.telephony;
+import static android.telephony.CellularIdentifierDisclosure.CELLULAR_IDENTIFIER_IMSI;
+import static android.telephony.CellularIdentifierDisclosure.NAS_PROTOCOL_MESSAGE_ATTACH_REQUEST;
import static android.telephony.PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN;
+import static android.telephony.SecurityAlgorithmUpdate.CONNECTION_EVENT_VOLTE_SIP;
+import static android.telephony.SecurityAlgorithmUpdate.SECURITY_ALGORITHM_EEA2;
+import static android.telephony.SecurityAlgorithmUpdate.SECURITY_ALGORITHM_HMAC_SHA1_96;
import static android.telephony.ServiceState.FREQUENCY_RANGE_LOW;
import static android.telephony.SubscriptionManager.ACTION_DEFAULT_SUBSCRIPTION_CHANGED;
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
@@ -57,11 +62,13 @@
import android.telephony.CellInfo;
import android.telephony.CellInfoLte;
import android.telephony.CellLocation;
+import android.telephony.CellularIdentifierDisclosure;
import android.telephony.LinkCapacityEstimate;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.PhoneCapability;
import android.telephony.PhysicalChannelConfig;
import android.telephony.PreciseDataConnectionState;
+import android.telephony.SecurityAlgorithmUpdate;
import android.telephony.ServiceState;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
@@ -181,6 +188,10 @@
TelephonyCallback.EVENT_EMERGENCY_CALLBACK_MODE_CHANGED);
READ_PRIVILEGED_PHONE_STATE_EVENTS.add(
TelephonyCallback.EVENT_SIMULTANEOUS_CELLULAR_CALLING_SUBSCRIPTIONS_CHANGED);
+ READ_PRIVILEGED_PHONE_STATE_EVENTS.add(
+ TelephonyCallback.EVENT_CELLULAR_IDENTIFIER_DISCLOSED_CHANGED);
+ READ_PRIVILEGED_PHONE_STATE_EVENTS.add(
+ TelephonyCallback.EVENT_SECURITY_ALGORITHMS_CHANGED);
}
// All events contribute to TelephonyRegistry#isActiveEmergencySessionPermissionRequired
@@ -211,7 +222,9 @@
TelephonyCallback.DataActivityListener,
TelephonyCallback.SimultaneousCellularCallingSupportListener,
TelephonyCallback.EmergencyCallbackModeListener,
- TelephonyCallback.CarrierRoamingNtnModeListener {
+ TelephonyCallback.CarrierRoamingNtnModeListener,
+ TelephonyCallback.SecurityAlgorithmsListener,
+ TelephonyCallback.CellularIdentifierDisclosedListener {
// This class isn't mockable to get invocation counts because the IBinder is null and
// crashes the TelephonyRegistry. Make a cheesy verify(times()) alternative.
public AtomicInteger invocationCount = new AtomicInteger(0);
@@ -351,6 +364,16 @@
invocationCount.incrementAndGet();
mCarrierRoamingNtnSignalStrength = ntnSignalStrength;
}
+
+ @Override
+ public void onSecurityAlgorithmsChanged(SecurityAlgorithmUpdate update) {
+ invocationCount.incrementAndGet();
+ }
+
+ @Override
+ public void onCellularIdentifierDisclosedChanged(CellularIdentifierDisclosure disclosure) {
+ invocationCount.incrementAndGet();
+ }
}
public class MySatelliteStateChangeListener implements ISatelliteStateChangeListener {
@@ -1838,4 +1861,49 @@
// We should not receive the new state change after monitoring end
assertFalse(mIsSatelliteEnabled);
}
+
+
+ @Test
+ @EnableFlags(Flags.FLAG_SECURITY_ALGORITHMS_UPDATE_INDICATIONS)
+ public void testNotifySecurityAlgorithmsChanged() {
+ int subId = 1;
+ int[] events = {TelephonyCallback.EVENT_SECURITY_ALGORITHMS_CHANGED};
+
+ mTelephonyRegistry.listenWithEventList(false, false, subId, mContext.getOpPackageName(),
+ mContext.getAttributionTag(), mTelephonyCallback.callback, events, false);
+
+ SecurityAlgorithmUpdate update =
+ new SecurityAlgorithmUpdate(
+ CONNECTION_EVENT_VOLTE_SIP, SECURITY_ALGORITHM_EEA2,
+ SECURITY_ALGORITHM_HMAC_SHA1_96, false);
+
+ mTelephonyRegistry.listenWithEventList(false, false, subId, mContext.getOpPackageName(),
+ mContext.getAttributionTag(), mTelephonyCallback.callback, events, false);
+ int invocationCount = mTelephonyCallback.invocationCount.get();
+ mTelephonyRegistry.notifySecurityAlgorithmsChanged(0, 1, update);
+ processAllMessages();
+ assertEquals(invocationCount + 1, mTelephonyCallback.invocationCount.get());
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_CELLULAR_IDENTIFIER_DISCLOSURE_INDICATIONS)
+ public void testNotifyCellularIdentifierDisclosedChanged() {
+ int subId = 1;
+ int[] events = {TelephonyCallback.EVENT_CELLULAR_IDENTIFIER_DISCLOSED_CHANGED};
+
+ CellularIdentifierDisclosure disclosure =
+ new CellularIdentifierDisclosure(NAS_PROTOCOL_MESSAGE_ATTACH_REQUEST,
+ CELLULAR_IDENTIFIER_IMSI,
+ "001001",
+ false);
+
+ mTelephonyRegistry.listenWithEventList(false, false, subId, mContext.getOpPackageName(),
+ mContext.getAttributionTag(), mTelephonyCallback.callback, events, false);
+ int invocationCount = mTelephonyCallback.invocationCount.get();
+ mTelephonyRegistry.notifyCellularIdentifierDisclosedChanged(0, 1,
+ disclosure);
+ processAllMessages();
+ assertEquals(invocationCount + 1, mTelephonyCallback.invocationCount.get());
+ }
+
}