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
...@@ -18,17 +18,13 @@ import android.content.res.Resources; ...@@ -18,17 +18,13 @@ import android.content.res.Resources;
import android.content.res.Resources.NotFoundException; import android.content.res.Resources.NotFoundException;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.ImageDecoder; import android.graphics.ImageDecoder;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.PowerManager;
import android.os.Process;
import android.os.StrictMode; import android.os.StrictMode;
import android.os.UserManager; import android.os.UserManager;
import android.provider.MediaStore; import android.provider.MediaStore;
...@@ -45,14 +41,12 @@ import android.view.inputmethod.InputMethodSubtype; ...@@ -45,14 +41,12 @@ import android.view.inputmethod.InputMethodSubtype;
import android.view.textclassifier.TextClassifier; import android.view.textclassifier.TextClassifier;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.widget.ImageViewCompat; import androidx.core.widget.ImageViewCompat;
import org.chromium.base.annotations.VerifiesOnLollipop;
import org.chromium.base.annotations.VerifiesOnLollipopMR1; import org.chromium.base.annotations.VerifiesOnLollipopMR1;
import org.chromium.base.annotations.VerifiesOnM; import org.chromium.base.annotations.VerifiesOnM;
import org.chromium.base.annotations.VerifiesOnN; import org.chromium.base.annotations.VerifiesOnN;
...@@ -180,94 +174,6 @@ public class ApiCompatibilityUtils { ...@@ -180,94 +174,6 @@ public class ApiCompatibilityUtils {
} }
} }
@VerifiesOnLollipop
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static class ApisL {
static final int FLAG_ACTIVITY_NEW_DOCUMENT = Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
static void finishAndRemoveTask(Activity activity) {
activity.finishAndRemoveTask();
}
static void finishAfterTransition(Activity activity) {
activity.finishAfterTransition();
}
static void setElevation(PopupWindow popupWindow, float elevationValue) {
popupWindow.setElevation(elevationValue);
}
static boolean isInteractive(PowerManager manager) {
return manager.isInteractive();
}
static boolean shouldSkipFirstUseHints(ContentResolver contentResolver) {
return Settings.Secure.getInt(contentResolver, Settings.Secure.SKIP_FIRST_USE_HINTS, 0)
!= 0;
}
static void setTaskDescription(Activity activity, String title, Bitmap icon, int color) {
ActivityManager.TaskDescription description =
new ActivityManager.TaskDescription(title, icon, color);
activity.setTaskDescription(description);
}
static void setStatusBarColor(Window window, int statusBarColor) {
// If both system bars are black, we can remove these from our layout,
// removing or shrinking the SurfaceFlinger overlay required for our views.
// This benefits battery usage on L and M. However, this no longer provides a battery
// benefit as of N and starts to cause flicker bugs on O, so don't bother on O and up.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O && statusBarColor == Color.BLACK
&& window.getNavigationBarColor() == Color.BLACK) {
window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
} else {
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
}
window.setStatusBarColor(statusBarColor);
}
static Drawable getDrawableForDensity(Resources res, int id, int density) {
// On newer OS versions, this check is done within getDrawableForDensity().
if (density == 0) {
return res.getDrawable(id, null);
}
return res.getDrawableForDensity(id, density, null);
}
static void setImageTintList(ImageView view, @Nullable ColorStateList tintList) {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
// Work around broken workaround in ImageViewCompat, see
// https://crbug.com/891609#c3.
if (tintList != null && view.getImageTintMode() == null) {
view.setImageTintMode(PorterDuff.Mode.SRC_IN);
}
}
ImageViewCompat.setImageTintList(view, tintList);
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
// Work around that the tint list is not cleared when setting tint list to null on L
// in some cases. See https://crbug.com/983686.
if (tintList == null) view.refreshDrawableState();
}
}
static Drawable getUserBadgedIcon(PackageManager packageManager, Drawable drawable) {
return packageManager.getUserBadgedIcon(drawable, Process.myUserHandle());
}
static Drawable getUserBadgedDrawableForDensity(
Drawable drawable, Rect badgeLocation, int density) {
PackageManager packageManager =
ContextUtils.getApplicationContext().getPackageManager();
return packageManager.getUserBadgedDrawableForDensity(
drawable, Process.myUserHandle(), badgeLocation, density);
}
static ColorFilter getColorFilter(Drawable drawable) {
return drawable.getColorFilter();
}
}
/** /**
* Compares two long values numerically. The value returned is identical to what would be * Compares two long values numerically. The value returned is identical to what would be
* returned by {@link Long#compare(long, long)} which is available since API level 19. * returned by {@link Long#compare(long, long)} which is available since API level 19.
...@@ -338,21 +244,11 @@ public class ApiCompatibilityUtils { ...@@ -338,21 +244,11 @@ public class ApiCompatibilityUtils {
*/ */
public static void finishAndRemoveTask(Activity activity) { public static void finishAndRemoveTask(Activity activity) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
ApisL.finishAndRemoveTask(activity); activity.finishAndRemoveTask();
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) { } else {
assert Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP;
// crbug.com/395772 : Fallback for Activity.finishAndRemoveTask() failing. // crbug.com/395772 : Fallback for Activity.finishAndRemoveTask() failing.
new FinishAndRemoveTaskWithRetry(activity).run(); new FinishAndRemoveTaskWithRetry(activity).run();
} else {
activity.finish();
}
}
/**
* Set elevation if supported.
*/
public static void setElevation(PopupWindow window, float elevationValue) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ApisL.setElevation(window, elevationValue);
} }
} }
...@@ -386,7 +282,7 @@ public class ApiCompatibilityUtils { ...@@ -386,7 +282,7 @@ public class ApiCompatibilityUtils {
@Override @Override
public void run() { public void run() {
ApisL.finishAndRemoveTask(mActivity); mActivity.finishAndRemoveTask();
mTryCount++; mTryCount++;
if (!mActivity.isFinishing()) { if (!mActivity.isFinishing()) {
if (mTryCount < MAX_TRY_COUNT) { if (mTryCount < MAX_TRY_COUNT) {
...@@ -398,51 +294,21 @@ public class ApiCompatibilityUtils { ...@@ -398,51 +294,21 @@ public class ApiCompatibilityUtils {
} }
} }
/**
* @return Whether the screen of the device is interactive.
*/
@SuppressWarnings("deprecation")
public static boolean isInteractive() {
PowerManager manager = (PowerManager) ContextUtils.getApplicationContext().getSystemService(
Context.POWER_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return ApisL.isInteractive(manager);
}
return manager.isScreenOn();
}
/**
* @see android.provider.Settings.Secure#SKIP_FIRST_USE_HINTS
*/
public static boolean shouldSkipFirstUseHints(ContentResolver contentResolver) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return ApisL.shouldSkipFirstUseHints(contentResolver);
}
return false;
}
/**
* @param activity Activity that should get the task description update.
* @param title Title of the activity.
* @param icon Icon of the activity.
* @param color Color of the activity. It must be a fully opaque color.
*/
public static void setTaskDescription(Activity activity, String title, Bitmap icon, int color) {
// TaskDescription requires an opaque color.
assert Color.alpha(color) == 255;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ApisL.setTaskDescription(activity, title, icon, color);
}
}
/** /**
* @see android.view.Window#setStatusBarColor(int color). * @see android.view.Window#setStatusBarColor(int color).
*/ */
public static void setStatusBarColor(Window window, int statusBarColor) { public static void setStatusBarColor(Window window, int statusBarColor) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // If both system bars are black, we can remove these from our layout,
ApisL.setStatusBarColor(window, statusBarColor); // removing or shrinking the SurfaceFlinger overlay required for our views.
// This benefits battery usage on L and M. However, this no longer provides a battery
// benefit as of N and starts to cause flicker bugs on O, so don't bother on O and up.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O && statusBarColor == Color.BLACK
&& window.getNavigationBarColor() == Color.BLACK) {
window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
} else {
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
} }
window.setStatusBarColor(statusBarColor);
} }
/** /**
...@@ -468,7 +334,20 @@ public class ApiCompatibilityUtils { ...@@ -468,7 +334,20 @@ public class ApiCompatibilityUtils {
} }
public static void setImageTintList(ImageView view, @Nullable ColorStateList tintList) { public static void setImageTintList(ImageView view, @Nullable ColorStateList tintList) {
ApisL.setImageTintList(view, tintList); if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
// Work around broken workaround in ImageViewCompat, see
// https://crbug.com/891609#c3.
if (tintList != null && view.getImageTintMode() == null) {
view.setImageTintMode(PorterDuff.Mode.SRC_IN);
}
}
ImageViewCompat.setImageTintList(view, tintList);
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
// Work around that the tint list is not cleared when setting tint list to null on L
// in some cases. See https://crbug.com/983686.
if (tintList == null) view.refreshDrawableState();
}
} }
/** /**
...@@ -478,53 +357,18 @@ public class ApiCompatibilityUtils { ...@@ -478,53 +357,18 @@ public class ApiCompatibilityUtils {
public static Drawable getDrawableForDensity(Resources res, int id, int density) { public static Drawable getDrawableForDensity(Resources res, int id, int density) {
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
try { try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // For Android Oreo+, Resources.getDrawable(id, null) delegates to
return ApisL.getDrawableForDensity(res, id, density); // Resources.getDrawableForDensity(id, 0, null), but before that the two functions are
} else if (density == 0) { // independent. This check can be removed after Oreo becomes the minimum supported API.
// On newer OS versions, this check is done within getDrawableForDensity(). if (density == 0) {
return res.getDrawable(id); return res.getDrawable(id, null);
} }
return res.getDrawableForDensity(id, density); return res.getDrawableForDensity(id, density, null);
} finally { } finally {
StrictMode.setThreadPolicy(oldPolicy); StrictMode.setThreadPolicy(oldPolicy);
} }
} }
/**
* @see android.app.Activity#finishAfterTransition().
*/
public static void finishAfterTransition(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ApisL.finishAfterTransition(activity);
} else {
activity.finish();
}
}
/**
* @see android.content.pm.PackageManager#getUserBadgedIcon(Drawable, android.os.UserHandle).
*/
public static Drawable getUserBadgedIcon(Context context, int id) {
Drawable drawable = getDrawable(context.getResources(), id);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
PackageManager packageManager = context.getPackageManager();
drawable = ApisL.getUserBadgedIcon(packageManager, drawable);
}
return drawable;
}
/**
* @see android.content.pm.PackageManager#getUserBadgedDrawableForDensity(Drawable drawable,
* UserHandle user, Rect badgeLocation, int badgeDensity).
*/
public static Drawable getUserBadgedDrawableForDensity(
Drawable drawable, Rect badgeLocation, int density) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
drawable = ApisL.getUserBadgedDrawableForDensity(drawable, badgeLocation, density);
}
return drawable;
}
/** /**
* @see android.content.res.Resources#getColor(int id). * @see android.content.res.Resources#getColor(int id).
*/ */
...@@ -533,16 +377,6 @@ public class ApiCompatibilityUtils { ...@@ -533,16 +377,6 @@ public class ApiCompatibilityUtils {
return res.getColor(id); return res.getColor(id);
} }
/**
* @see android.graphics.drawable.Drawable#getColorFilter().
*/
public static ColorFilter getColorFilter(Drawable drawable) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return ApisL.getColorFilter(drawable);
}
return null;
}
/** /**
* @see android.widget.TextView#setTextAppearance(int id). * @see android.widget.TextView#setTextAppearance(int id).
*/ */
...@@ -586,21 +420,6 @@ public class ApiCompatibilityUtils { ...@@ -586,21 +420,6 @@ public class ApiCompatibilityUtils {
return inputMethodSubType.getLocale(); return inputMethodSubType.getLocale();
} }
/**
* @see android.view.Window#FEATURE_INDETERMINATE_PROGRESS
*/
public static void setWindowIndeterminateProgress(Window window) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
@SuppressWarnings("deprecation")
int featureNumber = Window.FEATURE_INDETERMINATE_PROGRESS;
@SuppressWarnings("deprecation")
int featureValue = Window.PROGRESS_VISIBILITY_OFF;
window.setFeatureInt(featureNumber, featureValue);
}
}
/** /**
* @param activity The {@link Activity} to check. * @param activity The {@link Activity} to check.
* @return Whether or not {@code activity} is currently in Android N+ multi-window mode. * @return Whether or not {@code activity} is currently in Android N+ multi-window mode.
......
...@@ -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