Remove BuildInfo#isGreaterThanN()
The NMR1 SDK has been published upstream, so BuildInfo#isGreaterThanN is
no longer needed. This patch also removes reflection for
UserManager#isDemoUser() and ShortcutManager#reportShortcutUsed(),
and updates AndroidManifest.xml to remove the conditional include
of launchershortcut.xml and network_security_config.xml.
BUG=707302
Review-Url: https://codereview.chromium.org/2785373004
Cr-Commit-Position: refs/heads/master@{#461787}
CrOS-Libchrome-Original-Commit: df46c2242e4635dc77fce945bfc0ea0089efee31
diff --git a/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java b/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java
index 986973d..406f328 100644
--- a/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java
+++ b/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java
@@ -36,7 +36,6 @@
import android.widget.TextView;
import java.io.File;
-import java.lang.reflect.Method;
/**
* Utility class to use new APIs that were added after ICS (API level 14).
@@ -573,22 +572,13 @@
* @param context The Android context, used to retrieve the UserManager system service.
* @return Whether the device is running in demo mode.
*/
+ @SuppressWarnings("NewApi")
public static boolean isDemoUser(Context context) {
- // UserManager#isDemoUser() is only available in Android versions greater than N.
- if (!BuildInfo.isGreaterThanN()) return false;
+ // UserManager#isDemoUser() is only available in Android NMR1+.
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) return false;
- try {
- UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
- Method isDemoUserMethod = UserManager.class.getMethod("isDemoUser");
- boolean isDemoUser = (boolean) isDemoUserMethod.invoke(userManager);
- return isDemoUser;
- } catch (RuntimeException e) {
- // Ignore to avoid crashing on startup.
- } catch (Exception e) {
- // Ignore.
- }
-
- return false;
+ UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ return userManager.isDemoUser();
}
/**
diff --git a/base/android/java/src/org/chromium/base/BuildInfo.java b/base/android/java/src/org/chromium/base/BuildInfo.java
index 03bf4bc..de4ad08 100644
--- a/base/android/java/src/org/chromium/base/BuildInfo.java
+++ b/base/android/java/src/org/chromium/base/BuildInfo.java
@@ -153,13 +153,6 @@
}
/**
- * @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() {