Merge "Add ImsStateCallbackController"
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index db70d59..e7cb28c 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -74,6 +74,7 @@
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
import com.android.internal.telephony.uicc.UiccCard;
+import com.android.internal.telephony.uicc.UiccPort;
import com.android.internal.telephony.uicc.UiccProfile;
import com.android.internal.util.IndentingPrintWriter;
import com.android.phone.settings.SettingsConstants;
@@ -242,13 +243,13 @@
// if passed in subType is unknown, retrieve it here.
if (subType == -1) {
- final UiccCard uiccCard = phone.getUiccCard();
- if (uiccCard == null) {
+ final UiccPort uiccPort = phone.getUiccPort();
+ if (uiccPort == null) {
Log.e(LOG_TAG,
- "handleSimLock: uiccCard for phone " + phone.getPhoneId() + " is null");
+ "handleSimLock: uiccPort for phone " + phone.getPhoneId() + " is null");
return;
}
- final UiccProfile uiccProfile = uiccCard.getUiccProfile();
+ final UiccProfile uiccProfile = uiccPort.getUiccProfile();
if (uiccProfile == null) {
Log.e(LOG_TAG,
"handleSimLock: uiccProfile for phone " + phone.getPhoneId() + " is null");
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index f3f756c..a0b2277 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -190,6 +190,7 @@
import com.android.internal.telephony.uicc.UiccCard;
import com.android.internal.telephony.uicc.UiccCardApplication;
import com.android.internal.telephony.uicc.UiccController;
+import com.android.internal.telephony.uicc.UiccPort;
import com.android.internal.telephony.uicc.UiccProfile;
import com.android.internal.telephony.uicc.UiccSlot;
import com.android.internal.telephony.util.LocaleUtils;
@@ -504,7 +505,7 @@
MainThreadRequest request;
Message onCompleted;
AsyncResult ar;
- UiccCard uiccCard;
+ UiccPort uiccPort;
IccAPDUArgument iccArgument;
final Phone defaultPhone = getDefaultPhone();
@@ -554,15 +555,15 @@
case CMD_TRANSMIT_APDU_LOGICAL_CHANNEL:
request = (MainThreadRequest) msg.obj;
iccArgument = (IccAPDUArgument) request.argument;
- uiccCard = getUiccCardFromRequest(request);
- if (uiccCard == null) {
+ uiccPort = getUiccPortFromRequest(request);
+ if (uiccPort == null) {
loge("iccTransmitApduLogicalChannel: No UICC");
request.result = new IccIoResult(0x6F, 0, (byte[])null);
notifyRequester(request);
} else {
onCompleted = obtainMessage(EVENT_TRANSMIT_APDU_LOGICAL_CHANNEL_DONE,
request);
- uiccCard.iccTransmitApduLogicalChannel(
+ uiccPort.iccTransmitApduLogicalChannel(
iccArgument.channel, iccArgument.cla, iccArgument.command,
iccArgument.p1, iccArgument.p2, iccArgument.p3, iccArgument.data,
onCompleted);
@@ -591,15 +592,15 @@
case CMD_TRANSMIT_APDU_BASIC_CHANNEL:
request = (MainThreadRequest) msg.obj;
iccArgument = (IccAPDUArgument) request.argument;
- uiccCard = getUiccCardFromRequest(request);
- if (uiccCard == null) {
+ uiccPort = getUiccPortFromRequest(request);
+ if (uiccPort == null) {
loge("iccTransmitApduBasicChannel: No UICC");
request.result = new IccIoResult(0x6F, 0, (byte[])null);
notifyRequester(request);
} else {
onCompleted = obtainMessage(EVENT_TRANSMIT_APDU_BASIC_CHANNEL_DONE,
request);
- uiccCard.iccTransmitApduBasicChannel(
+ uiccPort.iccTransmitApduBasicChannel(
iccArgument.cla, iccArgument.command, iccArgument.p1, iccArgument.p2,
iccArgument.p3, iccArgument.data, onCompleted);
}
@@ -627,15 +628,15 @@
case CMD_EXCHANGE_SIM_IO:
request = (MainThreadRequest) msg.obj;
iccArgument = (IccAPDUArgument) request.argument;
- uiccCard = getUiccCardFromRequest(request);
- if (uiccCard == null) {
+ uiccPort = getUiccPortFromRequest(request);
+ if (uiccPort == null) {
loge("iccExchangeSimIO: No UICC");
request.result = new IccIoResult(0x6F, 0, (byte[])null);
notifyRequester(request);
} else {
onCompleted = obtainMessage(EVENT_EXCHANGE_SIM_IO_DONE,
request);
- uiccCard.iccExchangeSimIO(iccArgument.cla, /* fileID */
+ uiccPort.iccExchangeSimIO(iccArgument.cla, /* fileID */
iccArgument.command, iccArgument.p1, iccArgument.p2, iccArgument.p3,
iccArgument.data, onCompleted);
}
@@ -654,14 +655,14 @@
case CMD_SEND_ENVELOPE:
request = (MainThreadRequest) msg.obj;
- uiccCard = getUiccCardFromRequest(request);
- if (uiccCard == null) {
+ uiccPort = getUiccPortFromRequest(request);
+ if (uiccPort == null) {
loge("sendEnvelopeWithStatus: No UICC");
request.result = new IccIoResult(0x6F, 0, (byte[])null);
notifyRequester(request);
} else {
onCompleted = obtainMessage(EVENT_SEND_ENVELOPE_DONE, request);
- uiccCard.sendEnvelopeWithStatus((String)request.argument, onCompleted);
+ uiccPort.sendEnvelopeWithStatus((String)request.argument, onCompleted);
}
break;
@@ -686,16 +687,16 @@
case CMD_OPEN_CHANNEL:
request = (MainThreadRequest) msg.obj;
- uiccCard = getUiccCardFromRequest(request);
+ uiccPort = getUiccPortFromRequest(request);
Pair<String, Integer> openChannelArgs = (Pair<String, Integer>) request.argument;
- if (uiccCard == null) {
+ if (uiccPort == null) {
loge("iccOpenLogicalChannel: No UICC");
request.result = new IccOpenLogicalChannelResponse(-1,
IccOpenLogicalChannelResponse.STATUS_MISSING_RESOURCE, null);
notifyRequester(request);
} else {
onCompleted = obtainMessage(EVENT_OPEN_CHANNEL_DONE, request);
- uiccCard.iccOpenLogicalChannel(openChannelArgs.first,
+ uiccPort.iccOpenLogicalChannel(openChannelArgs.first,
openChannelArgs.second, onCompleted);
}
break;
@@ -743,14 +744,14 @@
case CMD_CLOSE_CHANNEL:
request = (MainThreadRequest) msg.obj;
- uiccCard = getUiccCardFromRequest(request);
- if (uiccCard == null) {
+ uiccPort = getUiccPortFromRequest(request);
+ if (uiccPort == null) {
loge("iccCloseLogicalChannel: No UICC");
request.result = false;
notifyRequester(request);
} else {
onCompleted = obtainMessage(EVENT_CLOSE_CHANNEL_DONE, request);
- uiccCard.iccCloseLogicalChannel((Integer) request.argument, onCompleted);
+ uiccPort.iccCloseLogicalChannel((Integer) request.argument, onCompleted);
}
break;
@@ -1464,16 +1465,16 @@
case CMD_GET_FORBIDDEN_PLMNS:
request = (MainThreadRequest) msg.obj;
- uiccCard = getUiccCardFromRequest(request);
- if (uiccCard == null) {
- loge("getForbiddenPlmns() UiccCard is null");
+ uiccPort = getUiccPortFromRequest(request);
+ if (uiccPort == null) {
+ loge("getForbiddenPlmns() UiccPort is null");
request.result = new IllegalArgumentException(
- "getForbiddenPlmns() UiccCard is null");
+ "getForbiddenPlmns() UiccPort is null");
notifyRequester(request);
break;
}
Integer appType = (Integer) request.argument;
- UiccCardApplication uiccApp = uiccCard.getApplicationByType(appType);
+ UiccCardApplication uiccApp = uiccPort.getApplicationByType(appType);
if (uiccApp == null) {
loge("getForbiddenPlmns() no app with specified type -- "
+ appType);
@@ -1769,9 +1770,9 @@
break;
case CMD_SET_FORBIDDEN_PLMNS:
request = (MainThreadRequest) msg.obj;
- uiccCard = getUiccCardFromRequest(request);
- if (uiccCard == null) {
- loge("setForbiddenPlmns: UiccCard is null");
+ uiccPort = getUiccPortFromRequest(request);
+ if (uiccPort == null) {
+ loge("setForbiddenPlmns: UiccPort is null");
request.result = -1;
notifyRequester(request);
break;
@@ -1780,7 +1781,7 @@
(Pair<Integer, List<String>>) request.argument;
appType = setFplmnsArgs.first;
List<String> fplmns = setFplmnsArgs.second;
- uiccApp = uiccCard.getApplicationByType(appType);
+ uiccApp = uiccPort.getApplicationByType(appType);
if (uiccApp == null) {
loge("setForbiddenPlmns: no app with specified type -- " + appType);
request.result = -1;
@@ -2298,10 +2299,10 @@
? getDefaultPhone() : getPhone(subId);
}
- private UiccCard getUiccCardFromRequest(MainThreadRequest request) {
+ private UiccPort getUiccPortFromRequest(MainThreadRequest request) {
Phone phone = getPhoneFromRequest(request);
return phone == null ? null :
- UiccController.getInstance().getUiccCard(phone.getPhoneId());
+ UiccController.getInstance().getUiccPort(phone.getPhoneId());
}
// returns phone associated with the subId.
@@ -6766,14 +6767,14 @@
loge("getCarrierPrivilegeStatus: Invalid subId");
return TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS;
}
- UiccCard card = UiccController.getInstance().getUiccCard(phone.getPhoneId());
- if (card == null) {
+ UiccPort port = UiccController.getInstance().getUiccPort(phone.getPhoneId());
+ if (port == null) {
loge("getCarrierPrivilegeStatus: No UICC");
return TelephonyManager.CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED;
}
return getCarrierPrivilegeStatusFromCarrierConfigRules(
- card.getCarrierPrivilegeStatusForCurrentTransaction(
+ port.getCarrierPrivilegeStatusForCurrentTransaction(
phone.getContext().getPackageManager()), Binder.getCallingUid(), phone);
}
@@ -6804,13 +6805,13 @@
}
int phoneId = SubscriptionManager.getPhoneId(subId);
- UiccCard card = UiccController.getInstance().getUiccCard(phoneId);
- if (card == null) {
+ UiccPort port = UiccController.getInstance().getUiccPort(phoneId);
+ if (port == null) {
loge("checkCarrierPrivilegesForPackage: No UICC on subId " + subId);
return TelephonyManager.CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED;
}
return getCarrierPrivilegeStatusFromCarrierConfigRules(
- card.getCarrierPrivilegeStatus(mApp.getPackageManager(), pkgName),
+ port.getCarrierPrivilegeStatus(mApp.getPackageManager(), pkgName),
getPhone(phoneId), pkgName);
}
@@ -6821,14 +6822,14 @@
return TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS;
int result = TelephonyManager.CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED;
for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) {
- UiccCard card = UiccController.getInstance().getUiccCard(i);
- if (card == null) {
+ UiccPort port = UiccController.getInstance().getUiccPort(i);
+ if (port == null) {
// No UICC in that slot.
continue;
}
result = getCarrierPrivilegeStatusFromCarrierConfigRules(
- card.getCarrierPrivilegeStatus(mApp.getPackageManager(), pkgName),
+ port.getCarrierPrivilegeStatus(mApp.getPackageManager(), pkgName),
getPhone(i), pkgName);
if (result == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
break;
@@ -6845,12 +6846,12 @@
loge("phoneId " + phoneId + " is not valid.");
return null;
}
- UiccCard card = UiccController.getInstance().getUiccCard(phoneId);
- if (card == null) {
+ UiccPort port = UiccController.getInstance().getUiccPort(phoneId);
+ if (port == null) {
loge("getCarrierPackageNamesForIntentAndPhone: No UICC");
return null ;
}
- return card.getCarrierPackageNamesForIntent(mApp.getPackageManager(), intent);
+ return port.getCarrierPackageNamesForIntent(mApp.getPackageManager(), intent);
}
@Override
@@ -6859,10 +6860,10 @@
PackageManager pm = mApp.getPackageManager();
List<String> privilegedPackages = new ArrayList<>();
List<PackageInfo> packages = null;
- UiccCard card = UiccController.getInstance().getUiccCard(phoneId);
+ UiccPort port = UiccController.getInstance().getUiccPort(phoneId);
// has UICC in that slot.
- if (card != null) {
- if (card.hasCarrierPrivilegeRules()) {
+ if (port != null) {
+ if (port.hasCarrierPrivilegeRules()) {
if (packages == null) {
// Only check packages in user 0 for now
packages = pm.getInstalledPackagesAsUser(
@@ -6875,7 +6876,7 @@
PackageInfo pkgInfo = packages.get(p);
if (pkgInfo != null && pkgInfo.packageName != null
&& getCarrierPrivilegeStatusFromCarrierConfigRules(
- card.getCarrierPrivilegeStatus(pkgInfo),
+ port.getCarrierPrivilegeStatus(pkgInfo),
getPhone(phoneId), pkgInfo.packageName)
== TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
privilegedPackages.add(pkgInfo.packageName);
@@ -6905,11 +6906,11 @@
private String getIccId(int subId) {
final Phone phone = getPhone(subId);
- UiccCard card = phone == null ? null : phone.getUiccCard();
- if (card == null) {
+ UiccPort port = phone == null ? null : phone.getUiccPort();
+ if (port == null) {
return null;
}
- String iccId = card.getIccId();
+ String iccId = port.getIccId();
if (TextUtils.isEmpty(iccId)) {
return null;
}
@@ -8080,7 +8081,7 @@
}
String aid = null;
try {
- aid = UiccController.getInstance().getUiccCard(phone.getPhoneId())
+ aid = UiccController.getInstance().getUiccPort(phone.getPhoneId())
.getApplicationByType(appType).getAid();
} catch (Exception e) {
Log.e(LOG_TAG, "Not getting aid. Exception ex=" + e);
@@ -8657,6 +8658,22 @@
return isAllowed;
}
+ private boolean haveCarrierPrivilegeAccess(UiccCard card, String callingPackage) {
+ // TODO once MEP API refactoring CL is merged, loop port list from UiccCardInfo,
+ // and if find the matching UiccPort by UiccController.getUiccPortForSlot(slot, portIdx)
+ // Update each UiccPort object based on privilege access
+ UiccPort[] uiccPorts = card.getUiccPortList();
+ for (UiccPort port : uiccPorts) {
+ UiccProfile profile = port.getUiccProfile();
+ if (profile == null ||
+ profile.getCarrierPrivilegeStatus(mApp.getPackageManager(), callingPackage)
+ != TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
+ return false;
+ }
+ }
+ return true;
+ }
+
@Override
public List<UiccCardInfo> getUiccCardsInfo(String callingPackage) {
// Verify that tha callingPackage belongs to the calling UID
@@ -8690,14 +8707,15 @@
// For an inactive eUICC, the UiccCard will be null even though the UiccCardInfo
// is available
UiccCard card = uiccController.getUiccCardForSlot(cardInfo.getSlotIndex());
- if (card == null || card.getUiccProfile() == null) {
- // assume no access if the card or profile is unavailable
+ // TODO remove card.getUiccPortList().length once MEP API refactoring CL is merged
+ // Get UiccPortInfo from CardInfo and process further based on each UiccPort
+ if (card == null || card.getUiccPortList().length == 0) {
+ // assume no access if the card or ports are unavailable
filteredInfos.add(cardInfo.getUnprivileged());
continue;
}
- UiccProfile profile = card.getUiccProfile();
- if (profile.getCarrierPrivilegeStatus(mApp.getPackageManager(), callingPackage)
- == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
+
+ if (haveCarrierPrivilegeAccess(card, callingPackage)) {
filteredInfos.add(cardInfo);
} else {
filteredInfos.add(cardInfo.getUnprivileged());
@@ -8818,11 +8836,11 @@
if (phone == null) {
return;
}
- UiccCard uiccCard = phone.getUiccCard();
- if (uiccCard == null) {
+ UiccPort uiccPort = phone.getUiccPort();
+ if (uiccPort == null) {
return;
}
- UiccProfile uiccProfile = uiccCard.getUiccProfile();
+ UiccProfile uiccProfile = uiccPort.getUiccProfile();
if (uiccProfile == null) {
return;
}
@@ -9329,11 +9347,11 @@
}
final long identity = Binder.clearCallingIdentity();
try {
- UiccCard uiccCard = phone.getUiccCard();
- if (uiccCard == null) {
+ UiccPort uiccPort = phone.getUiccPort();
+ if (uiccPort == null) {
return false;
}
- UiccProfile uiccProfile = uiccCard.getUiccProfile();
+ UiccProfile uiccProfile = uiccPort.getUiccProfile();
if (uiccProfile == null) {
return false;
}
diff --git a/src/com/android/phone/settings/RadioInfo.java b/src/com/android/phone/settings/RadioInfo.java
index b1ab413..375509c 100644
--- a/src/com/android/phone/settings/RadioInfo.java
+++ b/src/com/android/phone/settings/RadioInfo.java
@@ -17,6 +17,7 @@
package com.android.phone.settings;
import static android.net.ConnectivityManager.NetworkCallback;
+
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import android.content.ComponentName;
@@ -57,7 +58,6 @@
import android.telephony.CellSignalStrengthLte;
import android.telephony.CellSignalStrengthWcdma;
import android.telephony.DataSpecificRegistrationInfo;
-import android.telephony.data.NetworkSlicingConfig;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.PhysicalChannelConfig;
import android.telephony.RadioAccessFamily;
@@ -66,6 +66,7 @@
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;
+import android.telephony.data.NetworkSlicingConfig;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
@@ -102,8 +103,8 @@
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeoutException;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
/**
* Radio Information Class