Support launching a shortcut and a task to split screen am: bf9ce9c096
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/19801551 Change-Id: I0eacebd6ffa421f7cb7274d50b6dc1a0f5dd9c7f Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -28,6 +28,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ShortcutInfo;
|
||||||
import android.graphics.Insets;
|
import android.graphics.Insets;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -602,7 +603,21 @@ public class SystemUiProxy implements ISystemUiProxy, DisplayController.DisplayI
|
|||||||
mSplitScreen.startIntentAndTaskWithLegacyTransition(pendingIntent, fillInIntent,
|
mSplitScreen.startIntentAndTaskWithLegacyTransition(pendingIntent, fillInIntent,
|
||||||
taskId, mainOptions, sideOptions, sidePosition, splitRatio, adapter);
|
taskId, mainOptions, sideOptions, sidePosition, splitRatio, adapter);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.w(TAG, "Failed call startTasksWithLegacyTransition");
|
Log.w(TAG, "Failed call startIntentAndTaskWithLegacyTransition");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startShortcutAndTaskWithLegacyTransition(ShortcutInfo shortcutInfo, int taskId,
|
||||||
|
Bundle mainOptions, Bundle sideOptions,
|
||||||
|
@SplitConfigurationOptions.StagePosition int sidePosition, float splitRatio,
|
||||||
|
RemoteAnimationAdapter adapter) {
|
||||||
|
if (mSystemUiProxy != null) {
|
||||||
|
try {
|
||||||
|
mSplitScreen.startShortcutAndTaskWithLegacyTransition(shortcutInfo, taskId,
|
||||||
|
mainOptions, sideOptions, sidePosition, splitRatio, adapter);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.w(TAG, "Failed call startShortcutAndTaskWithLegacyTransition");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,16 +31,20 @@ import android.app.ActivityThread;
|
|||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ShortcutInfo;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.RemoteAnimationAdapter;
|
import android.view.RemoteAnimationAdapter;
|
||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
import android.window.TransitionInfo;
|
import android.window.TransitionInfo;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.android.launcher3.shortcuts.ShortcutKey;
|
||||||
import com.android.launcher3.statehandlers.DepthController;
|
import com.android.launcher3.statehandlers.DepthController;
|
||||||
import com.android.launcher3.statemanager.StateManager;
|
import com.android.launcher3.statemanager.StateManager;
|
||||||
import com.android.launcher3.testing.TestLogging;
|
import com.android.launcher3.testing.TestLogging;
|
||||||
@@ -66,6 +70,7 @@ import java.util.function.Consumer;
|
|||||||
* and is in the process of either a) selecting a second app or b) exiting intention to invoke split
|
* and is in the process of either a) selecting a second app or b) exiting intention to invoke split
|
||||||
*/
|
*/
|
||||||
public class SplitSelectStateController {
|
public class SplitSelectStateController {
|
||||||
|
private static final String TAG = "SplitSelectStateCtor";
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
@@ -196,7 +201,7 @@ public class SplitSelectStateController {
|
|||||||
null /* sideOptions */, STAGE_POSITION_BOTTOM_OR_RIGHT, splitRatio,
|
null /* sideOptions */, STAGE_POSITION_BOTTOM_OR_RIGHT, splitRatio,
|
||||||
new RemoteTransitionCompat(animationRunner, MAIN_EXECUTOR,
|
new RemoteTransitionCompat(animationRunner, MAIN_EXECUTOR,
|
||||||
ActivityThread.currentActivityThread().getApplicationThread()));
|
ActivityThread.currentActivityThread().getApplicationThread()));
|
||||||
// TODO: handle intent + task with shell transition
|
// TODO(b/237635859): handle intent/shortcut + task with shell transition
|
||||||
} else {
|
} else {
|
||||||
RemoteSplitLaunchAnimationRunner animationRunner =
|
RemoteSplitLaunchAnimationRunner animationRunner =
|
||||||
new RemoteSplitLaunchAnimationRunner(taskId1, taskPendingIntent, taskId2,
|
new RemoteSplitLaunchAnimationRunner(taskId1, taskPendingIntent, taskId2,
|
||||||
@@ -215,9 +220,17 @@ public class SplitSelectStateController {
|
|||||||
taskIds[1], null /* sideOptions */, STAGE_POSITION_BOTTOM_OR_RIGHT,
|
taskIds[1], null /* sideOptions */, STAGE_POSITION_BOTTOM_OR_RIGHT,
|
||||||
splitRatio, adapter);
|
splitRatio, adapter);
|
||||||
} else {
|
} else {
|
||||||
mSystemUiProxy.startIntentAndTaskWithLegacyTransition(taskPendingIntent,
|
final ShortcutInfo shortcutInfo = getShortcutInfo(mInitialTaskIntent,
|
||||||
fillInIntent, taskId2, mainOpts.toBundle(), null /* sideOptions */,
|
taskPendingIntent.getCreatorUserHandle());
|
||||||
stagePosition, splitRatio, adapter);
|
if (shortcutInfo != null) {
|
||||||
|
mSystemUiProxy.startShortcutAndTaskWithLegacyTransition(shortcutInfo, taskId2,
|
||||||
|
mainOpts.toBundle(), null /* sideOptions */, stagePosition, splitRatio,
|
||||||
|
adapter);
|
||||||
|
} else {
|
||||||
|
mSystemUiProxy.startIntentAndTaskWithLegacyTransition(taskPendingIntent,
|
||||||
|
fillInIntent, taskId2, mainOpts.toBundle(), null /* sideOptions */,
|
||||||
|
stagePosition, splitRatio, adapter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,6 +243,28 @@ public class SplitSelectStateController {
|
|||||||
this.mRecentsAnimationRunning = running;
|
this.mRecentsAnimationRunning = running;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private ShortcutInfo getShortcutInfo(Intent intent, UserHandle userHandle) {
|
||||||
|
if (intent == null || intent.getPackage() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String shortcutId = intent.getStringExtra(ShortcutKey.EXTRA_SHORTCUT_ID);
|
||||||
|
if (shortcutId == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final Context context = mContext.createPackageContextAsUser(
|
||||||
|
intent.getPackage(), 0 /* flags */, userHandle);
|
||||||
|
return new ShortcutInfo.Builder(context, shortcutId).build();
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
Log.w(TAG, "Failed to create a ShortcutInfo for " + intent.getPackage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requires Shell Transitions
|
* Requires Shell Transitions
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user