Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3023)

Unified Diff: base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java

Issue 2785373004: Remove BuildInfo#isGreaterThanN() (Closed)
Patch Set: Updates for network security config Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/android/java/src/org/chromium/base/BuildInfo.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java
diff --git a/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java b/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java
index 986973da036f0f32e814c2036a9fc8d22def6325..406f328c18058b11c6c8d72d85d429df38a368ad 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.view.inputmethod.InputMethodSubtype;
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 @@ public class ApiCompatibilityUtils {
* @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;
-
- 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.
- }
+ // UserManager#isDemoUser() is only available in Android NMR1+.
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) return false;
- return false;
+ UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ return userManager.isDemoUser();
}
/**
« no previous file with comments | « no previous file | base/android/java/src/org/chromium/base/BuildInfo.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698