Search in sources :

Example 21 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by AOSPA.

the class PopupDataProvider method onNotificationPosted.

@Override
public void onNotificationPosted(PackageUserKey postedPackageUserKey, NotificationKeyData notificationKey) {
    DotInfo dotInfo = mPackageUserToDotInfos.get(postedPackageUserKey);
    if (dotInfo == null) {
        dotInfo = new DotInfo();
        mPackageUserToDotInfos.put(postedPackageUserKey, dotInfo);
    }
    if (dotInfo.addOrUpdateNotificationKey(notificationKey)) {
        updateNotificationDots(postedPackageUserKey::equals);
    }
}
Also used : DotInfo(com.android.launcher3.dot.DotInfo)

Example 22 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by AOSPA.

the class PopupDataProvider method onNotificationFullRefresh.

@Override
public void onNotificationFullRefresh(List<StatusBarNotification> activeNotifications) {
    if (activeNotifications == null)
        return;
    // This will contain the PackageUserKeys which have updated dots.
    HashMap<PackageUserKey, DotInfo> updatedDots = new HashMap<>(mPackageUserToDotInfos);
    mPackageUserToDotInfos.clear();
    for (StatusBarNotification notification : activeNotifications) {
        PackageUserKey packageUserKey = PackageUserKey.fromNotification(notification);
        DotInfo dotInfo = mPackageUserToDotInfos.get(packageUserKey);
        if (dotInfo == null) {
            dotInfo = new DotInfo();
            mPackageUserToDotInfos.put(packageUserKey, dotInfo);
        }
        dotInfo.addOrUpdateNotificationKey(NotificationKeyData.fromNotification(notification));
    }
    // Add and remove from updatedDots so it contains the PackageUserKeys of updated dots.
    for (PackageUserKey packageUserKey : mPackageUserToDotInfos.keySet()) {
        DotInfo prevDot = updatedDots.get(packageUserKey);
        DotInfo newDot = mPackageUserToDotInfos.get(packageUserKey);
        if (prevDot == null || prevDot.getNotificationCount() != newDot.getNotificationCount()) {
            updatedDots.put(packageUserKey, newDot);
        } else {
            // No need to update the dot if it already existed (no visual change).
            // Note that if the dot was removed entirely, we wouldn't reach this point because
            // this loop only includes active notifications added above.
            updatedDots.remove(packageUserKey);
        }
    }
    if (!updatedDots.isEmpty()) {
        updateNotificationDots(updatedDots::containsKey);
    }
    trimNotifications(updatedDots);
}
Also used : DotInfo(com.android.launcher3.dot.DotInfo) StatusBarNotification(android.service.notification.StatusBarNotification) HashMap(java.util.HashMap) PackageUserKey(com.android.launcher3.util.PackageUserKey)

Example 23 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by AOSPA.

the class BindWidgetTest method getInvalidWidgetInfo.

/**
 * Returns a LauncherAppWidgetInfo with package name which is not present on the device
 */
private LauncherAppWidgetInfo getInvalidWidgetInfo() {
    String invalidPackage = "com.invalidpackage";
    int count = 0;
    String pkg = invalidPackage;
    Set<String> activePackage = getOnUiThread(() -> {
        Set<String> packages = new HashSet<>();
        InstallSessionHelper.INSTANCE.get(mTargetContext).getActiveSessions().keySet().forEach(packageUserKey -> packages.add(packageUserKey.mPackageName));
        return packages;
    });
    while (true) {
        try {
            mTargetContext.getPackageManager().getPackageInfo(pkg, PackageManager.GET_UNINSTALLED_PACKAGES);
        } catch (Exception e) {
            if (!activePackage.contains(pkg)) {
                break;
            }
        }
        pkg = invalidPackage + count;
        count++;
    }
    LauncherAppWidgetInfo item = new LauncherAppWidgetInfo(10, new ComponentName(pkg, "com.test.widgetprovider"));
    item.spanX = 2;
    item.spanY = 2;
    item.minSpanX = 2;
    item.minSpanY = 2;
    item.cellX = 0;
    item.cellY = 1;
    item.container = LauncherSettings.Favorites.CONTAINER_DESKTOP;
    return item;
}
Also used : LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) ComponentName(android.content.ComponentName) HashSet(java.util.HashSet)

