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

Commit 982ad633 authored by Jack He's avatar Jack He Committed by android-build-merger
Browse files

Merge "HFP: Dump state machine message verbatim" am: 357c4019

am: 0e5e9204

Change-Id: Id4c155591549fc4b7e59049d8067469a63f5ca62
parents 8dcb7d34 0e5e9204
Loading
Loading
Loading
Loading
+72 −0
Original line number Diff line number Diff line
/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.bluetooth.hfp;

/**
 * A blob of data representing an overall call state on the phone
 */
class HeadsetCallState extends HeadsetMessageObject {
    /**
     * Number of active calls
     */
    int mNumActive;
    /**
     * Number of held calls
     */
    int mNumHeld;
    /**
     * Current call setup state as defined in bthf_call_state_t of bt_hf.h or
     * {@link com.android.server.telecom.BluetoothPhoneServiceImpl} or {@link HeadsetHalConstants}
     */
    int mCallState;
    /**
     * Currently active call's phone number
     */
    String mNumber;
    /**
     * Phone number type
     */
    int mType;

    HeadsetCallState(int numActive, int numHeld, int callState, String number, int type) {
        mNumActive = numActive;
        mNumHeld = numHeld;
        mCallState = callState;
        mNumber = number;
        mType = type;
    }

    @Override
    public void buildString(StringBuilder builder) {
        if (builder == null) {
            return;
        }
        builder.append(this.getClass().getSimpleName())
                .append("[numActive=")
                .append(mNumActive)
                .append(", numHeld=")
                .append(mNumHeld)
                .append(", callState")
                .append(mCallState)
                .append(", number=");
        if (mNumber == null) {
            builder.append("null");
        } else {
            builder.append("***");
        }
        builder.append(mNumber).append(", type=").append(mType).append("]");
    }
}
+102 −0
Original line number Diff line number Diff line
/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.bluetooth.hfp;

/**
 * A blob of response data to AT+CLCC command from HF
 *
 * Example:
 *   AT+CLCC
 *   +CLCC:[index],[direction],[status],[mode],[mpty][,[number],[type]]
 */
class HeadsetClccResponse extends HeadsetMessageObject {
    /**
     * Index of the call, starting with 1, by the sequence of setup or receiving the calls
     */
    int mIndex;
    /**
     * Direction of the call, 0 is outgoing, 1 is incoming
     */
    int mDirection;
    /**
     * Status of the call, currently defined in bthf_call_state_t of bt_hf.h or
     * {@link com.android.server.telecom.BluetoothPhoneServiceImpl} or {@link HeadsetHalConstants}
     *
     * 0 - Active
     * 1 - Held
     * 2 - Dialing
     * 3 - Alerting
     * 4 - Incoming
     * 5 - Waiting
     * 6 - Call held by response and hold
     */
    int mStatus;
    /**
     * Call mode, 0 is Voice, 1 is Data, 2 is Fax
     */
    int mMode;
    /**
     * Multi-party indicator
     *
     * 0 - this call is NOT a member of a multi-party (conference) call
     * 1 - this call IS a multi-party (conference) call
     */
    boolean mMpty;
    /**
     * Phone number of the call (optional)
     */
    String mNumber;
    /**
     * Phone number type (optional)
     */
    int mType;

    HeadsetClccResponse(int index, int direction, int status, int mode, boolean mpty, String number,
            int type) {
        mIndex = index;
        mDirection = direction;
        mStatus = status;
        mMode = mode;
        mMpty = mpty;
        mNumber = number;
        mType = type;
    }

    @Override
    public void buildString(StringBuilder builder) {
        if (builder == null) {
            return;
        }
        builder.append(this.getClass().getSimpleName())
                .append("[index=")
                .append(mIndex)
                .append(", direction=")
                .append(mDirection)
                .append(", status=")
                .append(mStatus)
                .append(", callMode=")
                .append(mMode)
                .append(", isMultiParty=")
                .append(mMpty)
                .append(", number=");
        if (mNumber == null) {
            builder.append("null");
        } else {
            builder.append("***");
        }
        builder.append(", type=").append(mType).append("]");
    }
}
+68 −0
Original line number Diff line number Diff line
/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.bluetooth.hfp;

/**
 * A blob of data representing AG's device state in response to an AT+CIND command from HF
 */
class HeadsetDeviceState extends HeadsetMessageObject {
    /**
     * Service availability indicator
     *
     * 0 - no service, no home/roam network is available
     * 1 - presence of service, home/roam network available
     */
    int mService;
    /**
     * Roaming status indicator
     *
     * 0 - roaming is not active
     * 1 - roaming is active
     */
    int mRoam;
    /**
     * Signal strength indicator, value ranges from 0 to 5
     */
    int mSignal;
    /**
     * Battery charge indicator from AG, value ranges from 0 to 5
     */
    int mBatteryCharge;

    HeadsetDeviceState(int service, int roam, int signal, int batteryCharge) {
        mService = service;
        mRoam = roam;
        mSignal = signal;
        mBatteryCharge = batteryCharge;
    }

    @Override
    public void buildString(StringBuilder builder) {
        if (builder == null) {
            return;
        }
        builder.append(this.getClass().getSimpleName())
                .append("[hasCellularService=")
                .append(mService)
                .append(", isRoaming=")
                .append(mRoam)
                .append(", signalStrength")
                .append(mSignal)
                .append(", batteryCharge=")
                .append(mBatteryCharge)
                .append("]");
    }
}
+37 −0
Original line number Diff line number Diff line
/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.bluetooth.hfp;

import android.os.Message;

/**
 * An object passed through {@link Message#obj} on state machines
 */
public abstract class HeadsetMessageObject {
    /**
     * Build a representation of this object in a {@link StringBuilder}
     *
     * @param builder {@link StringBuilder} provided to build the string
     */
    public abstract void buildString(StringBuilder builder);

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        buildString(builder);
        return builder.toString();
    }
}
+0 −64
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.bluetooth.hfp;

import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -410,66 +409,3 @@ public class HeadsetPhoneState {
        }
    }
}

class HeadsetDeviceState {
    int mService;
    int mRoam;
    int mSignal;
    int mBatteryCharge;

    HeadsetDeviceState(int service, int roam, int signal, int batteryCharge) {
        mService = service;
        mRoam = roam;
        mSignal = signal;
        mBatteryCharge = batteryCharge;
    }
}

class HeadsetCallState {
    int mNumActive;
    int mNumHeld;
    int mCallState;
    String mNumber;
    int mType;

    HeadsetCallState(int numActive, int numHeld, int callState, String number, int type) {
        mNumActive = numActive;
        mNumHeld = numHeld;
        mCallState = callState;
        mNumber = number;
        mType = type;
    }
}

class HeadsetClccResponse {
    int mIndex;
    int mDirection;
    int mStatus;
    int mMode;
    boolean mMpty;
    String mNumber;
    int mType;

    HeadsetClccResponse(int index, int direction, int status, int mode, boolean mpty, String number,
            int type) {
        mIndex = index;
        mDirection = direction;
        mStatus = status;
        mMode = mode;
        mMpty = mpty;
        mNumber = number;
        mType = type;
    }
}

class HeadsetVendorSpecificResultCode {
    BluetoothDevice mDevice;
    String mCommand;
    String mArg;

    HeadsetVendorSpecificResultCode(BluetoothDevice device, String command, String arg) {
        mDevice = device;
        mCommand = command;
        mArg = arg;
    }
}
Loading