diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java index b81ffb766440e..42380198cf17a 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java @@ -20,10 +20,6 @@ import static android.app.ActivityManager.LOCK_TASK_MODE_LOCKED; import static android.app.ActivityManager.LOCK_TASK_MODE_NONE; import static android.app.ActivityManager.LOCK_TASK_MODE_PINNED; import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE; -import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; -import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; -import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; -import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import android.annotation.NonNull; import android.app.Activity; @@ -58,7 +54,6 @@ import android.view.RemoteAnimationTarget; import com.android.internal.app.IVoiceInteractionManagerService; import com.android.systemui.shared.recents.model.Task; -import com.android.systemui.shared.recents.model.Task.TaskKey; import com.android.systemui.shared.recents.model.ThumbnailData; import java.util.ArrayList; @@ -226,6 +221,22 @@ public class ActivityManagerWrapper { public void startRecentsActivity(Intent intent, long eventTime, final RecentsAnimationListener animationHandler, final Consumer resultCallback, Handler resultCallbackHandler) { + boolean result = startRecentsActivity(intent, eventTime, animationHandler); + if (resultCallback != null) { + resultCallbackHandler.post(new Runnable() { + @Override + public void run() { + resultCallback.accept(result); + } + }); + } + } + + /** + * Starts the recents activity. The caller should manage the thread on which this is called. + */ + public boolean startRecentsActivity( + Intent intent, long eventTime, RecentsAnimationListener animationHandler) { try { IRecentsAnimationRunner runner = null; if (animationHandler != null) { @@ -257,23 +268,9 @@ public class ActivityManagerWrapper { }; } ActivityTaskManager.getService().startRecentsActivity(intent, eventTime, runner); - if (resultCallback != null) { - resultCallbackHandler.post(new Runnable() { - @Override - public void run() { - resultCallback.accept(true); - } - }); - } + return true; } catch (Exception e) { - if (resultCallback != null) { - resultCallbackHandler.post(new Runnable() { - @Override - public void run() { - resultCallback.accept(false); - } - }); - } + return false; } } @@ -288,61 +285,33 @@ public class ActivityManagerWrapper { } } - /** - * Starts a task from Recents. - * - * @see {@link #startActivityFromRecentsAsync(TaskKey, ActivityOptions, int, int, Consumer, Handler)} - */ - public void startActivityFromRecentsAsync(Task.TaskKey taskKey, ActivityOptions options, - Consumer resultCallback, Handler resultCallbackHandler) { - startActivityFromRecentsAsync(taskKey, options, WINDOWING_MODE_UNDEFINED, - ACTIVITY_TYPE_UNDEFINED, resultCallback, resultCallbackHandler); - } - /** * Starts a task from Recents. * * @param resultCallback The result success callback * @param resultCallbackHandler The handler to receive the result callback */ - public void startActivityFromRecentsAsync(final Task.TaskKey taskKey, ActivityOptions options, - int windowingMode, int activityType, final Consumer resultCallback, - final Handler resultCallbackHandler) { - if (taskKey.windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { - // We show non-visible docked tasks in Recents, but we always want to launch - // them in the fullscreen stack. - if (options == null) { - options = ActivityOptions.makeBasic(); - } - options.setLaunchWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_SECONDARY); - } else if (windowingMode != WINDOWING_MODE_UNDEFINED - || activityType != ACTIVITY_TYPE_UNDEFINED) { - if (options == null) { - options = ActivityOptions.makeBasic(); - } - options.setLaunchWindowingMode(windowingMode); - options.setLaunchActivityType(activityType); - } - final ActivityOptions finalOptions = options; - - - boolean result = false; - try { - result = startActivityFromRecents(taskKey.id, finalOptions); - } catch (Exception e) { - // Fall through - } - final boolean finalResult = result; + public void startActivityFromRecentsAsync(Task.TaskKey taskKey, ActivityOptions options, + Consumer resultCallback, Handler resultCallbackHandler) { + final boolean result = startActivityFromRecents(taskKey, options); if (resultCallback != null) { resultCallbackHandler.post(new Runnable() { @Override public void run() { - resultCallback.accept(finalResult); + resultCallback.accept(result); } }); } } + /** + * Starts a task from Recents synchronously. + */ + public boolean startActivityFromRecents(Task.TaskKey taskKey, ActivityOptions options) { + ActivityOptionsCompat.addTaskInfo(options, taskKey); + return startActivityFromRecents(taskKey.id, options); + } + /** * Starts a task from Recents synchronously. */ diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityOptionsCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityOptionsCompat.java index 0db4faf9e493a..1a71f119419c5 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityOptionsCompat.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityOptionsCompat.java @@ -26,6 +26,8 @@ import android.app.ActivityOptions; import android.content.Context; import android.os.Handler; +import com.android.systemui.shared.recents.model.Task; + /** * Wrapper around internal ActivityOptions creation. */ @@ -94,4 +96,15 @@ public abstract class ActivityOptionsCompat { opts.setSourceInfo(ActivityOptions.SourceInfo.TYPE_LAUNCHER, uptimeMillis); return opts; } + + /** + * Sets Task specific information to the activity options + */ + public static void addTaskInfo(ActivityOptions opts, Task.TaskKey taskKey) { + if (taskKey.windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { + // We show non-visible docked tasks in Recents, but we always want to launch + // them in the fullscreen stack. + opts.setLaunchWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_SECONDARY); + } + } } diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/AssistDataReceiver.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/AssistDataReceiver.java deleted file mode 100644 index 7cd6c512b6606..0000000000000 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/AssistDataReceiver.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.systemui.shared.system; - -import android.graphics.Bitmap; -import android.os.Bundle; - -/** - * Abstract class for assist data receivers. - */ -public abstract class AssistDataReceiver { - public void onHandleAssistData(Bundle resultData) {} - public void onHandleAssistScreenshot(Bitmap screenshot) {} -} diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ContextCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ContextCompat.java deleted file mode 100644 index 51fcb0a841caf..0000000000000 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ContextCompat.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.shared.system; - -import android.content.Context; - -/** - * Wraps a context to expose some methods for launcher to call. - */ -public class ContextCompat { - private final Context mWrapped; - - public ContextCompat(Context context) { - mWrapped = context; - } - - public int getUserId() { - return mWrapped.getUserId(); - } -}