Loading AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FM_RADIO" /> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_ROUTING" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> Loading src/com/android/fmradio/FmMainActivity.java +2 −1 Original line number Diff line number Diff line Loading @@ -997,7 +997,8 @@ public class FmMainActivity extends Activity implements FmFavoriteEditDialog.Edi // if power down by other app, should disable station list, over // menu mMenuItemStationlList.setEnabled(enabled); mMenuItemHeadset.setEnabled(enabled); // If BT headset is in use, need to disable speaker/earphone switching menu. mMenuItemHeadset.setEnabled(enabled && !mService.isBluetoothHeadsetInUse()); } } Loading src/com/android/fmradio/FmService.java +13 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import android.app.Notification; import android.app.Notification.BigTextStyle; import android.app.PendingIntent; import android.app.Service; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothProfile; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.ContentValues; Loading Loading @@ -370,6 +372,17 @@ public class FmService extends Service implements FmRecorder.OnRecorderStateChan setForceUse(isSpeaker); } /** * Check if BT headset is connected * @return true if current is playing with BT headset */ public boolean isBluetoothHeadsetInUse() { BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); int a2dpState = btAdapter.getProfileConnectionState(BluetoothProfile.HEADSET); return (BluetoothProfile.STATE_CONNECTED == a2dpState || BluetoothProfile.STATE_CONNECTING == a2dpState); } private synchronized void startRender() { Log.d(TAG, "startRender"); mIsRender = true; Loading Loading
AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FM_RADIO" /> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_ROUTING" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> Loading
src/com/android/fmradio/FmMainActivity.java +2 −1 Original line number Diff line number Diff line Loading @@ -997,7 +997,8 @@ public class FmMainActivity extends Activity implements FmFavoriteEditDialog.Edi // if power down by other app, should disable station list, over // menu mMenuItemStationlList.setEnabled(enabled); mMenuItemHeadset.setEnabled(enabled); // If BT headset is in use, need to disable speaker/earphone switching menu. mMenuItemHeadset.setEnabled(enabled && !mService.isBluetoothHeadsetInUse()); } } Loading
src/com/android/fmradio/FmService.java +13 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import android.app.Notification; import android.app.Notification.BigTextStyle; import android.app.PendingIntent; import android.app.Service; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothProfile; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.ContentValues; Loading Loading @@ -370,6 +372,17 @@ public class FmService extends Service implements FmRecorder.OnRecorderStateChan setForceUse(isSpeaker); } /** * Check if BT headset is connected * @return true if current is playing with BT headset */ public boolean isBluetoothHeadsetInUse() { BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); int a2dpState = btAdapter.getProfileConnectionState(BluetoothProfile.HEADSET); return (BluetoothProfile.STATE_CONNECTED == a2dpState || BluetoothProfile.STATE_CONNECTING == a2dpState); } private synchronized void startRender() { Log.d(TAG, "startRender"); mIsRender = true; Loading