summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjdduke <jdduke@chromium.org>2015-08-14 11:06:36 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-14 18:07:07 +0000
commite5c1ef11a048c3650283b9a7bbb62d4d6e85e927 (patch)
tree76110b692e69ca85dfd2c72b40160c03934bf7a9
parent83c807aae22f28b152ff5b59f146ac8c0e017015 (diff)
downloadchromium_src-e5c1ef11a048c3650283b9a7bbb62d4d6e85e927.zip
chromium_src-e5c1ef11a048c3650283b9a7bbb62d4d6e85e927.tar.gz
chromium_src-e5c1ef11a048c3650283b9a7bbb62d4d6e85e927.tar.bz2
Revert of [Android] Add a java.lang.System wrapper. (patchset #2 id:20001 of https://codereview.chromium.org/1283543003/ )
Reason for revert: This doesn't actually work. Original issue's description: > [Android] Add a java.lang.System wrapper. > > Add a basic JNI wrapper for java.lang.System. Expose just the > getProperty() method, eliminating a deprecated __system_property_get > usage as well as a seperate System.getProperty wrapper. > > The remaining uses of __system_property_get will be removed in > https://codereview.chromium.org/1236283002/. > > BUG=392196, 392191 > > Committed: https://crrev.com/130c6bf9db16a69fca8488da8e15e978470e7e8b > Cr-Commit-Position: refs/heads/master@{#343245} TBR=rmcilroy@chromium.org,danakj@chromium.org,davidben@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=392196, 392191 Review URL: https://codereview.chromium.org/1294883002 Cr-Commit-Position: refs/heads/master@{#343430}
-rw-r--r--base/BUILD.gn9
-rw-r--r--base/android/base_jni_registrar.cc2
-rw-r--r--base/android/java_system.cc30
-rw-r--r--base/android/java_system.h30
-rw-r--r--base/base.gyp11
-rw-r--r--base/base.gypi2
-rw-r--r--net/android/java/src/org/chromium/net/ProxyChangeListener.java5
-rw-r--r--net/dns/dns_config_service_posix.cc20
-rw-r--r--net/proxy/proxy_config_service_android.cc11
9 files changed, 28 insertions, 92 deletions
diff --git a/base/BUILD.gn b/base/BUILD.gn
index f2b659a..ccb580f 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -96,8 +96,6 @@ component("base") {
"android/java_handler_thread.h",
"android/java_runtime.cc",
"android/java_runtime.h",
- "android/java_system.cc",
- "android/java_system.h",
"android/jni_android.cc",
"android/jni_android.h",
"android/jni_array.cc",
@@ -1564,7 +1562,6 @@ if (is_android) {
deps = [
":android_runtime_jni_headers",
- ":android_system_jni_headers",
]
jni_package = "base"
@@ -1576,12 +1573,6 @@ if (is_android) {
classes = [ "java/lang/Runtime.class" ]
}
- # GYP: //base.gyp:android_system_jni_headers
- generate_jar_jni("android_system_jni_headers") {
- jni_package = "base"
- classes = [ "java/lang/System.class" ]
- }
-
# GYP: //base.gyp:base_java
android_library("base_java") {
srcjar_deps = [
diff --git a/base/android/base_jni_registrar.cc b/base/android/base_jni_registrar.cc
index cedb0f2..752dcff 100644
--- a/base/android/base_jni_registrar.cc
+++ b/base/android/base_jni_registrar.cc
@@ -16,7 +16,6 @@
#include "base/android/important_file_writer_android.h"
#include "base/android/java_handler_thread.h"
#include "base/android/java_runtime.h"
-#include "base/android/java_system.h"
#include "base/android/jni_android.h"
#include "base/android/jni_registrar.h"
#include "base/android/jni_utils.h"
@@ -63,7 +62,6 @@ static RegistrationMethod kBaseRegisteredMethods[] = {
{"RecordHistogram", base::android::RegisterRecordHistogram},
{"RecordUserAction", base::android::RegisterRecordUserAction},
{"Runtime", base::android::JavaRuntime::Register},
- {"System", base::android::JavaSystem::Register},
{"SystemMessageHandler", base::MessagePumpForUI::RegisterBindings},
{"SysUtils", base::android::SysUtils::Register},
{"ThreadUtils", base::RegisterThreadUtils},
diff --git a/base/android/java_system.cc b/base/android/java_system.cc
deleted file mode 100644
index 1c4e518..0000000
--- a/base/android/java_system.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2015 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 "base/android/java_system.h"
-
-#include "base/android/jni_string.h"
-#include "jni/System_jni.h"
-
-namespace base {
-namespace android {
-
-bool JavaSystem::Register(JNIEnv* env) {
- return JNI_System::RegisterNativesImpl(env);
-}
-
-// static
-std::string JavaSystem::GetProperty(const base::StringPiece& property_name) {
- DCHECK(!property_name.empty());
- JNIEnv* env = AttachCurrentThread();
- ScopedJavaLocalRef<jstring> jproperty_name =
- ConvertUTF8ToJavaString(env, property_name);
- ScopedJavaLocalRef<jstring> jproperty =
- JNI_System::Java_System_getPropertyJLS_JLS(env, jproperty_name.obj());
- return jproperty.is_null() ? std::string()
- : ConvertJavaStringToUTF8(env, jproperty.obj());
-}
-
-} // namespace android
-} // namespace base
diff --git a/base/android/java_system.h b/base/android/java_system.h
deleted file mode 100644
index bab7257..0000000
--- a/base/android/java_system.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2015 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 BASE_ANDROID_JAVA_SYSTEM_H_
-#define BASE_ANDROID_JAVA_SYSTEM_H_
-
-#include <string>
-
-#include "base/android/jni_android.h"
-#include "base/base_export.h"
-#include "base/strings/string_piece.h"
-
-namespace base {
-namespace android {
-
-// Wrapper class for using the java.lang.System object from jni.
-class BASE_EXPORT JavaSystem {
- public:
- // Registers the jni class (once per process).
- static bool Register(JNIEnv* env);
-
- // See java.lang.System.getProperty().
- static std::string GetProperty(const base::StringPiece& stroperty_name);
-};
-
-} // namespace android
-} // namespace base
-
-#endif // BASE_ANDROID_JAVA_SYSTEM_H_
diff --git a/base/base.gyp b/base/base.gyp
index f5d0fbd..4a558d8 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -1381,7 +1381,6 @@
},
'dependencies': [
'android_runtime_jni_headers',
- 'android_system_jni_headers',
],
'includes': [ '../build/jni_generator.gypi' ],
},
@@ -1396,16 +1395,6 @@
'includes': [ '../build/jar_file_jni_generator.gypi' ],
},
{
- # GN: //base:android_system_jni_headers
- 'target_name': 'android_system_jni_headers',
- 'type': 'none',
- 'variables': {
- 'jni_gen_package': 'base',
- 'input_java_class': 'java/lang/System.class',
- },
- 'includes': [ '../build/jar_file_jni_generator.gypi' ],
- },
- {
# TODO(GN)
'target_name': 'base_unittests_jni_headers',
'type': 'none',
diff --git a/base/base.gypi b/base/base.gypi
index c982a13..cce8e44 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -50,8 +50,6 @@
'android/java_handler_thread.h',
'android/java_runtime.cc',
'android/java_runtime.h',
- 'android/java_system.cc',
- 'android/java_system.h',
'android/jni_android.cc',
'android/jni_android.h',
'android/jni_array.cc',
diff --git a/net/android/java/src/org/chromium/net/ProxyChangeListener.java b/net/android/java/src/org/chromium/net/ProxyChangeListener.java
index f3e9330..7df2d3b 100644
--- a/net/android/java/src/org/chromium/net/ProxyChangeListener.java
+++ b/net/android/java/src/org/chromium/net/ProxyChangeListener.java
@@ -73,6 +73,11 @@ public class ProxyChangeListener {
}
@CalledByNative
+ public static String getProperty(String property) {
+ return System.getProperty(property);
+ }
+
+ @CalledByNative
public void start(long nativePtr) {
assert mNativePtr == 0;
mNativePtr = nativePtr;
diff --git a/net/dns/dns_config_service_posix.cc b/net/dns/dns_config_service_posix.cc
index b6ab022..02877e7 100644
--- a/net/dns/dns_config_service_posix.cc
+++ b/net/dns/dns_config_service_posix.cc
@@ -30,7 +30,7 @@
#endif
#if defined(OS_ANDROID)
-#include "base/android/java_system.h"
+#include <sys/system_properties.h>
#include "net/base/network_change_notifier.h"
#endif
@@ -154,14 +154,22 @@ ConfigParsePosixResult ReadDnsConfig(DnsConfig* config) {
return result;
}
#else // defined(OS_ANDROID)
-// Theoretically, this is bad. The DNS system properties are implementation
-// details that may disappear in future Android releases. Practically, the DNS
-// code (and its clients) are already robust against failing to get the DNS
+// Theoretically, this is bad. __system_property_get is not a supported API
+// (but it's currently visible to anyone using Bionic), and the properties
+// are implementation details that may disappear in future Android releases.
+// Practically, libcutils provides property_get, which is a public API, and the
+// DNS code (and its clients) are already robust against failing to get the DNS
// config for whatever reason, so the properties can disappear and the world
// won't end.
+// TODO(ttuttle): Depend on libcutils, then switch this (and other uses of
+// __system_property_get) to property_get.
ConfigParsePosixResult ReadDnsConfig(DnsConfig* dns_config) {
- std::string dns1_string = base::android::JavaSystem::GetProperty("net.dns1");
- std::string dns2_string = base::android::JavaSystem::GetProperty("net.dns2");
+ std::string dns1_string, dns2_string;
+ char property_value[PROP_VALUE_MAX];
+ __system_property_get("net.dns1", property_value);
+ dns1_string = property_value;
+ __system_property_get("net.dns2", property_value);
+ dns2_string = property_value;
if (dns1_string.length() == 0 && dns2_string.length() == 0)
return CONFIG_PARSE_POSIX_NO_NAMESERVERS;
diff --git a/net/proxy/proxy_config_service_android.cc b/net/proxy/proxy_config_service_android.cc
index e47670d..66065fb 100644
--- a/net/proxy/proxy_config_service_android.cc
+++ b/net/proxy/proxy_config_service_android.cc
@@ -4,7 +4,8 @@
#include "net/proxy/proxy_config_service_android.h"
-#include "base/android/java_system.h"
+#include <sys/system_properties.h>
+
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
#include "base/basictypes.h"
@@ -155,8 +156,14 @@ void GetLatestProxyConfigInternal(const GetPropertyCallback& get_property,
}
std::string GetJavaProperty(const std::string& property) {
+ // Use Java System.getProperty to get configuration information.
// TODO(pliard): Conversion to/from UTF8 ok here?
- return base::android::JavaSystem::GetProperty(property);
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jstring> str = ConvertUTF8ToJavaString(env, property);
+ ScopedJavaLocalRef<jstring> result =
+ Java_ProxyChangeListener_getProperty(env, str.obj());
+ return result.is_null() ?
+ std::string() : ConvertJavaStringToUTF8(env, result.obj());
}
void CreateStaticProxyConfig(const std::string& host,