Merge "Merge Android 12 QPR3 ab/8391262" into stage-aosp-master
diff --git a/src/com/android/phone/ImsStateCallbackController.java b/src/com/android/phone/ImsStateCallbackController.java
index a7caab0..57c1787 100644
--- a/src/com/android/phone/ImsStateCallbackController.java
+++ b/src/com/android/phone/ImsStateCallbackController.java
@@ -296,6 +296,8 @@
logd(mLogPrefix + "connectionReady " + subId);
mSubId = subId;
+ if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) return;
+
mState = STATE_READY;
mReason = AVAILABLE;
mHasConfig = true;
@@ -439,6 +441,8 @@
logd(mLogPrefix + "connectionReady " + subId);
mSubId = subId;
+ if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) return;
+
mState = STATE_READY;
mReason = AVAILABLE;
mHasConfig = true;
@@ -642,7 +646,7 @@
}
void notifyInactive() {
- if (VDBG) logv("CallbackWrapper notifyInactive subId=" + mSubId);
+ logd("CallbackWrapper notifyInactive subId=" + mSubId);
try {
mCallback.onUnavailable(REASON_SUBSCRIPTION_INACTIVE);
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index eb1cf77..077c2a1 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -11219,11 +11219,17 @@
Log.d(LOG_TAG, "getModemService");
TelephonyPermissions.enforceShellOnly(Binder.getCallingUid(), "getModemService");
TelephonyPermissions
- .enforceCallingOrSelfReadPrivilegedPhoneStatePermissionOrCarrierPrivilege(
+ .enforceCallingOrSelfReadPrivilegedPhoneStatePermissionOrCarrierPrivilege(
mApp, SubscriptionManager.INVALID_SUBSCRIPTION_ID,
"getModemService");
result = mPhoneConfigurationManager.getModemService();
Log.d(LOG_TAG, "result = " + result);
return result;
}
+
+ @Override
+ public boolean isUsingNewDataStack() {
+ TelephonyPermissions.enforceShellOnly(Binder.getCallingUid(), "isUsingNewDataStack");
+ return getDefaultPhone().isUsingNewDataStack();
+ }
}
diff --git a/src/com/android/phone/TelephonyShellCommand.java b/src/com/android/phone/TelephonyShellCommand.java
index 7fbdbad..ac83fa9 100644
--- a/src/com/android/phone/TelephonyShellCommand.java
+++ b/src/com/android/phone/TelephonyShellCommand.java
@@ -30,6 +30,7 @@
import android.os.RemoteException;
import android.os.ServiceSpecificException;
import android.provider.BlockedNumberContract;
+import android.provider.DeviceConfig;
import android.telephony.BarringInfo;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionInfo;
@@ -171,6 +172,8 @@
"get-allowed-network-types-for-users";
private static final String SET_ALLOWED_NETWORK_TYPES_FOR_USER =
"set-allowed-network-types-for-users";
+ // Check if telephony new data stack is enabled.
+ private static final String GET_DATA_MODE = "get-data-mode";
// Take advantage of existing methods that already contain permissions checks when possible.
private final ITelephony mInterface;
@@ -325,6 +328,8 @@
case GET_ALLOWED_NETWORK_TYPES_FOR_USER:
case SET_ALLOWED_NETWORK_TYPES_FOR_USER:
return handleAllowedNetworkTypesCommand(cmd);
+ case GET_DATA_MODE:
+ return handleGetDataMode();
default: {
return handleDefaultCommands(cmd);
}
@@ -2910,4 +2915,35 @@
return -1;
}
+
+ private int handleGetDataMode() {
+ if (!checkShellUid()) {
+ return -1;
+ }
+
+ boolean newDataStackEnabled = false;
+ try {
+ newDataStackEnabled = mInterface.isUsingNewDataStack();
+ } catch (RemoteException e) {
+ getOutPrintWriter().println("Something went wrong. " + e);
+ return -1;
+ }
+
+ getOutPrintWriter().println("Telephony new data stack is "
+ + (newDataStackEnabled ? "enabled." : "disabled."));
+
+ boolean configEnabled = Boolean.parseBoolean(DeviceConfig.getProperty(
+ DeviceConfig.NAMESPACE_TELEPHONY, "new_telephony_data_enabled"));
+ if (configEnabled != newDataStackEnabled) {
+ getOutPrintWriter().println("The config has been "
+ + (configEnabled ? "enabled" : "disabled") + ". Need to reboot the device.");
+ } else {
+ getOutPrintWriter().println("Run the following command to "
+ + (configEnabled ? "disable" : "enable") + " the new telephony data stack.");
+ getOutPrintWriter().println("adb root && adb shell device_config put telephony "
+ + "new_telephony_data_enabled " + (configEnabled ? "false" : "true")
+ + " && adb reboot");
+ }
+ return 0;
+ }
}
diff --git a/tests/src/com/android/phone/ImsStateCallbackControllerTest.java b/tests/src/com/android/phone/ImsStateCallbackControllerTest.java
index cbd6ceb..cb4321c 100644
--- a/tests/src/com/android/phone/ImsStateCallbackControllerTest.java
+++ b/tests/src/com/android/phone/ImsStateCallbackControllerTest.java
@@ -822,6 +822,58 @@
verify(mRcsFeatureConnectorSlot0, times(0)).disconnect();
}
+ @Test
+ @SmallTest
+ public void testMmTelConnectionReadyWhenReEnableSim() throws Exception {
+ createController(1);
+
+ // MMTEL feature
+ mMmTelConnectorListenerSlot0.getValue().connectionReady(null, SLOT_0_SUB_ID);
+ processAllMessages();
+ mMmTelConnectorListenerSlot0.getValue()
+ .connectionUnavailable(UNAVAILABLE_REASON_DISCONNECTED);
+ processAllMessages();
+ mMmTelConnectorListenerSlot0.getValue().connectionReady(null,
+ SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+ processAllMessages();
+ mImsStateCallbackController
+ .registerImsStateCallback(SLOT_0_SUB_ID, FEATURE_MMTEL, mCallback0, "callback0");
+ processAllMessages();
+
+ assertTrue(mImsStateCallbackController.isRegistered(mCallback0));
+ verify(mCallback0, times(1)).onUnavailable(REASON_IMS_SERVICE_DISCONNECTED);
+ verify(mCallback0, times(0)).onAvailable();
+
+ mImsStateCallbackController.unregisterImsStateCallback(mCallback0);
+ processAllMessages();
+ assertFalse(mImsStateCallbackController.isRegistered(mCallback0));
+
+ // RCS feature
+ // TelephonyRcsService notifying active features
+ mImsStateCallbackController.notifyExternalRcsStateChanged(SLOT_0, false, true);
+ processAllMessages();
+ // RcsFeatureController notifying STATE_READY
+ mImsStateCallbackController.notifyExternalRcsStateChanged(SLOT_0, true, true);
+ processAllMessages();
+ mRcsConnectorListenerSlot0.getValue()
+ .connectionUnavailable(UNAVAILABLE_REASON_DISCONNECTED);
+ processAllMessages();
+ mRcsConnectorListenerSlot0.getValue().connectionReady(null,
+ SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+ processAllMessages();
+ mImsStateCallbackController
+ .registerImsStateCallback(SLOT_0_SUB_ID, FEATURE_RCS, mCallback1, "callback1");
+ processAllMessages();
+
+ assertTrue(mImsStateCallbackController.isRegistered(mCallback1));
+ verify(mCallback1, times(1)).onUnavailable(REASON_IMS_SERVICE_DISCONNECTED);
+ verify(mCallback1, times(0)).onAvailable();
+
+ mImsStateCallbackController.unregisterImsStateCallback(mCallback1);
+ processAllMessages();
+ assertFalse(mImsStateCallbackController.isRegistered(mCallback1));
+ }
+
private void createController(int slotCount) throws Exception {
if (Looper.myLooper() == null) {
Looper.prepare();