Merge "Choosing better points to output "start" events for TAPL" into ub-launcher3-rvc-dev

This commit is contained in:
TreeHugger Robot
2020-04-16 21:58:47 +00:00
committed by Android (Google) Code Review
15 changed files with 29 additions and 18 deletions
@@ -40,8 +40,6 @@ import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.logging.StatsLogUtils;
import com.android.launcher3.logging.StatsLogUtils.LogStateProvider;
import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.util.ViewCache;
@@ -332,7 +330,6 @@ public abstract class BaseActivity extends Activity implements LogStateProvider,
return;
}
try {
TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: shortcut", packageName);
getSystemService(LauncherApps.class).startShortcut(packageName, id, sourceBounds,
startActivityOptions, user);
} catch (SecurityException | IllegalStateException e) {
@@ -41,8 +41,6 @@ import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.model.AppLaunchTracker;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.uioverrides.WallpaperColorInfo;
import com.android.launcher3.util.DefaultDisplay;
@@ -173,7 +171,6 @@ public abstract class BaseDraggingActivity extends BaseActivity
startShortcutIntentSafely(intent, optsBundle, item, sourceContainer);
} else if (user == null || user.equals(Process.myUserHandle())) {
// Could be launching some bookkeeping activity
TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: activity", intent);
startActivity(intent, optsBundle);
AppLaunchTracker.INSTANCE.get(this).onStartApp(intent.getComponent(),
Process.myUserHandle(), sourceContainer);
+1
View File
@@ -1675,6 +1675,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
private void processShortcutFromDrop(PendingAddShortcutInfo info) {
Intent intent = new Intent(Intent.ACTION_CREATE_SHORTCUT).setComponent(info.componentName);
setWaitingForResult(PendingRequestArgs.forIntent(REQUEST_CREATE_SHORTCUT, intent, info));
TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: processShortcutFromDrop");
if (!info.activityInfo.startConfigActivity(this, REQUEST_CREATE_SHORTCUT)) {
handleActivityResult(REQUEST_CREATE_SHORTCUT, RESULT_CANCELED, null);
}
@@ -30,6 +30,8 @@ import android.util.SparseArray;
import android.widget.Toast;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.widget.DeferredAppWidgetHostView;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
import com.android.launcher3.widget.PendingAppWidgetHostView;
@@ -298,6 +300,7 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
}
try {
TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: startConfigActivity");
startAppWidgetConfigureActivityForResult(activity, widgetId, 0, requestCode, null);
} catch (ActivityNotFoundException | SecurityException e) {
Toast.makeText(activity, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
@@ -52,6 +52,8 @@ import com.android.launcher3.model.data.LauncherAppWidgetInfo;
import com.android.launcher3.model.data.PromiseAppInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.pm.InstallSessionHelper;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.views.FloatingIconView;
import com.android.launcher3.widget.PendingAppWidgetHostView;
@@ -240,6 +242,8 @@ public class ItemClickHandler {
private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher,
@Nullable String sourceContainer) {
TestLogging.recordEvent(
TestProtocol.SEQUENCE_MAIN, "start: startAppShortcutOrInfoActivity");
Intent intent;
if (item instanceof PromiseAppInfo) {
PromiseAppInfo promiseAppInfo = (PromiseAppInfo) item;
@@ -40,6 +40,8 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.popup.ArrowPopup;
import com.android.launcher3.shortcuts.DeepShortcutView;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
import com.android.launcher3.widget.WidgetsFullSheet;
@@ -184,6 +186,7 @@ public class OptionsPopupView extends ArrowPopup
}
public static boolean startSettings(View view) {
TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: startSettings");
Launcher launcher = Launcher.getLauncher(view.getContext());
launcher.startActivity(new Intent(Intent.ACTION_APPLICATION_PREFERENCES)
.setPackage(launcher.getPackageName())
@@ -314,7 +314,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
switchToAllApps();
allApps.freeze();
try {
allApps.getAppIcon(APP_NAME).dragToWorkspace(false);
allApps.getAppIcon(APP_NAME).dragToWorkspace(false, false);
mLauncher.getWorkspace().getWorkspaceAppIcon(APP_NAME).launch(getAppPackageName());
} finally {
allApps.unfreeze();
@@ -342,7 +342,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
getMenuItem(0);
final String shortcutName = menuItem.getText();
menuItem.dragToWorkspace(false);
menuItem.dragToWorkspace(false, false);
mLauncher.getWorkspace().getWorkspaceAppIcon(shortcutName).launch(getAppPackageName());
} finally {
allApps.unfreeze();
@@ -94,7 +94,7 @@ public class AddConfigWidgetTest extends AbstractLauncherUiTest {
WidgetConfigStartupMonitor monitor = new WidgetConfigStartupMonitor();
widgets.
getWidget(mWidgetInfo.getLabel(mTargetContext.getPackageManager())).
dragToWorkspace(true);
dragToWorkspace(true, false);
// Widget id for which the config activity was opened
mWidgetId = monitor.getWidgetId();
@@ -57,7 +57,7 @@ public class AddWidgetTest extends AbstractLauncherUiTest {
getWorkspace().
openAllWidgets().
getWidget(widgetInfo.getLabel(mTargetContext.getPackageManager())).
dragToWorkspace(false);
dragToWorkspace(false, false);
assertTrue(mActivityMonitor.itemExists(
(info, view) -> info instanceof LauncherAppWidgetInfo &&
@@ -83,7 +83,7 @@ public class AddWidgetTest extends AbstractLauncherUiTest {
mDevice.pressHome();
mLauncher.getWorkspace().openAllWidgets()
.getWidget("com.android.launcher3.testcomponent.CustomShortcutConfigActivity")
.dragToWorkspace(false);
.dragToWorkspace(false, true);
mLauncher.getWorkspace().getWorkspaceAppIcon("Shortcut")
.launch(getAppPackageName());
}
@@ -31,7 +31,6 @@ import java.util.regex.Pattern;
*/
public final class AppIcon extends Launchable {
private static final Pattern START_EVENT = Pattern.compile("start:");
private static final Pattern LONG_CLICK_EVENT = Pattern.compile("onAllAppsItemLongClick");
AppIcon(LauncherInstrumentation launcher, UiObject2 icon) {
@@ -64,6 +63,6 @@ public final class AppIcon extends Launchable {
@Override
protected void expectActivityStartEvents() {
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, START_EVENT);
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_START);
}
}
@@ -27,8 +27,6 @@ import java.util.regex.Pattern;
*/
public class AppIconMenuItem extends Launchable {
private static final Pattern START_SHORTCUT_EVENT = Pattern.compile("start: shortcut:");
AppIconMenuItem(LauncherInstrumentation launcher, UiObject2 shortcut) {
super(launcher, shortcut);
}
@@ -51,6 +49,6 @@ public class AppIconMenuItem extends Launchable {
@Override
protected void expectActivityStartEvents() {
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, START_SHORTCUT_EVENT);
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_START);
}
}
@@ -77,8 +77,9 @@ abstract class Launchable {
/**
* Drags an object to the center of homescreen.
* @param startsActivity whether it's expected to start an activity.
* @param isWidgetShortcut whether we drag a widget shortcut
*/
public void dragToWorkspace(boolean startsActivity) {
public void dragToWorkspace(boolean startsActivity, boolean isWidgetShortcut) {
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
final Point launchableCenter = getObject().getVisibleCenter();
final Point displaySize = mLauncher.getRealDisplaySize();
@@ -93,6 +94,7 @@ abstract class Launchable {
displaySize.y / 2),
getLongPressIndicator(),
startsActivity,
isWidgetShortcut,
() -> addExpectedEventsForLongClick());
}
}
@@ -99,6 +99,7 @@ public final class LauncherInstrumentation {
private static final Pattern EVENT_PILFER_POINTERS = Pattern.compile("pilferPointers");
static final Pattern EVENT_START_ACTIVITY = Pattern.compile("Activity\\.onStart");
static final Pattern EVENT_STOP_ACTIVITY = Pattern.compile("Activity\\.onStop");
static final Pattern EVENT_START = Pattern.compile("start:");
static final Pattern EVENT_TOUCH_DOWN_TIS = getTouchEventPatternTIS("ACTION_DOWN");
static final Pattern EVENT_TOUCH_UP_TIS = getTouchEventPatternTIS("ACTION_UP");
@@ -43,6 +43,7 @@ public class OptionsPopupMenuItem {
LauncherInstrumentation.log("OptionsPopupMenuItem before click "
+ mObject.getVisibleCenter() + " in " + mLauncher.getVisibleBounds(mObject));
mLauncher.clickLauncherObject(mObject);
mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_START);
if (!Build.MODEL.contains("Cuttlefish") ||
Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q &&
!"R".equals(Build.VERSION.CODENAME)) {
@@ -180,6 +180,7 @@ public final class Workspace extends Home {
mLauncher.getVisibleBounds(workspace).centerY()),
"deep_shortcuts_container",
false,
false,
() -> mLauncher.expectEvent(
TestProtocol.SEQUENCE_MAIN, LONG_CLICK_EVENT));
verifyActiveContainer();
@@ -202,7 +203,8 @@ public final class Workspace extends Home {
static void dragIconToWorkspace(
LauncherInstrumentation launcher, Launchable launchable, Point dest,
String longPressIndicator, boolean startsActivity, Runnable expectLongClickEvents) {
String longPressIndicator, boolean startsActivity, boolean isWidgetShortcut,
Runnable expectLongClickEvents) {
LauncherInstrumentation.log("dragIconToWorkspace: begin");
final Point launchableCenter = launchable.getObject().getVisibleCenter();
final long downTime = SystemClock.uptimeMillis();
@@ -224,6 +226,9 @@ public final class Workspace extends Home {
downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest,
LauncherInstrumentation.GestureScope.INSIDE),
NORMAL_STATE_ORDINAL);
if (startsActivity || isWidgetShortcut) {
launcher.expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_START);
}
if (startsActivity) {
launcher.expectEvent(
TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_STOP_ACTIVITY);