Merge "Merge "Address the API review comments." am: 322ff16301 am: 904826d293" into pi-dev-plus-aosp
This commit is contained in:
committed by
Android (Google) Code Review
commit
c71071cf89
@@ -42139,11 +42139,9 @@ package android.telecom {
|
|||||||
package android.telephony {
|
package android.telephony {
|
||||||
|
|
||||||
public final class AccessNetworkConstants {
|
public final class AccessNetworkConstants {
|
||||||
ctor public AccessNetworkConstants();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class AccessNetworkConstants.AccessNetworkType {
|
public static final class AccessNetworkConstants.AccessNetworkType {
|
||||||
ctor public AccessNetworkConstants.AccessNetworkType();
|
|
||||||
field public static final int CDMA2000 = 4; // 0x4
|
field public static final int CDMA2000 = 4; // 0x4
|
||||||
field public static final int EUTRAN = 3; // 0x3
|
field public static final int EUTRAN = 3; // 0x3
|
||||||
field public static final int GERAN = 1; // 0x1
|
field public static final int GERAN = 1; // 0x1
|
||||||
@@ -42153,7 +42151,6 @@ package android.telephony {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final class AccessNetworkConstants.EutranBand {
|
public static final class AccessNetworkConstants.EutranBand {
|
||||||
ctor public AccessNetworkConstants.EutranBand();
|
|
||||||
field public static final int BAND_1 = 1; // 0x1
|
field public static final int BAND_1 = 1; // 0x1
|
||||||
field public static final int BAND_10 = 10; // 0xa
|
field public static final int BAND_10 = 10; // 0xa
|
||||||
field public static final int BAND_11 = 11; // 0xb
|
field public static final int BAND_11 = 11; // 0xb
|
||||||
@@ -42205,7 +42202,6 @@ package android.telephony {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final class AccessNetworkConstants.GeranBand {
|
public static final class AccessNetworkConstants.GeranBand {
|
||||||
ctor public AccessNetworkConstants.GeranBand();
|
|
||||||
field public static final int BAND_450 = 3; // 0x3
|
field public static final int BAND_450 = 3; // 0x3
|
||||||
field public static final int BAND_480 = 4; // 0x4
|
field public static final int BAND_480 = 4; // 0x4
|
||||||
field public static final int BAND_710 = 5; // 0x5
|
field public static final int BAND_710 = 5; // 0x5
|
||||||
@@ -42223,7 +42219,6 @@ package android.telephony {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final class AccessNetworkConstants.UtranBand {
|
public static final class AccessNetworkConstants.UtranBand {
|
||||||
ctor public AccessNetworkConstants.UtranBand();
|
|
||||||
field public static final int BAND_1 = 1; // 0x1
|
field public static final int BAND_1 = 1; // 0x1
|
||||||
field public static final int BAND_10 = 10; // 0xa
|
field public static final int BAND_10 = 10; // 0xa
|
||||||
field public static final int BAND_11 = 11; // 0xb
|
field public static final int BAND_11 = 11; // 0xb
|
||||||
@@ -42664,7 +42659,8 @@ package android.telephony {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class NetworkScan {
|
public class NetworkScan {
|
||||||
method public void stop() throws android.os.RemoteException;
|
method public deprecated void stop() throws android.os.RemoteException;
|
||||||
|
method public void stopScan();
|
||||||
field public static final int ERROR_INTERRUPTED = 10002; // 0x2712
|
field public static final int ERROR_INTERRUPTED = 10002; // 0x2712
|
||||||
field public static final int ERROR_INVALID_SCAN = 2; // 0x2
|
field public static final int ERROR_INVALID_SCAN = 2; // 0x2
|
||||||
field public static final int ERROR_INVALID_SCANID = 10001; // 0x2711
|
field public static final int ERROR_INVALID_SCANID = 10001; // 0x2711
|
||||||
@@ -43129,7 +43125,8 @@ package android.telephony {
|
|||||||
method public boolean isVoicemailVibrationEnabled(android.telecom.PhoneAccountHandle);
|
method public boolean isVoicemailVibrationEnabled(android.telecom.PhoneAccountHandle);
|
||||||
method public boolean isWorldPhone();
|
method public boolean isWorldPhone();
|
||||||
method public void listen(android.telephony.PhoneStateListener, int);
|
method public void listen(android.telephony.PhoneStateListener, int);
|
||||||
method public android.telephony.NetworkScan requestNetworkScan(android.telephony.NetworkScanRequest, android.telephony.TelephonyScanManager.NetworkScanCallback);
|
method public android.telephony.NetworkScan requestNetworkScan(android.telephony.NetworkScanRequest, java.util.concurrent.Executor, android.telephony.TelephonyScanManager.NetworkScanCallback);
|
||||||
|
method public deprecated android.telephony.NetworkScan requestNetworkScan(android.telephony.NetworkScanRequest, android.telephony.TelephonyScanManager.NetworkScanCallback);
|
||||||
method public void sendDialerSpecialCode(java.lang.String);
|
method public void sendDialerSpecialCode(java.lang.String);
|
||||||
method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
|
method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
|
||||||
method public void sendUssdRequest(java.lang.String, android.telephony.TelephonyManager.UssdResponseCallback, android.os.Handler);
|
method public void sendUssdRequest(java.lang.String, android.telephony.TelephonyManager.UssdResponseCallback, android.os.Handler);
|
||||||
|
|||||||
@@ -4986,7 +4986,6 @@ package android.telecom {
|
|||||||
package android.telephony {
|
package android.telephony {
|
||||||
|
|
||||||
public static final class AccessNetworkConstants.TransportType {
|
public static final class AccessNetworkConstants.TransportType {
|
||||||
ctor public AccessNetworkConstants.TransportType();
|
|
||||||
field public static final int WLAN = 2; // 0x2
|
field public static final int WLAN = 2; // 0x2
|
||||||
field public static final int WWAN = 1; // 0x1
|
field public static final int WWAN = 1; // 0x1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ public final class AccessNetworkConstants {
|
|||||||
public static final int EUTRAN = 3;
|
public static final int EUTRAN = 3;
|
||||||
public static final int CDMA2000 = 4;
|
public static final int CDMA2000 = 4;
|
||||||
public static final int IWLAN = 5;
|
public static final int IWLAN = 5;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
private AccessNetworkType() {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +45,9 @@ public final class AccessNetworkConstants {
|
|||||||
public static final int WWAN = 1;
|
public static final int WWAN = 1;
|
||||||
/** Wireless Local Area Networks (i.e. Wifi) */
|
/** Wireless Local Area Networks (i.e. Wifi) */
|
||||||
public static final int WLAN = 2;
|
public static final int WLAN = 2;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
private TransportType() {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,6 +69,9 @@ public final class AccessNetworkConstants {
|
|||||||
public static final int BAND_DCS1800 = 12;
|
public static final int BAND_DCS1800 = 12;
|
||||||
public static final int BAND_PCS1900 = 13;
|
public static final int BAND_PCS1900 = 13;
|
||||||
public static final int BAND_ER900 = 14;
|
public static final int BAND_ER900 = 14;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
private GeranBand() {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,6 +101,9 @@ public final class AccessNetworkConstants {
|
|||||||
/** band 23, 24 are reserved */
|
/** band 23, 24 are reserved */
|
||||||
public static final int BAND_25 = 25;
|
public static final int BAND_25 = 25;
|
||||||
public static final int BAND_26 = 26;
|
public static final int BAND_26 = 26;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
private UtranBand() {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,6 +159,9 @@ public final class AccessNetworkConstants {
|
|||||||
public static final int BAND_66 = 66;
|
public static final int BAND_66 = 66;
|
||||||
public static final int BAND_68 = 68;
|
public static final int BAND_68 = 68;
|
||||||
public static final int BAND_70 = 70;
|
public static final int BAND_70 = 70;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
private EutranBand() {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -179,5 +194,11 @@ public final class AccessNetworkConstants {
|
|||||||
public static final int BAND_19 = 20;
|
public static final int BAND_19 = 20;
|
||||||
public static final int BAND_20 = 21;
|
public static final int BAND_20 = 21;
|
||||||
public static final int BAND_21 = 22;
|
public static final int BAND_21 = 22;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
private CdmaBands() {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
private AccessNetworkConstants() {};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The caller of
|
* The caller of
|
||||||
* {@link TelephonyManager#requestNetworkScan(NetworkScanRequest, NetworkScanCallback)}
|
* {@link TelephonyManager#requestNetworkScan(NetworkScanRequest, Executor, NetworkScanCallback)}
|
||||||
* will receive an instance of {@link NetworkScan}, which contains a callback method
|
* will receive an instance of {@link NetworkScan}, which contains a callback method
|
||||||
* {@link #stop()} for stopping the in-progress scan.
|
* {@link #stopScan()} for stopping the in-progress scan.
|
||||||
*/
|
*/
|
||||||
public class NetworkScan {
|
public class NetworkScan {
|
||||||
|
|
||||||
@@ -106,16 +106,26 @@ public class NetworkScan {
|
|||||||
* Use this method to stop an ongoing scan. When user requests a new scan, a {@link NetworkScan}
|
* Use this method to stop an ongoing scan. When user requests a new scan, a {@link NetworkScan}
|
||||||
* object will be returned, and the user can stop the scan by calling this method.
|
* object will be returned, and the user can stop the scan by calling this method.
|
||||||
*/
|
*/
|
||||||
public void stop() throws RemoteException {
|
public void stopScan() {
|
||||||
|
ITelephony telephony = getITelephony();
|
||||||
|
if (telephony == null) {
|
||||||
|
Rlog.e(TAG, "Failed to get the ITelephony instance.");
|
||||||
|
throw new RuntimeException("Failed to get the ITelephony instance.");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
ITelephony telephony = getITelephony();
|
telephony.stopNetworkScan(mSubId, mScanId);
|
||||||
if (telephony != null) {
|
|
||||||
telephony.stopNetworkScan(mSubId, mScanId);
|
|
||||||
} else {
|
|
||||||
throw new RemoteException("Failed to get the ITelephony instance.");
|
|
||||||
}
|
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Rlog.e(TAG, "stopNetworkScan RemoteException", ex);
|
Rlog.e(TAG, "stopNetworkScan RemoteException", ex);
|
||||||
|
ex.rethrowAsRuntimeException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @deprecated Use {@link #stopScan()} */
|
||||||
|
@Deprecated
|
||||||
|
public void stop() throws RemoteException {
|
||||||
|
try {
|
||||||
|
stopScan();
|
||||||
|
} catch (RuntimeException ex) {
|
||||||
throw new RemoteException("Failed to stop the network scan with id " + mScanId);
|
throw new RemoteException("Failed to stop the network scan with id " + mScanId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import android.content.Intent;
|
|||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkStats;
|
import android.net.NetworkStats;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.BatteryStats;
|
import android.os.BatteryStats;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -74,6 +75,7 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@@ -5394,21 +5396,35 @@ public class TelephonyManager {
|
|||||||
* <p>
|
* <p>
|
||||||
* Requires Permission:
|
* Requires Permission:
|
||||||
* {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}
|
* {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}
|
||||||
* Or the calling app has carrier privileges. @see #hasCarrierPrivileges
|
* Or the calling app has carrier privileges. @see #hasCarrierPrivileges()
|
||||||
*
|
*
|
||||||
* @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.
|
||||||
* @param callback Returns network scan results or errors.
|
* @param callback Returns network scan results or errors.
|
||||||
* @return A NetworkScan obj which contains a callback which can be used to stop the scan.
|
* @return A NetworkScan obj which contains a callback which can be used to stop the scan.
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||||
public NetworkScan requestNetworkScan(
|
public NetworkScan requestNetworkScan(
|
||||||
NetworkScanRequest request, TelephonyScanManager.NetworkScanCallback callback) {
|
NetworkScanRequest request, Executor executor,
|
||||||
|
TelephonyScanManager.NetworkScanCallback callback) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (mTelephonyScanManager == null) {
|
if (mTelephonyScanManager == null) {
|
||||||
mTelephonyScanManager = new TelephonyScanManager();
|
mTelephonyScanManager = new TelephonyScanManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mTelephonyScanManager.requestNetworkScan(getSubId(), request, callback);
|
return mTelephonyScanManager.requestNetworkScan(getSubId(), request, executor, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* Use {@link
|
||||||
|
* #requestNetworkScan(NetworkScanRequest, Executor, TelephonyScanManager.NetworkScanCallback)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||||
|
public NetworkScan requestNetworkScan(
|
||||||
|
NetworkScanRequest request, TelephonyScanManager.NetworkScanCallback callback) {
|
||||||
|
return requestNetworkScan(request, AsyncTask.THREAD_POOL_EXECUTOR, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import android.util.Log;
|
|||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import com.android.internal.telephony.ITelephony;
|
import com.android.internal.telephony.ITelephony;
|
||||||
|
|
||||||
@@ -55,8 +56,10 @@ public final class TelephonyScanManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The caller of
|
* The caller of
|
||||||
* {@link TelephonyManager#requestNetworkScan(NetworkScanRequest, NetworkScanCallback)} should
|
* {@link
|
||||||
* implement and provide this callback so that the scan results or errors can be returned.
|
* TelephonyManager#requestNetworkScan(NetworkScanRequest, Executor, NetworkScanCallback)}
|
||||||
|
* should implement and provide this callback so that the scan results or errors can be
|
||||||
|
* returned.
|
||||||
*/
|
*/
|
||||||
public static abstract class NetworkScanCallback {
|
public static abstract class NetworkScanCallback {
|
||||||
/** Returns the scan results to the user, this callback will be called multiple times. */
|
/** Returns the scan results to the user, this callback will be called multiple times. */
|
||||||
@@ -83,10 +86,13 @@ public final class TelephonyScanManager {
|
|||||||
|
|
||||||
private static class NetworkScanInfo {
|
private static class NetworkScanInfo {
|
||||||
private final NetworkScanRequest mRequest;
|
private final NetworkScanRequest mRequest;
|
||||||
|
private final Executor mExecutor;
|
||||||
private final NetworkScanCallback mCallback;
|
private final NetworkScanCallback mCallback;
|
||||||
|
|
||||||
NetworkScanInfo(NetworkScanRequest request, NetworkScanCallback callback) {
|
NetworkScanInfo(
|
||||||
|
NetworkScanRequest request, Executor executor, NetworkScanCallback callback) {
|
||||||
mRequest = request;
|
mRequest = request;
|
||||||
|
mExecutor = executor;
|
||||||
mCallback = callback;
|
mCallback = callback;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,10 +118,15 @@ public final class TelephonyScanManager {
|
|||||||
"Failed to find NetworkScanInfo with id " + message.arg2);
|
"Failed to find NetworkScanInfo with id " + message.arg2);
|
||||||
}
|
}
|
||||||
NetworkScanCallback callback = nsi.mCallback;
|
NetworkScanCallback callback = nsi.mCallback;
|
||||||
|
Executor executor = nsi.mExecutor;
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"Failed to find NetworkScanCallback with id " + message.arg2);
|
"Failed to find NetworkScanCallback with id " + message.arg2);
|
||||||
}
|
}
|
||||||
|
if (executor == null) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"Failed to find Executor with id " + message.arg2);
|
||||||
|
}
|
||||||
|
|
||||||
switch (message.what) {
|
switch (message.what) {
|
||||||
case CALLBACK_SCAN_RESULTS:
|
case CALLBACK_SCAN_RESULTS:
|
||||||
@@ -126,21 +137,22 @@ public final class TelephonyScanManager {
|
|||||||
for (int i = 0; i < parcelables.length; i++) {
|
for (int i = 0; i < parcelables.length; i++) {
|
||||||
ci[i] = (CellInfo) parcelables[i];
|
ci[i] = (CellInfo) parcelables[i];
|
||||||
}
|
}
|
||||||
callback.onResults((List<CellInfo>) Arrays.asList(ci));
|
executor.execute(() ->
|
||||||
|
callback.onResults((List<CellInfo>) 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);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CALLBACK_SCAN_ERROR:
|
case CALLBACK_SCAN_ERROR:
|
||||||
try {
|
try {
|
||||||
callback.onError(message.arg1);
|
executor.execute(() -> callback.onError(message.arg1));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Rlog.e(TAG, "Exception in networkscan callback onError", e);
|
Rlog.e(TAG, "Exception in networkscan callback onError", e);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CALLBACK_SCAN_COMPLETE:
|
case CALLBACK_SCAN_COMPLETE:
|
||||||
try {
|
try {
|
||||||
callback.onComplete();
|
executor.execute(() -> callback.onComplete());
|
||||||
mScanInfo.remove(message.arg2);
|
mScanInfo.remove(message.arg2);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Rlog.e(TAG, "Exception in networkscan callback onComplete", e);
|
Rlog.e(TAG, "Exception in networkscan callback onComplete", e);
|
||||||
@@ -171,12 +183,12 @@ public final class TelephonyScanManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public NetworkScan requestNetworkScan(int subId,
|
public NetworkScan requestNetworkScan(int subId,
|
||||||
NetworkScanRequest request, NetworkScanCallback callback) {
|
NetworkScanRequest request, Executor executor, NetworkScanCallback callback) {
|
||||||
try {
|
try {
|
||||||
ITelephony telephony = getITelephony();
|
ITelephony telephony = getITelephony();
|
||||||
if (telephony != null) {
|
if (telephony != null) {
|
||||||
int scanId = telephony.requestNetworkScan(subId, request, mMessenger, new Binder());
|
int scanId = telephony.requestNetworkScan(subId, request, mMessenger, new Binder());
|
||||||
saveScanInfo(scanId, request, callback);
|
saveScanInfo(scanId, request, executor, callback);
|
||||||
return new NetworkScan(scanId, subId);
|
return new NetworkScan(scanId, subId);
|
||||||
}
|
}
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
@@ -187,9 +199,10 @@ public final class TelephonyScanManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveScanInfo(int id, NetworkScanRequest request, NetworkScanCallback callback) {
|
private void saveScanInfo(
|
||||||
|
int id, NetworkScanRequest request, Executor executor, NetworkScanCallback callback) {
|
||||||
synchronized (mScanInfo) {
|
synchronized (mScanInfo) {
|
||||||
mScanInfo.put(id, new NetworkScanInfo(request, callback));
|
mScanInfo.put(id, new NetworkScanInfo(request, executor, callback));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user