1 /*
2  * Copyright (C) 2018 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 package com.android.bluetooth.avrcpcontroller;
17 
18 final class StackEvent {
19     // Event types for STACK_EVENT message
20     static final int EVENT_TYPE_NONE = 0;
21     static final int EVENT_TYPE_CONNECTION_STATE_CHANGED = 1;
22     static final int EVENT_TYPE_RC_FEATURES = 2;
23 
24     int mType = EVENT_TYPE_NONE;
25     boolean mRemoteControlConnected;
26     boolean mBrowsingConnected;
27     int mFeatures;
28 
StackEvent(int type)29     private StackEvent(int type) {
30         this.mType = type;
31     }
32 
33     @Override
toString()34     public String toString() {
35         switch (mType) {
36             case EVENT_TYPE_CONNECTION_STATE_CHANGED:
37                 return "EVENT_TYPE_CONNECTION_STATE_CHANGED " + mRemoteControlConnected;
38             case EVENT_TYPE_RC_FEATURES:
39                 return "EVENT_TYPE_RC_FEATURES";
40             default:
41                 return "Unknown";
42         }
43     }
44 
connectionStateChanged(boolean remoteControlConnected, boolean browsingConnected)45     static StackEvent connectionStateChanged(boolean remoteControlConnected,
46             boolean browsingConnected) {
47         StackEvent event = new StackEvent(EVENT_TYPE_CONNECTION_STATE_CHANGED);
48         event.mRemoteControlConnected = remoteControlConnected;
49         event.mBrowsingConnected = browsingConnected;
50         return event;
51     }
52 
rcFeatures(int features)53     static StackEvent rcFeatures(int features) {
54         StackEvent event = new StackEvent(EVENT_TYPE_RC_FEATURES);
55         event.mFeatures = features;
56         return event;
57     }
58 }
59