diff options
| author | Noah Zimmt <noahz@google.com> | 2019-12-20 00:45:42 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-12-20 00:45:42 +0000 |
| commit | 2115c17ced0ef09df205644c7aedb7b2a7597d17 (patch) | |
| tree | 585eeadc236df09028f1871b9a36fa729194995b /core/java/android | |
| parent | 42c621eea94bd72d131e6912c89ec4ad7d25fb20 (diff) | |
| parent | d80dc8fed49d63deedf6eb4393ce81fa4caf73c8 (diff) | |
Merge "[DO NOT MERGE] Revert submission 9950791-pick-precise-dataconn" into qt-qpr1-dev-plus-aosp
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/telephony/PhoneStateListener.java | 45 | ||||
| -rw-r--r-- | core/java/android/telephony/TelephonyRegistryManager.java | 48 |
2 files changed, 56 insertions, 37 deletions
diff --git a/core/java/android/telephony/PhoneStateListener.java b/core/java/android/telephony/PhoneStateListener.java index 51a9c864ee29..edab97ddba28 100644 --- a/core/java/android/telephony/PhoneStateListener.java +++ b/core/java/android/telephony/PhoneStateListener.java @@ -35,8 +35,8 @@ import android.telephony.Annotation.SrvccState; import android.telephony.emergency.EmergencyNumber; import android.telephony.ims.ImsReasonInfo; -import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.IPhoneStateListener; +import com.android.internal.annotations.VisibleForTesting; import dalvik.system.VMRuntime; @@ -188,13 +188,12 @@ public class PhoneStateListener { /** * Listen for {@link PreciseDataConnectionState} on the data connection (cellular). * - * <p>Requires permission {@link android.Manifest.permission#MODIFY_PHONE_STATE} - * or the calling app has carrier privileges - * (see {@link TelephonyManager#hasCarrierPrivileges}). - * * @see #onPreciseDataConnectionStateChanged + * + * @hide */ - @RequiresPermission((android.Manifest.permission.MODIFY_PHONE_STATE)) + @RequiresPermission((android.Manifest.permission.READ_PRECISE_PHONE_STATE)) + @SystemApi public static final int LISTEN_PRECISE_DATA_CONNECTION_STATE = 0x00001000; /** @@ -689,9 +688,8 @@ public class PhoneStateListener { } /** - * Callback providing update about the default/internet data connection on the registered - * subscription. - * + * Callback invoked when data connection state changes with precise information + * on the registered subscription. * Note, the registration subId comes from {@link TelephonyManager} object which registers * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. * If this TelephonyManager object was created with @@ -699,13 +697,12 @@ public class PhoneStateListener { * subId. Otherwise, this callback applies to * {@link SubscriptionManager#getDefaultSubscriptionId()}. * - * <p>Requires permission {@link android.Manifest.permission#MODIFY_PHONE_STATE} - * or the calling app has carrier privileges - * (see {@link TelephonyManager#hasCarrierPrivileges}). - * * @param dataConnectionState {@link PreciseDataConnectionState} + * + * @hide */ - @RequiresPermission((android.Manifest.permission.MODIFY_PHONE_STATE)) + @RequiresPermission((android.Manifest.permission.READ_PRECISE_PHONE_STATE)) + @SystemApi public void onPreciseDataConnectionStateChanged( @NonNull PreciseDataConnectionState dataConnectionState) { // default implementation empty @@ -1014,21 +1011,11 @@ public class PhoneStateListener { PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); if (psl == null) return; - if (state == TelephonyManager.DATA_DISCONNECTING - && VMRuntime.getRuntime().getTargetSdkVersion() < Build.VERSION_CODES.R) { - Binder.withCleanCallingIdentity(() -> mExecutor.execute( - () -> { - psl.onDataConnectionStateChanged( - TelephonyManager.DATA_CONNECTED, networkType); - psl.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED); - })); - } else { - Binder.withCleanCallingIdentity(() -> mExecutor.execute( - () -> { - psl.onDataConnectionStateChanged(state, networkType); - psl.onDataConnectionStateChanged(state); - })); - } + Binder.withCleanCallingIdentity(() -> mExecutor.execute( + () -> { + psl.onDataConnectionStateChanged(state, networkType); + psl.onDataConnectionStateChanged(state); + })); } public void onDataActivity(int direction) { diff --git a/core/java/android/telephony/TelephonyRegistryManager.java b/core/java/android/telephony/TelephonyRegistryManager.java index fc2dfb833a8f..af582a22aa0d 100644 --- a/core/java/android/telephony/TelephonyRegistryManager.java +++ b/core/java/android/telephony/TelephonyRegistryManager.java @@ -21,15 +21,19 @@ import android.annotation.RequiresPermission; import android.annotation.SystemApi; import android.annotation.TestApi; import android.content.Context; +import android.net.LinkProperties; +import android.net.NetworkCapabilities; import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.HandlerExecutor; import android.os.RemoteException; import android.os.ServiceManager; +import android.telephony.Annotation.ApnType; import android.telephony.Annotation.CallState; import android.telephony.Annotation.DataActivityType; import android.telephony.Annotation.DataFailureCause; +import android.telephony.Annotation.DataState; import android.telephony.Annotation.NetworkType; import android.telephony.Annotation.PreciseCallStates; import android.telephony.Annotation.RadioPowerState; @@ -361,18 +365,27 @@ public class TelephonyRegistryManager { * @param subId for which data connection state changed. * @param slotIndex for which data connections state changed. Can be derived from subId except * when subId is invalid. - * @param apnType the APN type that triggered this update - * @param preciseState the PreciseDataConnectionState - * - * @see android.telephony.PreciseDataConnection + * @param state latest data connection state, e.g, + * @param isDataConnectivityPossible indicates if data is allowed + * @param apn the APN {@link ApnSetting#getApnName()} of this data connection. + * @param apnType the apnType, "ims" for IMS APN, "emergency" for EMERGENCY APN. + * @param linkProperties {@link LinkProperties} associated with this data connection. + * @param networkCapabilities {@link NetworkCapabilities} associated with this data connection. + * @param networkType associated with this data connection. + * @param roaming {@code true} indicates in roaming, {@false} otherwise. * @see TelephonyManager#DATA_DISCONNECTED + * @see TelephonyManager#isDataConnectivityPossible() + * * @hide */ - public void notifyDataConnectionForSubscriber(int slotIndex, int subId, - String apnType, PreciseDataConnectionState preciseState) { + public void notifyDataConnectionForSubscriber(int slotIndex, int subId, @DataState int state, + boolean isDataConnectivityPossible, + @ApnType String apn, String apnType, LinkProperties linkProperties, + NetworkCapabilities networkCapabilities, int networkType, boolean roaming) { try { - sRegistry.notifyDataConnectionForSubscriber( - slotIndex, subId, apnType, preciseState); + sRegistry.notifyDataConnectionForSubscriber(slotIndex, subId, state, + isDataConnectivityPossible, + apn, apnType, linkProperties, networkCapabilities, networkType, roaming); } catch (RemoteException ex) { // system process is dead } @@ -641,6 +654,25 @@ public class TelephonyRegistryManager { } /** + * Notify data connection failed on certain subscription. + * + * @param subId for which data connection failed. + * @param slotIndex for which data conenction faled. Can be derived from subId except when subId + * is invalid. + * @param apnType the apnType, "ims" for IMS APN, "emergency" for EMERGENCY APN. Note each data + * connection can support multiple anyTypes. + * + * @hide + */ + public void notifyDataConnectionFailed(int subId, int slotIndex, String apnType) { + try { + sRegistry.notifyDataConnectionFailedForSubscriber(slotIndex, subId, apnType); + } catch (RemoteException ex) { + // system process is dead + } + } + + /** * TODO change from bundle to CellLocation? * @hide */ |
