Search in sources :

Example 1 with ShortcutQuery

use of android.content.pm.LauncherApps.ShortcutQuery in project platform_frameworks_base by android.

the class BaseShortcutManagerTest method buildPinnedQuery.

protected static ShortcutQuery buildPinnedQuery(String packageName) {
    final ShortcutQuery q = new ShortcutQuery();
    q.setPackage(packageName);
    q.setQueryFlags(ShortcutQuery.FLAG_GET_PINNED);
    return q;
}
Also used : ShortcutQuery(android.content.pm.LauncherApps.ShortcutQuery)

Example 2 with ShortcutQuery

use of android.content.pm.LauncherApps.ShortcutQuery in project android_frameworks_base by DirtyUnicorns.

the class BaseShortcutManagerTest method getLauncherShortcuts.

protected List<ShortcutInfo> getLauncherShortcuts(String launcher, int userId, int queryFlags) {
    final List<ShortcutInfo>[] ret = new List[1];
    runWithCaller(launcher, userId, () -> {
        final ShortcutQuery q = new ShortcutQuery();
        q.setQueryFlags(queryFlags);
        ret[0] = mLauncherApps.getShortcuts(q, UserHandle.of(userId));
    });
    return ret[0];
}
Also used : ShortcutQuery(android.content.pm.LauncherApps.ShortcutQuery) List(java.util.List) ArrayList(java.util.ArrayList) ShortcutManagerTestUtils.cloneShortcutList(com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.cloneShortcutList)

Example 3 with ShortcutQuery

use of android.content.pm.LauncherApps.ShortcutQuery in project android_frameworks_base by DirtyUnicorns.

the class ShortcutManagerTest1 method testGetShortcuts_resolveStrings.

public void testGetShortcuts_resolveStrings() throws Exception {
    runWithCaller(CALLING_PACKAGE_1, USER_0, () -> {
        ShortcutInfo si = new ShortcutInfo.Builder(mClientContext).setId("id").setActivity(new ComponentName(mClientContext, "dummy")).setTitleResId(10).setTextResId(11).setDisabledMessageResId(12).setIntent(makeIntent("action", ShortcutActivity.class)).build();
        mManager.setDynamicShortcuts(list(si));
    });
    runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
        ShortcutInfo si = new ShortcutInfo.Builder(mClientContext).setId("id").setActivity(new ComponentName(mClientContext, "dummy")).setTitleResId(10).setTextResId(11).setDisabledMessageResId(12).setIntent(makeIntent("action", ShortcutActivity.class)).build();
        mManager.setDynamicShortcuts(list(si));
    });
    runWithCaller(LAUNCHER_1, USER_0, () -> {
        final ShortcutQuery q = new ShortcutQuery();
        q.setQueryFlags(ShortcutQuery.FLAG_GET_DYNAMIC);
        // USER 0
        List<ShortcutInfo> ret = assertShortcutIds(assertAllStringsResolved(mLauncherApps.getShortcuts(q, HANDLE_USER_0)), "id");
        assertEquals("string-com.android.test.1-user:0-res:10/en", ret.get(0).getTitle());
        assertEquals("string-com.android.test.1-user:0-res:11/en", ret.get(0).getText());
        assertEquals("string-com.android.test.1-user:0-res:12/en", ret.get(0).getDisabledMessage());
        // USER P0
        ret = assertShortcutIds(assertAllStringsResolved(mLauncherApps.getShortcuts(q, HANDLE_USER_P0)), "id");
        assertEquals("string-com.android.test.1-user:20-res:10/en", ret.get(0).getTitle());
        assertEquals("string-com.android.test.1-user:20-res:11/en", ret.get(0).getText());
        assertEquals("string-com.android.test.1-user:20-res:12/en", ret.get(0).getDisabledMessage());
    });
}
Also used : ShortcutQuery(android.content.pm.LauncherApps.ShortcutQuery) ShortcutInfo(android.content.pm.ShortcutInfo) ComponentName(android.content.ComponentName)

Example 4 with ShortcutQuery

use of android.content.pm.LauncherApps.ShortcutQuery in project android_frameworks_base by DirtyUnicorns.

the class BaseShortcutManagerTest method buildQueryWithFlags.

protected static ShortcutQuery buildQueryWithFlags(int queryFlags) {
    final ShortcutQuery q = new ShortcutQuery();
    q.setQueryFlags(queryFlags);
    return q;
}
Also used : ShortcutQuery(android.content.pm.LauncherApps.ShortcutQuery)

Example 5 with ShortcutQuery

use of android.content.pm.LauncherApps.ShortcutQuery in project android_frameworks_base by DirtyUnicorns.

the class BaseShortcutManagerTest method buildAllQuery.

protected static ShortcutQuery buildAllQuery(String packageName) {
    final ShortcutQuery q = new ShortcutQuery();
    q.setPackage(packageName);
    q.setQueryFlags(ShortcutQuery.FLAG_GET_ALL_KINDS);
    return q;
}
Also used : ShortcutQuery(android.content.pm.LauncherApps.ShortcutQuery)

Aggregations

ShortcutQuery (android.content.pm.LauncherApps.ShortcutQuery)24 ComponentName (android.content.ComponentName)4 ShortcutInfo (android.content.pm.ShortcutInfo)4 ShortcutManagerTestUtils.cloneShortcutList (com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.cloneShortcutList)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4