Search in sources :

Example 1 with PackageWithUser

use of com.android.server.pm.ShortcutUser.PackageWithUser in project platform_frameworks_base by android.

the class ShortcutLauncher method saveToXml.

/**
     * Persist.
     */
@Override
public void saveToXml(XmlSerializer out, boolean forBackup) throws IOException {
    final int size = mPinnedShortcuts.size();
    if (size == 0) {
        // Nothing to write.
        return;
    }
    out.startTag(null, TAG_ROOT);
    ShortcutService.writeAttr(out, ATTR_PACKAGE_NAME, getPackageName());
    ShortcutService.writeAttr(out, ATTR_LAUNCHER_USER_ID, getPackageUserId());
    getPackageInfo().saveToXml(out);
    for (int i = 0; i < size; i++) {
        final PackageWithUser pu = mPinnedShortcuts.keyAt(i);
        if (forBackup && (pu.userId != getOwnerUserId())) {
            // Target package on a different user, skip. (i.e. work profile)
            continue;
        }
        out.startTag(null, TAG_PACKAGE);
        ShortcutService.writeAttr(out, ATTR_PACKAGE_NAME, pu.packageName);
        ShortcutService.writeAttr(out, ATTR_PACKAGE_USER_ID, pu.userId);
        final ArraySet<String> ids = mPinnedShortcuts.valueAt(i);
        final int idSize = ids.size();
        for (int j = 0; j < idSize; j++) {
            ShortcutService.writeTagValue(out, TAG_PIN, ids.valueAt(j));
        }
        out.endTag(null, TAG_PACKAGE);
    }
    out.endTag(null, TAG_ROOT);
}
Also used : PackageWithUser(com.android.server.pm.ShortcutUser.PackageWithUser)

Example 2 with PackageWithUser

use of com.android.server.pm.ShortcutUser.PackageWithUser in project platform_frameworks_base by android.

the class ShortcutLauncher method dump.

public void dump(@NonNull PrintWriter pw, @NonNull String prefix) {
    pw.println();
    pw.print(prefix);
    pw.print("Launcher: ");
    pw.print(getPackageName());
    pw.print("  Package user: ");
    pw.print(getPackageUserId());
    pw.print("  Owner user: ");
    pw.print(getOwnerUserId());
    pw.println();
    getPackageInfo().dump(pw, prefix + "  ");
    pw.println();
    final int size = mPinnedShortcuts.size();
    for (int i = 0; i < size; i++) {
        pw.println();
        final PackageWithUser pu = mPinnedShortcuts.keyAt(i);
        pw.print(prefix);
        pw.print("  ");
        pw.print("Package: ");
        pw.print(pu.packageName);
        pw.print("  User: ");
        pw.println(pu.userId);
        final ArraySet<String> ids = mPinnedShortcuts.valueAt(i);
        final int idSize = ids.size();
        for (int j = 0; j < idSize; j++) {
            pw.print(prefix);
            pw.print("    Pinned: ");
            pw.print(ids.valueAt(j));
            pw.println();
        }
    }
}
Also used : PackageWithUser(com.android.server.pm.ShortcutUser.PackageWithUser)

Example 3 with PackageWithUser

use of com.android.server.pm.ShortcutUser.PackageWithUser in project platform_frameworks_base by android.

the class ShortcutLauncher method pinShortcuts.

public void pinShortcuts(@UserIdInt int packageUserId, @NonNull String packageName, @NonNull List<String> ids) {
    final ShortcutPackage packageShortcuts = mShortcutUser.getPackageShortcutsIfExists(packageName);
    if (packageShortcuts == null) {
        // No need to instantiate.
        return;
    }
    final PackageWithUser pu = PackageWithUser.of(packageUserId, packageName);
    final int idSize = ids.size();
    if (idSize == 0) {
        mPinnedShortcuts.remove(pu);
    } else {
        final ArraySet<String> prevSet = mPinnedShortcuts.get(pu);
        // Pin shortcuts.  Make sure only pin the ones that were visible to the caller.
        // i.e. a non-dynamic, pinned shortcut by *other launchers* shouldn't be pinned here.
        final ArraySet<String> newSet = new ArraySet<>();
        for (int i = 0; i < idSize; i++) {
            final String id = ids.get(i);
            final ShortcutInfo si = packageShortcuts.findShortcutById(id);
            if (si == null) {
                continue;
            }
            if (si.isDynamic() || si.isManifestShortcut() || (prevSet != null && prevSet.contains(id))) {
                newSet.add(id);
            }
        }
        mPinnedShortcuts.put(pu, newSet);
    }
    packageShortcuts.refreshPinnedFlags();
}
Also used : ArraySet(android.util.ArraySet) ShortcutInfo(android.content.pm.ShortcutInfo) PackageWithUser(com.android.server.pm.ShortcutUser.PackageWithUser)

