Android Bluetooth SampleRate 변경
Android :
2019. 1. 8. 09:17
반응형
packages/apps/Settings/src/com/android/settings/development/DevelopmentSettings.java
2023 private void writeBluetoothConfigurationOption(Preference preference, 2024 Object newValue) { 2025 String[] summaries; 2026 int index; 2027 int codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID; 2028 int codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT; 2029 int sampleRateValue = BluetoothCodecConfig.SAMPLE_RATE_NONE; 2030 int bitsPerSampleValue = BluetoothCodecConfig.BITS_PER_SAMPLE_NONE; 2031 int channelModeValue = BluetoothCodecConfig.CHANNEL_MODE_NONE; 2032 long codecSpecific1Value = 0; 2033 long codecSpecific2Value = 0; 2034 long codecSpecific3Value = 0; 2035 long codecSpecific4Value = 0; 2036 2037 // Codec Type 2038 String codecType = mBluetoothSelectA2dpCodec.getValue(); 2039 if (preference == mBluetoothSelectA2dpCodec) { 2040 codecType = newValue.toString(); 2041 index = mBluetoothSelectA2dpCodec.findIndexOfValue(newValue.toString()); 2042 if (index >= 0) { 2043 summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_summaries); 2044 mBluetoothSelectA2dpCodec.setSummary(summaries[index]); 2045 } 2046 } 2047 index = mBluetoothSelectA2dpCodec.findIndexOfValue(codecType); 2048 switch (index) { 2049 case 0: 2050 // Reset the priority of the current codec to default 2051 String oldValue = mBluetoothSelectA2dpCodec.getValue(); 2052 switch (mBluetoothSelectA2dpCodec.findIndexOfValue(oldValue)) { 2053 case 0: 2054 break; // No current codec 2055 case 1: 2056 codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC; 2057 break; 2058 case 2: 2059 codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC; 2060 break; 2061 case 3: 2062 codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX; 2063 break; 2064 case 4: 2065 codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD; 2066 break; 2067 case 5: 2068 codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC; 2069 break; 2070 default: 2071 break; 2072 } 2073 break; 2074 case 1: 2075 codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC; 2076 codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; 2077 break; 2078 case 2: 2079 codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC; 2080 codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; 2081 break; 2082 case 3: 2083 codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX; 2084 codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; 2085 break; 2086 case 4: 2087 codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD; 2088 codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; 2089 break; 2090 case 5: 2091 codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC; 2092 codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; 2093 break; 2094 case 6: 2095 synchronized (mBluetoothA2dpLock) { 2096 if (mBluetoothA2dp != null) { 2097 mBluetoothA2dp.enableOptionalCodecs(); 2098 } 2099 } 2100 return; 2101 case 7: 2102 synchronized (mBluetoothA2dpLock) { 2103 if (mBluetoothA2dp != null) { 2104 mBluetoothA2dp.disableOptionalCodecs(); 2105 } 2106 } 2107 return; 2108 default: 2109 break; 2110 } 2111 2112 // Sample Rate 2113 String sampleRate = mBluetoothSelectA2dpSampleRate.getValue(); 2114 if (preference == mBluetoothSelectA2dpSampleRate) { 2115 sampleRate = newValue.toString(); 2116 index = mBluetoothSelectA2dpSampleRate.findIndexOfValue(newValue.toString()); 2117 if (index >= 0) { 2118 summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_sample_rate_summaries); 2119 mBluetoothSelectA2dpSampleRate.setSummary(summaries[index]); 2120 } 2121 } 2122 index = mBluetoothSelectA2dpSampleRate.findIndexOfValue(sampleRate); 2123 switch (index) { 2124 case 0: 2125 // Reset to default 2126 break; 2127 case 1: 2128 sampleRateValue = BluetoothCodecConfig.SAMPLE_RATE_44100; 2129 break; 2130 case 2: 2131 sampleRateValue = BluetoothCodecConfig.SAMPLE_RATE_48000; 2132 break; 2133 case 3: 2134 sampleRateValue = BluetoothCodecConfig.SAMPLE_RATE_88200; 2135 break; 2136 case 4: 2137 sampleRateValue = BluetoothCodecConfig.SAMPLE_RATE_96000; 2138 break; 2139 default: 2140 break; 2141 } 2142 2143 // Bits Per Sample 2144 String bitsPerSample = mBluetoothSelectA2dpBitsPerSample.getValue(); 2145 if (preference == mBluetoothSelectA2dpBitsPerSample) { 2146 bitsPerSample = newValue.toString(); 2147 index = mBluetoothSelectA2dpBitsPerSample.findIndexOfValue(newValue.toString()); 2148 if (index >= 0) { 2149 summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_bits_per_sample_summaries); 2150 mBluetoothSelectA2dpBitsPerSample.setSummary(summaries[index]); 2151 } 2152 } 2153 index = mBluetoothSelectA2dpBitsPerSample.findIndexOfValue(bitsPerSample); 2154 switch (index) { 2155 case 0: 2156 // Reset to default 2157 break; 2158 case 1: 2159 bitsPerSampleValue = BluetoothCodecConfig.BITS_PER_SAMPLE_16; 2160 break; 2161 case 2: 2162 bitsPerSampleValue = BluetoothCodecConfig.BITS_PER_SAMPLE_24; 2163 break; 2164 case 3: 2165 bitsPerSampleValue = BluetoothCodecConfig.BITS_PER_SAMPLE_32; 2166 break; 2167 default: 2168 break; 2169 } 2170 2171 // Channel Mode 2172 String channelMode = mBluetoothSelectA2dpChannelMode.getValue(); 2173 if (preference == mBluetoothSelectA2dpChannelMode) { 2174 channelMode = newValue.toString(); 2175 index = mBluetoothSelectA2dpChannelMode.findIndexOfValue(newValue.toString()); 2176 if (index >= 0) { 2177 summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_channel_mode_summaries); 2178 mBluetoothSelectA2dpChannelMode.setSummary(summaries[index]); 2179 } 2180 } 2181 index = mBluetoothSelectA2dpChannelMode.findIndexOfValue(channelMode); 2182 switch (index) { 2183 case 0: 2184 // Reset to default 2185 break; 2186 case 1: 2187 channelModeValue = BluetoothCodecConfig.CHANNEL_MODE_MONO; 2188 break; 2189 case 2: 2190 channelModeValue = BluetoothCodecConfig.CHANNEL_MODE_STEREO; 2191 break; 2192 default: 2193 break; 2194 } 2195 2196 // LDAC Playback Quality 2197 String ldacPlaybackQuality = mBluetoothSelectA2dpLdacPlaybackQuality.getValue(); 2198 if (preference == mBluetoothSelectA2dpLdacPlaybackQuality) { 2199 ldacPlaybackQuality = newValue.toString(); 2200 index = mBluetoothSelectA2dpLdacPlaybackQuality.findIndexOfValue(newValue.toString()); 2201 if (index >= 0) { 2202 summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_ldac_playback_quality_summaries); 2203 mBluetoothSelectA2dpLdacPlaybackQuality.setSummary(summaries[index]); 2204 } 2205 } 2206 index = mBluetoothSelectA2dpLdacPlaybackQuality.findIndexOfValue(ldacPlaybackQuality); 2207 switch (index) { 2208 case 0: 2209 case 1: 2210 case 2: 2211 case 3: 2212 codecSpecific1Value = 1000 + index; 2213 break; 2214 default: 2215 break; 2216 } 2217 2218 BluetoothCodecConfig codecConfig = 2219 new BluetoothCodecConfig(codecTypeValue, codecPriorityValue, 2220 sampleRateValue, bitsPerSampleValue, 2221 channelModeValue, codecSpecific1Value, 2222 codecSpecific2Value, codecSpecific3Value, 2223 codecSpecific4Value); 2224 2225 synchronized (mBluetoothA2dpLock) { 2226 if (mBluetoothA2dp != null) { 2227 mBluetoothA2dp.setCodecConfigPreference(codecConfig); 2228 } 2229 } 2230 }
반응형
'Android' 카테고리의 다른 글
Android system path 설정위치. (0) | 2019.01.16 |
---|---|
Android build system kati (0) | 2018.12.28 |
Android.bp build Soong (0) | 2018.12.28 |