1 /*
2  * Copyright (C) 2011 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 BleAdvertiserTestActivity extends PassFailButtons.TestListActivity {
33 
34     @Override
onCreate(Bundle savedInstanceState)35     protected void onCreate(Bundle savedInstanceState) {
36         super.onCreate(savedInstanceState);
37         setContentView(R.layout.pass_fail_list);
38         setPassFailButtonClickListeners();
39         setInfoResources(R.string.ble_advertiser_test_name, R.string.ble_advertiser_test_info, -1);
40 
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.BleAdvertiserHardwareScanFilterActivity.");
46         }
47 
48         setTestListAdapter(new ManifestTestListAdapter(this, getClass().getName(),
49                 disabledTest.toArray(new String[disabledTest.size()])));
50         if (!adapter.isEnabled()) {
51             new AlertDialog.Builder(this)
52                     .setTitle(R.string.ble_bluetooth_disable_title)
53                     .setMessage(R.string.ble_bluetooth_disable_message)
54                     .setOnCancelListener(new Dialog.OnCancelListener() {
55                         @Override
56                         public void onCancel(DialogInterface dialog) {
57                             finish();
58                         }
59                     })
60                     .create().show();
61         }
62     }
63 }
64