1ede67c26e7b2564ea35db6d9b3027a269c150e13Zhihai Xu/* 2ede67c26e7b2564ea35db6d9b3027a269c150e13Zhihai Xu * Copyright (C) 2012 The Android Open Source Project 3ede67c26e7b2564ea35db6d9b3027a269c150e13Zhihai Xu * 4ede67c26e7b2564ea35db6d9b3027a269c150e13Zhihai Xu * Licensed under the Apache License, Version 2.0 (the "License"); 5ede67c26e7b2564ea35db6d9b3027a269c150e13Zhihai Xu * you may not use this file except in compliance with the License. 6ede67c26e7b2564ea35db6d9b3027a269c150e13Zhihai Xu * You may obtain a copy of the License at 7ede67c26e7b2564ea35db6d9b3027a269c150e13Zhihai Xu * 8ede67c26e7b2564ea35db6d9b3027a269c150e13Zhihai Xu * http://www.apache.org/licenses/LICENSE-2.0 9ede67c26e7b2564ea35db6d9b3027a269c150e13Zhihai Xu * 10ede67c26e7b2564ea35db6d9b3027a269c150e13Zhihai Xu * Unless required by applicable law or agreed to in writing, software 11ede67c26e7b2564ea35db6d9b3027a269c150e13Zhihai Xu * distributed under the License is distributed on an "AS IS" BASIS, 12ede67c26e7b2564ea35db6d9b3027a269c150e13Zhihai Xu * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13ede67c26e7b2564ea35db6d9b3027a269c150e13Zhihai Xu * See the License for the specific language governing permissions and 14ede67c26e7b2564ea35db6d9b3027a269c150e13Zhihai Xu * limitations under the License. 15ede67c26e7b2564ea35db6d9b3027a269c150e13Zhihai Xu */ 16ede67c26e7b2564ea35db6d9b3027a269c150e13Zhihai Xu 17a7e8ef3f77ac74449f817f36f570a3545285be85fredcpackage com.android.bluetooth.btservice; 18a7e8ef3f77ac74449f817f36f570a3545285be85fredc 19a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport java.util.ArrayList; 20a7e8ef3f77ac74449f817f36f570a3545285be85fredc 21a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport android.content.Context; 22a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport android.content.res.Resources; 23a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport android.util.Log; 24a7e8ef3f77ac74449f817f36f570a3545285be85fredc 25a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport com.android.bluetooth.R; 26a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport com.android.bluetooth.a2dp.A2dpService; 27a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport com.android.bluetooth.hdp.HealthService; 28a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport com.android.bluetooth.hfp.HeadsetService; 29a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport com.android.bluetooth.hid.HidService; 30a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport com.android.bluetooth.pan.PanService; 3103b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Battaimport com.android.bluetooth.gatt.GattService; 3270be005a18a35ec5fcb46152f0dfbe82156efa3aKim Schulzimport com.android.bluetooth.map.BluetoothMapService; 33a7e8ef3f77ac74449f817f36f570a3545285be85fredc 34a7e8ef3f77ac74449f817f36f570a3545285be85fredcpublic class Config { 35a7e8ef3f77ac74449f817f36f570a3545285be85fredc private static final String TAG = "AdapterServiceConfig"; 36a7e8ef3f77ac74449f817f36f570a3545285be85fredc /** 37a7e8ef3f77ac74449f817f36f570a3545285be85fredc * List of profile services. 38a7e8ef3f77ac74449f817f36f570a3545285be85fredc */ 39a7e8ef3f77ac74449f817f36f570a3545285be85fredc @SuppressWarnings("rawtypes") 40a7e8ef3f77ac74449f817f36f570a3545285be85fredc //Do not inclue OPP and PBAP, because their services 41a7e8ef3f77ac74449f817f36f570a3545285be85fredc //are not managed by AdapterService 42a7e8ef3f77ac74449f817f36f570a3545285be85fredc private static final Class[] PROFILE_SERVICES = { 43a7e8ef3f77ac74449f817f36f570a3545285be85fredc HeadsetService.class, 44a7e8ef3f77ac74449f817f36f570a3545285be85fredc A2dpService.class, 45a7e8ef3f77ac74449f817f36f570a3545285be85fredc HidService.class, 46a7e8ef3f77ac74449f817f36f570a3545285be85fredc HealthService.class, 4703b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta PanService.class, 4870be005a18a35ec5fcb46152f0dfbe82156efa3aKim Schulz GattService.class, 4970be005a18a35ec5fcb46152f0dfbe82156efa3aKim Schulz BluetoothMapService.class 50a7e8ef3f77ac74449f817f36f570a3545285be85fredc }; 51a7e8ef3f77ac74449f817f36f570a3545285be85fredc /** 52a7e8ef3f77ac74449f817f36f570a3545285be85fredc * Resource flag to indicate whether profile is supported or not. 53a7e8ef3f77ac74449f817f36f570a3545285be85fredc */ 54a7e8ef3f77ac74449f817f36f570a3545285be85fredc private static final int[] PROFILE_SERVICES_FLAG = { 55a7e8ef3f77ac74449f817f36f570a3545285be85fredc R.bool.profile_supported_hs_hfp, 56a7e8ef3f77ac74449f817f36f570a3545285be85fredc R.bool.profile_supported_a2dp, 57a7e8ef3f77ac74449f817f36f570a3545285be85fredc R.bool.profile_supported_hid, 58a7e8ef3f77ac74449f817f36f570a3545285be85fredc R.bool.profile_supported_hdp, 5903b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta R.bool.profile_supported_pan, 6070be005a18a35ec5fcb46152f0dfbe82156efa3aKim Schulz R.bool.profile_supported_gatt, 6170be005a18a35ec5fcb46152f0dfbe82156efa3aKim Schulz R.bool.profile_supported_map 62a7e8ef3f77ac74449f817f36f570a3545285be85fredc }; 63a7e8ef3f77ac74449f817f36f570a3545285be85fredc 64a7e8ef3f77ac74449f817f36f570a3545285be85fredc private static Class[] SUPPORTED_PROFILES = new Class[0]; 65a7e8ef3f77ac74449f817f36f570a3545285be85fredc 66a7e8ef3f77ac74449f817f36f570a3545285be85fredc static void init(Context ctx) { 67a7e8ef3f77ac74449f817f36f570a3545285be85fredc if (ctx == null) { 68a7e8ef3f77ac74449f817f36f570a3545285be85fredc return; 69a7e8ef3f77ac74449f817f36f570a3545285be85fredc } 70a7e8ef3f77ac74449f817f36f570a3545285be85fredc Resources resources = ctx.getResources(); 71a7e8ef3f77ac74449f817f36f570a3545285be85fredc if (resources == null) { 72a7e8ef3f77ac74449f817f36f570a3545285be85fredc return; 73a7e8ef3f77ac74449f817f36f570a3545285be85fredc } 74a7e8ef3f77ac74449f817f36f570a3545285be85fredc ArrayList<Class> profiles = new ArrayList<Class>(PROFILE_SERVICES.length); 75a7e8ef3f77ac74449f817f36f570a3545285be85fredc for (int i=0; i < PROFILE_SERVICES_FLAG.length; i++) { 76a7e8ef3f77ac74449f817f36f570a3545285be85fredc boolean supported = resources.getBoolean(PROFILE_SERVICES_FLAG[i]); 77a7e8ef3f77ac74449f817f36f570a3545285be85fredc if (supported) { 78a7e8ef3f77ac74449f817f36f570a3545285be85fredc Log.d(TAG, "Adding " + PROFILE_SERVICES[i].getSimpleName()); 79a7e8ef3f77ac74449f817f36f570a3545285be85fredc profiles.add(PROFILE_SERVICES[i]); 80a7e8ef3f77ac74449f817f36f570a3545285be85fredc } 81a7e8ef3f77ac74449f817f36f570a3545285be85fredc } 82a7e8ef3f77ac74449f817f36f570a3545285be85fredc int totalProfiles = profiles.size(); 83a7e8ef3f77ac74449f817f36f570a3545285be85fredc SUPPORTED_PROFILES = new Class[totalProfiles]; 84a7e8ef3f77ac74449f817f36f570a3545285be85fredc profiles.toArray(SUPPORTED_PROFILES); 85a7e8ef3f77ac74449f817f36f570a3545285be85fredc } 86a7e8ef3f77ac74449f817f36f570a3545285be85fredc 87a7e8ef3f77ac74449f817f36f570a3545285be85fredc static Class[] getSupportedProfiles() { 88a7e8ef3f77ac74449f817f36f570a3545285be85fredc return SUPPORTED_PROFILES; 89a7e8ef3f77ac74449f817f36f570a3545285be85fredc } 90a7e8ef3f77ac74449f817f36f570a3545285be85fredc} 91