aboutsummaryrefslogtreecommitdiff
path: root/apps/SdkController/src/com/android/tools/sdkcontroller/lib/ProtocolConstants.java
blob: 32abf2bc05a0d7c681d9218c94823c9d46785078 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// Copyright 2012 Google Inc. All Rights Reserved.

package com.android.tools.sdkcontroller.lib;

/**
 * Contains declarations of constants that are tied to emulator implementation.
 * These constants can be changed only simultaneously in both places.
 */
public final class ProtocolConstants {
    /*
     * Constants related to data transfer.
     */

    /** Signature of a packet sent via SDK controller socket ('SDKC') */
    public static final int PACKET_SIGNATURE = 0x53444B43;

    /*
     * Header sizes for packets sent / received by SDK controller emulator.
     */

    /**
     * 12 bytes (3 ints) for the packet header:
     * <p/>
     * - Signature.
     * <p/>
     * - Total packet size.
     * <p/>
     * - Packet type.
     */
    public static final int PACKET_HEADER_SIZE = 12;
    /**
     * 16 bytes (4 ints) for the message header:
     * <p/>
     * - Common packet header.
     * <p/>
     * - Message type.
     */
    public static final int MESSAGE_HEADER_SIZE = 16;
    /**
     * 20 bytes (5 ints) for the query header:
     * <p/>
     * - Common packet header.
     * <p/>
     * - Query ID.
     * <p/>
     * - Query type.
     */
    public static final int QUERY_HEADER_SIZE = 20;
    /**
     * 16 bytes (4 ints) for the query response:
     * <p/>
     * - Common packet header.
     * <p/>
     * - Query ID.
     */
    public static final int QUERY_RESP_HEADER_SIZE = 16;

    /*
     * Types of packets transferred via SDK Controller channel.
     */

    /** Packet is a message. */
    public static final int PACKET_TYPE_MESSAGE = 1;
    /** Packet is a query. */
    public static final int PACKET_TYPE_QUERY = 2;
    /** Packet is a response to a query. */
    public static final int PACKET_TYPE_QUERY_RESPONSE = 3;

    /*
     * Constants related to handshake protocol between the emulator and a channel.
     */

    /**
     * Query type for a special "handshake" query.
     * <p/>
     * When emulator connects to SDK controller, the first thing that goes
     * through the socket is a special "handshake" query that delivers channel name
     * to the service.
     */
    public static final int QUERY_HANDSHAKE = -1;
    /**
     * Handshake query response on condition that service-side channel is available
     * (registered).
     */
    public static final int HANDSHAKE_RESP_CONNECTED = 0;
    /**
     * Handshake query response on condition that service-side channel is not
     * available (not registered).
     */
    public static final int HANDSHAKE_RESP_NOPORT = 1;
    /**
     * Handshake query response on condition that there is already an existing
     * emulator connection for this channel. Emulator should stop connection
     * attempts in this case.
     */
    public static final int HANDSHAKE_RESP_DUP = -1;
    /** Response to an unknown handshake query type. */
    public static final int HANDSHAKE_RESP_QUERY_UNKNOWN = -2;

    /*
     * Constants related to multi-touch emulation.
     */

    /** Received frame is JPEG image. */
    public static final int MT_FRAME_JPEG = 1;
    /** Received frame is RGB565 bitmap. */
    public static final int MT_FRAME_RGB565 = 2;
    /** Received frame is RGB888 bitmap. */
    public static final int MT_FRAME_RGB888 = 3;

    /** Pointer(s) moved. */
    public static final int MT_MOVE = 1;
    /** First pointer down message. */
    public static final int MT_FISRT_DOWN = 2;
    /** Last pointer up message. */
    public static final int MT_LAST_UP = 3;
    /** Pointer down message. */
    public static final int MT_POINTER_DOWN = 4;
    /** Pointer up message. */
    public static final int MT_POINTER_UP = 5;
    /** Sends framebuffer update. */
    public static final int MT_FB_UPDATE = 6;
    /** Frame buffer update has been received. */
    public static final int MT_FB_ACK = 7;
    /** Frame buffer update has been handled. */
    public static final int MT_FB_HANDLED = 8;
    /** Size of an event entry in the touch event message to the emulator. */
    public static final int MT_EVENT_ENTRY_SIZE = 16;

    /*
     * Constants related to sensor emulation.
     */

    /** Query type for a query that should return the list of available sensors. */
    public static final int SENSORS_QUERY_LIST = 1;
    /** Message that starts sensor emulation. */
    public static final int SENSORS_START = 1;
    /** Message that stops sensor emulation. */
    public static final int SENSORS_STOP = 2;
    /** Message that enables emulation of a particular sensor. */
    public static final int SENSORS_ENABLE = 3;
    /** Message that disables emulation of a particular sensor. */
    public static final int SENSORS_DISABLE = 4;
    /** Message that delivers sensor events to emulator. */
    public static final int SENSORS_SENSOR_EVENT = 5;
}