Support Remote actions

Bug: 168846477
Test: Manual
Change-Id: I7b9dc96bc7a8ccb25ccb4b7135880768256f1ef3
This commit is contained in:
Samuel Fufa
2020-09-23 00:45:27 -07:00
parent 006d2a3d6d
commit 02be2a43f5
11 changed files with 307 additions and 169 deletions

View File

@@ -25,7 +25,9 @@ import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_SA
import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_SUSPENDED;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.LauncherApps;
import android.content.pm.PackageInstaller.SessionInfo;
import android.os.Process;
@@ -49,6 +51,7 @@ import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
import com.android.launcher3.model.data.PromiseAppInfo;
import com.android.launcher3.model.data.RemoteActionItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.pm.InstallSessionHelper;
import com.android.launcher3.testing.TestLogging;
@@ -236,6 +239,27 @@ public class ItemClickHandler {
startAppShortcutOrInfoActivity(v, shortcut, launcher);
}
/**
* Event handler for a {@link android.app.RemoteAction} click
*
*/
public static void onClickRemoteAction(Launcher launcher,
RemoteActionItemInfo remoteActionInfo) {
try {
PendingIntent pendingIntent = remoteActionInfo.getRemoteAction().getActionIntent();
if (remoteActionInfo.shouldStartInLauncher()) {
launcher.startIntentSenderForResult(pendingIntent.getIntentSender(), 0, null, 0, 0,
0);
} else {
pendingIntent.send();
}
} catch (PendingIntent.CanceledException | IntentSender.SendIntentException e) {
Toast.makeText(launcher,
launcher.getResources().getText(R.string.shortcut_not_available),
Toast.LENGTH_SHORT).show();
}
}
private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher) {
TestLogging.recordEvent(
TestProtocol.SEQUENCE_MAIN, "start: startAppShortcutOrInfoActivity");