Commit 6215c6bf authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Remove ApiCompatibilityUtils.getActivityNewDocumentFlag()

It's not needed since KitKat support has been removed.

Bug: none
Change-Id: Id3602b3b942899aae5fcf6a074cf82f34b7cf6b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2380339Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802672}
parent 79016035
...@@ -411,14 +411,6 @@ public class ApiCompatibilityUtils { ...@@ -411,14 +411,6 @@ public class ApiCompatibilityUtils {
return manager.isScreenOn(); return manager.isScreenOn();
} }
@SuppressWarnings("deprecation")
public static int getActivityNewDocumentFlag() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return ApisL.FLAG_ACTIVITY_NEW_DOCUMENT;
}
return Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
}
/** /**
* @see android.provider.Settings.Secure#SKIP_FIRST_USE_HINTS * @see android.provider.Settings.Secure#SKIP_FIRST_USE_HINTS
*/ */
......
...@@ -416,8 +416,7 @@ public class IntentUtils { ...@@ -416,8 +416,7 @@ public class IntentUtils {
/** Returns whether the intent starts an activity in a new task or a new document. */ /** Returns whether the intent starts an activity in a new task or a new document. */
public static boolean isIntentForNewTaskOrNewDocument(Intent intent) { public static boolean isIntentForNewTaskOrNewDocument(Intent intent) {
int testFlags = int testFlags = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
Intent.FLAG_ACTIVITY_NEW_TASK | ApiCompatibilityUtils.getActivityNewDocumentFlag();
return (intent.getFlags() & testFlags) != 0; return (intent.getFlags() & testFlags) != 0;
} }
......
...@@ -22,7 +22,6 @@ import androidx.annotation.NonNull; ...@@ -22,7 +22,6 @@ import androidx.annotation.NonNull;
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.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.PackageManagerUtils; import org.chromium.base.PackageManagerUtils;
import org.chromium.base.StrictModeContext; import org.chromium.base.StrictModeContext;
...@@ -252,7 +251,7 @@ public class ShareHelper extends org.chromium.components.browser_ui.share.ShareH ...@@ -252,7 +251,7 @@ public class ShareHelper extends org.chromium.components.browser_ui.share.ShareH
*/ */
public static Intent createShareFileAppCompatibilityIntent(String fileContentType) { public static Intent createShareFileAppCompatibilityIntent(String fileContentType) {
Intent intent = new Intent(Intent.ACTION_SEND); Intent intent = new Intent(Intent.ACTION_SEND);
intent.addFlags(ApiCompatibilityUtils.getActivityNewDocumentFlag()); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
intent.setType(fileContentType); intent.setType(fileContentType);
return intent; return intent;
} }
...@@ -264,7 +263,7 @@ public class ShareHelper extends org.chromium.components.browser_ui.share.ShareH ...@@ -264,7 +263,7 @@ public class ShareHelper extends org.chromium.components.browser_ui.share.ShareH
*/ */
public static Intent getShareImageIntent(Uri imageUri) { public static Intent getShareImageIntent(Uri imageUri) {
Intent intent = new Intent(Intent.ACTION_SEND); Intent intent = new Intent(Intent.ACTION_SEND);
intent.addFlags(ApiCompatibilityUtils.getActivityNewDocumentFlag()); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
intent.setType("image/jpeg"); intent.setType("image/jpeg");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra(Intent.EXTRA_STREAM, imageUri); intent.putExtra(Intent.EXTRA_STREAM, imageUri);
......
...@@ -12,7 +12,6 @@ import android.provider.Browser; ...@@ -12,7 +12,6 @@ import android.provider.Browser;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
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.chrome.browser.ChromeTabbedActivity; import org.chromium.chrome.browser.ChromeTabbedActivity;
...@@ -187,8 +186,7 @@ public class TabDelegate extends AsyncTabCreator { ...@@ -187,8 +186,7 @@ public class TabDelegate extends AsyncTabCreator {
@Override @Override
public void createNewStandaloneFrame(Intent intent) { public void createNewStandaloneFrame(Intent intent) {
assert intent != null; assert intent != null;
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
| ApiCompatibilityUtils.getActivityNewDocumentFlag());
IntentHandler.startActivityForTrustedIntent(intent); IntentHandler.startActivityForTrustedIntent(intent);
} }
} }
...@@ -93,8 +93,7 @@ public class WebappLauncherActivity extends Activity { ...@@ -93,8 +93,7 @@ public class WebappLauncherActivity extends Activity {
Intent sourceIntent, @NonNull String webApkPackageName, @NonNull String url) { Intent sourceIntent, @NonNull String webApkPackageName, @NonNull String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setPackage(webApkPackageName); intent.setPackage(webApkPackageName);
intent.setFlags( intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
Intent.FLAG_ACTIVITY_NEW_TASK | ApiCompatibilityUtils.getActivityNewDocumentFlag());
Bundle extras = sourceIntent.getExtras(); Bundle extras = sourceIntent.getExtras();
if (extras != null) { if (extras != null) {
intent.putExtras(extras); intent.putExtras(extras);
...@@ -282,8 +281,7 @@ public class WebappLauncherActivity extends Activity { ...@@ -282,8 +281,7 @@ public class WebappLauncherActivity extends Activity {
appContext.getPackageName(), ChromeLauncherActivity.class.getName()); appContext.getPackageName(), ChromeLauncherActivity.class.getName());
launchIntent.putExtra(ShortcutHelper.REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB, true); launchIntent.putExtra(ShortcutHelper.REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB, true);
launchIntent.putExtra(ShortcutHelper.EXTRA_SOURCE, webappSource); launchIntent.putExtra(ShortcutHelper.EXTRA_SOURCE, webappSource);
launchIntent.setFlags( launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
Intent.FLAG_ACTIVITY_NEW_TASK | ApiCompatibilityUtils.getActivityNewDocumentFlag());
Log.e(TAG, "Shortcut (%s) opened in Chrome.", webappUrl); Log.e(TAG, "Shortcut (%s) opened in Chrome.", webappUrl);
...@@ -350,8 +348,7 @@ public class WebappLauncherActivity extends Activity { ...@@ -350,8 +348,7 @@ public class WebappLauncherActivity extends Activity {
launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_ANIMATION launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_ANIMATION
| Intent.FLAG_ACTIVITY_FORWARD_RESULT); | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
} else { } else {
launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT
| ApiCompatibilityUtils.getActivityNewDocumentFlag()
| Intent.FLAG_ACTIVITY_CLEAR_TOP); | Intent.FLAG_ACTIVITY_CLEAR_TOP);
} }
......
...@@ -19,7 +19,6 @@ import org.junit.Test; ...@@ -19,7 +19,6 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.ActivityState; import org.chromium.base.ActivityState;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
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;
...@@ -101,8 +100,7 @@ public final class WebApkActivityTest { ...@@ -101,8 +100,7 @@ public final class WebApkActivityTest {
// Move WebAPK to the background by launching Chrome. // Move WebAPK to the background by launching Chrome.
Intent intent = new Intent(InstrumentationRegistry.getTargetContext(), mainClass); Intent intent = new Intent(InstrumentationRegistry.getTargetContext(), mainClass);
intent.setFlags( intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
Intent.FLAG_ACTIVITY_NEW_TASK | ApiCompatibilityUtils.getActivityNewDocumentFlag());
InstrumentationRegistry.getTargetContext().startActivity(intent); InstrumentationRegistry.getTargetContext().startActivity(intent);
ChromeActivityTestRule.waitFor(mainClass); ChromeActivityTestRule.waitFor(mainClass);
......
...@@ -11,7 +11,6 @@ import org.hamcrest.Matchers; ...@@ -11,7 +11,6 @@ import org.hamcrest.Matchers;
import org.junit.runner.Description; import org.junit.runner.Description;
import org.junit.runners.model.Statement; import org.junit.runners.model.Statement;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.test.util.ScalableTimeout; import org.chromium.base.test.util.ScalableTimeout;
import org.chromium.chrome.browser.ShortcutHelper; import org.chromium.chrome.browser.ShortcutHelper;
import org.chromium.chrome.browser.browserservices.BrowserServicesIntentDataProvider; import org.chromium.chrome.browser.browserservices.BrowserServicesIntentDataProvider;
...@@ -77,8 +76,7 @@ public class WebApkActivityTestRule extends ChromeActivityTestRule<WebappActivit ...@@ -77,8 +76,7 @@ public class WebApkActivityTestRule extends ChromeActivityTestRule<WebappActivit
intent.putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, webApkInfo.webApkPackageName()); intent.putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, webApkInfo.webApkPackageName());
intent.putExtra(ShortcutHelper.EXTRA_ID, webApkInfo.id()); intent.putExtra(ShortcutHelper.EXTRA_ID, webApkInfo.id());
intent.putExtra(ShortcutHelper.EXTRA_URL, webApkInfo.url()); intent.putExtra(ShortcutHelper.EXTRA_URL, webApkInfo.url());
intent.addFlags( intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
Intent.FLAG_ACTIVITY_NEW_TASK | ApiCompatibilityUtils.getActivityNewDocumentFlag());
return intent; return intent;
} }
} }
...@@ -289,10 +289,10 @@ public class ShareHelper { ...@@ -289,10 +289,10 @@ public class ShareHelper {
*/ */
public static void shareWithUi(ShareParams params) { public static void shareWithUi(ShareParams params) {
if (TargetChosenReceiver.isSupported()) { if (TargetChosenReceiver.isSupported()) {
// On L+ open system share sheet. // On LMR1+ open system share sheet.
shareWithSystemSheet(params); shareWithSystemSheet(params);
} else { } else {
// On K and below open custom share dialog. // On L and below open custom share dialog.
showCompatShareDialog(params); showCompatShareDialog(params);
} }
} }
...@@ -305,7 +305,6 @@ public class ShareHelper { ...@@ -305,7 +305,6 @@ public class ShareHelper {
public static void shareDirectly( public static void shareDirectly(
@NonNull ShareParams params, @NonNull ComponentName component) { @NonNull ShareParams params, @NonNull ComponentName component) {
Intent intent = getShareLinkIntent(params); Intent intent = getShareLinkIntent(params);
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
intent.setComponent(component); intent.setComponent(component);
fireIntent(params.getWindow(), intent, null); fireIntent(params.getWindow(), intent, null);
} }
...@@ -317,8 +316,8 @@ public class ShareHelper { ...@@ -317,8 +316,8 @@ public class ShareHelper {
final String action = final String action =
isMultipleFileShare ? Intent.ACTION_SEND_MULTIPLE : Intent.ACTION_SEND; isMultipleFileShare ? Intent.ACTION_SEND_MULTIPLE : Intent.ACTION_SEND;
Intent intent = new Intent(action); Intent intent = new Intent(action);
intent.addFlags(ApiCompatibilityUtils.getActivityNewDocumentFlag() intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_FORWARD_RESULT
| Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
intent.putExtra(EXTRA_TASK_ID, params.getWindow().getActivity().get().getTaskId()); intent.putExtra(EXTRA_TASK_ID, params.getWindow().getActivity().get().getTaskId());
Uri screenshotUri = params.getScreenshotUri(); Uri screenshotUri = params.getScreenshotUri();
...@@ -366,7 +365,7 @@ public class ShareHelper { ...@@ -366,7 +365,7 @@ public class ShareHelper {
*/ */
public static Intent getShareLinkAppCompatibilityIntent() { public static Intent getShareLinkAppCompatibilityIntent() {
Intent intent = new Intent(Intent.ACTION_SEND); Intent intent = new Intent(Intent.ACTION_SEND);
intent.addFlags(ApiCompatibilityUtils.getActivityNewDocumentFlag()); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
intent.putExtra(Intent.EXTRA_SUBJECT, ""); intent.putExtra(Intent.EXTRA_SUBJECT, "");
intent.putExtra(Intent.EXTRA_TEXT, ""); intent.putExtra(Intent.EXTRA_TEXT, "");
intent.setType("text/plain"); intent.setType("text/plain");
......
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