Commit 99239417 authored by Gang Wu's avatar Gang Wu Committed by Commit Bot

Catch IllegalArgumentException when call AppTask#getTaskInfo

When we call AppTask#getTaskInfo may get IllegalArgumentException,
we can use AndroidTaskUtils#getTaskInfoFromTask to handle it.

Bug: 1126525
Change-Id: I5bf9b2cf02b6c3afc3854a8e249c30ba8c6f3928
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2405745Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Gang Wu <gangwu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806191}
parent ae454177
...@@ -29,6 +29,7 @@ import org.chromium.chrome.browser.ChromeTabbedActivity; ...@@ -29,6 +29,7 @@ import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.ChromeTabbedActivity2; import org.chromium.chrome.browser.ChromeTabbedActivity2;
import org.chromium.chrome.browser.IntentHandler; import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.util.AndroidTaskUtils;
import org.chromium.ui.display.DisplayAndroidManager; import org.chromium.ui.display.DisplayAndroidManager;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
...@@ -204,10 +205,11 @@ public class MultiWindowUtils implements ActivityStateListener { ...@@ -204,10 +205,11 @@ public class MultiWindowUtils implements ActivityStateListener {
public static String getActivityNameFromTask(AppTask task) { public static String getActivityNameFromTask(AppTask task) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return ""; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return "";
if (task.getTaskInfo() == null || task.getTaskInfo().baseActivity == null) return ""; ActivityManager.RecentTaskInfo taskInfo = AndroidTaskUtils.getTaskInfoFromTask(task);
if (taskInfo == null || taskInfo.baseActivity == null) return "";
String baseActivity = task.getTaskInfo().baseActivity.getClassName(); String baseActivity = taskInfo.baseActivity.getClassName();
// Contrary to the documentation task.getTaskInfo().baseActivity for the .LauncherMain // Contrary to the documentation taskInfo.baseActivity for the .LauncherMain
// activity alias is the alias itself, and not the implementation. Filed b/66729258; // activity alias is the alias itself, and not the implementation. Filed b/66729258;
// for now translate the alias manually. // for now translate the alias manually.
if (TextUtils.equals(baseActivity, ChromeTabbedActivity.MAIN_LAUNCHER_ACTIVITY_NAME)) { if (TextUtils.equals(baseActivity, ChromeTabbedActivity.MAIN_LAUNCHER_ACTIVITY_NAME)) {
......
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