Implement more location checks
Make the following modifications to APIs and required permissions. Move the following APIs from checking coarse permission to fine permission (except for apps targeting pre-Q): TelephonyManager.getCellLocation() (deprecated) TelephonyManager.getNeighboringCellInfo() TelephonyManager.getAllCellInfo() TelephonyManager.requestCellInfoUpdate() PhoneStateListener#onCellLocationChanged PhoneStateListener#onCellInfoChanged Start checking for fine permission on the following APIs: (Note -- these will only be logged, not denied until a future CL) TelephonyManager.requestNetworkScan() TelephonyScanManager.requestNetworkScan() NetworkScanCallback#onResults Start checking for coarse permission on the following APIs: (Note -- these will only be logged, not denied until a future CL) TelephonyManager#getAvailableNetworks TelephonyManager#getServiceStateForSubscriber and #getServiceState PhoneStateListener#onServiceStateChanged Bug: 116258458 Test: manual via testapps Change-Id: I45326ddacbcf538da50ca544d67eed12cf0c0861
This commit is contained in:
@@ -1653,10 +1653,7 @@ public class TelephonyManager {
|
||||
* @deprecated use {@link #getAllCellInfo} instead, which returns a superset of this API.
|
||||
*/
|
||||
@Deprecated
|
||||
@RequiresPermission(anyOf = {
|
||||
android.Manifest.permission.ACCESS_COARSE_LOCATION,
|
||||
android.Manifest.permission.ACCESS_FINE_LOCATION
|
||||
})
|
||||
@RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION)
|
||||
public CellLocation getCellLocation() {
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
@@ -4886,7 +4883,7 @@ public class TelephonyManager {
|
||||
* @return List of {@link android.telephony.CellInfo}; null if cell
|
||||
* information is unavailable.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION)
|
||||
@RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION)
|
||||
public List<CellInfo> getAllCellInfo() {
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
@@ -4963,7 +4960,7 @@ public class TelephonyManager {
|
||||
* @param executor the executor on which callback will be invoked.
|
||||
* @param callback a callback to receive CellInfo.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION)
|
||||
@RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION)
|
||||
public void requestCellInfoUpdate(
|
||||
@NonNull @CallbackExecutor Executor executor, @NonNull CellInfoCallback callback) {
|
||||
try {
|
||||
@@ -5002,7 +4999,7 @@ public class TelephonyManager {
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(allOf = {android.Manifest.permission.ACCESS_COARSE_LOCATION,
|
||||
@RequiresPermission(allOf = {android.Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
android.Manifest.permission.MODIFY_PHONE_STATE})
|
||||
public void requestCellInfoUpdate(@NonNull WorkSource workSource,
|
||||
@NonNull @CallbackExecutor Executor executor, @NonNull CellInfoCallback callback) {
|
||||
@@ -6561,9 +6558,10 @@ public class TelephonyManager {
|
||||
*
|
||||
* <p> Note that this scan can take a long time (sometimes minutes) to happen.
|
||||
*
|
||||
* <p>Requires Permission:
|
||||
* <p>Requires Permissions:
|
||||
* {@link android.Manifest.permission#MODIFY_PHONE_STATE} or that the calling app has carrier
|
||||
* privileges (see {@link #hasCarrierPrivileges})
|
||||
* and {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}.
|
||||
*
|
||||
* @return {@link CellNetworkScanResult} with the status
|
||||
* {@link CellNetworkScanResult#STATUS_SUCCESS} and a list of
|
||||
@@ -6572,12 +6570,15 @@ public class TelephonyManager {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
@RequiresPermission(allOf = {
|
||||
android.Manifest.permission.MODIFY_PHONE_STATE,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION
|
||||
})
|
||||
public CellNetworkScanResult getAvailableNetworks() {
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
if (telephony != null) {
|
||||
return telephony.getCellNetworkScanResults(getSubId());
|
||||
return telephony.getCellNetworkScanResults(getSubId(), getOpPackageName());
|
||||
}
|
||||
} catch (RemoteException ex) {
|
||||
Rlog.e(TAG, "getAvailableNetworks RemoteException", ex);
|
||||
@@ -6596,7 +6597,8 @@ public class TelephonyManager {
|
||||
*
|
||||
* <p>Requires Permission:
|
||||
* {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling
|
||||
* app has carrier privileges (see {@link #hasCarrierPrivileges}).
|
||||
* app has carrier privileges (see {@link #hasCarrierPrivileges})
|
||||
* and {@link android.Manifest.permission#ACCESS_FINE_LOCATION}.
|
||||
*
|
||||
* @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
|
||||
@@ -6607,7 +6609,10 @@ public class TelephonyManager {
|
||||
* @return A NetworkScan obj which contains a callback which can be used to stop the scan.
|
||||
*/
|
||||
@SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
@RequiresPermission(allOf = {
|
||||
android.Manifest.permission.MODIFY_PHONE_STATE,
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
})
|
||||
public NetworkScan requestNetworkScan(
|
||||
NetworkScanRequest request, Executor executor,
|
||||
TelephonyScanManager.NetworkScanCallback callback) {
|
||||
@@ -6616,7 +6621,8 @@ public class TelephonyManager {
|
||||
mTelephonyScanManager = new TelephonyScanManager();
|
||||
}
|
||||
}
|
||||
return mTelephonyScanManager.requestNetworkScan(getSubId(), request, executor, callback);
|
||||
return mTelephonyScanManager.requestNetworkScan(getSubId(), request, executor, callback,
|
||||
getOpPackageName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6626,7 +6632,10 @@ public class TelephonyManager {
|
||||
* @removed
|
||||
*/
|
||||
@Deprecated
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
@RequiresPermission(allOf = {
|
||||
android.Manifest.permission.MODIFY_PHONE_STATE,
|
||||
Manifest.permission.ACCESS_FINE_LOCATION
|
||||
})
|
||||
public NetworkScan requestNetworkScan(
|
||||
NetworkScanRequest request, TelephonyScanManager.NetworkScanCallback callback) {
|
||||
return requestNetworkScan(request, AsyncTask.SERIAL_EXECUTOR, callback);
|
||||
@@ -8594,10 +8603,14 @@ public class TelephonyManager {
|
||||
* given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultSubscriptionId()}
|
||||
*
|
||||
* <p>Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
||||
* or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}).
|
||||
* or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges})
|
||||
* and {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}.
|
||||
*/
|
||||
@SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
|
||||
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
||||
@RequiresPermission(allOf = {
|
||||
Manifest.permission.READ_PHONE_STATE,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION
|
||||
})
|
||||
public ServiceState getServiceState() {
|
||||
return getServiceStateForSubscriber(getSubId());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user