use of android.content.pm.ShortcutInfo in project android_frameworks_base by ResurrectionRemix.
the class ShortcutPackage method addOrUpdateDynamicShortcut.
/**
* Add a shortcut, or update one with the same ID, with taking over existing flags.
*
* It checks the max number of dynamic shortcuts.
*/
public void addOrUpdateDynamicShortcut(@NonNull ShortcutInfo newShortcut) {
Preconditions.checkArgument(newShortcut.isEnabled(), "add/setDynamicShortcuts() cannot publish disabled shortcuts");
newShortcut.addFlags(ShortcutInfo.FLAG_DYNAMIC);
final ShortcutInfo oldShortcut = mShortcuts.get(newShortcut.getId());
final boolean wasPinned;
if (oldShortcut == null) {
wasPinned = false;
} else {
// It's an update case.
// Make sure the target is updatable. (i.e. should be mutable.)
oldShortcut.ensureUpdatableWith(newShortcut);
wasPinned = oldShortcut.isPinned();
}
// If it was originally pinned, the new one should be pinned too.
if (wasPinned) {
newShortcut.addFlags(ShortcutInfo.FLAG_PINNED);
}
addShortcutInner(newShortcut);
}
use of android.content.pm.ShortcutInfo in project android_frameworks_base by ResurrectionRemix.
the class ShortcutPackage method deleteAllDynamicShortcuts.
/**
* Remove all dynamic shortcuts.
*/
public void deleteAllDynamicShortcuts() {
final long now = mShortcutUser.mService.injectCurrentTimeMillis();
boolean changed = false;
for (int i = mShortcuts.size() - 1; i >= 0; i--) {
final ShortcutInfo si = mShortcuts.valueAt(i);
if (si.isDynamic()) {
changed = true;
si.setTimestamp(now);
si.clearFlags(ShortcutInfo.FLAG_DYNAMIC);
// It may still be pinned, so clear the rank.
si.setRank(0);
}
}
if (changed) {
removeOrphans();
}
}
use of android.content.pm.ShortcutInfo in project android_frameworks_base by ResurrectionRemix.
the class ShortcutPackage method clearAllImplicitRanks.
/** Clears the implicit ranks for all shortcuts. */
public void clearAllImplicitRanks() {
for (int i = mShortcuts.size() - 1; i >= 0; i--) {
final ShortcutInfo si = mShortcuts.valueAt(i);
si.clearImplicitRankAndRankChangedFlag();
}
}
use of android.content.pm.ShortcutInfo in project android_frameworks_base by ResurrectionRemix.
the class ShortcutPackage method dump.
public void dump(@NonNull PrintWriter pw, @NonNull String prefix) {
pw.println();
pw.print(prefix);
pw.print("Package: ");
pw.print(getPackageName());
pw.print(" UID: ");
pw.print(mPackageUid);
pw.println();
pw.print(prefix);
pw.print(" ");
pw.print("Calls: ");
pw.print(getApiCallCount());
pw.println();
// getApiCallCount() may have updated mLastKnownForegroundElapsedTime.
pw.print(prefix);
pw.print(" ");
pw.print("Last known FG: ");
pw.print(mLastKnownForegroundElapsedTime);
pw.println();
// This should be after getApiCallCount(), which may update it.
pw.print(prefix);
pw.print(" ");
pw.print("Last reset: [");
pw.print(mLastResetTime);
pw.print("] ");
pw.print(ShortcutService.formatTime(mLastResetTime));
pw.println();
getPackageInfo().dump(pw, prefix + " ");
pw.println();
pw.print(prefix);
pw.println(" Shortcuts:");
long totalBitmapSize = 0;
final ArrayMap<String, ShortcutInfo> shortcuts = mShortcuts;
final int size = shortcuts.size();
for (int i = 0; i < size; i++) {
final ShortcutInfo si = shortcuts.valueAt(i);
pw.print(prefix);
pw.print(" ");
pw.println(si.toInsecureString());
if (si.getBitmapPath() != null) {
final long len = new File(si.getBitmapPath()).length();
pw.print(prefix);
pw.print(" ");
pw.print("bitmap size=");
pw.println(len);
totalBitmapSize += len;
}
}
pw.print(prefix);
pw.print(" ");
pw.print("Total bitmap size: ");
pw.print(totalBitmapSize);
pw.print(" (");
pw.print(Formatter.formatFileSize(mShortcutUser.mService.mContext, totalBitmapSize));
pw.println(")");
}
use of android.content.pm.ShortcutInfo in project android_frameworks_base by ResurrectionRemix.
the class ShortcutPackage method dumpCheckin.
@Override
public JSONObject dumpCheckin(boolean clear) throws JSONException {
final JSONObject result = super.dumpCheckin(clear);
int numDynamic = 0;
int numPinned = 0;
int numManifest = 0;
int numBitmaps = 0;
long totalBitmapSize = 0;
final ArrayMap<String, ShortcutInfo> shortcuts = mShortcuts;
final int size = shortcuts.size();
for (int i = 0; i < size; i++) {
final ShortcutInfo si = shortcuts.valueAt(i);
if (si.isDynamic())
numDynamic++;
if (si.isDeclaredInManifest())
numManifest++;
if (si.isPinned())
numPinned++;
if (si.getBitmapPath() != null) {
numBitmaps++;
totalBitmapSize += new File(si.getBitmapPath()).length();
}
}
result.put(KEY_DYNAMIC, numDynamic);
result.put(KEY_MANIFEST, numManifest);
result.put(KEY_PINNED, numPinned);
result.put(KEY_BITMAPS, numBitmaps);
result.put(KEY_BITMAP_BYTES, totalBitmapSize);
return result;
}
Aggregations