Merge "Make sure sendresult after association was created" into sc-v2-dev am: e1211c6726
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16132112 Change-Id: I57376842363715ca36596d814a06f28acc8e9b54
This commit is contained in:
@@ -29,4 +29,6 @@ oneway interface ICompanionDeviceDiscoveryService {
|
|||||||
in String callingPackage,
|
in String callingPackage,
|
||||||
in IFindDeviceCallback findCallback,
|
in IFindDeviceCallback findCallback,
|
||||||
in AndroidFuture<Association> serviceCallback);
|
in AndroidFuture<Association> serviceCallback);
|
||||||
|
|
||||||
|
void onAssociationCreated();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,8 +254,14 @@ public class CompanionDeviceActivity extends Activity {
|
|||||||
Log.i(LOG_TAG, "onDeviceConfirmed(selectedDevice = " + selectedDevice + ")");
|
Log.i(LOG_TAG, "onDeviceConfirmed(selectedDevice = " + selectedDevice + ")");
|
||||||
getService().onDeviceSelected(
|
getService().onDeviceSelected(
|
||||||
getCallingPackage(), getDeviceMacAddress(selectedDevice.device));
|
getCallingPackage(), getDeviceMacAddress(selectedDevice.device));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setResultAndFinish() {
|
||||||
|
Log.i(LOG_TAG, "setResultAndFinish(selectedDevice = "
|
||||||
|
+ getService().mSelectedDevice.device + ")");
|
||||||
setResult(RESULT_OK,
|
setResult(RESULT_OK,
|
||||||
new Intent().putExtra(CompanionDeviceManager.EXTRA_DEVICE, selectedDevice.device));
|
new Intent().putExtra(
|
||||||
|
CompanionDeviceManager.EXTRA_DEVICE, getService().mSelectedDevice.device));
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,11 @@ public class CompanionDeviceDiscoveryService extends Service {
|
|||||||
CompanionDeviceDiscoveryService::startDiscovery,
|
CompanionDeviceDiscoveryService::startDiscovery,
|
||||||
CompanionDeviceDiscoveryService.this, request));
|
CompanionDeviceDiscoveryService.this, request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAssociationCreated() {
|
||||||
|
Handler.getMain().post(CompanionDeviceDiscoveryService.this::onAssociationCreated);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private ScanCallback mBLEScanCallback;
|
private ScanCallback mBLEScanCallback;
|
||||||
@@ -222,6 +227,11 @@ public class CompanionDeviceDiscoveryService extends Service {
|
|||||||
SCAN_TIMEOUT);
|
SCAN_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainThread
|
||||||
|
private void onAssociationCreated() {
|
||||||
|
mActivity.setResultAndFinish();
|
||||||
|
}
|
||||||
|
|
||||||
private boolean shouldScan(List<? extends DeviceFilter> mediumSpecificFilters) {
|
private boolean shouldScan(List<? extends DeviceFilter> mediumSpecificFilters) {
|
||||||
return !isEmpty(mediumSpecificFilters) || isEmpty(mFilters);
|
return !isEmpty(mediumSpecificFilters) || isEmpty(mFilters);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -457,6 +457,9 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
|
|||||||
}, FgThread.getExecutor()).whenComplete(uncheckExceptions((association, err) -> {
|
}, FgThread.getExecutor()).whenComplete(uncheckExceptions((association, err) -> {
|
||||||
if (err == null) {
|
if (err == null) {
|
||||||
addAssociation(association, userId);
|
addAssociation(association, userId);
|
||||||
|
mServiceConnectors.forUser(userId).post(service -> {
|
||||||
|
service.onAssociationCreated();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
Slog.e(LOG_TAG, "Failed to discover device(s)", err);
|
Slog.e(LOG_TAG, "Failed to discover device(s)", err);
|
||||||
callback.onFailure("No devices found: " + err.getMessage());
|
callback.onFailure("No devices found: " + err.getMessage());
|
||||||
|
|||||||
Reference in New Issue
Block a user