OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chromoting.jni; | 5 package org.chromium.chromoting.jni; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.app.AlertDialog; | 8 import android.app.AlertDialog; |
9 import android.content.Context; | 9 import android.content.Context; |
10 import android.content.DialogInterface; | 10 import android.content.DialogInterface; |
11 import android.content.SharedPreferences; | 11 import android.content.SharedPreferences; |
12 import android.graphics.Bitmap; | 12 import android.graphics.Bitmap; |
13 import android.graphics.Point; | 13 import android.graphics.Point; |
14 import android.os.Build; | 14 import android.os.Build; |
15 import android.os.Looper; | 15 import android.os.Looper; |
16 import android.util.Log; | 16 import android.util.Log; |
17 import android.view.KeyEvent; | 17 import android.view.KeyEvent; |
18 import android.view.View; | 18 import android.view.View; |
19 import android.widget.CheckBox; | 19 import android.widget.CheckBox; |
20 import android.widget.TextView; | 20 import android.widget.TextView; |
21 import android.widget.Toast; | |
22 | 21 |
23 import org.chromium.base.CalledByNative; | 22 import org.chromium.base.CalledByNative; |
24 import org.chromium.base.JNINamespace; | 23 import org.chromium.base.JNINamespace; |
25 import org.chromium.chromoting.R; | 24 import org.chromium.chromoting.R; |
26 | 25 |
27 import java.nio.ByteBuffer; | 26 import java.nio.ByteBuffer; |
28 import java.nio.ByteOrder; | 27 import java.nio.ByteOrder; |
29 | 28 |
30 /** | 29 /** |
31 * Initializes the Chromium remoting library, and provides JNI calls into it. | 30 * Initializes the Chromium remoting library, and provides JNI calls into it. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 66 |
68 public static State fromValue(int value) { | 67 public static State fromValue(int value) { |
69 return values()[value]; | 68 return values()[value]; |
70 } | 69 } |
71 } | 70 } |
72 | 71 |
73 /** | 72 /** |
74 * This enum must match the C++ enumeration remoting::protocol::ErrorCod
e. | 73 * This enum must match the C++ enumeration remoting::protocol::ErrorCod
e. |
75 */ | 74 */ |
76 public enum Error { | 75 public enum Error { |
77 OK(0), | 76 OK(0, 0), |
78 PEER_IS_OFFLINE(1), | 77 PEER_IS_OFFLINE(1, R.string.error_host_is_offline), |
79 SESSION_REJECTED(2), | 78 SESSION_REJECTED(2, R.string.error_invalid_access_code), |
80 INCOMPATIBLE_PROTOCOL(3), | 79 INCOMPATIBLE_PROTOCOL(3, R.string.error_incompatible_protocol), |
81 AUTHENTICATION_FAILED(4), | 80 AUTHENTICATION_FAILED(4, R.string.error_invalid_access_code), |
82 CHANNEL_CONNECTION_ERROR(5), | 81 CHANNEL_CONNECTION_ERROR(5, R.string.error_p2p_failure), |
83 SIGNALING_ERROR(6), | 82 SIGNALING_ERROR(6, R.string.error_p2p_failure), |
84 SIGNALING_TIMEOUT(7), | 83 SIGNALING_TIMEOUT(7, R.string.error_p2p_failure), |
85 HOST_OVERLOAD(8), | 84 HOST_OVERLOAD(8, R.string.error_host_overload), |
86 UNKNOWN_ERROR(9); | 85 UNKNOWN_ERROR(9, R.string.error_unexpected); |
87 | 86 |
88 private final int mValue; | 87 private final int mValue; |
| 88 private final int mMessage; |
89 | 89 |
90 Error(int value) { | 90 Error(int value, int message) { |
91 mValue = value; | 91 mValue = value; |
| 92 mMessage = message; |
92 } | 93 } |
93 | 94 |
94 public int value() { | 95 public int value() { |
95 return mValue; | 96 return mValue; |
96 } | 97 } |
97 | 98 |
| 99 public int message() { |
| 100 return mMessage; |
| 101 } |
| 102 |
98 public static Error fromValue(int value) { | 103 public static Error fromValue(int value) { |
99 return values()[value]; | 104 return values()[value]; |
100 } | 105 } |
101 } | 106 } |
102 | 107 |
| 108 |
103 /** | 109 /** |
104 * Notified on connection state change. | 110 * Notified on connection state change. |
105 * @param state The new connection state. | 111 * @param state The new connection state. |
106 * @param error The error code, if state is STATE_FAILED. | 112 * @param error The error code, if state is STATE_FAILED. |
107 */ | 113 */ |
108 void onConnectionState(State state, Error error); | 114 void onConnectionState(State state, Error error); |
109 } | 115 } |
110 | 116 |
111 /* | 117 /* |
112 * Connection-initiating state machine. | 118 * Connection-initiating state machine. |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 buffer.asIntBuffer().get(data, 0, data.length); | 414 buffer.asIntBuffer().get(data, 0, data.length); |
409 sCursorBitmap = Bitmap.createBitmap(data, width, height, Bitmap.Config.A
RGB_8888); | 415 sCursorBitmap = Bitmap.createBitmap(data, width, height, Bitmap.Config.A
RGB_8888); |
410 } | 416 } |
411 | 417 |
412 /** Position of cursor hotspot within cursor image. Called on the graphics t
hread. */ | 418 /** Position of cursor hotspot within cursor image. Called on the graphics t
hread. */ |
413 public static Point getCursorHotspot() { return sCursorHotspot; } | 419 public static Point getCursorHotspot() { return sCursorHotspot; } |
414 | 420 |
415 /** Returns the current cursor shape. Called on the graphics thread. */ | 421 /** Returns the current cursor shape. Called on the graphics thread. */ |
416 public static Bitmap getCursorBitmap() { return sCursorBitmap; } | 422 public static Bitmap getCursorBitmap() { return sCursorBitmap; } |
417 } | 423 } |
OLD | NEW |