Merge "Ensure that ScanInfo is cached before callbacks fire" am: af740606e8 am: f8caad7478
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1864976 Change-Id: Ia8fd33f656c3f1e4448b0ae7da357f4af6c6c281
This commit is contained in:
@@ -36,6 +36,7 @@ import com.android.telephony.Rlog;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,16 +153,9 @@ public final class TelephonyScanManager {
|
|||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"Failed to find NetworkScanInfo with id " + message.arg2);
|
"Failed to find NetworkScanInfo with id " + message.arg2);
|
||||||
}
|
}
|
||||||
NetworkScanCallback callback = nsi.mCallback;
|
|
||||||
Executor executor = nsi.mExecutor;
|
final NetworkScanCallback callback = nsi.mCallback;
|
||||||
if (callback == null) {
|
final Executor executor = nsi.mExecutor;
|
||||||
throw new RuntimeException(
|
|
||||||
"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_RESTRICTED_SCAN_RESULTS:
|
case CALLBACK_RESTRICTED_SCAN_RESULTS:
|
||||||
@@ -246,17 +240,24 @@ public final class TelephonyScanManager {
|
|||||||
NetworkScanRequest request, Executor executor, NetworkScanCallback callback,
|
NetworkScanRequest request, Executor executor, NetworkScanCallback callback,
|
||||||
String callingPackage, @Nullable String callingFeatureId) {
|
String callingPackage, @Nullable String callingFeatureId) {
|
||||||
try {
|
try {
|
||||||
|
Objects.requireNonNull(request, "Request was null");
|
||||||
|
Objects.requireNonNull(callback, "Callback was null");
|
||||||
|
Objects.requireNonNull(executor, "Executor was null");
|
||||||
final ITelephony telephony = getITelephony();
|
final ITelephony telephony = getITelephony();
|
||||||
if (telephony == null) return null;
|
if (telephony == null) return null;
|
||||||
|
|
||||||
int scanId = telephony.requestNetworkScan(
|
// The lock must be taken before calling requestNetworkScan because the resulting
|
||||||
subId, request, mMessenger, new Binder(), callingPackage,
|
// scanId can be invoked asynchronously on another thread at any time after
|
||||||
callingFeatureId);
|
// requestNetworkScan invoked, leaving a critical section between that call and adding
|
||||||
if (scanId == INVALID_SCAN_ID) {
|
// the record to the ScanInfo cache.
|
||||||
Rlog.e(TAG, "Failed to initiate network scan");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
synchronized (mScanInfo) {
|
synchronized (mScanInfo) {
|
||||||
|
int scanId = telephony.requestNetworkScan(
|
||||||
|
subId, request, mMessenger, new Binder(), callingPackage,
|
||||||
|
callingFeatureId);
|
||||||
|
if (scanId == INVALID_SCAN_ID) {
|
||||||
|
Rlog.e(TAG, "Failed to initiate network scan");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// We link to death whenever a scan is started to ensure that we are linked
|
// We link to death whenever a scan is started to ensure that we are linked
|
||||||
// at the point that phone process death might matter.
|
// at the point that phone process death might matter.
|
||||||
// We never unlink because:
|
// We never unlink because:
|
||||||
|
|||||||
Reference in New Issue
Block a user