Search in sources :

Example 21 with ShortcutQuery

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

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 22 with ShortcutQuery

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

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 23 with ShortcutQuery

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

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 24 with ShortcutQuery

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

the class BaseShortcutManagerTest method buildQuery.

protected static ShortcutQuery buildQuery(long changedSince, String packageName, List<String> shortcutIds, ComponentName componentName, /* @ShortcutQuery.QueryFlags */
int flags) {
    final ShortcutQuery q = new ShortcutQuery();
    q.setChangedSince(changedSince);
    q.setPackage(packageName);
    q.setShortcutIds(shortcutIds);
    q.setActivity(componentName);
    q.setQueryFlags(flags);
    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