Commit 761be790 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Remove some bits of ApiCompatibilityUtils that are no longer needed

Since KitKat support is deprecated, >= L checks can be removed and < L
code can be removed.

Bug: none
Change-Id: I123e3c1d5d33d7cf031d7c248d12a8002c2209da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2393156
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805552}
parent 31db08c8
...@@ -31,7 +31,6 @@ import androidx.annotation.IntDef; ...@@ -31,7 +31,6 @@ import androidx.annotation.IntDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.CallbackController; import org.chromium.base.CallbackController;
import org.chromium.base.CommandLine; import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
...@@ -682,7 +681,6 @@ public class ChromeTabbedActivity extends ChromeActivity<ChromeActivityComponent ...@@ -682,7 +681,6 @@ public class ChromeTabbedActivity extends ChromeActivity<ChromeActivityComponent
// The dataset has already been created, we need to initialize our state. // The dataset has already been created, we need to initialize our state.
mTabModelSelectorImpl.notifyChanged(); mTabModelSelectorImpl.notifyChanged();
ApiCompatibilityUtils.setWindowIndeterminateProgress(getWindow());
// Check for incognito tabs to handle the case where Chrome was swiped away in the // Check for incognito tabs to handle the case where Chrome was swiped away in the
// background. // background.
......
...@@ -18,7 +18,6 @@ import android.os.PowerManager; ...@@ -18,7 +18,6 @@ import android.os.PowerManager;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.net.ConnectionType; import org.chromium.net.ConnectionType;
import org.chromium.net.NetworkChangeNotifier; import org.chromium.net.NetworkChangeNotifier;
...@@ -183,8 +182,10 @@ public class DeviceConditions { ...@@ -183,8 +182,10 @@ public class DeviceConditions {
public static boolean isCurrentlyScreenOnAndUnlocked(Context context) { public static boolean isCurrentlyScreenOnAndUnlocked(Context context) {
KeyguardManager keyguardManager = KeyguardManager keyguardManager =
(KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
return keyguardManager != null && !keyguardManager.isKeyguardLocked() if (keyguardManager == null || keyguardManager.isKeyguardLocked()) return false;
&& ApiCompatibilityUtils.isInteractive();
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
return powerManager.isInteractive();
} }
private static Intent getBatteryStatus(Context context) { private static Intent getBatteryStatus(Context context) {
......
...@@ -15,6 +15,7 @@ import android.content.Context; ...@@ -15,6 +15,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.PowerManager;
import android.os.SystemClock; import android.os.SystemClock;
import android.provider.Browser; import android.provider.Browser;
import android.provider.MediaStore; import android.provider.MediaStore;
...@@ -28,7 +29,6 @@ import androidx.annotation.Nullable; ...@@ -28,7 +29,6 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import androidx.browser.customtabs.CustomTabsSessionToken; import androidx.browser.customtabs.CustomTabsSessionToken;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.FileUtils; import org.chromium.base.FileUtils;
import org.chromium.base.IntentUtils; import org.chromium.base.IntentUtils;
...@@ -1049,8 +1049,12 @@ public class IntentHandler { ...@@ -1049,8 +1049,12 @@ 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()) return false; PowerManager powerManager =
(PowerManager) appContext.getSystemService(Context.POWER_SERVICE);
if (!powerManager.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();
} }
......
...@@ -10,11 +10,11 @@ import android.content.Intent; ...@@ -10,11 +10,11 @@ import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.PowerManager;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ApplicationStatus; import org.chromium.base.ApplicationStatus;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
...@@ -44,7 +44,9 @@ public class PowerBroadcastReceiver extends BroadcastReceiver { ...@@ -44,7 +44,9 @@ 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(); PowerManager powerManager =
(PowerManager) context.getSystemService(Context.POWER_SERVICE);
return powerManager.isInteractive();
} }
} }
......
...@@ -8,6 +8,7 @@ import static androidx.browser.customtabs.CustomTabsIntent.COLOR_SCHEME_DARK; ...@@ -8,6 +8,7 @@ import static androidx.browser.customtabs.CustomTabsIntent.COLOR_SCHEME_DARK;
import static androidx.browser.customtabs.CustomTabsIntent.COLOR_SCHEME_LIGHT; import static androidx.browser.customtabs.CustomTabsIntent.COLOR_SCHEME_LIGHT;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
...@@ -23,7 +24,6 @@ import androidx.annotation.Nullable; ...@@ -23,7 +24,6 @@ import androidx.annotation.Nullable;
import androidx.browser.customtabs.CustomTabsIntent; import androidx.browser.customtabs.CustomTabsIntent;
import androidx.browser.customtabs.CustomTabsSessionToken; import androidx.browser.customtabs.CustomTabsSessionToken;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.IntentUtils; import org.chromium.base.IntentUtils;
import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R; import org.chromium.chrome.R;
...@@ -109,8 +109,9 @@ public class CustomTabActivity extends BaseCustomTabActivity { ...@@ -109,8 +109,9 @@ public class CustomTabActivity extends BaseCustomTabActivity {
} }
// Setting task title and icon to be null will preserve the client app's title and icon. // Setting task title and icon to be null will preserve the client app's title and icon.
ApiCompatibilityUtils.setTaskDescription(this, null, null, setTaskDescription(new ActivityManager.TaskDescription(
mIntentDataProvider.getToolbarColor()); null, null, mIntentDataProvider.getToolbarColor()));
getComponent().resolveBottomBarDelegate().showBottomBarIfNecessary(); getComponent().resolveBottomBarDelegate().showBottomBarIfNecessary();
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.customtabs; package org.chromium.chrome.browser.customtabs;
import android.app.ActivityManager;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.text.TextUtils; import android.text.TextUtils;
...@@ -203,8 +204,8 @@ public class CustomTabTaskDescriptionHelper implements NativeInitObserver, Destr ...@@ -203,8 +204,8 @@ public class CustomTabTaskDescriptionHelper implements NativeInitObserver, Destr
} }
private void updateTaskDescription() { private void updateTaskDescription() {
ApiCompatibilityUtils.setTaskDescription( mActivity.setTaskDescription(new ActivityManager.TaskDescription(
mActivity, computeTitle(), computeIcon(), computeThemeColor()); computeTitle(), computeIcon(), computeThemeColor()));
} }
/** /**
......
...@@ -11,6 +11,7 @@ import android.content.Intent; ...@@ -11,6 +11,7 @@ import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.SystemClock; import android.os.SystemClock;
import android.provider.Settings;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
...@@ -115,7 +116,9 @@ public abstract class FirstRunFlowSequencer { ...@@ -115,7 +116,9 @@ public abstract class FirstRunFlowSequencer {
@VisibleForTesting @VisibleForTesting
protected boolean shouldSkipFirstUseHints() { protected boolean shouldSkipFirstUseHints() {
return ApiCompatibilityUtils.shouldSkipFirstUseHints(mActivity.getContentResolver()); return Settings.Secure.getInt(
mActivity.getContentResolver(), Settings.Secure.SKIP_FIRST_USE_HINTS, 0)
!= 0;
} }
@VisibleForTesting @VisibleForTesting
......
...@@ -12,6 +12,7 @@ import android.graphics.Bitmap; ...@@ -12,6 +12,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Process;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.View; import android.view.View;
...@@ -19,7 +20,6 @@ import android.widget.RemoteViews; ...@@ -19,7 +20,6 @@ import android.widget.RemoteViews;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.StrictModeContext; import org.chromium.base.StrictModeContext;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.components.browser_ui.notifications.NotificationMetadata; import org.chromium.components.browser_ui.notifications.NotificationMetadata;
...@@ -245,8 +245,9 @@ public class CustomNotificationBuilder extends NotificationBuilderBase { ...@@ -245,8 +245,9 @@ public class CustomNotificationBuilder extends NotificationBuilderBase {
Bitmap bitmap = Bitmap.createBitmap(colors, size, size, Bitmap.Config.ARGB_8888); Bitmap bitmap = Bitmap.createBitmap(colors, size, size, Bitmap.Config.ARGB_8888);
Drawable inputDrawable = new BitmapDrawable(resources, bitmap); Drawable inputDrawable = new BitmapDrawable(resources, bitmap);
Drawable outputDrawable = ApiCompatibilityUtils.getUserBadgedDrawableForDensity( Drawable outputDrawable =
inputDrawable, null /* badgeLocation */, metrics.densityDpi); mContext.getPackageManager().getUserBadgedDrawableForDensity(inputDrawable,
Process.myUserHandle(), 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.
......
...@@ -6,8 +6,8 @@ package org.chromium.chrome.browser.omaha; ...@@ -6,8 +6,8 @@ package org.chromium.chrome.browser.omaha;
import android.content.Context; import android.content.Context;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.os.PowerManager;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ApplicationStatus; import org.chromium.base.ApplicationStatus;
import org.chromium.chrome.browser.AppHooks; import org.chromium.chrome.browser.AppHooks;
...@@ -46,9 +46,10 @@ public abstract class OmahaDelegateBase extends OmahaDelegate { ...@@ -46,9 +46,10 @@ public abstract class OmahaDelegateBase extends OmahaDelegate {
@Override @Override
boolean isChromeBeingUsed() { boolean isChromeBeingUsed() {
boolean isChromeVisible = ApplicationStatus.hasVisibleActivities(); if (!ApplicationStatus.hasVisibleActivities()) return false;
boolean isScreenOn = ApiCompatibilityUtils.isInteractive();
return isChromeVisible && isScreenOn; PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
return powerManager.isInteractive();
} }
@Override @Override
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.settings; package org.chromium.chrome.browser.settings;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
...@@ -123,9 +124,10 @@ public class SettingsActivity extends ChromeBaseAppCompatActivity ...@@ -123,9 +124,10 @@ public class SettingsActivity extends ChromeBaseAppCompatActivity
} }
Resources res = getResources(); Resources res = getResources();
ApiCompatibilityUtils.setTaskDescription(this, res.getString(R.string.app_name),
setTaskDescription(new ActivityManager.TaskDescription(res.getString(R.string.app_name),
BitmapFactory.decodeResource(res, R.mipmap.app_icon), BitmapFactory.decodeResource(res, R.mipmap.app_icon),
ApiCompatibilityUtils.getColor(res, R.color.default_primary_color)); ApiCompatibilityUtils.getColor(res, R.color.default_primary_color)));
setStatusBarColor(); setStatusBarColor();
} }
......
...@@ -9,9 +9,9 @@ import android.content.BroadcastReceiver; ...@@ -9,9 +9,9 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.os.PowerManager;
import android.os.SystemClock; import android.os.SystemClock;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
...@@ -82,7 +82,11 @@ public class IdleDetector extends BroadcastReceiver { ...@@ -82,7 +82,11 @@ public class IdleDetector extends BroadcastReceiver {
@CalledByNative @CalledByNative
private boolean isScreenLocked() { private boolean isScreenLocked() {
Context context = ContextUtils.getApplicationContext(); Context context = ContextUtils.getApplicationContext();
KeyguardManager myKM = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); KeyguardManager keyguardManager =
return myKM.inKeyguardRestrictedInputMode() || !ApiCompatibilityUtils.isInteractive(); (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
if (keyguardManager.inKeyguardRestrictedInputMode()) return true;
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
return !powerManager.isInteractive();
} }
} }
...@@ -22,7 +22,6 @@ import android.widget.PopupWindow.OnDismissListener; ...@@ -22,7 +22,6 @@ import android.widget.PopupWindow.OnDismissListener;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ObserverList; import org.chromium.base.ObserverList;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
...@@ -354,10 +353,10 @@ public class AnchoredPopupWindow implements OnTouchListener, RectProvider.Observ ...@@ -354,10 +353,10 @@ public class AnchoredPopupWindow implements OnTouchListener, RectProvider.Observ
} }
/** /**
* Sets the elevation of the popup, if elevation is supported. * Sets the elevation of the popup.
*/ */
public void setElevation(float elevation) { public void setElevation(float elevation) {
ApiCompatibilityUtils.setElevation(mPopupWindow, elevation); mPopupWindow.setElevation(elevation);
} }
/** /**
......
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