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;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.CallbackController;
import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils;
......@@ -682,7 +681,6 @@ public class ChromeTabbedActivity extends ChromeActivity<ChromeActivityComponent
// The dataset has already been created, we need to initialize our state.
mTabModelSelectorImpl.notifyChanged();
ApiCompatibilityUtils.setWindowIndeterminateProgress(getWindow());
// Check for incognito tabs to handle the case where Chrome was swiped away in the
// background.
......
......@@ -18,7 +18,6 @@ import android.os.PowerManager;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.net.ConnectionType;
import org.chromium.net.NetworkChangeNotifier;
......@@ -183,8 +182,10 @@ public class DeviceConditions {
public static boolean isCurrentlyScreenOnAndUnlocked(Context context) {
KeyguardManager keyguardManager =
(KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
return keyguardManager != null && !keyguardManager.isKeyguardLocked()
&& ApiCompatibilityUtils.isInteractive();
if (keyguardManager == null || keyguardManager.isKeyguardLocked()) return false;
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
return powerManager.isInteractive();
}
private static Intent getBatteryStatus(Context context) {
......
......@@ -15,6 +15,7 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.SystemClock;
import android.provider.Browser;
import android.provider.MediaStore;
......@@ -28,7 +29,6 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.browser.customtabs.CustomTabsSessionToken;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ContextUtils;
import org.chromium.base.FileUtils;
import org.chromium.base.IntentUtils;
......@@ -1049,8 +1049,12 @@ public class IntentHandler {
// Only process Intents if the screen is on and the device is unlocked;
// i.e. the user will see what is going on.
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;
return !((KeyguardManager) appContext.getSystemService(Context.KEYGUARD_SERVICE))
.inKeyguardRestrictedInputMode();
}
......
......@@ -10,11 +10,11 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.os.Handler;
import android.os.Looper;
import android.os.PowerManager;
import androidx.annotation.IntDef;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.ContextUtils;
import org.chromium.base.ThreadUtils;
......@@ -44,7 +44,9 @@ public class PowerBroadcastReceiver extends BroadcastReceiver {
static class PowerManagerHelper {
/** @return whether the screen is on or not. */
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;
import static androidx.browser.customtabs.CustomTabsIntent.COLOR_SCHEME_LIGHT;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
......@@ -23,7 +24,6 @@ import androidx.annotation.Nullable;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.browser.customtabs.CustomTabsSessionToken;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.IntentUtils;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R;
......@@ -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.
ApiCompatibilityUtils.setTaskDescription(this, null, null,
mIntentDataProvider.getToolbarColor());
setTaskDescription(new ActivityManager.TaskDescription(
null, null, mIntentDataProvider.getToolbarColor()));
getComponent().resolveBottomBarDelegate().showBottomBarIfNecessary();
}
......
......@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.customtabs;
import android.app.ActivityManager;
import android.content.Intent;
import android.graphics.Bitmap;
import android.text.TextUtils;
......@@ -203,8 +204,8 @@ public class CustomTabTaskDescriptionHelper implements NativeInitObserver, Destr
}
private void updateTaskDescription() {
ApiCompatibilityUtils.setTaskDescription(
mActivity, computeTitle(), computeIcon(), computeThemeColor());
mActivity.setTaskDescription(new ActivityManager.TaskDescription(
computeTitle(), computeIcon(), computeThemeColor()));
}
/**
......
......@@ -11,6 +11,7 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemClock;
import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
......@@ -115,7 +116,9 @@ public abstract class FirstRunFlowSequencer {
@VisibleForTesting
protected boolean shouldSkipFirstUseHints() {
return ApiCompatibilityUtils.shouldSkipFirstUseHints(mActivity.getContentResolver());
return Settings.Secure.getInt(
mActivity.getContentResolver(), Settings.Secure.SKIP_FIRST_USE_HINTS, 0)
!= 0;
}
@VisibleForTesting
......
......@@ -12,6 +12,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Process;
import android.text.format.DateFormat;
import android.util.DisplayMetrics;
import android.view.View;
......@@ -19,7 +20,6 @@ import android.widget.RemoteViews;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.StrictModeContext;
import org.chromium.chrome.R;
import org.chromium.components.browser_ui.notifications.NotificationMetadata;
......@@ -245,8 +245,9 @@ public class CustomNotificationBuilder extends NotificationBuilderBase {
Bitmap bitmap = Bitmap.createBitmap(colors, size, size, Bitmap.Config.ARGB_8888);
Drawable inputDrawable = new BitmapDrawable(resources, bitmap);
Drawable outputDrawable = ApiCompatibilityUtils.getUserBadgedDrawableForDensity(
inputDrawable, null /* badgeLocation */, metrics.densityDpi);
Drawable outputDrawable =
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 drawable if the work profile badge was applied.
......
......@@ -6,8 +6,8 @@ package org.chromium.chrome.browser.omaha;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.os.PowerManager;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ApplicationStatus;
import org.chromium.chrome.browser.AppHooks;
......@@ -46,9 +46,10 @@ public abstract class OmahaDelegateBase extends OmahaDelegate {
@Override
boolean isChromeBeingUsed() {
boolean isChromeVisible = ApplicationStatus.hasVisibleActivities();
boolean isScreenOn = ApiCompatibilityUtils.isInteractive();
return isChromeVisible && isScreenOn;
if (!ApplicationStatus.hasVisibleActivities()) return false;
PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
return powerManager.isInteractive();
}
@Override
......
......@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.settings;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager.NameNotFoundException;
......@@ -123,9 +124,10 @@ public class SettingsActivity extends ChromeBaseAppCompatActivity
}
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),
ApiCompatibilityUtils.getColor(res, R.color.default_primary_color));
ApiCompatibilityUtils.getColor(res, R.color.default_primary_color)));
setStatusBarColor();
}
......
......@@ -9,9 +9,9 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.PowerManager;
import android.os.SystemClock;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ContextUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
......@@ -82,7 +82,11 @@ public class IdleDetector extends BroadcastReceiver {
@CalledByNative
private boolean isScreenLocked() {
Context context = ContextUtils.getApplicationContext();
KeyguardManager myKM = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
return myKM.inKeyguardRestrictedInputMode() || !ApiCompatibilityUtils.isInteractive();
KeyguardManager keyguardManager =
(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;
import androidx.annotation.IntDef;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ObserverList;
import java.lang.annotation.Retention;
......@@ -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) {
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