aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHidehiko Abe <hidehiko@google.com>2018-04-21 02:59:58 +0900
committerHidehiko Abe <hidehiko@google.com>2018-04-24 00:49:13 +0900
commitca6c42abc66e142da1036f0061976d671862c457 (patch)
tree93be624d5f40e9fc4f15a73e9a62b53a7e310073
parent02d8c056c1f7396f54b5871f2d09e89be6244bb4 (diff)
downloadlibmojo-ca6c42abc66e142da1036f0061976d671862c457.tar.gz
Remove unnecessary diffs from Chrome repository in base/android.
Copy build_info.cc, BuildInfo.java and scoped_java_ref.cc from Chrome repository. Delete NativeLibraries.template which aren't used. Bug: 73606903 Test: Built locally. Tested with DUT for JNI crash, and made sure stack trace was printed. Change-Id: Ia09176486ad59e9257cc74db088fb74bcb603a3e
-rw-r--r--Android.bp9
-rw-r--r--base/android/build_info.cc25
-rw-r--r--base/android/java/src/org/chromium/base/BuildInfo.java47
-rw-r--r--base/android/java/templates/NativeLibraries.template95
-rw-r--r--base/android/scoped_java_ref.cc2
5 files changed, 36 insertions, 142 deletions
diff --git a/Android.bp b/Android.bp
index 0d9a8ce..24f235a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -230,6 +230,8 @@ genrule {
],
}
+// TODO(hidehiko): Remove JNI for ContextUtils, after cleaning up the
+// depended code.
genrule {
name: "libmojo_jni_headers",
cmd: "$(location soong/jni_generator_helper.sh)" +
@@ -405,14 +407,9 @@ java_library {
srcs: [
":libmojo_mojom_java_srcs",
- "base/android/java/src/org/chromium/base/BuildInfo.java",
- "base/android/java/src/org/chromium/base/ContextUtils.java",
- "base/android/java/src/org/chromium/base/Log.java",
- "base/android/java/src/org/chromium/base/PackageUtils.java",
- "base/android/java/src/org/chromium/base/VisibleForTesting.java",
+ "base/android/java/src/**/*.java",
"mojo/android/system/src/**/*.java",
"mojo/public/java/system/src/**/*.java",
"mojo/public/java/bindings/src/**/*.java",
- "base/android/java/src/org/chromium/base/annotations/**/*.java",
],
}
diff --git a/base/android/build_info.cc b/base/android/build_info.cc
index 80b9e0a..869c703 100644
--- a/base/android/build_info.cc
+++ b/base/android/build_info.cc
@@ -6,7 +6,6 @@
#include <string>
-#include "base/android/context_utils.h"
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/android/scoped_java_ref.h"
@@ -49,22 +48,18 @@ BuildInfo::BuildInfo(JNIEnv* env)
model_(StrDupJString(Java_BuildInfo_getDeviceModel(env))),
brand_(StrDupJString(Java_BuildInfo_getBrand(env))),
android_build_id_(StrDupJString(Java_BuildInfo_getAndroidBuildId(env))),
- android_build_fp_(StrDupJString(
- Java_BuildInfo_getAndroidBuildFingerprint(env))),
- gms_version_code_(StrDupJString(Java_BuildInfo_getGMSVersionCode(
- env, GetApplicationContext()))),
- package_version_code_(StrDupJString(Java_BuildInfo_getPackageVersionCode(
- env, GetApplicationContext()))),
- package_version_name_(StrDupJString(Java_BuildInfo_getPackageVersionName(
- env, GetApplicationContext()))),
- package_label_(StrDupJString(Java_BuildInfo_getPackageLabel(
- env, GetApplicationContext()))),
- package_name_(StrDupJString(Java_BuildInfo_getPackageName(
- env, GetApplicationContext()))),
+ android_build_fp_(
+ StrDupJString(Java_BuildInfo_getAndroidBuildFingerprint(env))),
+ gms_version_code_(StrDupJString(Java_BuildInfo_getGMSVersionCode(env))),
+ package_version_code_(
+ StrDupJString(Java_BuildInfo_getPackageVersionCode(env))),
+ package_version_name_(
+ StrDupJString(Java_BuildInfo_getPackageVersionName(env))),
+ package_label_(StrDupJString(Java_BuildInfo_getPackageLabel(env))),
+ package_name_(StrDupJString(Java_BuildInfo_getPackageName(env))),
build_type_(StrDupJString(Java_BuildInfo_getBuildType(env))),
sdk_int_(Java_BuildInfo_getSdkInt(env)),
- java_exception_info_(NULL) {
-}
+ java_exception_info_(NULL) {}
// static
BuildInfo* BuildInfo::GetInstance() {
diff --git a/base/android/java/src/org/chromium/base/BuildInfo.java b/base/android/java/src/org/chromium/base/BuildInfo.java
index 141b62b..de4ad08 100644
--- a/base/android/java/src/org/chromium/base/BuildInfo.java
+++ b/base/android/java/src/org/chromium/base/BuildInfo.java
@@ -44,8 +44,8 @@ public class BuildInfo {
/**
* @return The build fingerprint for the current Android install. The value is truncated to a
- * 128 characters as this is used for crash and UMA reporting, which should avoid huge
- * strings.
+ * 128 characters as this is used for crash and UMA reporting, which should avoid huge
+ * strings.
*/
@CalledByNative
public static String getAndroidBuildFingerprint() {
@@ -64,10 +64,11 @@ public class BuildInfo {
}
@CalledByNative
- public static String getGMSVersionCode(Context context) {
+ public static String getGMSVersionCode() {
String msg = "gms versionCode not available.";
try {
- PackageManager packageManager = context.getPackageManager();
+ PackageManager packageManager =
+ ContextUtils.getApplicationContext().getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo("com.google.android.gms", 0);
msg = Integer.toString(packageInfo.versionCode);
} catch (NameNotFoundException e) {
@@ -77,11 +78,11 @@ public class BuildInfo {
}
@CalledByNative
- public static String getPackageVersionCode(Context context) {
+ public static String getPackageVersionCode() {
String msg = "versionCode not available.";
try {
- PackageManager pm = context.getPackageManager();
- PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
+ PackageManager pm = ContextUtils.getApplicationContext().getPackageManager();
+ PackageInfo pi = pm.getPackageInfo(getPackageName(), 0);
msg = "";
if (pi.versionCode > 0) {
msg = Integer.toString(pi.versionCode);
@@ -93,11 +94,11 @@ public class BuildInfo {
}
@CalledByNative
- public static String getPackageVersionName(Context context) {
+ public static String getPackageVersionName() {
String msg = "versionName not available";
try {
- PackageManager pm = context.getPackageManager();
- PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
+ PackageManager pm = ContextUtils.getApplicationContext().getPackageManager();
+ PackageInfo pi = pm.getPackageInfo(getPackageName(), 0);
msg = "";
if (pi.versionName != null) {
msg = pi.versionName;
@@ -109,15 +110,16 @@ public class BuildInfo {
}
@CalledByNative
- public static String getPackageLabel(Context context) {
+ public static String getPackageLabel() {
// Third-party code does disk read on the getApplicationInfo call. http://crbug.com/614343
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
try {
- PackageManager packageManager = context.getPackageManager();
- ApplicationInfo appInfo = packageManager.getApplicationInfo(context.getPackageName(),
- PackageManager.GET_META_DATA);
+ PackageManager packageManager =
+ ContextUtils.getApplicationContext().getPackageManager();
+ ApplicationInfo appInfo = packageManager.getApplicationInfo(
+ getPackageName(), PackageManager.GET_META_DATA);
CharSequence label = packageManager.getApplicationLabel(appInfo);
- return label != null ? label.toString() : "";
+ return label != null ? label.toString() : "";
} catch (NameNotFoundException e) {
return "";
} finally {
@@ -126,9 +128,11 @@ public class BuildInfo {
}
@CalledByNative
- public static String getPackageName(Context context) {
- String packageName = context != null ? context.getPackageName() : null;
- return packageName != null ? packageName : "";
+ public static String getPackageName() {
+ if (ContextUtils.getApplicationContext() == null) {
+ return "";
+ }
+ return ContextUtils.getApplicationContext().getPackageName();
}
@CalledByNative
@@ -149,13 +153,6 @@ public class BuildInfo {
}
/**
- * @return Whether the current build version is greater than Android N.
- */
- public static boolean isGreaterThanN() {
- return Build.VERSION.SDK_INT > 24 || Build.VERSION.CODENAME.equals("NMR1");
- }
-
- /**
* @return Whether the current device is running Android O release or newer.
*/
public static boolean isAtLeastO() {
diff --git a/base/android/java/templates/NativeLibraries.template b/base/android/java/templates/NativeLibraries.template
deleted file mode 100644
index 8b812a6..0000000
--- a/base/android/java/templates/NativeLibraries.template
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright 2014 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.
-
-package org.chromium.base.library_loader;
-
-import org.chromium.base.annotations.SuppressFBWarnings;
-
-@SuppressFBWarnings
-public class NativeLibraries {
- /**
- * IMPORTANT NOTE: The variables defined here must _not_ be 'final'.
- *
- * The reason for this is very subtle:
- *
- * - This template is used to generate several distinct, but similar
- * files used in different contexts:
- *
- * o .../gen/templates/org/chromium/base/library_loader/NativeLibraries.java
- *
- * This file is used to build base.jar, which is the library
- * jar used by chromium projects. However, the
- * corresponding NativeLibraries.class file will _not_ be part
- * of the final base.jar.
- *
- * o .../$PROJECT/native_libraries_java/NativeLibraries.java
- *
- * This file is used to build an APK (e.g. $PROJECT
- * could be 'content_shell_apk'). Its content will depend on
- * this target's specific build configuration, and differ from
- * the source file above.
- *
- * - During the final link, all .jar files are linked together into
- * a single .dex file, and the second version of NativeLibraries.class
- * will be put into the final output file, and used at runtime.
- *
- * - If the variables were defined as 'final', their value would be
- * optimized out inside of 'base.jar', and could not be specialized
- * for every chromium program. This, however, doesn't apply to arrays of
- * strings, which can be defined as final.
- *
- * This exotic scheme is used to avoid injecting project-specific, or
- * even build-specific, values into the base layer. E.g. this is
- * how the component build is supported on Android without modifying
- * the sources of each and every Chromium-based target.
- */
-
-#if defined(ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE) && \
- !defined(ENABLE_CHROMIUM_LINKER)
-#error "Must have ENABLE_CHROMIUM_LINKER to enable library in zip file"
-#endif
-
- // Set to true to enable the use of the Chromium Linker.
-#if defined(ENABLE_CHROMIUM_LINKER)
- public static boolean sUseLinker = true;
-#else
- public static boolean sUseLinker = false;
-#endif
-
-#if defined(ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE)
- public static boolean sUseLibraryInZipFile = true;
-#else
- public static boolean sUseLibraryInZipFile = false;
-#endif
-
-#if defined(ENABLE_CHROMIUM_LINKER_TESTS)
- public static boolean sEnableLinkerTests = true;
-#else
- public static boolean sEnableLinkerTests = false;
-#endif
-
- // This is the list of native libraries to be loaded (in the correct order)
- // by LibraryLoader.java. The base java library is compiled with no
- // array defined, and then the build system creates a version of the file
- // with the real list of libraries required (which changes based upon which
- // .apk is being built).
- // TODO(cjhopman): This is public since it is referenced by NativeTestActivity.java
- // directly. The two ways of library loading should be refactored into one.
- public static final String[] LIBRARIES =
-#if defined(NATIVE_LIBRARIES_LIST)
- NATIVE_LIBRARIES_LIST;
-#else
- {};
-#endif
-
- // This is the expected version of the 'main' native library, which is the one that
- // implements the initial set of base JNI functions including
- // base::android::nativeGetVersionName()
- static String sVersionNumber =
-#if defined(NATIVE_LIBRARIES_VERSION_NUMBER)
- NATIVE_LIBRARIES_VERSION_NUMBER;
-#else
- "";
-#endif
-}
diff --git a/base/android/scoped_java_ref.cc b/base/android/scoped_java_ref.cc
index 2876ba4..7d31a75 100644
--- a/base/android/scoped_java_ref.cc
+++ b/base/android/scoped_java_ref.cc
@@ -84,7 +84,7 @@ void JavaRef<jobject>::ResetGlobalRef() {
jobject JavaRef<jobject>::ReleaseInternal() {
jobject obj = obj_;
- obj_ = NULL;
+ obj_ = nullptr;
return obj;
}