Home | History | Annotate | Download | only in hfpclient
      1 /*
      2  * Copyright (c) 2017 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 // Defines an event that is sent via a callback from JNI -> Java.
     18 //
     19 // See examples in NativeInterface.java
     20 package com.android.bluetooth.hfpclient;
     21 
     22 import android.bluetooth.BluetoothDevice;
     23 
     24 public class StackEvent {
     25     // Type of event that signifies a native event and consumed by state machine
     26     public static final int STACK_EVENT = 100;
     27 
     28     // Event types for STACK_EVENT message (coming from native)
     29     public static final int EVENT_TYPE_NONE = 0;
     30     public static final int EVENT_TYPE_CONNECTION_STATE_CHANGED = 1;
     31     public static final int EVENT_TYPE_AUDIO_STATE_CHANGED = 2;
     32     public static final int EVENT_TYPE_VR_STATE_CHANGED = 3;
     33     public static final int EVENT_TYPE_NETWORK_STATE = 4;
     34     public static final int EVENT_TYPE_ROAMING_STATE = 5;
     35     public static final int EVENT_TYPE_NETWORK_SIGNAL = 6;
     36     public static final int EVENT_TYPE_BATTERY_LEVEL = 7;
     37     public static final int EVENT_TYPE_OPERATOR_NAME = 8;
     38     public static final int EVENT_TYPE_CALL = 9;
     39     public static final int EVENT_TYPE_CALLSETUP = 10;
     40     public static final int EVENT_TYPE_CALLHELD = 11;
     41     public static final int EVENT_TYPE_RESP_AND_HOLD = 12;
     42     public static final int EVENT_TYPE_CLIP = 13;
     43     public static final int EVENT_TYPE_CALL_WAITING = 14;
     44     public static final int EVENT_TYPE_CURRENT_CALLS = 15;
     45     public static final int EVENT_TYPE_VOLUME_CHANGED = 16;
     46     public static final int EVENT_TYPE_CMD_RESULT = 17;
     47     public static final int EVENT_TYPE_SUBSCRIBER_INFO = 18;
     48     public static final int EVENT_TYPE_IN_BAND_RINGTONE = 19;
     49     public static final int EVENT_TYPE_RING_INDICATION = 21;
     50 
     51     public int type = EVENT_TYPE_NONE;
     52     public int valueInt = 0;
     53     public int valueInt2 = 0;
     54     public int valueInt3 = 0;
     55     public int valueInt4 = 0;
     56     public String valueString = null;
     57     public BluetoothDevice device = null;
     58 
     59     StackEvent(int type) {
     60         this.type = type;
     61     }
     62 
     63     @Override
     64     public String toString() {
     65         // event dump
     66         StringBuilder result = new StringBuilder();
     67         result.append("StackEvent {type:" + eventTypeToString(type));
     68         result.append(", value1:" + valueInt);
     69         result.append(", value2:" + valueInt2);
     70         result.append(", value3:" + valueInt3);
     71         result.append(", value4:" + valueInt4);
     72         result.append(", string: \"" + valueString + "\"");
     73         result.append(", device:" + device + "}");
     74         return result.toString();
     75     }
     76 
     77     // for debugging only
     78     private static String eventTypeToString(int type) {
     79         switch (type) {
     80             case EVENT_TYPE_NONE:
     81                 return "EVENT_TYPE_NONE";
     82             case EVENT_TYPE_CONNECTION_STATE_CHANGED:
     83                 return "EVENT_TYPE_CONNECTION_STATE_CHANGED";
     84             case EVENT_TYPE_AUDIO_STATE_CHANGED:
     85                 return "EVENT_TYPE_AUDIO_STATE_CHANGED";
     86             case EVENT_TYPE_NETWORK_STATE:
     87                 return "EVENT_TYPE_NETWORK_STATE";
     88             case EVENT_TYPE_ROAMING_STATE:
     89                 return "EVENT_TYPE_ROAMING_STATE";
     90             case EVENT_TYPE_NETWORK_SIGNAL:
     91                 return "EVENT_TYPE_NETWORK_SIGNAL";
     92             case EVENT_TYPE_BATTERY_LEVEL:
     93                 return "EVENT_TYPE_BATTERY_LEVEL";
     94             case EVENT_TYPE_OPERATOR_NAME:
     95                 return "EVENT_TYPE_OPERATOR_NAME";
     96             case EVENT_TYPE_CALL:
     97                 return "EVENT_TYPE_CALL";
     98             case EVENT_TYPE_CALLSETUP:
     99                 return "EVENT_TYPE_CALLSETUP";
    100             case EVENT_TYPE_CALLHELD:
    101                 return "EVENT_TYPE_CALLHELD";
    102             case EVENT_TYPE_CLIP:
    103                 return "EVENT_TYPE_CLIP";
    104             case EVENT_TYPE_CALL_WAITING:
    105                 return "EVENT_TYPE_CALL_WAITING";
    106             case EVENT_TYPE_CURRENT_CALLS:
    107                 return "EVENT_TYPE_CURRENT_CALLS";
    108             case EVENT_TYPE_VOLUME_CHANGED:
    109                 return "EVENT_TYPE_VOLUME_CHANGED";
    110             case EVENT_TYPE_CMD_RESULT:
    111                 return "EVENT_TYPE_CMD_RESULT";
    112             case EVENT_TYPE_SUBSCRIBER_INFO:
    113                 return "EVENT_TYPE_SUBSCRIBER_INFO";
    114             case EVENT_TYPE_RESP_AND_HOLD:
    115                 return "EVENT_TYPE_RESP_AND_HOLD";
    116             case EVENT_TYPE_RING_INDICATION:
    117                 return "EVENT_TYPE_RING_INDICATION";
    118             default:
    119                 return "EVENT_TYPE_UNKNOWN:" + type;
    120         }
    121     }
    122 }
    123 
    124