Merge changes from topics "nw-scan-cts", "nw-scan-changes"
* changes: Add shell permissions for CTS testing Allow requestNetworkScan to return sanitized info
This commit is contained in:
@@ -261,6 +261,7 @@ applications that come with the platform
|
|||||||
<permission name="android.permission.MOUNT_FORMAT_FILESYSTEMS"/>
|
<permission name="android.permission.MOUNT_FORMAT_FILESYSTEMS"/>
|
||||||
<permission name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
|
<permission name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
|
||||||
<permission name="android.permission.MOVE_PACKAGE"/>
|
<permission name="android.permission.MOVE_PACKAGE"/>
|
||||||
|
<permission name="android.permission.NETWORK_SCAN"/>
|
||||||
<permission name="android.permission.PACKAGE_USAGE_STATS" />
|
<permission name="android.permission.PACKAGE_USAGE_STATS" />
|
||||||
<!-- Needed for test only -->
|
<!-- Needed for test only -->
|
||||||
<permission name="android.permission.PACKET_KEEPALIVE_OFFLOAD" />
|
<permission name="android.permission.PACKET_KEEPALIVE_OFFLOAD" />
|
||||||
|
|||||||
@@ -118,6 +118,8 @@
|
|||||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
|
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
|
||||||
<uses-permission android:name="android.permission.MOUNT_FORMAT_FILESYSTEMS" />
|
<uses-permission android:name="android.permission.MOUNT_FORMAT_FILESYSTEMS" />
|
||||||
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
|
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
|
||||||
|
<!-- Shell only holds android.permission.NETWORK_SCAN in order to to enable CTS testing -->
|
||||||
|
<uses-permission android:name="android.permission.NETWORK_SCAN" />
|
||||||
<uses-permission android:name="android.permission.REGISTER_CALL_PROVIDER" />
|
<uses-permission android:name="android.permission.REGISTER_CALL_PROVIDER" />
|
||||||
<uses-permission android:name="android.permission.REGISTER_CONNECTION_MANAGER" />
|
<uses-permission android:name="android.permission.REGISTER_CONNECTION_MANAGER" />
|
||||||
<uses-permission android:name="android.permission.REGISTER_SIM_SUBSCRIPTION" />
|
<uses-permission android:name="android.permission.REGISTER_SIM_SUBSCRIPTION" />
|
||||||
|
|||||||
@@ -109,6 +109,22 @@ public abstract class CellIdentity implements Parcelable {
|
|||||||
return mType;
|
return mType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return MCC or null for CDMA
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public String getMccString() {
|
||||||
|
return mMccStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return MNC or null for CDMA
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public String getMncString() {
|
||||||
|
return mMncStr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the channel number of the cell identity.
|
* Returns the channel number of the cell identity.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -109,6 +109,13 @@ public final class CellIdentityCdma extends CellIdentity {
|
|||||||
return new CellIdentityCdma(this);
|
return new CellIdentityCdma(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public CellIdentityCdma sanitizeLocationInfo() {
|
||||||
|
return new CellIdentityCdma(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
|
||||||
|
CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
|
||||||
|
mAlphaLong, mAlphaShort);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take the latitude and longitude in 1/4 seconds and see if
|
* Take the latitude and longitude in 1/4 seconds and see if
|
||||||
* the reported location is on Null Island.
|
* the reported location is on Null Island.
|
||||||
|
|||||||
@@ -97,6 +97,12 @@ public final class CellIdentityGsm extends CellIdentity {
|
|||||||
return new CellIdentityGsm(this);
|
return new CellIdentityGsm(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public CellIdentityGsm sanitizeLocationInfo() {
|
||||||
|
return new CellIdentityGsm(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
|
||||||
|
CellInfo.UNAVAILABLE, mMccStr, mMncStr, mAlphaLong, mAlphaShort);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 3-digit Mobile Country Code, 0..999,
|
* @return 3-digit Mobile Country Code, 0..999,
|
||||||
* {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable.
|
* {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable.
|
||||||
|
|||||||
@@ -113,6 +113,13 @@ public final class CellIdentityLte extends CellIdentity {
|
|||||||
cid.mMncStr, cid.mAlphaLong, cid.mAlphaShort);
|
cid.mMncStr, cid.mAlphaLong, cid.mAlphaShort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public CellIdentityLte sanitizeLocationInfo() {
|
||||||
|
return new CellIdentityLte(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
|
||||||
|
CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
|
||||||
|
mMccStr, mMncStr, mAlphaLong, mAlphaShort);
|
||||||
|
}
|
||||||
|
|
||||||
CellIdentityLte copy() {
|
CellIdentityLte copy() {
|
||||||
return new CellIdentityLte(this);
|
return new CellIdentityLte(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,12 @@ public final class CellIdentityNr extends CellIdentity {
|
|||||||
mNci = nci;
|
mNci = nci;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public CellIdentityNr sanitizeLocationInfo() {
|
||||||
|
return new CellIdentityNr(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
|
||||||
|
mMccStr, mMncStr, CellInfo.UNAVAILABLE, mAlphaLong, mAlphaShort);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a CellLocation object for this CellIdentity.
|
* @return a CellLocation object for this CellIdentity.
|
||||||
* @hide
|
* @hide
|
||||||
|
|||||||
@@ -90,6 +90,12 @@ public final class CellIdentityTdscdma extends CellIdentity {
|
|||||||
cid.uarfcn, cid.operatorNames.alphaLong, cid.operatorNames.alphaShort);
|
cid.uarfcn, cid.operatorNames.alphaLong, cid.operatorNames.alphaShort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public CellIdentityTdscdma sanitizeLocationInfo() {
|
||||||
|
return new CellIdentityTdscdma(mMccStr, mMncStr, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
|
||||||
|
CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, mAlphaLong, mAlphaShort);
|
||||||
|
}
|
||||||
|
|
||||||
CellIdentityTdscdma copy() {
|
CellIdentityTdscdma copy() {
|
||||||
return new CellIdentityTdscdma(this);
|
return new CellIdentityTdscdma(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,13 @@ public final class CellIdentityWcdma extends CellIdentity {
|
|||||||
cid.mMncStr, cid.mAlphaLong, cid.mAlphaShort);
|
cid.mMncStr, cid.mAlphaLong, cid.mAlphaShort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public CellIdentityWcdma sanitizeLocationInfo() {
|
||||||
|
return new CellIdentityWcdma(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
|
||||||
|
CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, mMccStr, mMncStr,
|
||||||
|
mAlphaLong, mAlphaShort);
|
||||||
|
}
|
||||||
|
|
||||||
CellIdentityWcdma copy() {
|
CellIdentityWcdma copy() {
|
||||||
return new CellIdentityWcdma(this);
|
return new CellIdentityWcdma(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,6 +197,11 @@ public abstract class CellInfo implements Parcelable {
|
|||||||
@NonNull
|
@NonNull
|
||||||
public abstract CellSignalStrength getCellSignalStrength();
|
public abstract CellSignalStrength getCellSignalStrength();
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public CellInfo sanitizeLocationInfo() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the connection status of this cell.
|
* Gets the connection status of this cell.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -90,6 +90,15 @@ public final class CellInfoCdma extends CellInfo implements Parcelable {
|
|||||||
public CellSignalStrengthCdma getCellSignalStrength() {
|
public CellSignalStrengthCdma getCellSignalStrength() {
|
||||||
return mCellSignalStrengthCdma;
|
return mCellSignalStrengthCdma;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@Override
|
||||||
|
public CellInfo sanitizeLocationInfo() {
|
||||||
|
CellInfoCdma result = new CellInfoCdma(this);
|
||||||
|
result.mCellIdentityCdma = mCellIdentityCdma.sanitizeLocationInfo();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void setCellSignalStrength(CellSignalStrengthCdma css) {
|
public void setCellSignalStrength(CellSignalStrengthCdma css) {
|
||||||
mCellSignalStrengthCdma = css;
|
mCellSignalStrengthCdma = css;
|
||||||
|
|||||||
@@ -84,6 +84,15 @@ public final class CellInfoGsm extends CellInfo implements Parcelable {
|
|||||||
public CellSignalStrengthGsm getCellSignalStrength() {
|
public CellSignalStrengthGsm getCellSignalStrength() {
|
||||||
return mCellSignalStrengthGsm;
|
return mCellSignalStrengthGsm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@Override
|
||||||
|
public CellInfo sanitizeLocationInfo() {
|
||||||
|
CellInfoGsm result = new CellInfoGsm(this);
|
||||||
|
result.mCellIdentityGsm = mCellIdentityGsm.sanitizeLocationInfo();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void setCellSignalStrength(CellSignalStrengthGsm css) {
|
public void setCellSignalStrength(CellSignalStrengthGsm css) {
|
||||||
mCellSignalStrengthGsm = css;
|
mCellSignalStrengthGsm = css;
|
||||||
|
|||||||
@@ -96,6 +96,15 @@ public final class CellInfoLte extends CellInfo implements Parcelable {
|
|||||||
if (DBG) log("getCellSignalStrength: " + mCellSignalStrengthLte);
|
if (DBG) log("getCellSignalStrength: " + mCellSignalStrengthLte);
|
||||||
return mCellSignalStrengthLte;
|
return mCellSignalStrengthLte;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@Override
|
||||||
|
public CellInfo sanitizeLocationInfo() {
|
||||||
|
CellInfoLte result = new CellInfoLte(this);
|
||||||
|
result.mCellIdentityLte = mCellIdentityLte.sanitizeLocationInfo();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||||
public void setCellSignalStrength(CellSignalStrengthLte css) {
|
public void setCellSignalStrength(CellSignalStrengthLte css) {
|
||||||
|
|||||||
@@ -36,6 +36,13 @@ public final class CellInfoNr extends CellInfo {
|
|||||||
mCellSignalStrength = CellSignalStrengthNr.CREATOR.createFromParcel(in);
|
mCellSignalStrength = CellSignalStrengthNr.CREATOR.createFromParcel(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CellInfoNr(CellInfoNr other, boolean sanitizeLocationInfo) {
|
||||||
|
super(other);
|
||||||
|
mCellIdentity = sanitizeLocationInfo ? other.mCellIdentity.sanitizeLocationInfo()
|
||||||
|
: other.mCellIdentity;
|
||||||
|
mCellSignalStrength = other.mCellSignalStrength;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NonNull
|
@NonNull
|
||||||
public CellIdentity getCellIdentity() {
|
public CellIdentity getCellIdentity() {
|
||||||
@@ -48,6 +55,12 @@ public final class CellInfoNr extends CellInfo {
|
|||||||
return mCellSignalStrength;
|
return mCellSignalStrength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@Override
|
||||||
|
public CellInfo sanitizeLocationInfo() {
|
||||||
|
return new CellInfoNr(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(super.hashCode(), mCellIdentity, mCellSignalStrength);
|
return Objects.hash(super.hashCode(), mCellIdentity, mCellSignalStrength);
|
||||||
|
|||||||
@@ -90,6 +90,14 @@ public final class CellInfoTdscdma extends CellInfo implements Parcelable {
|
|||||||
return mCellSignalStrengthTdscdma;
|
return mCellSignalStrengthTdscdma;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@Override
|
||||||
|
public CellInfo sanitizeLocationInfo() {
|
||||||
|
CellInfoTdscdma result = new CellInfoTdscdma(this);
|
||||||
|
result.mCellIdentityTdscdma = mCellIdentityTdscdma.sanitizeLocationInfo();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void setCellSignalStrength(CellSignalStrengthTdscdma css) {
|
public void setCellSignalStrength(CellSignalStrengthTdscdma css) {
|
||||||
mCellSignalStrengthTdscdma = css;
|
mCellSignalStrengthTdscdma = css;
|
||||||
|
|||||||
@@ -84,6 +84,15 @@ public final class CellInfoWcdma extends CellInfo implements Parcelable {
|
|||||||
public CellSignalStrengthWcdma getCellSignalStrength() {
|
public CellSignalStrengthWcdma getCellSignalStrength() {
|
||||||
return mCellSignalStrengthWcdma;
|
return mCellSignalStrengthWcdma;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@Override
|
||||||
|
public CellInfo sanitizeLocationInfo() {
|
||||||
|
CellInfoWcdma result = new CellInfoWcdma(this);
|
||||||
|
result.mCellIdentityWcdma = mCellIdentityWcdma.sanitizeLocationInfo();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void setCellSignalStrength(CellSignalStrengthWcdma css) {
|
public void setCellSignalStrength(CellSignalStrengthWcdma css) {
|
||||||
mCellSignalStrengthWcdma = css;
|
mCellSignalStrengthWcdma = css;
|
||||||
|
|||||||
@@ -6864,6 +6864,17 @@ public class TelephonyManager {
|
|||||||
* app has carrier privileges (see {@link #hasCarrierPrivileges})
|
* app has carrier privileges (see {@link #hasCarrierPrivileges})
|
||||||
* and {@link android.Manifest.permission#ACCESS_FINE_LOCATION}.
|
* and {@link android.Manifest.permission#ACCESS_FINE_LOCATION}.
|
||||||
*
|
*
|
||||||
|
* If the system-wide location switch is off, apps may still call this API, with the
|
||||||
|
* following constraints:
|
||||||
|
* <ol>
|
||||||
|
* <li>The app must hold the {@code android.permission.NETWORK_SCAN} permission.</li>
|
||||||
|
* <li>The app must not supply any specific bands or channels to scan.</li>
|
||||||
|
* <li>The app must only specify MCC/MNC pairs that are
|
||||||
|
* associated to a SIM in the device.</li>
|
||||||
|
* <li>Returned results will have no meaningful info other than signal strength
|
||||||
|
* and MCC/MNC info.</li>
|
||||||
|
* </ol>
|
||||||
|
*
|
||||||
* @param request Contains all the RAT with bands/channels that need to be scanned.
|
* @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
|
* @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
|
* request may trigger multiple callbacks and they must be invoked in the same order as
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ public final class TelephonyScanManager {
|
|||||||
public static final int CALLBACK_SCAN_ERROR = 2;
|
public static final int CALLBACK_SCAN_ERROR = 2;
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public static final int CALLBACK_SCAN_COMPLETE = 3;
|
public static final int CALLBACK_SCAN_COMPLETE = 3;
|
||||||
|
/** @hide */
|
||||||
|
public static final int CALLBACK_RESTRICTED_SCAN_RESULTS = 4;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public static final int INVALID_SCAN_ID = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The caller of
|
* The caller of
|
||||||
@@ -129,6 +134,7 @@ public final class TelephonyScanManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
|
case CALLBACK_RESTRICTED_SCAN_RESULTS:
|
||||||
case CALLBACK_SCAN_RESULTS:
|
case CALLBACK_SCAN_RESULTS:
|
||||||
try {
|
try {
|
||||||
final Bundle b = message.getData();
|
final Bundle b = message.getData();
|
||||||
@@ -139,7 +145,7 @@ public final class TelephonyScanManager {
|
|||||||
}
|
}
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
Rlog.d(TAG, "onResults: " + ci.toString());
|
Rlog.d(TAG, "onResults: " + ci.toString());
|
||||||
callback.onResults((List<CellInfo>) Arrays.asList(ci));
|
callback.onResults(Arrays.asList(ci));
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Rlog.e(TAG, "Exception in networkscan callback onResults", e);
|
Rlog.e(TAG, "Exception in networkscan callback onResults", e);
|
||||||
@@ -200,6 +206,10 @@ public final class TelephonyScanManager {
|
|||||||
if (telephony != null) {
|
if (telephony != null) {
|
||||||
int scanId = telephony.requestNetworkScan(
|
int scanId = telephony.requestNetworkScan(
|
||||||
subId, request, mMessenger, new Binder(), callingPackage);
|
subId, request, mMessenger, new Binder(), callingPackage);
|
||||||
|
if (scanId == INVALID_SCAN_ID) {
|
||||||
|
Rlog.e(TAG, "Failed to initiate network scan");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
saveScanInfo(scanId, request, executor, callback);
|
saveScanInfo(scanId, request, executor, callback);
|
||||||
return new NetworkScan(scanId, subId);
|
return new NetworkScan(scanId, subId);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user