diff options
| author | 2019-10-14 14:53:51 -0700 | |
|---|---|---|
| committer | 2019-10-14 14:53:51 -0700 | |
| commit | 417ac2760b64cff28c9af500288723fc531cb8eb (patch) | |
| tree | 98139c5d97721ca4fce959ade13838b54a51c59b | |
| parent | e03e86498f6ecc57381b5a5fad3582487c3e98f7 (diff) | |
| parent | 2cd6c07dee836809949088ce5297fe0cc1e923ef (diff) | |
Merge changes Icc6e7da7,I9007978b,I060511af am: 8dbe1f3b9b am: b9732abea7
am: 2cd6c07dee
Change-Id: I63beda0fc9f67c34d907be9c692a327fea236fb1
4 files changed, 38 insertions, 36 deletions
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 103d3aee6a13..2ea1a1a41333 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -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) { @@ -1843,23 +1839,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) { diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java index 6d0ed3257686..0ce552ae330a 100644 --- a/telephony/java/android/telephony/PhoneStateListener.java +++ b/telephony/java/android/telephony/PhoneStateListener.java @@ -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; diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 3f118eff9dcf..23166814c079 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -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; } // @@ -6581,11 +6601,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(); } /** diff --git a/telephony/java/com/android/internal/telephony/TelephonyProperties.java b/telephony/java/com/android/internal/telephony/TelephonyProperties.java index dd9b2421a333..bf5c0a18cc96 100644 --- a/telephony/java/com/android/internal/telephony/TelephonyProperties.java +++ b/telephony/java/com/android/internal/telephony/TelephonyProperties.java @@ -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"; } |