use of com.android.server.pm.ShortcutUser.PackageWithUser in project android_frameworks_base by crdroidandroid.
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();
}
}
}
use of com.android.server.pm.ShortcutUser.PackageWithUser in project android_frameworks_base by crdroidandroid.
the class ShortcutLauncher method onRestoreBlocked.
/**
* Called when the new package can't receive the backup, due to signature or version mismatch.
*/
@Override
protected void onRestoreBlocked() {
final ArrayList<PackageWithUser> pinnedPackages = new ArrayList<>(mPinnedShortcuts.keySet());
mPinnedShortcuts.clear();
for (int i = pinnedPackages.size() - 1; i >= 0; i--) {
final PackageWithUser pu = pinnedPackages.get(i);
final ShortcutPackage p = mShortcutUser.getPackageShortcutsIfExists(pu.packageName);
if (p != null) {
p.refreshPinnedFlags();
}
}
}
use of com.android.server.pm.ShortcutUser.PackageWithUser in project platform_frameworks_base by android.
the class ShortcutService method checkPackageChanges.
/**
* Called when a user is unlocked.
* - Check all known packages still exist, and otherwise perform cleanup.
* - If a package still exists, check the version code. If it's been updated, may need to
* update timestamps of its shortcuts.
*/
@VisibleForTesting
void checkPackageChanges(@UserIdInt int ownerUserId) {
if (DEBUG) {
Slog.d(TAG, "checkPackageChanges() ownerUserId=" + ownerUserId);
}
if (injectIsSafeModeEnabled()) {
Slog.i(TAG, "Safe mode, skipping checkPackageChanges()");
return;
}
final long start = injectElapsedRealtime();
try {
final ArrayList<PackageWithUser> gonePackages = new ArrayList<>();
synchronized (mLock) {
final ShortcutUser user = getUserShortcutsLocked(ownerUserId);
// Find packages that have been uninstalled.
user.forAllPackageItems(spi -> {
if (spi.getPackageInfo().isShadow()) {
return;
}
if (!isPackageInstalled(spi.getPackageName(), spi.getPackageUserId())) {
if (DEBUG) {
Slog.d(TAG, "Uninstalled: " + spi.getPackageName() + " user " + spi.getPackageUserId());
}
gonePackages.add(PackageWithUser.of(spi));
}
});
if (gonePackages.size() > 0) {
for (int i = gonePackages.size() - 1; i >= 0; i--) {
final PackageWithUser pu = gonePackages.get(i);
cleanUpPackageLocked(pu.packageName, ownerUserId, pu.userId, /* appStillExists = */
false);
}
}
rescanUpdatedPackagesLocked(ownerUserId, user.getLastAppScanTime(), /* forceRescan=*/
false);
}
} finally {
logDurationStat(Stats.CHECK_PACKAGE_CHANGES, start);
}
verifyStates();
}
use of com.android.server.pm.ShortcutUser.PackageWithUser in project platform_frameworks_base by android.
the class ShortcutLauncher method onRestoreBlocked.
/**
* Called when the new package can't receive the backup, due to signature or version mismatch.
*/
@Override
protected void onRestoreBlocked() {
final ArrayList<PackageWithUser> pinnedPackages = new ArrayList<>(mPinnedShortcuts.keySet());
mPinnedShortcuts.clear();
for (int i = pinnedPackages.size() - 1; i >= 0; i--) {
final PackageWithUser pu = pinnedPackages.get(i);
final ShortcutPackage p = mShortcutUser.getPackageShortcutsIfExists(pu.packageName);
if (p != null) {
p.refreshPinnedFlags();
}
}
}
use of com.android.server.pm.ShortcutUser.PackageWithUser in project android_frameworks_base by DirtyUnicorns.
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);
}
Aggregations