Merge changes Ib3e373c2,Ia5d6f545 into ub-launcher3-qt-r1-dev
am: 1343f03e2e
Change-Id: Ie3f4c2c15e331c84f0f048c6337ae4e58111ec56
diff --git a/go/src/com/android/launcher3/shortcuts/DeepShortcutManager.java b/go/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
index 1e44910..73adaa1 100644
--- a/go/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
+++ b/go/src/com/android/launcher3/shortcuts/DeepShortcutManager.java
@@ -25,6 +25,7 @@
import android.os.UserHandle;
import com.android.launcher3.ItemInfo;
+import com.android.launcher3.notification.NotificationKeyData;
import java.util.Collections;
import java.util.List;
@@ -52,6 +53,11 @@
return false;
}
+ public static boolean supportsNotificationDots(
+ ItemInfo info, List<NotificationKeyData> notifications) {
+ return false;
+ }
+
public boolean wasLastCallSuccess() {
return false;
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/AppToOverviewAnimationProvider.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/AppToOverviewAnimationProvider.java
index 5e77e0a..5ebefa3 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/AppToOverviewAnimationProvider.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/AppToOverviewAnimationProvider.java
@@ -81,6 +81,7 @@
});
factory.onRemoteAnimationReceived(null);
factory.createActivityController(RECENTS_LAUNCH_DURATION);
+ factory.setRecentsAttachedToAppWindow(true, false);
mActivity = activity;
mRecentsView = mActivity.getOverviewPanel();
return false;
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewCommandHelper.java
index 6533c63..a94f25d 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewCommandHelper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewCommandHelper.java
@@ -99,6 +99,7 @@
@Override
protected void onTransitionComplete() {
+ // TODO(b/138729100) This doesn't execute first time launcher is run
if (mTriggeredFromAltTab) {
RecentsView rv = (RecentsView) mHelper.getVisibleRecentsView();
if (rv == null) {
diff --git a/src/com/android/launcher3/popup/PopupDataProvider.java b/src/com/android/launcher3/popup/PopupDataProvider.java
index 2d301ac..dd496b0 100644
--- a/src/com/android/launcher3/popup/PopupDataProvider.java
+++ b/src/com/android/launcher3/popup/PopupDataProvider.java
@@ -40,6 +40,7 @@
import java.util.function.Predicate;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
/**
* Provides data for the popup menu that appears after long-clicking on apps.
@@ -167,12 +168,14 @@
return count == null ? 0 : count;
}
- public DotInfo getDotInfoForItem(ItemInfo info) {
- if (!DeepShortcutManager.supportsShortcuts(info)) {
+ public @Nullable DotInfo getDotInfoForItem(@NonNull ItemInfo info) {
+ DotInfo dotInfo = mPackageUserToDotInfos.get(PackageUserKey.fromItemInfo(info));
+ List<NotificationKeyData> notifications =
+ dotInfo == null ? Collections.EMPTY_LIST : dotInfo.getNotificationKeys();
+ if (!DeepShortcutManager.supportsNotificationDots(info, notifications)) {
return null;
}
-
- return mPackageUserToDotInfos.get(PackageUserKey.fromItemInfo(info));
+ return dotInfo;
}
public @NonNull List<NotificationKeyData> getNotificationKeysForItem(ItemInfo info) {
diff --git a/src/com/android/launcher3/popup/RemoteActionShortcut.java b/src/com/android/launcher3/popup/RemoteActionShortcut.java
index 41ab4df..5a5fbab 100644
--- a/src/com/android/launcher3/popup/RemoteActionShortcut.java
+++ b/src/com/android/launcher3/popup/RemoteActionShortcut.java
@@ -29,11 +29,12 @@
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
import com.android.launcher3.userevent.nano.LauncherLogProto;
public class RemoteActionShortcut extends SystemShortcut<BaseDraggingActivity> {
private static final String TAG = "RemoteActionShortcut";
- private static final boolean DEBUG = false;
+ private static final boolean DEBUG = Utilities.IS_DEBUG_DEVICE;
private final RemoteAction mAction;
diff --git a/src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java b/src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java
index 6b6f70d..f42bafe 100644
--- a/src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java
+++ b/src_shortcuts_overrides/com/android/launcher3/shortcuts/DeepShortcutManager.java
@@ -30,6 +30,7 @@
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.WorkspaceItemInfo;
+import com.android.launcher3.notification.NotificationKeyData;
import java.util.ArrayList;
import java.util.Collections;
@@ -64,10 +65,40 @@
}
public static boolean supportsShortcuts(ItemInfo info) {
- boolean isItemPromise = info instanceof WorkspaceItemInfo
- && ((WorkspaceItemInfo) info).hasPromiseIconUi();
- return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION
- && !info.isDisabled() && !isItemPromise;
+ return isActive(info) && isApp(info);
+ }
+
+ public static boolean supportsNotificationDots(
+ ItemInfo info, List<NotificationKeyData> notifications) {
+ if (!isActive(info)) {
+ return false;
+ }
+ return isApp(info) || (isPinnedShortcut(info)
+ && shouldShowNotificationDotForPinnedShortcut(info, notifications));
+ }
+
+ private static boolean isApp(ItemInfo info) {
+ return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
+ }
+
+ private static boolean isPinnedShortcut(ItemInfo info) {
+ return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT
+ && info.container != ItemInfo.NO_ID
+ && info instanceof WorkspaceItemInfo;
+ }
+
+ private static boolean shouldShowNotificationDotForPinnedShortcut(
+ ItemInfo info, List<NotificationKeyData> notifications) {
+ String shortcutId = ((WorkspaceItemInfo) info).getDeepShortcutId();
+ if (shortcutId == null) {
+ return false;
+ }
+ for (NotificationKeyData notification : notifications) {
+ if (shortcutId.equals(notification.shortcutId)) {
+ return true;
+ }
+ }
+ return false;
}
public boolean wasLastCallSuccess() {
@@ -183,6 +214,12 @@
return shortcutIds;
}
+ private static boolean isActive(ItemInfo info) {
+ boolean isLoading = info instanceof WorkspaceItemInfo
+ && ((WorkspaceItemInfo) info).hasPromiseIconUi();
+ return !isLoading && !info.isDisabled();
+ }
+
/**
* Query the system server for all the shortcuts matching the given parameters.
* If packageName == null, we query for all shortcuts with the passed flags, regardless of app.
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index 8dc8cea..fc19baa 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -38,6 +38,7 @@
import androidx.test.InstrumentationRegistry;
import androidx.test.uiautomator.By;
+import androidx.test.uiautomator.BySelector;
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.Until;
@@ -330,30 +331,27 @@
}
protected void startAppFast(String packageName) {
- final Instrumentation instrumentation = getInstrumentation();
- final Intent intent = instrumentation.getContext().getPackageManager().
- getLaunchIntentForPackage(packageName);
- intent.addCategory(Intent.CATEGORY_LAUNCHER);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- instrumentation.getTargetContext().startActivity(intent);
- assertTrue(packageName + " didn't start",
- mDevice.wait(Until.hasObject(By.pkg(packageName).depth(0)), DEFAULT_UI_TIMEOUT));
+ startIntent(
+ getInstrumentation().getContext().getPackageManager().getLaunchIntentForPackage(
+ packageName),
+ By.pkg(packageName).depth(0));
}
protected void startTestActivity(int activityNumber) {
final String packageName = getAppPackageName();
- final Instrumentation instrumentation = getInstrumentation();
- final Intent intent = instrumentation.getContext().getPackageManager().
+ final Intent intent = getInstrumentation().getContext().getPackageManager().
getLaunchIntentForPackage(packageName);
- intent.addCategory(Intent.CATEGORY_LAUNCHER);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(new ComponentName(packageName,
"com.android.launcher3.tests.Activity" + activityNumber));
- instrumentation.getTargetContext().startActivity(intent);
- assertTrue(packageName + " didn't start",
- mDevice.wait(
- Until.hasObject(By.pkg(packageName).text("TestActivity" + activityNumber)),
- DEFAULT_UI_TIMEOUT));
+ startIntent(intent, By.pkg(packageName).text("TestActivity" + activityNumber));
+ }
+
+ private void startIntent(Intent intent, BySelector selector) {
+ intent.addCategory(Intent.CATEGORY_LAUNCHER);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ getInstrumentation().getTargetContext().startActivity(intent);
+ assertTrue("App didn't start: " + selector,
+ mDevice.wait(Until.hasObject(selector), DEFAULT_UI_TIMEOUT));
}
public static String resolveSystemApp(String category) {
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index 4dab44f..c2a3c1c 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -190,7 +190,7 @@
launcher -> assertTrue("ensureScrollable didn't make workspace scrollable",
isWorkspaceScrollable(launcher)));
assertNotNull("ensureScrollable didn't add Chrome app",
- workspace.tryGetWorkspaceAppIcon("Chrome"));
+ workspace.getWorkspaceAppIcon("Chrome"));
// Test flinging workspace.
workspace.flingBackward();
@@ -206,7 +206,7 @@
assertTrue("Launcher internal state is not Home", isInState(LauncherState.NORMAL));
// Test starting a workspace app.
- final AppIcon app = workspace.tryGetWorkspaceAppIcon("Chrome");
+ final AppIcon app = workspace.getWorkspaceAppIcon("Chrome");
assertNotNull("No Chrome app in workspace", app);
}
diff --git a/tests/src/com/android/launcher3/util/rule/LauncherActivityRule.java b/tests/src/com/android/launcher3/util/rule/LauncherActivityRule.java
index 2042403..62fe26d 100644
--- a/tests/src/com/android/launcher3/util/rule/LauncherActivityRule.java
+++ b/tests/src/com/android/launcher3/util/rule/LauncherActivityRule.java
@@ -19,6 +19,7 @@
import android.app.Application;
import android.app.Application.ActivityLifecycleCallbacks;
import android.os.Bundle;
+
import androidx.test.InstrumentationRegistry;
import com.android.launcher3.Launcher;
@@ -84,19 +85,27 @@
}
@Override
- public void onActivityStarted(Activity activity) { }
+ public void onActivityStarted(Activity activity) {
+ if (activity instanceof Launcher) {
+ mActivity.getRotationHelper().forceAllowRotationForTesting(true);
+ }
+ }
@Override
- public void onActivityResumed(Activity activity) { }
+ public void onActivityResumed(Activity activity) {
+ }
@Override
- public void onActivityPaused(Activity activity) { }
+ public void onActivityPaused(Activity activity) {
+ }
@Override
- public void onActivityStopped(Activity activity) { }
+ public void onActivityStopped(Activity activity) {
+ }
@Override
- public void onActivitySaveInstanceState(Activity activity, Bundle bundle) { }
+ public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
+ }
@Override
public void onActivityDestroyed(Activity activity) {
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java
index 9ff354a..f070280 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java
@@ -120,7 +120,7 @@
mLauncher.assertTrue("Unable to scroll to a clickable icon: " + appName,
hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector));
- final UiObject2 appIcon = mLauncher.getObjectInContainer(appListRecycler,
+ final UiObject2 appIcon = mLauncher.waitForObjectInContainer(appListRecycler,
appIconSelector);
return new AppIcon(mLauncher, appIcon);
}
diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
index bbd2c29..25e6e8c 100644
--- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
+++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java
@@ -74,7 +74,7 @@
flingForward();
}
- mLauncher.getObjectInContainer(verifyActiveContainer(), clearAllSelector).click();
+ mLauncher.waitForObjectInContainer(verifyActiveContainer(), clearAllSelector).click();
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
"dismissed all tasks")) {
return new Workspace(mLauncher);
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index fe7401c..6348c41 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -178,6 +178,7 @@
PackageManager pm = getContext().getPackageManager();
ProviderInfo pi = pm.resolveContentProvider(
testProviderAuthority, MATCH_ALL | MATCH_DISABLED_COMPONENTS);
+ assertNotNull("Cannot find content provider for " + testProviderAuthority, pi);
ComponentName cn = new ComponentName(pi.packageName, pi.name);
if (pm.getComponentEnabledSetting(cn) != COMPONENT_ENABLED_STATE_ENABLED) {
@@ -678,13 +679,6 @@
}
@NonNull
- UiObject2 getObjectInContainer(UiObject2 container, BySelector selector) {
- final UiObject2 object = container.findObject(selector);
- assertNotNull("Can't find an object with selector: " + selector, object);
- return object;
- }
-
- @NonNull
List<UiObject2> getObjectsInContainer(UiObject2 container, String resName) {
return container.findObjects(getLauncherObjectSelector(resName));
}
diff --git a/tests/tapl/com/android/launcher3/tapl/TestHelpers.java b/tests/tapl/com/android/launcher3/tapl/TestHelpers.java
index 399c59d..a089a52 100644
--- a/tests/tapl/com/android/launcher3/tapl/TestHelpers.java
+++ b/tests/tapl/com/android/launcher3/tapl/TestHelpers.java
@@ -109,7 +109,7 @@
DropBoxManager.Entry entry;
StringBuilder errorDetails = new StringBuilder();
while (null != (entry = dropbox.getNextEntry(label, timestamp))) {
- if (errorDetails.length() != 0) errorDetails.append("------------------------------");
+ errorDetails.append("------------------------------\n");
timestamp = entry.getTimeMillis();
errorDetails.append(new Date(timestamp));
errorDetails.append(": ");
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 07f8b64..639902f 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -108,10 +108,13 @@
*/
@NonNull
public AppIcon getWorkspaceAppIcon(String appName) {
- return new AppIcon(mLauncher,
- mLauncher.getObjectInContainer(
- verifyActiveContainer(),
- AppIcon.getAppIconSelector(appName, mLauncher)));
+ try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+ "want to get a workspace icon")) {
+ return new AppIcon(mLauncher,
+ mLauncher.waitForObjectInContainer(
+ verifyActiveContainer(),
+ AppIcon.getAppIconSelector(appName, mLauncher)));
+ }
}
/**
@@ -142,13 +145,13 @@
@NonNull
public AppIcon getHotseatAppIcon(String appName) {
- return new AppIcon(mLauncher, mLauncher.getObjectInContainer(
+ return new AppIcon(mLauncher, mLauncher.waitForObjectInContainer(
mHotseat, AppIcon.getAppIconSelector(appName, mLauncher)));
}
@NonNull
public Folder getHotseatFolder(String appName) {
- return new Folder(mLauncher, mLauncher.getObjectInContainer(
+ return new Folder(mLauncher, mLauncher.waitForObjectInContainer(
mHotseat, Folder.getSelector(appName, mLauncher)));
}