Example 4 with PackageWithUser

use of com.android.server.pm.ShortcutUser.PackageWithUser in project android_frameworks_base by DirtyUnicorns.

the class ShortcutLauncher method dump.

public void dump(@NonNull PrintWriter pw, @NonNull String prefix) {
    pw.println();
    pw.print(prefix);
    pw.print("Launcher: ");
    pw.print(getPackageName());
    pw.print("  Package user: ");
    pw.print(getPackageUserId());
    pw.print("  Owner user: ");
    pw.print(getOwnerUserId());
    pw.println();
    getPackageInfo().dump(pw, prefix + "  ");
    pw.println();
    final int size = mPinnedShortcuts.size();
    for (int i = 0; i < size; i++) {
        pw.println();
        final PackageWithUser pu = mPinnedShortcuts.keyAt(i);
        pw.print(prefix);
        pw.print("  ");
        pw.print("Package: ");
        pw.print(pu.packageName);
        pw.print("  User: ");
        pw.println(pu.userId);
        final ArraySet<String> ids = mPinnedShortcuts.valueAt(i);
        final int idSize = ids.size();
        for (int j = 0; j < idSize; j++) {
            pw.print(prefix);
            pw.print("    Pinned: ");
            pw.print(ids.valueAt(j));
            pw.println();
        }
    }
}
Also used : PackageWithUser(com.android.server.pm.ShortcutUser.PackageWithUser)

Example 5 with PackageWithUser

use of com.android.server.pm.ShortcutUser.PackageWithUser in project android_frameworks_base by ResurrectionRemix.

the class ShortcutLauncher method saveToXml.

/**
     * Persist.
     */
@Override
public void saveToXml(XmlSerializer out, boolean forBackup) throws IOException {
    final int size = mPinnedShortcuts.size();
    if (size == 0) {
        // Nothing to write.
        return;
    }
    out.startTag(null, TAG_ROOT);
    ShortcutService.writeAttr(out, ATTR_PACKAGE_NAME, getPackageName());
    ShortcutService.writeAttr(out, ATTR_LAUNCHER_USER_ID, getPackageUserId());
    getPackageInfo().saveToXml(out);
    for (int i = 0; i < size; i++) {
        final PackageWithUser pu = mPinnedShortcuts.keyAt(i);
        if (forBackup && (pu.userId != getOwnerUserId())) {
            // Target package on a different user, skip. (i.e. work profile)
            continue;
        }
        out.startTag(null, TAG_PACKAGE);
        ShortcutService.writeAttr(out, ATTR_PACKAGE_NAME, pu.packageName);
        ShortcutService.writeAttr(out, ATTR_PACKAGE_USER_ID, pu.userId);
        final ArraySet<String> ids = mPinnedShortcuts.valueAt(i);
        final int idSize = ids.size();
        for (int j = 0; j < idSize; j++) {
            ShortcutService.writeTagValue(out, TAG_PIN, ids.valueAt(j));
        }
        out.endTag(null, TAG_PACKAGE);
    }
    out.endTag(null, TAG_ROOT);
}
Also used : PackageWithUser(com.android.server.pm.ShortcutUser.PackageWithUser)

Aggregations

PackageWithUser (com.android.server.pm.ShortcutUser.PackageWithUser)20 ArrayList (java.util.ArrayList)8 ShortcutInfo (android.content.pm.ShortcutInfo)4 ArraySet (android.util.ArraySet)4 VisibleForTesting (com.android.internal.annotations.VisibleForTesting)4