Merge changes Icc6e7da7,I9007978b,I060511af
* changes: Add APIs to return max possible active phones. Combine getPhoneCount, getSimCount and isMultiSimEnabled. Remove permission check for LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE
This commit is contained in:
@@ -79,7 +79,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Since phone process can be restarted, this class provides a centralized place
|
||||
@@ -863,10 +862,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
}
|
||||
}
|
||||
if ((events & PhoneStateListener
|
||||
.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE) != 0
|
||||
&& TelephonyPermissions.checkReadPhoneStateOnAnyActiveSub(
|
||||
r.context, r.callerPid, r.callerUid, r.callingPackage,
|
||||
"listen_active_data_subid_change")) {
|
||||
.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE) != 0) {
|
||||
try {
|
||||
r.callback.onActiveDataSubIdChanged(mActiveDataSubId);
|
||||
} catch (RemoteException ex) {
|
||||
@@ -1845,23 +1841,11 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
log("notifyActiveDataSubIdChanged: activeDataSubId=" + activeDataSubId);
|
||||
}
|
||||
|
||||
// Create a copy to prevent the IPC call while checking carrier privilege under the lock.
|
||||
List<Record> copiedRecords;
|
||||
synchronized (mRecords) {
|
||||
copiedRecords = new ArrayList<>(mRecords);
|
||||
}
|
||||
mActiveDataSubId = activeDataSubId;
|
||||
|
||||
// Filter the record that does not listen to this change or does not have the permission.
|
||||
copiedRecords = copiedRecords.stream().filter(r -> r.matchPhoneStateListenerEvent(
|
||||
PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE)
|
||||
&& TelephonyPermissions.checkReadPhoneStateOnAnyActiveSub(
|
||||
mContext, r.callerPid, r.callerUid, r.callingPackage,
|
||||
"notifyActiveDataSubIdChanged")).collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
synchronized (mRecords) {
|
||||
for (Record r : copiedRecords) {
|
||||
if (mRecords.contains(r)) {
|
||||
for (Record r : mRecords) {
|
||||
if (r.matchPhoneStateListenerEvent(
|
||||
PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE)) {
|
||||
try {
|
||||
r.callback.onActiveDataSubIdChanged(activeDataSubId);
|
||||
} catch (RemoteException ex) {
|
||||
|
||||
@@ -302,11 +302,6 @@ public class PhoneStateListener {
|
||||
* it could be the current active opportunistic subscription in use, or the
|
||||
* subscription user selected as default data subscription in DSDS mode.
|
||||
*
|
||||
* Requires Permission: No permission is required to listen, but notification requires
|
||||
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} or the calling
|
||||
* app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges})
|
||||
* on any active subscription.
|
||||
*
|
||||
* @see #onActiveDataSubscriptionIdChanged
|
||||
*/
|
||||
public static final int LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE = 0x00400000;
|
||||
|
||||
@@ -271,9 +271,6 @@ public class TelephonyManager {
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
private TelephonyScanManager mTelephonyScanManager;
|
||||
|
||||
private static String multiSimConfig =
|
||||
SystemProperties.get(TelephonyProperties.PROPERTY_MULTI_SIM_CONFIG);
|
||||
|
||||
/** Enum indicating multisim variants
|
||||
* DSDS - Dual SIM Dual Standby
|
||||
* DSDA - Dual SIM Dual Active
|
||||
@@ -365,7 +362,6 @@ public class TelephonyManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of phones available.
|
||||
* Returns 0 if none of voice, sms, data is not supported
|
||||
@@ -398,6 +394,31 @@ public class TelephonyManager {
|
||||
return phoneCount;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Return how many phone / logical modem can be active simultaneously, in terms of device
|
||||
* capability.
|
||||
* For example, for a dual-SIM capable device, it always returns 2, even if only one logical
|
||||
* modem / SIM is active (aka in single SIM mode).
|
||||
*
|
||||
* TODO: b/139642279 publicize and rename.
|
||||
* @hide
|
||||
*/
|
||||
public static int getMaxPhoneCount() {
|
||||
// TODO: b/139642279 when turning on this feature, remove dependency of
|
||||
// PROPERTY_REBOOT_REQUIRED_ON_MODEM_CHANGE and always return result based on
|
||||
// PROPERTY_MAX_ACTIVE_MODEMS.
|
||||
String rebootRequired = SystemProperties.get(
|
||||
TelephonyProperties.PROPERTY_REBOOT_REQUIRED_ON_MODEM_CHANGE);
|
||||
if (rebootRequired.equals("false")) {
|
||||
// If no reboot is required, return max possible active modems.
|
||||
return SystemProperties.getInt(
|
||||
TelephonyProperties.PROPERTY_MAX_ACTIVE_MODEMS, getDefault().getPhoneCount());
|
||||
} else {
|
||||
return getDefault().getPhoneCount();
|
||||
}
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
|
||||
public static TelephonyManager from(Context context) {
|
||||
@@ -433,8 +454,7 @@ public class TelephonyManager {
|
||||
/** {@hide} */
|
||||
@UnsupportedAppUsage
|
||||
public boolean isMultiSimEnabled() {
|
||||
return (multiSimConfig.equals("dsds") || multiSimConfig.equals("dsda") ||
|
||||
multiSimConfig.equals("tsts"));
|
||||
return getPhoneCount() > 1;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -6550,11 +6570,7 @@ public class TelephonyManager {
|
||||
public int getSimCount() {
|
||||
// FIXME Need to get it from Telephony Dev Controller when that gets implemented!
|
||||
// and then this method shouldn't be used at all!
|
||||
if(isMultiSimEnabled()) {
|
||||
return getPhoneCount();
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
return getPhoneCount();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -231,4 +231,11 @@ public interface TelephonyProperties
|
||||
String DISPLAY_OPPORTUNISTIC_SUBSCRIPTION_CARRIER_TEXT_PROPERTY_NAME =
|
||||
"persist.radio.display_opportunistic_carrier";
|
||||
|
||||
/**
|
||||
* How many logical modems can be active simultaneously. For example, if a device is dual-SIM
|
||||
* capable but currently only one SIM slot and one logical modem is active, this value is still
|
||||
* two.
|
||||
* Type: int
|
||||
*/
|
||||
static final String PROPERTY_MAX_ACTIVE_MODEMS = "ro.telephony.max.active.modems";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user