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(); |
} |
/** |