summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
authornyquist@chromium.org <nyquist@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-05 01:15:22 +0000
committernyquist@chromium.org <nyquist@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-05 01:15:22 +0000
commit598bf6cfa875b0a5837c69a1845a887891e0fa53 (patch)
treec84d7f6d8be4be039d2d7cb911af79b2fdff14e3 /sync
parent3ded155c70c538f95fb38954b8199e18dc24df89 (diff)
downloadchromium_src-598bf6cfa875b0a5837c69a1845a887891e0fa53.zip
chromium_src-598bf6cfa875b0a5837c69a1845a887891e0fa53.tar.gz
chromium_src-598bf6cfa875b0a5837c69a1845a887891e0fa53.tar.bz2
Depend on stored sync session GUID for Android.
This changes the Android port of Chrome to depend on the pref kSyncSessionsGUID to be set before the SessionModelAssociator is initialized. We now also force-removes any foreign sessions that are using the current client's GUID as a session tag. This also lead to the removal of the Android specific session utils. BUG=157419 Review URL: https://chromiumcodereview.appspot.com/11414013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171109 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r--sync/sync.gyp2
-rw-r--r--sync/util/get_session_name.cc6
-rw-r--r--sync/util/session_utils_android.cc75
-rw-r--r--sync/util/session_utils_android.h22
4 files changed, 4 insertions, 101 deletions
diff --git a/sync/sync.gyp b/sync/sync.gyp
index 061330b..6a2bf58 100644
--- a/sync/sync.gyp
+++ b/sync/sync.gyp
@@ -188,8 +188,6 @@
'util/logging.h',
'util/nigori.cc',
'util/nigori.h',
- 'util/session_utils_android.cc',
- 'util/session_utils_android.h',
'util/time.cc',
'util/time.h',
],
diff --git a/sync/util/get_session_name.cc b/sync/util/get_session_name.cc
index 244aa14..1896ebc 100644
--- a/sync/util/get_session_name.cc
+++ b/sync/util/get_session_name.cc
@@ -22,7 +22,7 @@
#elif defined(OS_WIN)
#include "sync/util/get_session_name_win.h"
#elif defined(OS_ANDROID)
-#include "sync/util/session_utils_android.h"
+#include "base/android/build_info.h"
#endif
namespace syncer {
@@ -53,7 +53,9 @@ std::string GetSessionNameSynchronously() {
#elif defined(OS_WIN)
session_name = internal::GetComputerName();
#elif defined(OS_ANDROID)
- session_name = internal::GetModel();
+ base::android::BuildInfo* android_build_info =
+ base::android::BuildInfo::GetInstance();
+ session_name = android_build_info->model();
#endif
if (session_name == "Unknown" || session_name.empty())
diff --git a/sync/util/session_utils_android.cc b/sync/util/session_utils_android.cc
deleted file mode 100644
index 72db208..0000000
--- a/sync/util/session_utils_android.cc
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <jni.h>
-#include <sys/system_properties.h>
-
-#include "sync/util/session_utils_android.h"
-
-#include "base/android/jni_android.h"
-#include "base/android/jni_string.h"
-#include "base/android/scoped_java_ref.h"
-#include "base/logging.h"
-
-using base::android::AttachCurrentThread;
-using base::android::CheckException;
-using base::android::ConvertUTF8ToJavaString;
-using base::android::GetApplicationContext;
-using base::android::GetClass;
-using base::android::JavaRef;
-using base::android::MethodID;
-using base::android::ScopedJavaLocalRef;
-
-namespace {
-
-ScopedJavaLocalRef<jstring> GetAndroidIdJNI(
- JNIEnv* env, const JavaRef<jobject>& content_resolver) {
- ScopedJavaLocalRef<jclass> clazz(
- GetClass(env, "android/provider/Settings$Secure"));
- jmethodID j_get_string = MethodID::Get<MethodID::TYPE_STATIC>(
- env, clazz.obj(), "getString",
- "(Landroid/content/ContentResolver;Ljava/lang/String;)"
- "Ljava/lang/String;");
- ScopedJavaLocalRef<jstring> j_android_id =
- ConvertUTF8ToJavaString(env, "android_id");
- jstring android_id = static_cast<jstring>(
- env->CallStaticObjectMethod(
- clazz.obj(), j_get_string, content_resolver.obj(),
- j_android_id.obj()));
- CheckException(env);
- return ScopedJavaLocalRef<jstring>(env, android_id);
-}
-
-ScopedJavaLocalRef<jobject> GetContentResolver(JNIEnv* env) {
- ScopedJavaLocalRef<jclass> clazz(GetClass(env, "android/content/Context"));
- jmethodID j_get_content_resolver_method = MethodID::Get<
- MethodID::TYPE_INSTANCE>(
- env, clazz.obj(), "getContentResolver",
- "()Landroid/content/ContentResolver;");
- jobject content_resolver = env->CallObjectMethod(
- GetApplicationContext(), j_get_content_resolver_method);
- CheckException(env);
- return ScopedJavaLocalRef<jobject>(env, content_resolver);
-}
-
-}
-
-namespace syncer {
-namespace internal {
-
-std::string GetAndroidId() {
- JNIEnv* env = AttachCurrentThread();
- ScopedJavaLocalRef<jstring> android_id =
- GetAndroidIdJNI(env, GetContentResolver(env));
- return ConvertJavaStringToUTF8(android_id);
-}
-
-std::string GetModel() {
- char model[PROP_VALUE_MAX];
- __system_property_get("ro.product.model", model);
- return model;
-}
-
-} // namespace internal
-} // namespace syncer
diff --git a/sync/util/session_utils_android.h b/sync/util/session_utils_android.h
deleted file mode 100644
index 79058d2..0000000
--- a/sync/util/session_utils_android.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef SYNC_UTIL_SESSION_UTILS_ANDROID_H_
-#define SYNC_UTIL_SESSION_UTILS_ANDROID_H_
-
-#include <string>
-
-namespace syncer {
-namespace internal {
-
-// Return the unique identifier of this device.
-std::string GetAndroidId();
-
-// Return the end-user-visible name for this device.
-std::string GetModel();
-
-} // namespace internal
-} // namespace syncer
-
-#endif // SYNC_UTIL_SESSION_UTILS_ANDROID_H_