Revert "[DO NOT MERGE] Revert submission 9950791-pick-precise-dataconn"

This reverts commit d80dc8fed4.

Bug: 143082463
Test: compilation

Merged-In: Ib6a769f5a0cae923ca47a842733bd28755a90ed5
Change-Id: I455788f72fc6dec23c0d0d24a1ca8ee9c2f637c9
This commit is contained in:
Nathan Harold
2019-12-19 17:36:15 -08:00
parent 2115c17ced
commit dcbe98371e
11 changed files with 328 additions and 205 deletions

View File

@@ -35,8 +35,8 @@ import android.telephony.Annotation.SrvccState;
import android.telephony.emergency.EmergencyNumber;
import android.telephony.ims.ImsReasonInfo;
import com.android.internal.telephony.IPhoneStateListener;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.IPhoneStateListener;
import dalvik.system.VMRuntime;
@@ -188,12 +188,13 @@ public class PhoneStateListener {
/**
* Listen for {@link PreciseDataConnectionState} on the data connection (cellular).
*
* @see #onPreciseDataConnectionStateChanged
* <p>Requires permission {@link android.Manifest.permission#MODIFY_PHONE_STATE}
* or the calling app has carrier privileges
* (see {@link TelephonyManager#hasCarrierPrivileges}).
*
* @hide
* @see #onPreciseDataConnectionStateChanged
*/
@RequiresPermission((android.Manifest.permission.READ_PRECISE_PHONE_STATE))
@SystemApi
@RequiresPermission((android.Manifest.permission.MODIFY_PHONE_STATE))
public static final int LISTEN_PRECISE_DATA_CONNECTION_STATE = 0x00001000;
/**
@@ -688,8 +689,9 @@ public class PhoneStateListener {
}
/**
* Callback invoked when data connection state changes with precise information
* on the registered subscription.
* Callback providing update about the default/internet data connection 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
@@ -697,12 +699,13 @@ public class PhoneStateListener {
* subId. Otherwise, this callback applies to
* {@link SubscriptionManager#getDefaultSubscriptionId()}.
*
* @param dataConnectionState {@link PreciseDataConnectionState}
* <p>Requires permission {@link android.Manifest.permission#MODIFY_PHONE_STATE}
* or the calling app has carrier privileges
* (see {@link TelephonyManager#hasCarrierPrivileges}).
*
* @hide
* @param dataConnectionState {@link PreciseDataConnectionState}
*/
@RequiresPermission((android.Manifest.permission.READ_PRECISE_PHONE_STATE))
@SystemApi
@RequiresPermission((android.Manifest.permission.MODIFY_PHONE_STATE))
public void onPreciseDataConnectionStateChanged(
@NonNull PreciseDataConnectionState dataConnectionState) {
// default implementation empty
@@ -1011,11 +1014,21 @@ public class PhoneStateListener {
PhoneStateListener psl = mPhoneStateListenerWeakRef.get();
if (psl == null) return;
Binder.withCleanCallingIdentity(() -> mExecutor.execute(
() -> {
psl.onDataConnectionStateChanged(state, networkType);
psl.onDataConnectionStateChanged(state);
}));
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);
}));
}
}
public void onDataActivity(int direction) {

View File

@@ -21,19 +21,15 @@ 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;
@@ -365,27 +361,18 @@ 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 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()
* @param apnType the APN type that triggered this update
* @param preciseState the PreciseDataConnectionState
*
* @see android.telephony.PreciseDataConnection
* @see TelephonyManager#DATA_DISCONNECTED
* @hide
*/
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) {
public void notifyDataConnectionForSubscriber(int slotIndex, int subId,
String apnType, PreciseDataConnectionState preciseState) {
try {
sRegistry.notifyDataConnectionForSubscriber(slotIndex, subId, state,
isDataConnectivityPossible,
apn, apnType, linkProperties, networkCapabilities, networkType, roaming);
sRegistry.notifyDataConnectionForSubscriber(
slotIndex, subId, apnType, preciseState);
} catch (RemoteException ex) {
// system process is dead
}
@@ -653,25 +640,6 @@ 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

View File

@@ -24,6 +24,8 @@ import android.telephony.CallQuality;
import android.telephony.CellInfo;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.PhoneCapability;
import android.telephony.PhysicalChannelConfig;
import android.telephony.PreciseDataConnectionState;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.emergency.EmergencyNumber;
@@ -54,13 +56,8 @@ interface ITelephonyRegistry {
@UnsupportedAppUsage(maxTargetSdk = 28)
void notifyDataActivity(int state);
void notifyDataActivityForSubscriber(in int subId, int state);
void notifyDataConnection(int state, boolean isDataConnectivityPossible,
String apn, String apnType, in LinkProperties linkProperties,
in NetworkCapabilities networkCapabilities, int networkType, boolean roaming);
void notifyDataConnectionForSubscriber(int phoneId, int subId, int state,
boolean isDataConnectivityPossible,
String apn, String apnType, in LinkProperties linkProperties,
in NetworkCapabilities networkCapabilities, int networkType, boolean roaming);
void notifyDataConnectionForSubscriber(
int phoneId, int subId, String apnType, in PreciseDataConnectionState preciseState);
@UnsupportedAppUsage
void notifyDataConnectionFailed(String apnType);
void notifyDataConnectionFailedForSubscriber(int phoneId, int subId, String apnType);