Commit 1cdf8507 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Remove KitKat code in //components

Bug: 1041930
Change-Id: I0cab3e0712e7188bafe53bb3e828f78c259f94c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2298941
Commit-Queue: Yaron Friedman <yfriedman@chromium.org>
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#788601}
parent fff5b652
......@@ -21,7 +21,6 @@ import java.util.List;
*/
public interface NotificationManagerProxy {
// Implemented by NotificationManagerCompat and thus available on all API levels.
// Note that on < Kitkat, this always returns true.
boolean areNotificationsEnabled();
void cancel(int id);
......
......@@ -12,7 +12,6 @@ import android.graphics.PorterDuff;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.VectorDrawable;
import android.os.Build;
import androidx.annotation.DrawableRes;
import androidx.appcompat.content.res.AppCompatResources;
......@@ -95,10 +94,6 @@ public class TintedDrawable extends BitmapDrawable {
@RemovableInRelease
private static boolean isVectorDrawable(Context context, @DrawableRes int drawableId) {
Drawable drawable = AppCompatResources.getDrawable(context, drawableId);
if (drawable instanceof VectorDrawableCompat) return true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return drawable instanceof VectorDrawable;
}
return false;
return drawable instanceof VectorDrawableCompat || drawable instanceof VectorDrawable;
}
}
......@@ -7,7 +7,6 @@ package org.chromium.components.crash.browser;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import android.text.TextUtils;
import org.chromium.base.BuildInfo;
......@@ -34,9 +33,6 @@ public abstract class PackagePaths {
*/
@CalledByNative
public static String[] makePackagePaths(String arch) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return new String[] {"", ""};
}
try {
PackageManager pm = ContextUtils.getApplicationContext().getPackageManager();
PackageInfo pi = pm.getPackageInfo(BuildInfo.getInstance().packageName,
......
......@@ -6,7 +6,6 @@ package org.chromium.components.embedder_support.media;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Build;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
......@@ -57,9 +56,6 @@ public class ActivityContentVideoViewEmbedder implements ContentVideoViewEmbedde
} else {
mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
int systemUiVisibility = decor.getSystemUiVisibility();
int flags = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
......
......@@ -18,7 +18,6 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.os.StrictMode;
import android.os.SystemClock;
import android.provider.Browser;
......@@ -1494,8 +1493,6 @@ public class ExternalNavigationHandler {
* capable activities. If the intent is pdf type, return the platform pdf viewer if
* it is available so user don't need to choose it from Intent picker.
*
* Note this function is slow on Android versions less than Lollipop.
*
* @param intent Intent to open.
* @param allowSelfOpen Whether chrome itself is allowed to open the intent.
* @return true if the intent can be resolved, or false otherwise.
......@@ -1712,7 +1709,6 @@ public class ExternalNavigationHandler {
@VisibleForTesting
protected String getDefaultSmsPackageNameFromSystem() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return null;
return Telephony.Sms.getDefaultSmsPackage(ContextUtils.getApplicationContext());
}
......
......@@ -33,7 +33,6 @@ import org.chromium.base.IntentUtils;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Batch;
import org.chromium.base.test.util.DisableIf;
import org.chromium.components.external_intents.ExternalNavigationHandler.OverrideUrlLoadingResult;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.WebContents;
......@@ -53,8 +52,6 @@ import java.util.regex.Pattern;
*/
@RunWith(BaseJUnit4ClassRunner.class)
// clang-format off
@DisableIf.Build(message = "Flaky on K - see https://crbug.com/851444",
sdk_is_less_than = Build.VERSION_CODES.LOLLIPOP)
@Batch(Batch.UNIT_TESTS)
public class ExternalNavigationHandlerTest {
// clang-format on
......
......@@ -4,8 +4,6 @@
package org.chromium.components.gcm_driver;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.IntDef;
......@@ -129,7 +127,6 @@ public class GCMMessage {
* been created through {@link #toBundle}.
*/
@Nullable
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static GCMMessage createFromBundle(Bundle bundle) {
return create(bundle, new BundleReader());
}
......@@ -263,7 +260,6 @@ public class GCMMessage {
* for purposes of scheduling a job. Only methods available in BaseBundle may be used here,
* as it may have to be converted to a PersistableBundle.
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public Bundle toBundle() {
return serialize(new BundleWriter());
}
......
......@@ -7,7 +7,6 @@ package org.chromium.components.gcm_driver;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import android.os.Build;
import android.os.Bundle;
import org.json.JSONException;
......@@ -17,7 +16,6 @@ import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.base.test.util.MinAndroidSdkLevel;
/**
* Unit tests for GCMMessage.
......@@ -109,7 +107,6 @@ public class GCMMessageTest {
* because it depends on PersistableBundle.
*/
@Test
@MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP)
public void testSerializationToPersistableBundle() {
Bundle extras = new Bundle();
......@@ -141,7 +138,6 @@ public class GCMMessageTest {
* on PersistableBundle.
*/
@Test
@MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP)
public void testRawDataSerializationBehaviour() {
Bundle extras = new Bundle();
extras.putString("subtype", "MyAppId");
......
......@@ -3,13 +3,11 @@
// found in the LICENSE file.
package org.chromium.components.minidump_uploader;
import android.annotation.TargetApi;
import android.app.job.JobInfo;
import android.app.job.JobParameters;
import android.app.job.JobScheduler;
import android.app.job.JobService;
import android.content.Context;
import android.os.Build;
import android.os.PersistableBundle;
import org.chromium.base.ContextUtils;
......@@ -18,7 +16,6 @@ import org.chromium.base.Log;
/**
* Class that interacts with the Android JobScheduler to upload Minidumps at appropriate times.
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public abstract class MinidumpUploadJobService extends JobService {
private static final String TAG = "MinidumpJobService";
......
......@@ -8,7 +8,6 @@ import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import android.text.TextUtils;
import com.google.android.play.core.splitinstall.SplitInstallManager;
......@@ -34,17 +33,14 @@ class CrashKeyRecorder {
// Get modules that are fully installed as split APKs (excluding base which is always
// installed). Tree set to have ordered and, thus, deterministic results.
Set<String> fullyInstalledModules = new TreeSet<>();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Split APKs are only supported on Android L+.
try {
PackageManager pm = context.getPackageManager();
PackageInfo packageInfo = pm.getPackageInfo(BuildInfo.getInstance().packageName, 0);
if (packageInfo.splitNames != null) {
fullyInstalledModules.addAll(Arrays.asList(packageInfo.splitNames));
}
} catch (NameNotFoundException e) {
throw new RuntimeException(e);
try {
PackageManager pm = context.getPackageManager();
PackageInfo packageInfo = pm.getPackageInfo(BuildInfo.getInstance().packageName, 0);
if (packageInfo.splitNames != null) {
fullyInstalledModules.addAll(Arrays.asList(packageInfo.splitNames));
}
} catch (NameNotFoundException e) {
throw new RuntimeException(e);
}
// Create temporary split install manager to retrieve both fully installed and emulated
......
......@@ -4,10 +4,8 @@
package org.chromium.policy;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.os.UserManager;
......@@ -25,17 +23,11 @@ public class AppRestrictionsProvider extends AbstractAppRestrictionsProvider {
super(context);
// getApplicationRestrictions method of UserManager was introduced in JELLY_BEAN_MR2.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
} else {
mUserManager = null;
}
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
}
@Override
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
protected Bundle getApplicationRestrictions(String packageName) {
if (mUserManager == null) return new Bundle();
try {
long startTime = SystemClock.elapsedRealtime();
Bundle bundle = mUserManager.getApplicationRestrictions(packageName);
......@@ -57,10 +49,7 @@ public class AppRestrictionsProvider extends AbstractAppRestrictionsProvider {
}
@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected String getRestrictionChangeIntentAction() {
// Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED was introduced in LOLLIPOP.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return null;
return Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED;
}
}
......@@ -4,8 +4,6 @@
package org.chromium.policy;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.VisibleForTesting;
......@@ -65,46 +63,44 @@ public class PolicyConverter {
mNativePolicyConverter, PolicyConverter.this, key, (String[]) value);
return;
}
// App restrictions can only contain bundles and bundle arrays on Android M, however our
// version of Robolectric only supports Lollipop, and allowing this on LOLLIPOP doesn't
// cause problems.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (value instanceof Bundle) {
Bundle bundle = (Bundle) value;
// JNI can't take a Bundle argument without a lot of extra work, but the native code
// already accepts arbitrary JSON strings, so convert to JSON.
try {
PolicyConverterJni.get().setPolicyString(mNativePolicyConverter,
PolicyConverter.this, key, convertBundleToJson(bundle).toString());
} catch (JSONException e) {
// Chrome requires all policies to be expressible as JSON, so this can't be a
// valid policy.
Log.w(TAG, "Invalid bundle in app restrictions " + bundle.toString()
+ " for key " + key);
}
return;
// App restrictions can only contain bundles and bundle arrays on Android M, but
// allowing this on LOLLIPOP doesn't cause problems.
if (value instanceof Bundle) {
Bundle bundle = (Bundle) value;
// JNI can't take a Bundle argument without a lot of extra work, but the native code
// already accepts arbitrary JSON strings, so convert to JSON.
try {
PolicyConverterJni.get().setPolicyString(mNativePolicyConverter,
PolicyConverter.this, key, convertBundleToJson(bundle).toString());
} catch (JSONException e) {
// Chrome requires all policies to be expressible as JSON, so this can't be a
// valid policy.
Log.w(TAG,
"Invalid bundle in app restrictions " + bundle.toString() + " for key "
+ key);
}
if (value instanceof Bundle[]) {
Bundle[] bundleArray = (Bundle[]) value;
// JNI can't take a Bundle[] argument without a lot of extra work, but the native
// code already accepts arbitrary JSON strings, so convert to JSON.
try {
PolicyConverterJni.get().setPolicyString(mNativePolicyConverter,
PolicyConverter.this, key,
convertBundleArrayToJson(bundleArray).toString());
} catch (JSONException e) {
// Chrome requires all policies to be expressible as JSON, so this can't be a
// valid policy.
Log.w(TAG, "Invalid bundle array in app restrictions "
+ Arrays.toString(bundleArray) + " for key " + key);
}
return;
return;
}
if (value instanceof Bundle[]) {
Bundle[] bundleArray = (Bundle[]) value;
// JNI can't take a Bundle[] argument without a lot of extra work, but the native
// code already accepts arbitrary JSON strings, so convert to JSON.
try {
PolicyConverterJni.get().setPolicyString(mNativePolicyConverter,
PolicyConverter.this, key,
convertBundleArrayToJson(bundleArray).toString());
} catch (JSONException e) {
// Chrome requires all policies to be expressible as JSON, so this can't be a
// valid policy.
Log.w(TAG,
"Invalid bundle array in app restrictions " + Arrays.toString(bundleArray)
+ " for key " + key);
}
return;
}
assert false : "Invalid setting " + value + " for key " + key;
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private JSONObject convertBundleToJson(Bundle bundle) throws JSONException {
JSONObject json = new JSONObject();
Set<String> keys = bundle.keySet();
......@@ -117,7 +113,6 @@ public class PolicyConverter {
return json;
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private JSONArray convertBundleArrayToJson(Bundle[] bundleArray) throws JSONException {
JSONArray json = new JSONArray();
for (Bundle bundle : bundleArray) {
......
......@@ -7,7 +7,6 @@ package org.chromium.components.signin;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AuthenticatorDescription;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
......@@ -335,7 +334,6 @@ public class AccountManagerFacadeImpl implements AccountManagerFacade {
new UpdateAccountRestrictionPatternsTask().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void subscribeToAppRestrictionChanges() {
IntentFilter filter = new IntentFilter(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED);
BroadcastReceiver receiver = new BroadcastReceiver() {
......@@ -386,7 +384,6 @@ public class AccountManagerFacadeImpl implements AccountManagerFacade {
}
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private static String[] getAccountRestrictionPatternPostJellyBeanMr2() {
// This method uses AppRestrictions directly, rather than using the Policy interface,
// because it must be callable in contexts in which the native library hasn't been loaded.
......
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