Commit d42cfe13 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Prevent verification errors from ApiCompatibilityUtils.java

More hardening against verification failures caused by inlining.

Also removes some unnecessary passing around of Application context.

TBR=agrieve # Trivial change to ui/android

Bug: 1006812
Change-Id: Icde0541166a7cac69edaf1a7638c41827c2711ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1819354
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarSam Maier <smaier@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699912}
parent 612d8837
...@@ -10,7 +10,6 @@ import android.content.Context; ...@@ -10,7 +10,6 @@ import android.content.Context;
import android.content.ContextWrapper; import android.content.ContextWrapper;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.AssetManager; import android.content.res.AssetManager;
import android.os.Build;
import android.os.Process; import android.os.Process;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
...@@ -18,7 +17,6 @@ import androidx.annotation.Nullable; ...@@ -18,7 +17,6 @@ import androidx.annotation.Nullable;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.MainDex; import org.chromium.base.annotations.MainDex;
import org.chromium.base.annotations.VerifiesOnP;
/** /**
* This class provides Android application context related utility methods. * This class provides Android application context related utility methods.
...@@ -138,19 +136,8 @@ public class ContextUtils { ...@@ -138,19 +136,8 @@ public class ContextUtils {
} }
/** @return The name of the current process. E.g. "org.chromium.chrome:privileged_process0". */ /** @return The name of the current process. E.g. "org.chromium.chrome:privileged_process0". */
@VerifiesOnP
public static String getProcessName() { public static String getProcessName() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { return ApiCompatibilityUtils.getProcessName();
return Application.getProcessName();
}
try {
Class<?> activityThreadClazz = Class.forName("android.app.ActivityThread");
return (String) activityThreadClazz.getMethod("currentProcessName").invoke(null);
} catch (Exception e) {
// If fallback logic is ever needed, refer to:
// https://chromium-review.googlesource.com/c/chromium/src/+/905563/1
throw new RuntimeException(e);
}
} }
/** /**
......
...@@ -184,7 +184,7 @@ public class DeviceConditions { ...@@ -184,7 +184,7 @@ public class DeviceConditions {
KeyguardManager keyguardManager = KeyguardManager keyguardManager =
(KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
return keyguardManager != null && !keyguardManager.isKeyguardLocked() return keyguardManager != null && !keyguardManager.isKeyguardLocked()
&& ApiCompatibilityUtils.isInteractive(context); && ApiCompatibilityUtils.isInteractive();
} }
private static Intent getBatteryStatus(Context context) { private static Intent getBatteryStatus(Context context) {
......
...@@ -1028,7 +1028,7 @@ public class IntentHandler { ...@@ -1028,7 +1028,7 @@ public class IntentHandler {
// Only process Intents if the screen is on and the device is unlocked; // Only process Intents if the screen is on and the device is unlocked;
// i.e. the user will see what is going on. // i.e. the user will see what is going on.
Context appContext = ContextUtils.getApplicationContext(); Context appContext = ContextUtils.getApplicationContext();
if (!ApiCompatibilityUtils.isInteractive(appContext)) return false; if (!ApiCompatibilityUtils.isInteractive()) return false;
if (!isDeviceProvisioned(appContext)) return true; if (!isDeviceProvisioned(appContext)) return true;
return !((KeyguardManager) appContext.getSystemService(Context.KEYGUARD_SERVICE)) return !((KeyguardManager) appContext.getSystemService(Context.KEYGUARD_SERVICE))
.inKeyguardRestrictedInputMode(); .inKeyguardRestrictedInputMode();
......
...@@ -44,7 +44,7 @@ public class PowerBroadcastReceiver extends BroadcastReceiver { ...@@ -44,7 +44,7 @@ public class PowerBroadcastReceiver extends BroadcastReceiver {
static class PowerManagerHelper { static class PowerManagerHelper {
/** @return whether the screen is on or not. */ /** @return whether the screen is on or not. */
public boolean isScreenOn(Context context) { public boolean isScreenOn(Context context) {
return ApiCompatibilityUtils.isInteractive(context); return ApiCompatibilityUtils.isInteractive();
} }
} }
......
...@@ -14,7 +14,6 @@ import androidx.annotation.Nullable; ...@@ -14,7 +14,6 @@ import androidx.annotation.Nullable;
import androidx.browser.customtabs.CustomTabsService; import androidx.browser.customtabs.CustomTabsService;
import androidx.browser.customtabs.CustomTabsSessionToken; import androidx.browser.customtabs.CustomTabsSessionToken;
import org.chromium.base.ContextUtils;
import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.Origin;
import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer; import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer;
import org.chromium.chrome.browser.init.ProcessInitializationHandler; import org.chromium.chrome.browser.init.ProcessInitializationHandler;
...@@ -114,8 +113,8 @@ public class CustomTabsConnectionService extends CustomTabsService { ...@@ -114,8 +113,8 @@ public class CustomTabsConnectionService extends CustomTabsService {
private boolean isFirstRunDone() { private boolean isFirstRunDone() {
if (mBindIntent == null) return true; if (mBindIntent == null) return true;
boolean firstRunNecessary = FirstRunFlowSequencer.checkIfFirstRunIsNecessary( boolean firstRunNecessary =
ContextUtils.getApplicationContext(), mBindIntent, false); FirstRunFlowSequencer.checkIfFirstRunIsNecessary(mBindIntent, false);
if (!firstRunNecessary) { if (!firstRunNecessary) {
mBindIntent = null; mBindIntent = null;
return true; return true;
......
...@@ -12,7 +12,6 @@ import android.view.View; ...@@ -12,7 +12,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.ObserverList; import org.chromium.base.ObserverList;
...@@ -72,12 +71,12 @@ public class SpaceDisplay extends RecyclerView.AdapterDataObserver { ...@@ -72,12 +71,12 @@ public class SpaceDisplay extends RecyclerView.AdapterDataObserver {
if (downloadDirectory.exists()) { if (downloadDirectory.exists()) {
StatFs statFs = new StatFs(downloadDirectory.getPath()); StatFs statFs = new StatFs(downloadDirectory.getPath());
if (mFetchTotalSize) { if (mFetchTotalSize) {
blocks = ApiCompatibilityUtils.getBlockCount(statFs); blocks = statFs.getBlockCountLong();
} else { } else {
blocks = ApiCompatibilityUtils.getAvailableBlocks(statFs); blocks = statFs.getAvailableBlocksLong();
} }
return blocks * ApiCompatibilityUtils.getBlockSize(statFs); return blocks * statFs.getBlockSizeLong();
} else { } else {
Log.e(TAG, "Download directory doesn't exist."); Log.e(TAG, "Download directory doesn't exist.");
return 0L; return 0L;
......
...@@ -9,7 +9,6 @@ import android.os.Environment; ...@@ -9,7 +9,6 @@ import android.os.Environment;
import android.os.StatFs; import android.os.StatFs;
import android.util.Pair; import android.util.Pair;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.CollectionUtil; import org.chromium.base.CollectionUtil;
import org.chromium.base.LocaleUtils; import org.chromium.base.LocaleUtils;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
...@@ -46,11 +45,11 @@ public class SystemInfoFeedbackSource extends AsyncFeedbackSourceAdapter<StatFs> ...@@ -46,11 +45,11 @@ public class SystemInfoFeedbackSource extends AsyncFeedbackSourceAdapter<StatFs>
StatFs statFs = getResult(); StatFs statFs = getResult();
if (statFs != null) { if (statFs != null) {
long blockSize = ApiCompatibilityUtils.getBlockSize(statFs); long blockSize = statFs.getBlockSizeLong();
long availSpace = ConversionUtils.bytesToMegabytes( long availSpace =
ApiCompatibilityUtils.getAvailableBlocks(statFs) * blockSize); ConversionUtils.bytesToMegabytes(statFs.getAvailableBlocksLong() * blockSize);
long totalSpace = ConversionUtils.bytesToMegabytes( long totalSpace =
ApiCompatibilityUtils.getBlockCount(statFs) * blockSize); ConversionUtils.bytesToMegabytes(statFs.getBlockCountLong() * blockSize);
feedback.put("Available Storage (MB)", Long.toString(availSpace)); feedback.put("Available Storage (MB)", Long.toString(availSpace));
feedback.put("Total Storage (MB)", Long.toString(totalSpace)); feedback.put("Total Storage (MB)", Long.toString(totalSpace));
......
...@@ -73,7 +73,7 @@ public abstract class FirstRunFlowSequencer { ...@@ -73,7 +73,7 @@ public abstract class FirstRunFlowSequencer {
*/ */
public void start() { public void start() {
if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE) if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)
|| ApiCompatibilityUtils.isDemoUser(mActivity)) { || ApiCompatibilityUtils.isDemoUser()) {
onFlowIsKnown(null); onFlowIsKnown(null);
return; return;
} }
...@@ -228,16 +228,15 @@ public abstract class FirstRunFlowSequencer { ...@@ -228,16 +228,15 @@ public abstract class FirstRunFlowSequencer {
/** /**
* Checks if the First Run needs to be launched. * Checks if the First Run needs to be launched.
* @param context The context.
* @param fromIntent The intent that was used to launch Chrome. * @param fromIntent The intent that was used to launch Chrome.
* @param preferLightweightFre Whether to prefer the Lightweight First Run Experience. * @param preferLightweightFre Whether to prefer the Lightweight First Run Experience.
* @return Whether the First Run Experience needs to be launched. * @return Whether the First Run Experience needs to be launched.
*/ */
public static boolean checkIfFirstRunIsNecessary( public static boolean checkIfFirstRunIsNecessary(
Context context, Intent fromIntent, boolean preferLightweightFre) { Intent fromIntent, boolean preferLightweightFre) {
// If FRE is disabled (e.g. in tests), proceed directly to the intent handling. // If FRE is disabled (e.g. in tests), proceed directly to the intent handling.
if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE) if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)
|| ApiCompatibilityUtils.isDemoUser(context)) { || ApiCompatibilityUtils.isDemoUser()) {
return false; return false;
} }
...@@ -270,7 +269,7 @@ public abstract class FirstRunFlowSequencer { ...@@ -270,7 +269,7 @@ public abstract class FirstRunFlowSequencer {
public static boolean launch(Context caller, Intent fromIntent, boolean requiresBroadcast, public static boolean launch(Context caller, Intent fromIntent, boolean requiresBroadcast,
boolean preferLightweightFre) { boolean preferLightweightFre) {
// Check if the user needs to go through First Run at all. // Check if the user needs to go through First Run at all.
if (!checkIfFirstRunIsNecessary(caller, fromIntent, preferLightweightFre)) return false; if (!checkIfFirstRunIsNecessary(fromIntent, preferLightweightFre)) return false;
String intentUrl = IntentHandler.getUrlFromIntent(fromIntent); String intentUrl = IntentHandler.getUrlFromIntent(fromIntent);
Uri uri = intentUrl != null ? Uri.parse(intentUrl) : null; Uri uri = intentUrl != null ? Uri.parse(intentUrl) : null;
......
...@@ -6,7 +6,6 @@ package org.chromium.chrome.browser.init; ...@@ -6,7 +6,6 @@ package org.chromium.chrome.browser.init;
import android.content.Intent; import android.content.Intent;
import org.chromium.base.ContextUtils;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.base.library_loader.LibraryLoader; import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer; import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer;
...@@ -71,7 +70,7 @@ class NativeInitializationController { ...@@ -71,7 +70,7 @@ class NativeInitializationController {
ThreadUtils.assertOnUiThread(); ThreadUtils.assertOnUiThread();
assert mBackgroundTasksComplete == null; assert mBackgroundTasksComplete == null;
boolean fetchVariationsSeed = FirstRunFlowSequencer.checkIfFirstRunIsNecessary( boolean fetchVariationsSeed = FirstRunFlowSequencer.checkIfFirstRunIsNecessary(
ContextUtils.getApplicationContext(), mActivityDelegate.getInitialIntent(), false); mActivityDelegate.getInitialIntent(), false);
mBackgroundTasksComplete = false; mBackgroundTasksComplete = false;
new AsyncInitTaskRunner() { new AsyncInitTaskRunner() {
......
...@@ -18,7 +18,6 @@ import androidx.annotation.WorkerThread; ...@@ -18,7 +18,6 @@ import androidx.annotation.WorkerThread;
import com.google.ipc.invalidation.external.client.android.service.AndroidLogger; import com.google.ipc.invalidation.external.client.android.service.AndroidLogger;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.CommandLine; import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
...@@ -415,7 +414,7 @@ public class ProcessInitializationHandler { ...@@ -415,7 +414,7 @@ public class ProcessInitializationHandler {
DownloadManagerService.getDownloadManagerService()); DownloadManagerService.getDownloadManagerService());
} }
if (ApiCompatibilityUtils.isPrintingSupported()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
String errorText = ContextUtils.getApplicationContext().getString( String errorText = ContextUtils.getApplicationContext().getString(
R.string.error_printing_failed); R.string.error_printing_failed);
PrintingControllerImpl.create(new PrintDocumentAdapterWrapper(), errorText); PrintingControllerImpl.create(new PrintDocumentAdapterWrapper(), errorText);
......
...@@ -259,7 +259,7 @@ public class LocaleManager { ...@@ -259,7 +259,7 @@ public class LocaleManager {
} }
}; };
if (TemplateUrlServiceFactory.get().isDefaultSearchManaged() if (TemplateUrlServiceFactory.get().isDefaultSearchManaged()
|| ApiCompatibilityUtils.isDemoUser(activity)) { || ApiCompatibilityUtils.isDemoUser()) {
finalizeInternalCallback.onResult(true); finalizeInternalCallback.onResult(true);
return; return;
} }
......
...@@ -250,7 +250,7 @@ public class CustomNotificationBuilder extends NotificationBuilderBase { ...@@ -250,7 +250,7 @@ public class CustomNotificationBuilder extends NotificationBuilderBase {
Drawable inputDrawable = new BitmapDrawable(resources, bitmap); Drawable inputDrawable = new BitmapDrawable(resources, bitmap);
Drawable outputDrawable = ApiCompatibilityUtils.getUserBadgedDrawableForDensity( Drawable outputDrawable = ApiCompatibilityUtils.getUserBadgedDrawableForDensity(
mContext, inputDrawable, null /* badgeLocation */, metrics.densityDpi); inputDrawable, null /* badgeLocation */, metrics.densityDpi);
// The input bitmap is immutable, so the output drawable will be a different instance from // The input bitmap is immutable, so the output drawable will be a different instance from
// the input drawable if the work profile badge was applied. // the input drawable if the work profile badge was applied.
......
...@@ -47,7 +47,7 @@ public abstract class OmahaDelegateBase extends OmahaDelegate { ...@@ -47,7 +47,7 @@ public abstract class OmahaDelegateBase extends OmahaDelegate {
@Override @Override
boolean isChromeBeingUsed() { boolean isChromeBeingUsed() {
boolean isChromeVisible = ApplicationStatus.hasVisibleActivities(); boolean isChromeVisible = ApplicationStatus.hasVisibleActivities();
boolean isScreenOn = ApiCompatibilityUtils.isInteractive(getContext()); boolean isScreenOn = ApiCompatibilityUtils.isInteractive();
return isChromeVisible && isScreenOn; return isChromeVisible && isScreenOn;
} }
......
...@@ -95,7 +95,7 @@ class PermissionParamsListBuilder { ...@@ -95,7 +95,7 @@ class PermissionParamsListBuilder {
} else if (shouldShowNotificationsDisabledWarning(permission)) { } else if (shouldShowNotificationsDisabledWarning(permission)) {
permissionParams.warningTextResource = permissionParams.warningTextResource =
R.string.page_info_android_permission_blocked; R.string.page_info_android_permission_blocked;
intentOverride = ApiCompatibilityUtils.getNotificationSettingsIntent(mContext); intentOverride = ApiCompatibilityUtils.getNotificationSettingsIntent();
} else if (!hasAndroidPermission(permission.type)) { } else if (!hasAndroidPermission(permission.type)) {
permissionParams.warningTextResource = permissionParams.warningTextResource =
R.string.page_info_android_permission_blocked; R.string.page_info_android_permission_blocked;
......
...@@ -406,8 +406,7 @@ public class SearchWidgetProvider extends AppWidgetProvider { ...@@ -406,8 +406,7 @@ public class SearchWidgetProvider extends AppWidgetProvider {
} }
static boolean shouldShowFullString() { static boolean shouldShowFullString() {
boolean freIsNotNecessary = !FirstRunFlowSequencer.checkIfFirstRunIsNecessary( boolean freIsNotNecessary = !FirstRunFlowSequencer.checkIfFirstRunIsNecessary(null, false);
getDelegate().getContext(), null, false);
boolean noNeedToCheckForSearchDialog = boolean noNeedToCheckForSearchDialog =
!LocaleManager.getInstance().needToCheckForSearchEnginePromo(); !LocaleManager.getInstance().needToCheckForSearchEnginePromo();
return freIsNotNecessary && noNeedToCheckForSearchDialog; return freIsNotNecessary && noNeedToCheckForSearchDialog;
......
...@@ -306,7 +306,7 @@ public class SigninManager ...@@ -306,7 +306,7 @@ public class SigninManager
* Google Play Services installed. * Google Play Services installed.
*/ */
public boolean isSigninSupported() { public boolean isSigninSupported() {
return !ApiCompatibilityUtils.isDemoUser(mContext) && isGooglePlayServicesPresent(mContext) return !ApiCompatibilityUtils.isDemoUser() && isGooglePlayServicesPresent(mContext)
&& !SigninManagerJni.get().isMobileIdentityConsistencyEnabled(); && !SigninManagerJni.get().isMobileIdentityConsistencyEnabled();
} }
......
...@@ -23,7 +23,6 @@ import org.junit.Rule; ...@@ -23,7 +23,6 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.test.util.CallbackHelper; import org.chromium.base.test.util.CallbackHelper;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
...@@ -165,7 +164,7 @@ public class PrintingControllerTest { ...@@ -165,7 +164,7 @@ public class PrintingControllerTest {
@LargeTest @LargeTest
@Feature({"Printing"}) @Feature({"Printing"})
public void testNormalPrintingFlow() throws Throwable { public void testNormalPrintingFlow() throws Throwable {
if (!ApiCompatibilityUtils.isPrintingSupported()) return; if (!(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)) return;
mActivityTestRule.startMainActivityWithURL(URL); mActivityTestRule.startMainActivityWithURL(URL);
final Tab currentTab = mActivityTestRule.getActivity().getActivityTab(); final Tab currentTab = mActivityTestRule.getActivity().getActivityTab();
...@@ -234,7 +233,7 @@ public class PrintingControllerTest { ...@@ -234,7 +233,7 @@ public class PrintingControllerTest {
@MediumTest @MediumTest
@Feature({"Printing"}) @Feature({"Printing"})
public void testPrintCloseWindowBeforeStart() throws Throwable { public void testPrintCloseWindowBeforeStart() throws Throwable {
if (!ApiCompatibilityUtils.isPrintingSupported()) return; if (!(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)) return;
mActivityTestRule.startMainActivityWithURL(URL); mActivityTestRule.startMainActivityWithURL(URL);
final Tab currentTab = mActivityTestRule.getActivity().getActivityTab(); final Tab currentTab = mActivityTestRule.getActivity().getActivityTab();
...@@ -262,7 +261,7 @@ public class PrintingControllerTest { ...@@ -262,7 +261,7 @@ public class PrintingControllerTest {
@LargeTest @LargeTest
@Feature({"Printing"}) @Feature({"Printing"})
public void testPrintCloseWindowBeforeOnWrite() throws Throwable { public void testPrintCloseWindowBeforeOnWrite() throws Throwable {
if (!ApiCompatibilityUtils.isPrintingSupported()) return; if (!(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)) return;
mActivityTestRule.startMainActivityWithURL(URL); mActivityTestRule.startMainActivityWithURL(URL);
final Tab currentTab = mActivityTestRule.getActivity().getActivityTab(); final Tab currentTab = mActivityTestRule.getActivity().getActivityTab();
...@@ -329,7 +328,7 @@ public class PrintingControllerTest { ...@@ -329,7 +328,7 @@ public class PrintingControllerTest {
@MediumTest @MediumTest
@Feature({"Printing"}) @Feature({"Printing"})
public void testCancelPrintBeforeWriteResultCallbacks() throws Throwable { public void testCancelPrintBeforeWriteResultCallbacks() throws Throwable {
if (!ApiCompatibilityUtils.isPrintingSupported()) return; if (!(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)) return;
mActivityTestRule.startMainActivityWithURL(URL); mActivityTestRule.startMainActivityWithURL(URL);
...@@ -388,7 +387,7 @@ public class PrintingControllerTest { ...@@ -388,7 +387,7 @@ public class PrintingControllerTest {
@SmallTest @SmallTest
@Feature({"Printing"}) @Feature({"Printing"})
public void testPdfWritingDoneCalledWithoutInitailizePrintingTask() throws Throwable { public void testPdfWritingDoneCalledWithoutInitailizePrintingTask() throws Throwable {
if (!ApiCompatibilityUtils.isPrintingSupported()) return; if (!(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)) return;
mActivityTestRule.startMainActivityWithURL(URL); mActivityTestRule.startMainActivityWithURL(URL);
final PrintingControllerImpl controller = createControllerOnUiThread(); final PrintingControllerImpl controller = createControllerOnUiThread();
......
...@@ -46,7 +46,7 @@ public class IdleDetector extends BroadcastReceiver { ...@@ -46,7 +46,7 @@ public class IdleDetector extends BroadcastReceiver {
} }
@CalledByNative @CalledByNative
static private IdleDetector create() { private static IdleDetector create() {
return new IdleDetector(); return new IdleDetector();
} }
...@@ -83,7 +83,6 @@ public class IdleDetector extends BroadcastReceiver { ...@@ -83,7 +83,6 @@ public class IdleDetector extends BroadcastReceiver {
private boolean isScreenLocked() { private boolean isScreenLocked() {
Context context = ContextUtils.getApplicationContext(); Context context = ContextUtils.getApplicationContext();
KeyguardManager myKM = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); KeyguardManager myKM = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
return myKM.inKeyguardRestrictedInputMode() return myKM.inKeyguardRestrictedInputMode() || !ApiCompatibilityUtils.isInteractive();
|| !ApiCompatibilityUtils.isInteractive(context);
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment