summaryrefslogtreecommitdiffstats
path: root/remoting/client
diff options
context:
space:
mode:
authorsolb@chromium.org <solb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-09 03:56:44 +0000
committersolb@chromium.org <solb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-09 03:56:44 +0000
commit8895ea754b03ca88286805228dd2861346320254 (patch)
tree3fec2e40c96d352e678eb02e7164f3f128be4ed4 /remoting/client
parentec640116870dbd130b83c7739ba7691714038d55 (diff)
downloadchromium_src-8895ea754b03ca88286805228dd2861346320254.zip
chromium_src-8895ea754b03ca88286805228dd2861346320254.tar.gz
chromium_src-8895ea754b03ca88286805228dd2861346320254.tar.bz2
Resolve several Chromoting Android UI-related crashes and misbehaviors
This protects several places where the UI once allowed users to hit dangerous edge cases: - Canceling the auth prompt on the app's first run now leaves the switcher's label text unset. - Launching the app on a device with no usable accounts once again offers to add a new account. - Trying to authenticate to an account for the first time while disconnected is detected as a network problem. - The account switcher is made unavailable when the only usable account is already selected. - There's a new refresh button for updating the currently-displayed host list from the directory server. - Pressing a device's extra/exotic buttons with high keycodes no longer DCHECKS to crash the app. - Many third-party keyboards that stubbornly covered the bottom of the remote desktop image no longer do so. - All native threads are actually properly detached from the JVM. BUG=259594 Review URL: https://chromiumcodereview.appspot.com/22662003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216556 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client')
-rw-r--r--remoting/client/jni/android_keymap.cc7
-rw-r--r--remoting/client/jni/chromoting_jni_instance.cc3
-rw-r--r--remoting/client/jni/chromoting_jni_runtime.cc21
-rw-r--r--remoting/client/jni/chromoting_jni_runtime.h4
4 files changed, 29 insertions, 6 deletions
diff --git a/remoting/client/jni/android_keymap.cc b/remoting/client/jni/android_keymap.cc
index 743e15e..45d67c4 100644
--- a/remoting/client/jni/android_keymap.cc
+++ b/remoting/client/jni/android_keymap.cc
@@ -199,12 +199,15 @@ const uint32 usb_keycodes[] = {
0x0700b7, // NUMPAD_RIGHT_PAREN
};
-}
+} // namespace
namespace remoting {
uint32 AndroidKeycodeToUsbKeycode(size_t android) {
- DCHECK_LT(android, sizeof (usb_keycodes) / sizeof (uint32));
+ if (android >= sizeof (usb_keycodes) / sizeof (uint32)) {
+ LOG(WARNING) << "Attempted to decode out-of-range Android keycode";
+ return 0;
+ }
return usb_keycodes[android];
}
diff --git a/remoting/client/jni/chromoting_jni_instance.cc b/remoting/client/jni/chromoting_jni_instance.cc
index 3e11b2fa..b68aab9 100644
--- a/remoting/client/jni/chromoting_jni_instance.cc
+++ b/remoting/client/jni/chromoting_jni_instance.cc
@@ -132,8 +132,7 @@ void ChromotingJniInstance::PerformKeyboardAction(int key_code, bool key_down) {
action.set_usb_keycode(usb_code);
action.set_pressed(key_down);
connection_->input_stub()->InjectKeyEvent(action);
- }
- else {
+ } else {
LOG(WARNING) << "Ignoring unknown keycode: " << key_code;
}
}
diff --git a/remoting/client/jni/chromoting_jni_runtime.cc b/remoting/client/jni/chromoting_jni_runtime.cc
index 8fa9018..8d51a83 100644
--- a/remoting/client/jni/chromoting_jni_runtime.cc
+++ b/remoting/client/jni/chromoting_jni_runtime.cc
@@ -7,6 +7,7 @@
#include "base/android/base_jni_registrar.h"
#include "base/android/jni_android.h"
#include "base/memory/singleton.h"
+#include "base/synchronization/waitable_event.h"
#include "media/base/yuv_convert.h"
#include "net/android/net_jni_registrar.h"
#include "remoting/base/url_request_context.h"
@@ -68,8 +69,19 @@ ChromotingJniRuntime::~ChromotingJniRuntime() {
JNIEnv* env = base::android::AttachCurrentThread();
env->DeleteGlobalRef(class_);
- // TODO(solb): Detach all threads from JVM here.
- // crbug.com/259594
+
+ base::WaitableEvent done_event(false, false);
+ network_task_runner_->PostTask(FROM_HERE, base::Bind(
+ &ChromotingJniRuntime::DetachFromVmAndSignal,
+ base::Unretained(this),
+ &done_event));
+ done_event.Wait();
+ display_task_runner_->PostTask(FROM_HERE, base::Bind(
+ &ChromotingJniRuntime::DetachFromVmAndSignal,
+ base::Unretained(this),
+ &done_event));
+ done_event.Wait();
+ base::android::DetachFromVM();
}
void ChromotingJniRuntime::ConnectToHost(const char* username,
@@ -178,4 +190,9 @@ void ChromotingJniRuntime::RedrawCanvas() {
env->GetStaticMethodID(class_, "redrawGraphicsInternal", "()V"));
}
+void ChromotingJniRuntime::DetachFromVmAndSignal(base::WaitableEvent* waiter) {
+ base::android::DetachFromVM();
+ waiter->Signal();
+}
+
} // namespace remoting
diff --git a/remoting/client/jni/chromoting_jni_runtime.h b/remoting/client/jni/chromoting_jni_runtime.h
index 1a6952b..93f933f 100644
--- a/remoting/client/jni/chromoting_jni_runtime.h
+++ b/remoting/client/jni/chromoting_jni_runtime.h
@@ -6,6 +6,7 @@
#define REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_H_
#include <jni.h>
+#include <string>
#include "base/at_exit.h"
#include "net/url_request/url_request_context_getter.h"
@@ -94,6 +95,9 @@ class ChromotingJniRuntime {
// cross-thread calls on the class.
virtual ~ChromotingJniRuntime();
+ // Detaches JVM from the current thread, then signals. Doesn't own |waiter|.
+ void DetachFromVmAndSignal(base::WaitableEvent* waiter);
+
// Reference to the Java class into which we make JNI calls.
jclass class_;