rename renounce fine location data
rename renounce fine location data to include location data
Bug: 210923726
Test: cts
Change-Id: Ic2ce84f51bf394031903ae180788216cfa910fc0
diff --git a/core/api/current.txt b/core/api/current.txt
index 14c0262..7e5baa95c 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -43378,7 +43378,7 @@
method public int getPhoneType();
method @RequiresPermission(anyOf={"android.permission.READ_PRIVILEGED_PHONE_STATE", android.Manifest.permission.READ_PHONE_STATE}) public int getPreferredOpportunisticDataSubscription();
method @Nullable @RequiresPermission(allOf={android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.ACCESS_COARSE_LOCATION}) public android.telephony.ServiceState getServiceState();
- method @Nullable @RequiresPermission(allOf={android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.ACCESS_COARSE_LOCATION}) public android.telephony.ServiceState getServiceState(boolean, boolean);
+ method @Nullable @RequiresPermission(allOf={android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.ACCESS_COARSE_LOCATION}) public android.telephony.ServiceState getServiceState(int);
method @Nullable public android.telephony.SignalStrength getSignalStrength();
method public int getSimCarrierId();
method @Nullable public CharSequence getSimCarrierIdName();
@@ -43433,10 +43433,10 @@
method @Deprecated public void listen(android.telephony.PhoneStateListener, int);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void rebootModem();
method public void registerTelephonyCallback(@NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyCallback);
- method public void registerTelephonyCallback(boolean, boolean, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyCallback);
+ method public void registerTelephonyCallback(int, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyCallback);
method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public void requestCellInfoUpdate(@NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.CellInfoCallback);
method @RequiresPermission(allOf={android.Manifest.permission.MODIFY_PHONE_STATE, android.Manifest.permission.ACCESS_FINE_LOCATION}) public android.telephony.NetworkScan requestNetworkScan(android.telephony.NetworkScanRequest, java.util.concurrent.Executor, android.telephony.TelephonyScanManager.NetworkScanCallback);
- method @Nullable @RequiresPermission(allOf={android.Manifest.permission.MODIFY_PHONE_STATE, android.Manifest.permission.ACCESS_FINE_LOCATION}) public android.telephony.NetworkScan requestNetworkScan(boolean, @NonNull android.telephony.NetworkScanRequest, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyScanManager.NetworkScanCallback);
+ method @Nullable @RequiresPermission(allOf={android.Manifest.permission.MODIFY_PHONE_STATE, android.Manifest.permission.ACCESS_FINE_LOCATION}) public android.telephony.NetworkScan requestNetworkScan(int, @NonNull android.telephony.NetworkScanRequest, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyScanManager.NetworkScanCallback);
method public void sendDialerSpecialCode(String);
method public String sendEnvelopeWithStatus(String);
method @RequiresPermission(android.Manifest.permission.CALL_PHONE) public void sendUssdRequest(String, android.telephony.TelephonyManager.UssdResponseCallback, android.os.Handler);
@@ -43546,6 +43546,9 @@
field public static final String EXTRA_STATE_RINGING;
field public static final String EXTRA_SUBSCRIPTION_ID = "android.telephony.extra.SUBSCRIPTION_ID";
field public static final String EXTRA_VOICEMAIL_NUMBER = "android.telephony.extra.VOICEMAIL_NUMBER";
+ field public static final int INCLUDE_LOCATION_DATA_COARSE = 1; // 0x1
+ field public static final int INCLUDE_LOCATION_DATA_FINE = 2; // 0x2
+ field public static final int INCLUDE_LOCATION_DATA_NONE = 0; // 0x0
field public static final String METADATA_HIDE_VOICEMAIL_SETTINGS_MENU = "android.telephony.HIDE_VOICEMAIL_SETTINGS_MENU";
field public static final int MULTISIM_ALLOWED = 0; // 0x0
field public static final int MULTISIM_NOT_SUPPORTED_BY_CARRIER = 2; // 0x2
diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java
index 30d4959..0985bb1 100644
--- a/telecomm/java/android/telecom/Connection.java
+++ b/telecomm/java/android/telecom/Connection.java
@@ -45,6 +45,7 @@
import android.os.RemoteException;
import android.os.SystemClock;
import android.telephony.CallQuality;
+import android.telephony.CellIdentity;
import android.telephony.ims.ImsStreamMediaProfile;
import android.util.ArraySet;
import android.view.Surface;
@@ -846,10 +847,10 @@
"android.telecom.extra.AUDIO_CODEC_BANDWIDTH_KHZ";
/**
- * Last known cell identity key to be used to fill geo location header in case of an emergency
- * call. This entry will not be filled if call is not identified as an emergency call.
- * {@link Connection}. Only provided to the {@link ConnectionService} for the purpose
- * of placing an emergency call; will not be present in the {@link InCallService} layer.
+ * Last known cell identity key {@link CellIdentity} to be used to fill geo location header
+ * in case of an emergency call. This entry will not be filled if call is not identified as
+ * an emergency call. Only provided to the {@link ConnectionService} for the purpose of
+ * placing an emergency call; will not be present in the {@link InCallService} layer.
* The {@link ConnectionService}'s implementation will be logged for fine location access
* when an outgoing call is placed in this case.
*/
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index d03c2bc..6f3ff9e 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -8960,7 +8960,7 @@
public NetworkScan requestNetworkScan(
NetworkScanRequest request, Executor executor,
TelephonyScanManager.NetworkScanCallback callback) {
- return requestNetworkScan(false, request, executor, callback);
+ return requestNetworkScan(INCLUDE_LOCATION_DATA_FINE, request, executor, callback);
}
/**
@@ -8985,9 +8985,8 @@
* and MCC/MNC info.</li>
* </ol>
*
- * @param renounceFineLocationAccess Set this to true if the caller would not like to receive
- * location related information which will be sent if the caller already possess
- * {@link android.Manifest.permission#ACCESS_FINE_LOCATION} and do not renounce the permission
+ * @param includeLocationData Specifies if the caller would like to receive
+ * location related information.
* @param request Contains all the RAT with bands/channels that need to be scanned.
* @param executor The executor through which the callback should be invoked. Since the scan
* request may trigger multiple callbacks and they must be invoked in the same order as
@@ -9002,7 +9001,8 @@
Manifest.permission.ACCESS_FINE_LOCATION
})
public @Nullable NetworkScan requestNetworkScan(
- boolean renounceFineLocationAccess, @NonNull NetworkScanRequest request,
+ @IncludeLocationData int includeLocationData,
+ @NonNull NetworkScanRequest request,
@NonNull Executor executor,
@NonNull TelephonyScanManager.NetworkScanCallback callback) {
synchronized (sCacheLock) {
@@ -9010,7 +9010,8 @@
mTelephonyScanManager = new TelephonyScanManager();
}
}
- return mTelephonyScanManager.requestNetworkScan(getSubId(), renounceFineLocationAccess,
+ return mTelephonyScanManager.requestNetworkScan(getSubId(),
+ includeLocationData != INCLUDE_LOCATION_DATA_FINE,
request, executor, callback,
getOpPackageName(), getAttributionTag());
}
@@ -12170,10 +12171,15 @@
})
@RequiresFeature(PackageManager.FEATURE_TELEPHONY_RADIO_ACCESS)
public @Nullable ServiceState getServiceState() {
- return getServiceState(getRenouncedPermissions()
- .contains(Manifest.permission.ACCESS_FINE_LOCATION),
- getRenouncedPermissions()
- .contains(Manifest.permission.ACCESS_COARSE_LOCATION));
+ if (getRenouncedPermissions().contains(Manifest.permission.ACCESS_FINE_LOCATION)) {
+ if (getRenouncedPermissions().contains(Manifest.permission.ACCESS_COARSE_LOCATION)) {
+ return getServiceState(INCLUDE_LOCATION_DATA_NONE);
+ } else {
+ return getServiceState(INCLUDE_LOCATION_DATA_COARSE);
+ }
+ }
+
+ return getServiceState(INCLUDE_LOCATION_DATA_FINE);
}
/**
@@ -12193,12 +12199,8 @@
* <p>Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
* or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges})
* and {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}.
- * @param renounceFineLocationAccess Set this to true if the caller would not like to receive
- * location related information which will be sent if the caller already possess
- * {@link android.Manifest.permission#ACCESS_FINE_LOCATION} and do not renounce the permission
- * @param renounceCoarseLocationAccess Set this to true if the caller would not like to
- * receive location related information which will be sent if the caller already possess
- * {@link Manifest.permission#ACCESS_COARSE_LOCATION} and do not renounce the permissions.
+ * @param includeLocationData Specifies if the caller would like to receive
+ * location related information.
* May return {@code null} when the subscription is inactive or when there was an error
* communicating with the phone process.
*/
@@ -12207,10 +12209,10 @@
Manifest.permission.READ_PHONE_STATE,
Manifest.permission.ACCESS_COARSE_LOCATION
})
- public @Nullable ServiceState getServiceState(boolean renounceFineLocationAccess,
- boolean renounceCoarseLocationAccess) {
- return getServiceStateForSubscriber(getSubId(), renounceFineLocationAccess,
- renounceCoarseLocationAccess);
+ public @Nullable ServiceState getServiceState(@IncludeLocationData int includeLocationData) {
+ return getServiceStateForSubscriber(getSubId(),
+ includeLocationData != INCLUDE_LOCATION_DATA_FINE,
+ includeLocationData == INCLUDE_LOCATION_DATA_NONE);
}
/**
@@ -16168,12 +16170,57 @@
*/
public void registerTelephonyCallback(@NonNull @CallbackExecutor Executor executor,
@NonNull TelephonyCallback callback) {
- registerTelephonyCallback(
- getRenouncedPermissions().contains(Manifest.permission.ACCESS_FINE_LOCATION),
- getRenouncedPermissions().contains(Manifest.permission.ACCESS_COARSE_LOCATION),
- executor, callback);
+ if (getRenouncedPermissions().contains(Manifest.permission.ACCESS_FINE_LOCATION)) {
+ if (getRenouncedPermissions().contains(Manifest.permission.ACCESS_COARSE_LOCATION)) {
+ registerTelephonyCallback(INCLUDE_LOCATION_DATA_NONE, executor, callback);
+ return;
+ } else {
+ registerTelephonyCallback(INCLUDE_LOCATION_DATA_COARSE, executor, callback);
+ return;
+ }
+ }
+
+ registerTelephonyCallback(INCLUDE_LOCATION_DATA_FINE, executor, callback);
}
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = {"INCLUDE_LOCATION_DATA_"}, value = {
+ INCLUDE_LOCATION_DATA_NONE,
+ INCLUDE_LOCATION_DATA_COARSE,
+ INCLUDE_LOCATION_DATA_FINE})
+ public @interface IncludeLocationData {}
+
+ /**
+ * Specifies to not include any location related data.
+ *
+ * Indicates whether the caller would not like to receive
+ * location related information which will be sent if the caller already possess
+ * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION} and do not renounce the
+ * permissions.
+ */
+ public static final int INCLUDE_LOCATION_DATA_NONE = 0;
+
+ /**
+ * Include coarse location data.
+ *
+ * Indicates whether the caller would not like to receive
+ * location related information which will be sent if the caller already possess
+ * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION} and do not renounce the
+ * permissions.
+ */
+ public static final int INCLUDE_LOCATION_DATA_COARSE = 1;
+
+ /**
+ * Include fine location data.
+ *
+ * Indicates whether the caller would not like to receive
+ * location related information which will be sent if the caller already possess
+ * {@link android.Manifest.permission#ACCESS_FINE_LOCATION} and do not renounce the
+ * permissions.
+ */
+ public static final int INCLUDE_LOCATION_DATA_FINE = 2;
+
/**
* Registers a callback object to receive notification of changes in specified telephony states.
* <p>
@@ -16207,17 +16254,12 @@
* apps. To avoid confusion, calling this method supersede renouncing permissions with a
* custom context.
*
- * @param renounceFineLocationAccess Set this to true if the caller would not like to receive
- * location related information which will be sent if the caller already possess
- * {@link android.Manifest.permission#ACCESS_FINE_LOCATION} and do not renounce the permissions.
- * @param renounceCoarseLocationAccess Set this to true if the caller would not like to
- * receive location related information which will be sent if the caller already possess
- * {@link Manifest.permission#ACCESS_COARSE_LOCATION} and do not renounce the permissions.
+ * @param includeLocationData Specifies if the caller would like to receive
+ * location related information.
* @param executor The executor of where the callback will execute.
* @param callback The {@link TelephonyCallback} object to register.
*/
- public void registerTelephonyCallback(boolean renounceFineLocationAccess,
- boolean renounceCoarseLocationAccess,
+ public void registerTelephonyCallback(@IncludeLocationData int includeLocationData,
@NonNull @CallbackExecutor Executor executor,
@NonNull TelephonyCallback callback) {
if (mContext == null) {
@@ -16230,8 +16272,10 @@
mTelephonyRegistryMgr = (TelephonyRegistryManager)
mContext.getSystemService(Context.TELEPHONY_REGISTRY_SERVICE);
if (mTelephonyRegistryMgr != null) {
- mTelephonyRegistryMgr.registerTelephonyCallback(renounceFineLocationAccess,
- renounceCoarseLocationAccess, executor, mSubId, getOpPackageName(),
+ mTelephonyRegistryMgr.registerTelephonyCallback(
+ includeLocationData != INCLUDE_LOCATION_DATA_FINE,
+ includeLocationData == INCLUDE_LOCATION_DATA_NONE,
+ executor, mSubId, getOpPackageName(),
getAttributionTag(), callback, getITelephony() != null);
} else {
throw new IllegalStateException("telephony service is null.");