use of android.content.pm.ShortcutInfo in project android_frameworks_base by ResurrectionRemix.
the class ShortcutPackage method verifyStates.
@Override
public void verifyStates() {
super.verifyStates();
boolean failed = false;
final ArrayMap<ComponentName, ArrayList<ShortcutInfo>> all = sortShortcutsToActivities();
// Make sure each activity won't have more than max shortcuts.
for (int outer = all.size() - 1; outer >= 0; outer--) {
final ArrayList<ShortcutInfo> list = all.valueAt(outer);
if (list.size() > mShortcutUser.mService.getMaxActivityShortcuts()) {
failed = true;
Log.e(TAG_VERIFY, "Package " + getPackageName() + ": activity " + all.keyAt(outer) + " has " + all.valueAt(outer).size() + " shortcuts.");
}
// Sort by rank.
Collections.sort(list, (a, b) -> Integer.compare(a.getRank(), b.getRank()));
// Split into two arrays for each kind.
final ArrayList<ShortcutInfo> dynamicList = new ArrayList<>(list);
dynamicList.removeIf((si) -> !si.isDynamic());
final ArrayList<ShortcutInfo> manifestList = new ArrayList<>(list);
dynamicList.removeIf((si) -> !si.isManifestShortcut());
verifyRanksSequential(dynamicList);
verifyRanksSequential(manifestList);
}
// Verify each shortcut's status.
for (int i = mShortcuts.size() - 1; i >= 0; i--) {
final ShortcutInfo si = mShortcuts.valueAt(i);
if (!(si.isDeclaredInManifest() || si.isDynamic() || si.isPinned())) {
failed = true;
Log.e(TAG_VERIFY, "Package " + getPackageName() + ": shortcut " + si.getId() + " is not manifest, dynamic or pinned.");
}
if (si.isDeclaredInManifest() && si.isDynamic()) {
failed = true;
Log.e(TAG_VERIFY, "Package " + getPackageName() + ": shortcut " + si.getId() + " is both dynamic and manifest at the same time.");
}
if (si.getActivity() == null) {
failed = true;
Log.e(TAG_VERIFY, "Package " + getPackageName() + ": shortcut " + si.getId() + " has null activity.");
}
if ((si.isDynamic() || si.isManifestShortcut()) && !si.isEnabled()) {
failed = true;
Log.e(TAG_VERIFY, "Package " + getPackageName() + ": shortcut " + si.getId() + " is not floating, but is disabled.");
}
if (si.isFloating() && si.getRank() != 0) {
failed = true;
Log.e(TAG_VERIFY, "Package " + getPackageName() + ": shortcut " + si.getId() + " is floating, but has rank=" + si.getRank());
}
if (si.getIcon() != null) {
failed = true;
Log.e(TAG_VERIFY, "Package " + getPackageName() + ": shortcut " + si.getId() + " still has an icon");
}
if (si.hasIconFile() && si.hasIconResource()) {
failed = true;
Log.e(TAG_VERIFY, "Package " + getPackageName() + ": shortcut " + si.getId() + " has both resource and bitmap icons");
}
}
if (failed) {
throw new IllegalStateException("See logcat for errors");
}
}
use of android.content.pm.ShortcutInfo in project android_frameworks_base by ResurrectionRemix.
the class ShortcutPackage method deleteShortcutInner.
private ShortcutInfo deleteShortcutInner(@NonNull String id) {
final ShortcutInfo shortcut = mShortcuts.remove(id);
if (shortcut != null) {
mShortcutUser.mService.removeIcon(getPackageUserId(), shortcut);
shortcut.clearFlags(ShortcutInfo.FLAG_DYNAMIC | ShortcutInfo.FLAG_PINNED | ShortcutInfo.FLAG_MANIFEST);
}
return shortcut;
}
use of android.content.pm.ShortcutInfo in project android_frameworks_base by ResurrectionRemix.
the class ShortcutPackage method enableWithId.
public void enableWithId(@NonNull String shortcutId) {
final ShortcutInfo shortcut = mShortcuts.get(shortcutId);
if (shortcut != null) {
ensureNotImmutable(shortcut);
shortcut.clearFlags(ShortcutInfo.FLAG_DISABLED);
}
}
use of android.content.pm.ShortcutInfo in project android_frameworks_base by ResurrectionRemix.
the class ShortcutService method fillInDefaultActivity.
/**
* When a shortcut has no target activity, set the default one from the package.
*/
private void fillInDefaultActivity(List<ShortcutInfo> shortcuts) {
ComponentName defaultActivity = null;
for (int i = shortcuts.size() - 1; i >= 0; i--) {
final ShortcutInfo si = shortcuts.get(i);
if (si.getActivity() == null) {
if (defaultActivity == null) {
defaultActivity = injectGetDefaultMainActivity(si.getPackage(), si.getUserId());
Preconditions.checkState(defaultActivity != null, "Launcher activity not found for package " + si.getPackage());
}
si.setActivity(defaultActivity);
}
}
}
use of android.content.pm.ShortcutInfo in project android_frameworks_base by ResurrectionRemix.
the class ShortcutManagerTestUtils method parceled.
public static ShortcutInfo parceled(ShortcutInfo si) {
Parcel p = Parcel.obtain();
p.writeParcelable(si, 0);
p.setDataPosition(0);
ShortcutInfo si2 = p.readParcelable(ShortcutManagerTestUtils.class.getClassLoader());
p.recycle();
return si2;
}
Aggregations