Auto-pass when device does not support multi-advertising.
Bug: 18108754
Change-Id: I7f9b97cef188d33b3d9bb6f210142fd0b9a0bc32
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index fa86474..b61370e 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -260,7 +260,7 @@
<string name="ble_scanner_power_level_instruction">Count: Ultra low < low < medium < high\nRssi: Ultra low < low < medium < high\nDistance to see count freezing: Ultra low < low < medium < high\nA common error is ultra low, low and medium behave similarly, with similar rssi, freeze at similar distance.\n\n All power level receive a different mac address. After 15 mins, a green text "Get a new Mac address" will show up.</string>
<string name="ble_scanner_scan_filter_name">BLE Hardware Scan Filter</string>
<string name="ble_scanner_scan_filter_info">Lock the screen of scanner, and connect to monsoon. It will not wake up when advertiser is advertising unscannable, and scanner is scanning with filter.</string>
- <string name="ble_scanner_scan_filter_instruction">For monsoon test:\n\tClick scan with filter, lock the screen, connect to monsoon. It will not wake up when advertiser is advertising unscannable data packets, but will show a peak in power usage when advertiser is advertising scannable data.\nFor logcat test:\n\tClick scan with filter, logcat the scanner. No data will be received by GattService when advertiser is advertising unscannable data.</string>
+ <string name="ble_scanner_scan_filter_instruction">Scan filter is to scan data with service UUID = 0x6666 only. If you scan without scan filter, data with service UUID = 0x5555 and 0x6666 will show up on screen.\nFor monsoon test:\n\tClick scan with filter, lock the screen, connect to monsoon. It will not wake up when advertiser is advertising unscannable data packets, but will show a peak in power usage when advertiser is advertising scannable data.\nFor logcat test:\n\tClick scan with filter, logcat the scanner. No data will be received by GattService when advertiser is advertising unscannable data.</string>
<string name="ble_scan_with_filter">Scan with filter</string>
<string name="ble_scan_without_filter">Scan without filter</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleAdvertiserHardwareScanFilterActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleAdvertiserHardwareScanFilterActivity.java
index 242bb08..be2fef9 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleAdvertiserHardwareScanFilterActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleAdvertiserHardwareScanFilterActivity.java
@@ -83,6 +83,7 @@
public void onResume() {
super.onResume();
IntentFilter filter = new IntentFilter();
+ filter.addAction(BleAdvertiserService.BLE_ADV_NOT_SUPPORT);
filter.addAction(BleAdvertiserService.BLE_START_SCANNABLE);
filter.addAction(BleAdvertiserService.BLE_START_UNSCANNABLE);
filter.addAction(BleAdvertiserService.BLE_STOP_SCANNABLE);
@@ -106,6 +107,10 @@
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
}
+ private void pass() {
+ this.setTestResultAndFinish(true);
+ }
+
private void stopAdvertising() {
Intent intent = new Intent(BleAdvertiserHardwareScanFilterActivity.this,
BleAdvertiserService.class);
@@ -130,6 +135,9 @@
case BleAdvertiserService.BLE_STOP_UNSCANNABLE:
showMessage("Stop advertising");
break;
+ case BleAdvertiserService.BLE_ADV_NOT_SUPPORT:
+ pass();
+ break;
}
}
};
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleAdvertiserPowerLevelActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleAdvertiserPowerLevelActivity.java
index 3568002..1cc9206 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleAdvertiserPowerLevelActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleAdvertiserPowerLevelActivity.java
@@ -67,6 +67,7 @@
IntentFilter filter = new IntentFilter();
filter.addAction(BleAdvertiserService.BLE_START_POWER_LEVEL);
filter.addAction(BleAdvertiserService.BLE_STOP_POWER_LEVEL);
+ filter.addAction(BleAdvertiserService.BLE_ADV_NOT_SUPPORT);
registerReceiver(onBroadcast, filter);
}
@@ -94,6 +95,10 @@
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
}
+ private void pass() {
+ this.setTestResultAndFinish(true);
+ }
+
private BroadcastReceiver onBroadcast = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -104,6 +109,9 @@
case BleAdvertiserService.BLE_STOP_POWER_LEVEL:
showMessage("Stop advertising");
break;
+ case BleAdvertiserService.BLE_ADV_NOT_SUPPORT:
+ pass();
+ break;
}
}
};
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleAdvertiserService.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleAdvertiserService.java
index 7b4235b..281b2e8 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleAdvertiserService.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleAdvertiserService.java
@@ -53,6 +53,8 @@
public static final int COMMAND_START_UNSCANNABLE = 6;
public static final int COMMAND_STOP_UNSCANNABLE = 7;
+ public static final String BLE_ADV_NOT_SUPPORT =
+ "com.android.cts.verifier.bluetooth.BLE_ADV_NOT_SUPPORT";
public static final String BLE_START_ADVERTISE =
"com.android.cts.verifier.bluetooth.BLE_START_ADVERTISE";
public static final String BLE_STOP_ADVERTISE =
@@ -147,11 +149,15 @@
public void onDestroy() {
super.onDestroy();
if (mAdvertiser != null) {
- mAdvertiser.stopAdvertising(mCallback);
+ stopAdvertiser();
}
}
private void stopAdvertiser() {
+ if (mAdvertiser == null) {
+ mAdvertiserStatus = 0;
+ return;
+ }
if ((mAdvertiserStatus & (1 << COMMAND_START_ADVERTISE)) > 0) {
mAdvertiser.stopAdvertising(mCallback);
}
@@ -186,8 +192,12 @@
}
private void handleIntent(Intent intent) {
- if (mAdvertiser == null) {
- showMessage("Multi advertising not supported on this device");
+ if (mBluetoothAdapter != null && !mBluetoothAdapter.isMultipleAdvertisementSupported()) {
+ showMessage("Multiple advertisement is not supported.");
+ sendBroadcast(new Intent(BLE_ADV_NOT_SUPPORT));
+ return;
+ } else if (mAdvertiser == null) {
+ showMessage("Cannot start advertising on this device.");
return;
}
int command = intent.getIntExtra(EXTRA_COMMAND, -1);