Example 24 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by AOSPA.

the class WidgetsListAdapterTest method setWidgetsOnSearch_expandedApp_shouldResetExpandedApp.

@Test
public void setWidgetsOnSearch_expandedApp_shouldResetExpandedApp() {
    // GIVEN a list of widgets entries:
    // [Empty item
    // com.google.test0,
    // com.google.test0 content,
    // com.google.test1,
    // com.google.test1 content,
    // com.google.test2,
    // com.google.test2 content]
    // The visible widgets entries:
    // [Empty item,
    // com.google.test0,
    // com.google.test1,
    // com.google.test2].
    ArrayList<WidgetsListBaseEntry> allEntries = generateSampleMap(3);
    mAdapter.setWidgetsOnSearch(allEntries);
    // GIVEN com.google.test.1 header is expanded. The visible entries list becomes:
    // [Empty item, com.google.test0, com.google.test1, com.google.test1 content,
    // com.google.test2]
    mAdapter.onHeaderClicked(/* showWidgets= */
    true, new PackageUserKey(TEST_PACKAGE_PLACEHOLDER + 1, mUserHandle));
    Mockito.reset(mListener);
    // WHEN same widget entries are set again.
    mAdapter.setWidgetsOnSearch(allEntries);
    // THEN expanded app is reset and the visible entries list becomes:
    // [Empty item, com.google.test0, com.google.test1, com.google.test2]
    verify(mListener).onItemRangeChanged(eq(2), eq(1), isNull());
    verify(mListener).onItemRangeRemoved(/* positionStart= */
    3, /* itemCount= */
    1);
}
Also used : WidgetsListBaseEntry(com.android.launcher3.widget.model.WidgetsListBaseEntry) PackageUserKey(com.android.launcher3.util.PackageUserKey) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 25 with PackageUserKey

use of com.android.launcher3.util.PackageUserKey in project android_packages_apps_Launcher3 by AOSPA.

the class LauncherModel method onUpdateSessionDisplay.

/**
 * Updates the icons and label of all pending icons for the provided package name.
 */
@Override
public void onUpdateSessionDisplay(PackageUserKey key, PackageInstaller.SessionInfo info) {
    mApp.getIconCache().updateSessionCache(key, info);
    HashSet<String> packages = new HashSet<>();
    packages.add(key.mPackageName);
    enqueueModelUpdateTask(new CacheDataUpdatedTask(CacheDataUpdatedTask.OP_SESSION_UPDATE, key.mUser, packages));
}
Also used : CacheDataUpdatedTask(com.android.launcher3.model.CacheDataUpdatedTask) HashSet(java.util.HashSet)

Aggregations

PackageUserKey (com.android.launcher3.util.PackageUserKey)94 ArrayList (java.util.ArrayList)53 Context (android.content.Context)42 ComponentName (android.content.ComponentName)39 UserHandle (android.os.UserHandle)35 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)31 HashMap (java.util.HashMap)31 HashSet (java.util.HashSet)31 List (java.util.List)29 WidgetManagerHelper (com.android.launcher3.widget.WidgetManagerHelper)26 IconCache (com.android.launcher3.icons.IconCache)24 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)24 WidgetsListBaseEntry (com.android.launcher3.widget.model.WidgetsListBaseEntry)24 DotInfo (com.android.launcher3.dot.DotInfo)22 Log (android.util.Log)21 FeatureFlags (com.android.launcher3.config.FeatureFlags)21 PackageItemInfo (com.android.launcher3.model.data.PackageItemInfo)21 IntSet (com.android.launcher3.util.IntSet)21 Predicate (java.util.function.Predicate)21 Test (org.junit.Test)21