• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2012 Google Inc. All Rights Reserved.
2 
3 package com.android.tools.sdkcontroller.lib;
4 
5 /**
6  * Contains declarations of constants that are tied to emulator implementation.
7  * These constants can be changed only simultaneously in both places.
8  */
9 public final class ProtocolConstants {
10     /*
11      * Constants related to data transfer.
12      */
13 
14     /** Signature of a packet sent via SDK controller socket ('SDKC') */
15     public static final int PACKET_SIGNATURE = 0x53444B43;
16 
17     /*
18      * Header sizes for packets sent / received by SDK controller emulator.
19      */
20 
21     /**
22      * 12 bytes (3 ints) for the packet header:
23      * <p/>
24      * - Signature.
25      * <p/>
26      * - Total packet size.
27      * <p/>
28      * - Packet type.
29      */
30     public static final int PACKET_HEADER_SIZE = 12;
31     /**
32      * 16 bytes (4 ints) for the message header:
33      * <p/>
34      * - Common packet header.
35      * <p/>
36      * - Message type.
37      */
38     public static final int MESSAGE_HEADER_SIZE = 16;
39     /**
40      * 20 bytes (5 ints) for the query header:
41      * <p/>
42      * - Common packet header.
43      * <p/>
44      * - Query ID.
45      * <p/>
46      * - Query type.
47      */
48     public static final int QUERY_HEADER_SIZE = 20;
49     /**
50      * 16 bytes (4 ints) for the query response:
51      * <p/>
52      * - Common packet header.
53      * <p/>
54      * - Query ID.
55      */
56     public static final int QUERY_RESP_HEADER_SIZE = 16;
57 
58     /*
59      * Types of packets transferred via SDK Controller channel.
60      */
61 
62     /** Packet is a message. */
63     public static final int PACKET_TYPE_MESSAGE = 1;
64     /** Packet is a query. */
65     public static final int PACKET_TYPE_QUERY = 2;
66     /** Packet is a response to a query. */
67     public static final int PACKET_TYPE_QUERY_RESPONSE = 3;
68 
69     /*
70      * Constants related to handshake protocol between the emulator and a channel.
71      */
72 
73     /**
74      * Query type for a special "handshake" query.
75      * <p/>
76      * When emulator connects to SDK controller, the first thing that goes
77      * through the socket is a special "handshake" query that delivers channel name
78      * to the service.
79      */
80     public static final int QUERY_HANDSHAKE = -1;
81     /**
82      * Handshake query response on condition that service-side channel is available
83      * (registered).
84      */
85     public static final int HANDSHAKE_RESP_CONNECTED = 0;
86     /**
87      * Handshake query response on condition that service-side channel is not
88      * available (not registered).
89      */
90     public static final int HANDSHAKE_RESP_NOPORT = 1;
91     /**
92      * Handshake query response on condition that there is already an existing
93      * emulator connection for this channel. Emulator should stop connection
94      * attempts in this case.
95      */
96     public static final int HANDSHAKE_RESP_DUP = -1;
97     /** Response to an unknown handshake query type. */
98     public static final int HANDSHAKE_RESP_QUERY_UNKNOWN = -2;
99 
100     /*
101      * Constants related to multi-touch emulation.
102      */
103 
104     /** Received frame is JPEG image. */
105     public static final int MT_FRAME_JPEG = 1;
106     /** Received frame is RGB565 bitmap. */
107     public static final int MT_FRAME_RGB565 = 2;
108     /** Received frame is RGB888 bitmap. */
109     public static final int MT_FRAME_RGB888 = 3;
110 
111     /** Pointer(s) moved. */
112     public static final int MT_MOVE = 1;
113     /** First pointer down message. */
114     public static final int MT_FISRT_DOWN = 2;
115     /** Last pointer up message. */
116     public static final int MT_LAST_UP = 3;
117     /** Pointer down message. */
118     public static final int MT_POINTER_DOWN = 4;
119     /** Pointer up message. */
120     public static final int MT_POINTER_UP = 5;
121     /** Sends framebuffer update. */
122     public static final int MT_FB_UPDATE = 6;
123     /** Frame buffer update has been received. */
124     public static final int MT_FB_ACK = 7;
125     /** Frame buffer update has been handled. */
126     public static final int MT_FB_HANDLED = 8;
127     /** Size of an event entry in the touch event message to the emulator. */
128     public static final int MT_EVENT_ENTRY_SIZE = 16;
129 
130     /*
131      * Constants related to sensor emulation.
132      */
133 
134     /** Query type for a query that should return the list of available sensors. */
135     public static final int SENSORS_QUERY_LIST = 1;
136     /** Message that starts sensor emulation. */
137     public static final int SENSORS_START = 1;
138     /** Message that stops sensor emulation. */
139     public static final int SENSORS_STOP = 2;
140     /** Message that enables emulation of a particular sensor. */
141     public static final int SENSORS_ENABLE = 3;
142     /** Message that disables emulation of a particular sensor. */
143     public static final int SENSORS_DISABLE = 4;
144     /** Message that delivers sensor events to emulator. */
145     public static final int SENSORS_SENSOR_EVENT = 5;
146 }
147