1 /* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.cts.verifier.bluetooth; 18 19 import android.app.AlertDialog; 20 import android.app.Dialog; 21 import android.bluetooth.BluetoothAdapter; 22 import android.content.DialogInterface; 23 import android.os.Bundle; 24 25 import com.android.cts.verifier.ManifestTestListAdapter; 26 import com.android.cts.verifier.PassFailButtons; 27 import com.android.cts.verifier.R; 28 29 import java.util.ArrayList; 30 import java.util.List; 31 32 public class BleScannerTestActivity extends PassFailButtons.TestListActivity { 33 34 @Override onCreate(Bundle savedInstanceState)35 public void onCreate(Bundle savedInstanceState) { 36 super.onCreate(savedInstanceState); 37 setContentView(R.layout.pass_fail_list); 38 setPassFailButtonClickListeners(); 39 setInfoResources(R.string.ble_scanner_test_name, 40 R.string.ble_scanner_test_info, -1); 41 BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); 42 List<String> disabledTest = new ArrayList<String>(); 43 if (adapter == null || !adapter.isOffloadedFilteringSupported()) { 44 disabledTest.add( 45 "com.android.cts.verifier.bluetooth.BleScannerHardwareScanFilterActivity"); 46 } 47 48 setTestListAdapter(new ManifestTestListAdapter(this, getClass().getName(), 49 disabledTest.toArray(new String[disabledTest.size()]))); 50 51 if (!adapter.isEnabled()) { 52 new AlertDialog.Builder(this) 53 .setTitle(R.string.ble_bluetooth_disable_title) 54 .setMessage(R.string.ble_bluetooth_disable_message) 55 .setOnCancelListener(new Dialog.OnCancelListener() { 56 @Override 57 public void onCancel(DialogInterface dialog) { 58 finish(); 59 } 60 }) 61 .create().show(); 62 } 63 } 64 } 65