Fix carrierconfig shell command is not working when slot is specified
Using getSubId@Phone instead of
getActiveSubscriptionInfoForSimSlotIndex@SubscriptionManager
to get the subId. So that the command can skip the subscriber
identifier access check.
Bug: 168186484
Test: adb shell cmd phone cc set-value -s 0 rtt_supported_bool true
Merged-in: I71bdb767c2e2e999adc27deb9eb1618589859360
Change-Id: I71bdb767c2e2e999adc27deb9eb1618589859360
(cherry picked from commit f25799b477299f46e3bb2952354a187b3f365428)
diff --git a/src/com/android/phone/TelephonyShellCommand.java b/src/com/android/phone/TelephonyShellCommand.java
index 512ca03..d24b4e3 100644
--- a/src/com/android/phone/TelephonyShellCommand.java
+++ b/src/com/android/phone/TelephonyShellCommand.java
@@ -24,13 +24,14 @@
import android.os.RemoteException;
import android.provider.BlockedNumberContract;
import android.telephony.CarrierConfigManager;
-import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.emergency.EmergencyNumber;
import android.telephony.ims.feature.ImsFeature;
import android.util.Log;
import com.android.internal.telephony.ITelephony;
+import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.emergency.EmergencyNumberTracker;
import com.android.internal.telephony.util.TelephonyUtils;
@@ -739,17 +740,21 @@
try {
slotId = Integer.parseInt(slotString);
} catch (NumberFormatException e) {
+ getErrPrintWriter().println(tag + slotString + " is not a valid number for SLOT_ID.");
+ return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+ }
+
+ if (!SubscriptionManager.isValidPhoneId(slotId)) {
getErrPrintWriter().println(tag + slotString + " is not a valid SLOT_ID.");
return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
}
- SubscriptionInfo subInfo =
- mSubscriptionManager.getActiveSubscriptionInfoForSimSlotIndex(slotId);
- if (subInfo == null) {
+ Phone phone = PhoneFactory.getPhone(slotId);
+ if (phone == null) {
getErrPrintWriter().println(tag + "No subscription found in slot " + slotId + ".");
return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
}
- return subInfo.getSubscriptionId();
+ return phone.getSubId();
}
private boolean checkShellUid() {