Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc4b5b82 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 4410151 from d9f086df to pi-release

Change-Id: Ie869c82a9c3f7b831b7e26740786ceb015901f09
parents 8af03f01 d9f086df
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
cc_library_shared {
    name: "libbluetooth_jni",
    compile_multilib: "first",
    srcs: [
        "com_android_bluetooth_btservice_AdapterService.cpp",
        "com_android_bluetooth_hfp.cpp",
+7 −2
Original line number Diff line number Diff line
@@ -95,8 +95,12 @@ static void audio_state_cb(const RawAddress* bd_addr,
static void vr_cmd_cb(const RawAddress* bd_addr, bthf_client_vr_state_t state) {
  CallbackEnv sCallbackEnv(__func__);
  if (!sCallbackEnv.valid()) return;

  ScopedLocalRef<jbyteArray> addr(sCallbackEnv.get(), marshall_bda(bd_addr));
  if (!addr.get()) return;

  sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onVrStateChanged,
                               (jint)state);
                               (jint)state, addr.get());
}

static void network_state_cb(const RawAddress* bd_addr,
@@ -348,7 +352,8 @@ static void classInitNative(JNIEnv* env, jclass clazz) {
      env->GetMethodID(clazz, "onConnectionStateChanged", "(III[B)V");
  method_onAudioStateChanged =
      env->GetMethodID(clazz, "onAudioStateChanged", "(I[B)V");
  method_onVrStateChanged = env->GetMethodID(clazz, "onVrStateChanged", "(I)V");
  method_onVrStateChanged =
      env->GetMethodID(clazz, "onVrStateChanged", "(I[B)V");
  method_onNetworkState = env->GetMethodID(clazz, "onNetworkState", "(I[B)V");
  method_onNetworkRoaming = env->GetMethodID(clazz, "onNetworkRoaming", "(I[B)V");
  method_onNetworkSignal = env->GetMethodID(clazz, "onNetworkSignal", "(I[B)V");
+4 −4
Original line number Diff line number Diff line
@@ -418,11 +418,11 @@ class AvrcpControllerStateMachine extends StateMachine {
                    break;

                    case MESSAGE_PROCESS_TRACK_CHANGED:
                        // Music start playing automatically and update Metadata
                        mBroadcastMetadata = true;
                        mAddressedPlayer.updateCurrentTrack((TrackInfo) msg.obj);
                        if (mBroadcastMetadata) {
                        broadcastMetaDataChanged(
                                mAddressedPlayer.getCurrentTrack().getMediaMetaData());
                        }
                        break;

                    case MESSAGE_PROCESS_PLAY_POS_CHANGED:
+24 −4
Original line number Diff line number Diff line
@@ -582,14 +582,34 @@ public class HeadsetClientService extends ProfileService {
    }

    boolean startVoiceRecognition(BluetoothDevice device) {
        Log.e(TAG, "startVoiceRecognition API not available");
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        HeadsetClientStateMachine sm = getStateMachine(device);
        if (sm == null) {
            Log.e(TAG, "Cannot allocate SM for device " + device);
            return false;
        }
        int connectionState = sm.getConnectionState(device);
        if (connectionState != BluetoothProfile.STATE_CONNECTED) {
            return false;
        }
        sm.sendMessage(HeadsetClientStateMachine.VOICE_RECOGNITION_START);
        return true;
    }

    boolean stopVoiceRecognition(BluetoothDevice device) {
        Log.e(TAG, "stopVoiceRecognition API not available");
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        HeadsetClientStateMachine sm = getStateMachine(device);
        if (sm == null) {
            Log.e(TAG, "Cannot allocate SM for device " + device);
            return false;
        }
        int connectionState = sm.getConnectionState(device);
        if (connectionState != BluetoothProfile.STATE_CONNECTED) {
            return false;
        }
        sm.sendMessage(HeadsetClientStateMachine.VOICE_RECOGNITION_STOP);
        return true;
    }

    int getAudioState(BluetoothDevice device) {
        HeadsetClientStateMachine sm = getStateMachine(device);
+50 −0
Original line number Diff line number Diff line
@@ -75,10 +75,13 @@ public class HeadsetClientStateMachine extends StateMachine {
    static final int NO_ACTION = 0;

    // external actions
    public static final int AT_OK = 0;
    public static final int CONNECT = 1;
    public static final int DISCONNECT = 2;
    public static final int CONNECT_AUDIO = 3;
    public static final int DISCONNECT_AUDIO = 4;
    public static final int VOICE_RECOGNITION_START = 5;
    public static final int VOICE_RECOGNITION_STOP = 6;
    public static final int SET_MIC_VOLUME = 7;
    public static final int SET_SPEAKER_VOLUME = 8;
    public static final int DIAL_NUMBER = 10;
@@ -151,6 +154,7 @@ public class HeadsetClientStateMachine extends StateMachine {
    private static AudioManager sAudioManager;
    private int mAudioState;
    private boolean mAudioWbs;
    private int mVoiceRecognitionActive;
    private final BluetoothAdapter mAdapter;
    private TelecomManager mTelecomManager;

@@ -674,6 +678,7 @@ public class HeadsetClientStateMachine extends StateMachine {
        }
        mAudioState = BluetoothHeadsetClient.STATE_AUDIO_DISCONNECTED;
        mAudioWbs = false;
        mVoiceRecognitionActive = HeadsetClientHalConstants.VR_STATE_STOPPED;

        mTelecomManager = (TelecomManager) context.getSystemService(context.TELECOM_SERVICE);

@@ -1111,6 +1116,28 @@ public class HeadsetClientStateMachine extends StateMachine {
                    }
                    break;

                case VOICE_RECOGNITION_START:
                    if (mVoiceRecognitionActive == HeadsetClientHalConstants.VR_STATE_STOPPED) {
                        if (NativeInterface.startVoiceRecognitionNative(
                                    getByteAddress(mCurrentDevice))) {
                            addQueuedAction(VOICE_RECOGNITION_START);
                        } else {
                            Log.e(TAG, "ERROR: Couldn't start voice recognition");
                        }
                    }
                    break;

                case VOICE_RECOGNITION_STOP:
                    if (mVoiceRecognitionActive == HeadsetClientHalConstants.VR_STATE_STARTED) {
                        if (NativeInterface.stopVoiceRecognitionNative(
                                    getByteAddress(mCurrentDevice))) {
                            addQueuedAction(VOICE_RECOGNITION_STOP);
                        } else {
                            Log.e(TAG, "ERROR: Couldn't stop voice recognition");
                        }
                    }
                    break;

                // Called only for Mute/Un-mute - Mic volume change is not allowed.
                case SET_MIC_VOLUME:
                    break;
@@ -1283,6 +1310,17 @@ public class HeadsetClientStateMachine extends StateMachine {
                            intent.putExtra(BluetoothDevice.EXTRA_DEVICE, event.device);
                            mService.sendBroadcast(intent, ProfileService.BLUETOOTH_PERM);
                            break;
                        case StackEvent.EVENT_TYPE_VR_STATE_CHANGED:
                            if (mVoiceRecognitionActive != event.valueInt) {
                                mVoiceRecognitionActive = event.valueInt;

                                intent = new Intent(BluetoothHeadsetClient.ACTION_AG_EVENT);
                                intent.putExtra(BluetoothHeadsetClient.EXTRA_VOICE_RECOGNITION,
                                        mVoiceRecognitionActive);
                                intent.putExtra(BluetoothDevice.EXTRA_DEVICE, event.device);
                                mService.sendBroadcast(intent, ProfileService.BLUETOOTH_PERM);
                            }
                            break;
                        case StackEvent.EVENT_TYPE_CALL:
                        case StackEvent.EVENT_TYPE_CALLSETUP:
                        case StackEvent.EVENT_TYPE_CALLHELD:
@@ -1327,6 +1365,18 @@ public class HeadsetClientStateMachine extends StateMachine {
                                case QUERY_CURRENT_CALLS:
                                    queryCallsDone();
                                    break;
                                case VOICE_RECOGNITION_START:
                                    if (event.valueInt == AT_OK) {
                                        mVoiceRecognitionActive =
                                                HeadsetClientHalConstants.VR_STATE_STARTED;
                                    }
                                    break;
                                case VOICE_RECOGNITION_STOP:
                                    if (event.valueInt == AT_OK) {
                                        mVoiceRecognitionActive =
                                                HeadsetClientHalConstants.VR_STATE_STOPPED;
                                    }
                                    break;
                                default:
                                    Log.w(TAG, "Unhandled AT OK " + event);
                                    break;
Loading