Java Code Examples for android.content.pm.ShortcutInfo#isDeclaredInManifest()

The following examples show how to use android.content.pm.ShortcutInfo#isDeclaredInManifest() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShortcutPackage.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** @return true if there's any shortcuts that are not manifest shortcuts. */
public boolean hasNonManifestShortcuts() {
    for (int i = mShortcuts.size() - 1; i >= 0; i--) {
        final ShortcutInfo si = mShortcuts.valueAt(i);
        if (!si.isDeclaredInManifest()) {
            return true;
        }
    }
    return false;
}
 
Example 2
Source File: ShortcutPackage.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@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);

    // TODO Log update frequency too.

    return result;
}