use of com.android.launcher3.tapl.AddToHomeScreenPrompt in project android_packages_apps_Launcher3 by ProtonAOSP.
the class RequestPinItemTest method runTest.
private void runTest(String activityMethod, boolean isWidget, ItemOperator itemMatcher, Intent... commandIntents) throws Throwable {
clearHomescreen();
mDevice.pressHome();
// Open Pin item activity
BlockingBroadcastReceiver openMonitor = new BlockingBroadcastReceiver(RequestPinItemActivity.class.getName());
mLauncher.getWorkspace().switchToAllApps().getAppIcon("Test Pin Item").launch(getAppPackageName());
assertNotNull(openMonitor.blockingGetExtraIntent());
// Set callback
PendingIntent callback = PendingIntent.getBroadcast(mTargetContext, 0, new Intent(mCallbackAction), PendingIntent.FLAG_ONE_SHOT);
mTargetContext.sendBroadcast(RequestPinItemActivity.getCommandIntent(RequestPinItemActivity.class, "setCallback").putExtra(RequestPinItemActivity.EXTRA_PARAM + "0", callback));
for (Intent command : commandIntents) {
mTargetContext.sendBroadcast(command);
}
// call the requested method to start the flow
mTargetContext.sendBroadcast(RequestPinItemActivity.getCommandIntent(RequestPinItemActivity.class, activityMethod));
final AddToHomeScreenPrompt addToHomeScreenPrompt = mLauncher.getAddToHomeScreenPrompt();
// Accept confirmation:
BlockingBroadcastReceiver resultReceiver = new BlockingBroadcastReceiver(mCallbackAction);
addToHomeScreenPrompt.addAutomatically();
Intent result = resultReceiver.blockingGetIntent();
assertNotNull(result);
mAppWidgetId = result.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
if (isWidget) {
assertNotSame(-1, mAppWidgetId);
}
// Go back to home
mLauncher.pressHome();
Wait.atMost("", new ItemSearchCondition(itemMatcher), DEFAULT_ACTIVITY_TIMEOUT, mLauncher);
}
use of com.android.launcher3.tapl.AddToHomeScreenPrompt in project android_packages_apps_Launcher3 by AOSPA.
the class RequestPinItemTest method runTest.
private void runTest(String activityMethod, boolean isWidget, ItemOperator itemMatcher, Intent... commandIntents) throws Throwable {
clearHomescreen();
mDevice.pressHome();
// Open Pin item activity
BlockingBroadcastReceiver openMonitor = new BlockingBroadcastReceiver(RequestPinItemActivity.class.getName());
mLauncher.getWorkspace().switchToAllApps().getAppIcon("Test Pin Item").launch(getAppPackageName());
assertNotNull(openMonitor.blockingGetExtraIntent());
// Set callback
PendingIntent callback = PendingIntent.getBroadcast(mTargetContext, 0, new Intent(mCallbackAction), PendingIntent.FLAG_ONE_SHOT);
mTargetContext.sendBroadcast(RequestPinItemActivity.getCommandIntent(RequestPinItemActivity.class, "setCallback").putExtra(RequestPinItemActivity.EXTRA_PARAM + "0", callback));
for (Intent command : commandIntents) {
mTargetContext.sendBroadcast(command);
}
// call the requested method to start the flow
mTargetContext.sendBroadcast(RequestPinItemActivity.getCommandIntent(RequestPinItemActivity.class, activityMethod));
final AddToHomeScreenPrompt addToHomeScreenPrompt = mLauncher.getAddToHomeScreenPrompt();
// Accept confirmation:
BlockingBroadcastReceiver resultReceiver = new BlockingBroadcastReceiver(mCallbackAction);
addToHomeScreenPrompt.addAutomatically();
Intent result = resultReceiver.blockingGetIntent();
assertNotNull(result);
mAppWidgetId = result.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
if (isWidget) {
assertNotSame(-1, mAppWidgetId);
}
// Go back to home
mLauncher.pressHome();
Wait.atMost("", new ItemSearchCondition(itemMatcher), DEFAULT_ACTIVITY_TIMEOUT, mLauncher);
}
Aggregations