1 /* 2 * Copyright (C) 2012 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.bluetooth.btservice; 18 19 import java.util.ArrayList; 20 21 import android.content.Context; 22 import android.content.res.Resources; 23 import android.os.SystemProperties; 24 import android.util.Log; 25 26 import com.android.bluetooth.R; 27 import com.android.bluetooth.a2dp.A2dpService; 28 import com.android.bluetooth.a2dp.A2dpSinkService; 29 import com.android.bluetooth.avrcp.AvrcpControllerService; 30 import com.android.bluetooth.hdp.HealthService; 31 import com.android.bluetooth.hfp.HeadsetService; 32 import com.android.bluetooth.hfpclient.HeadsetClientService; 33 import com.android.bluetooth.hid.HidService; 34 import com.android.bluetooth.pan.PanService; 35 import com.android.bluetooth.gatt.GattService; 36 import com.android.bluetooth.map.BluetoothMapService; 37 import com.android.bluetooth.sap.SapService; 38 39 public class Config { 40 private static final String TAG = "AdapterServiceConfig"; 41 /** 42 * List of profile services. 43 */ 44 @SuppressWarnings("rawtypes") 45 //Do not inclue OPP and PBAP, because their services 46 //are not managed by AdapterService 47 private static final Class[] PROFILE_SERVICES = { 48 HeadsetService.class, 49 A2dpService.class, 50 A2dpSinkService.class, 51 HidService.class, 52 HealthService.class, 53 PanService.class, 54 GattService.class, 55 BluetoothMapService.class, 56 HeadsetClientService.class, 57 AvrcpControllerService.class, 58 SapService.class 59 }; 60 /** 61 * Resource flag to indicate whether profile is supported or not. 62 */ 63 private static final int[] PROFILE_SERVICES_FLAG = { 64 R.bool.profile_supported_hs_hfp, 65 R.bool.profile_supported_a2dp, 66 R.bool.profile_supported_a2dp_sink, 67 R.bool.profile_supported_hid, 68 R.bool.profile_supported_hdp, 69 R.bool.profile_supported_pan, 70 R.bool.profile_supported_gatt, 71 R.bool.profile_supported_map, 72 R.bool.profile_supported_hfpclient, 73 R.bool.profile_supported_avrcp_controller, 74 R.bool.profile_supported_sap, 75 }; 76 77 private static Class[] SUPPORTED_PROFILES = new Class[0]; 78 init(Context ctx)79 static void init(Context ctx) { 80 if (ctx == null) { 81 return; 82 } 83 Resources resources = ctx.getResources(); 84 if (resources == null) { 85 return; 86 } 87 ArrayList<Class> profiles = new ArrayList<Class>(PROFILE_SERVICES.length); 88 for (int i=0; i < PROFILE_SERVICES_FLAG.length; i++) { 89 boolean supported = resources.getBoolean(PROFILE_SERVICES_FLAG[i]); 90 if (supported) { 91 Log.d(TAG, "Adding " + PROFILE_SERVICES[i].getSimpleName()); 92 profiles.add(PROFILE_SERVICES[i]); 93 } 94 } 95 int totalProfiles = profiles.size(); 96 SUPPORTED_PROFILES = new Class[totalProfiles]; 97 profiles.toArray(SUPPORTED_PROFILES); 98 } 99 getSupportedProfiles()100 static Class[] getSupportedProfiles() { 101 return SUPPORTED_PROFILES; 102 } 103 } 104