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; 23aebc726105204f8a7b977eb3556c14b5ba18a5caHemant Guptaimport android.os.SystemProperties; 24a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport android.util.Log; 25a7e8ef3f77ac74449f817f36f570a3545285be85fredc 26a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport com.android.bluetooth.R; 27a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport com.android.bluetooth.a2dp.A2dpService; 28c030f08f419d596c4aa216c9cca9867e7b5486f0Mike Lockwoodimport com.android.bluetooth.a2dp.A2dpSinkService; 29066ad9e16a548218b139424f758b92db7af34af2Mike Lockwoodimport com.android.bluetooth.avrcp.AvrcpControllerService; 30a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport com.android.bluetooth.hdp.HealthService; 31a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport com.android.bluetooth.hfp.HeadsetService; 328d536f3db19e8ea7426e98e470dc15d10ecbae87Mike Lockwoodimport com.android.bluetooth.hfpclient.HeadsetClientService; 33a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport com.android.bluetooth.hid.HidService; 34a7e8ef3f77ac74449f817f36f570a3545285be85fredcimport com.android.bluetooth.pan.PanService; 3503b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Battaimport com.android.bluetooth.gatt.GattService; 3670be005a18a35ec5fcb46152f0dfbe82156efa3aKim Schulzimport com.android.bluetooth.map.BluetoothMapService; 37a7e8ef3f77ac74449f817f36f570a3545285be85fredc 38a7e8ef3f77ac74449f817f36f570a3545285be85fredcpublic class Config { 39a7e8ef3f77ac74449f817f36f570a3545285be85fredc private static final String TAG = "AdapterServiceConfig"; 40a7e8ef3f77ac74449f817f36f570a3545285be85fredc /** 41a7e8ef3f77ac74449f817f36f570a3545285be85fredc * List of profile services. 42a7e8ef3f77ac74449f817f36f570a3545285be85fredc */ 43a7e8ef3f77ac74449f817f36f570a3545285be85fredc @SuppressWarnings("rawtypes") 44a7e8ef3f77ac74449f817f36f570a3545285be85fredc //Do not inclue OPP and PBAP, because their services 45a7e8ef3f77ac74449f817f36f570a3545285be85fredc //are not managed by AdapterService 46a7e8ef3f77ac74449f817f36f570a3545285be85fredc private static final Class[] PROFILE_SERVICES = { 47a7e8ef3f77ac74449f817f36f570a3545285be85fredc HeadsetService.class, 48a7e8ef3f77ac74449f817f36f570a3545285be85fredc A2dpService.class, 49c030f08f419d596c4aa216c9cca9867e7b5486f0Mike Lockwood A2dpSinkService.class, 50a7e8ef3f77ac74449f817f36f570a3545285be85fredc HidService.class, 51a7e8ef3f77ac74449f817f36f570a3545285be85fredc HealthService.class, 5203b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta PanService.class, 5370be005a18a35ec5fcb46152f0dfbe82156efa3aKim Schulz GattService.class, 54aebc726105204f8a7b977eb3556c14b5ba18a5caHemant Gupta BluetoothMapService.class, 558d536f3db19e8ea7426e98e470dc15d10ecbae87Mike Lockwood HeadsetClientService.class, 56066ad9e16a548218b139424f758b92db7af34af2Mike Lockwood AvrcpControllerService.class, 57a7e8ef3f77ac74449f817f36f570a3545285be85fredc }; 58a7e8ef3f77ac74449f817f36f570a3545285be85fredc /** 59a7e8ef3f77ac74449f817f36f570a3545285be85fredc * Resource flag to indicate whether profile is supported or not. 60a7e8ef3f77ac74449f817f36f570a3545285be85fredc */ 61a7e8ef3f77ac74449f817f36f570a3545285be85fredc private static final int[] PROFILE_SERVICES_FLAG = { 62a7e8ef3f77ac74449f817f36f570a3545285be85fredc R.bool.profile_supported_hs_hfp, 63a7e8ef3f77ac74449f817f36f570a3545285be85fredc R.bool.profile_supported_a2dp, 64c030f08f419d596c4aa216c9cca9867e7b5486f0Mike Lockwood R.bool.profile_supported_a2dp_sink, 65a7e8ef3f77ac74449f817f36f570a3545285be85fredc R.bool.profile_supported_hid, 66a7e8ef3f77ac74449f817f36f570a3545285be85fredc R.bool.profile_supported_hdp, 6703b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta R.bool.profile_supported_pan, 6870be005a18a35ec5fcb46152f0dfbe82156efa3aKim Schulz R.bool.profile_supported_gatt, 69aebc726105204f8a7b977eb3556c14b5ba18a5caHemant Gupta R.bool.profile_supported_map, 70066ad9e16a548218b139424f758b92db7af34af2Mike Lockwood R.bool.profile_supported_hfpclient, 71066ad9e16a548218b139424f758b92db7af34af2Mike Lockwood R.bool.profile_supported_avrcp_controller, 72a7e8ef3f77ac74449f817f36f570a3545285be85fredc }; 73a7e8ef3f77ac74449f817f36f570a3545285be85fredc 74a7e8ef3f77ac74449f817f36f570a3545285be85fredc private static Class[] SUPPORTED_PROFILES = new Class[0]; 75a7e8ef3f77ac74449f817f36f570a3545285be85fredc 76a7e8ef3f77ac74449f817f36f570a3545285be85fredc static void init(Context ctx) { 77a7e8ef3f77ac74449f817f36f570a3545285be85fredc if (ctx == null) { 78a7e8ef3f77ac74449f817f36f570a3545285be85fredc return; 79a7e8ef3f77ac74449f817f36f570a3545285be85fredc } 80a7e8ef3f77ac74449f817f36f570a3545285be85fredc Resources resources = ctx.getResources(); 81a7e8ef3f77ac74449f817f36f570a3545285be85fredc if (resources == null) { 82a7e8ef3f77ac74449f817f36f570a3545285be85fredc return; 83a7e8ef3f77ac74449f817f36f570a3545285be85fredc } 84a7e8ef3f77ac74449f817f36f570a3545285be85fredc ArrayList<Class> profiles = new ArrayList<Class>(PROFILE_SERVICES.length); 85a7e8ef3f77ac74449f817f36f570a3545285be85fredc for (int i=0; i < PROFILE_SERVICES_FLAG.length; i++) { 86a7e8ef3f77ac74449f817f36f570a3545285be85fredc boolean supported = resources.getBoolean(PROFILE_SERVICES_FLAG[i]); 87a7e8ef3f77ac74449f817f36f570a3545285be85fredc if (supported) { 88a7e8ef3f77ac74449f817f36f570a3545285be85fredc Log.d(TAG, "Adding " + PROFILE_SERVICES[i].getSimpleName()); 89a7e8ef3f77ac74449f817f36f570a3545285be85fredc profiles.add(PROFILE_SERVICES[i]); 90a7e8ef3f77ac74449f817f36f570a3545285be85fredc } 91a7e8ef3f77ac74449f817f36f570a3545285be85fredc } 92a7e8ef3f77ac74449f817f36f570a3545285be85fredc int totalProfiles = profiles.size(); 93a7e8ef3f77ac74449f817f36f570a3545285be85fredc SUPPORTED_PROFILES = new Class[totalProfiles]; 94a7e8ef3f77ac74449f817f36f570a3545285be85fredc profiles.toArray(SUPPORTED_PROFILES); 95a7e8ef3f77ac74449f817f36f570a3545285be85fredc } 96a7e8ef3f77ac74449f817f36f570a3545285be85fredc 97a7e8ef3f77ac74449f817f36f570a3545285be85fredc static Class[] getSupportedProfiles() { 98a7e8ef3f77ac74449f817f36f570a3545285be85fredc return SUPPORTED_PROFILES; 99a7e8ef3f77ac74449f817f36f570a3545285be85fredc } 100a7e8ef3f77ac74449f817f36f570a3545285be85fredc} 101