Merge changes I64bf55bb,I91e80704 into ub-contactsdialer-h-dev
* changes:
Add API level check for call to getPendingJob in logging
Fix crash when "Add contact" shortcut is pinned
diff --git a/src/com/android/contacts/DynamicShortcuts.java b/src/com/android/contacts/DynamicShortcuts.java
index 49cc722..170d9b4 100644
--- a/src/com/android/contacts/DynamicShortcuts.java
+++ b/src/com/android/contacts/DynamicShortcuts.java
@@ -87,6 +87,13 @@
private static final int LONG_LABEL_MAX_LENGTH = 30;
private static final int MAX_SHORTCUTS = 3;
+ private static final String EXTRA_SHORTCUT_TYPE = "extraShortcutType";
+
+ // Because pinned shortcuts persist across app upgrades these values should not be changed
+ // though new ones may be added
+ private static final int SHORTCUT_TYPE_UNKNOWN = 0;
+ private static final int SHORTCUT_TYPE_CONTACT_URI = 1;
+
// The spec specifies that it should be 44dp @ xxxhdpi
// Note that ShortcutManager.getIconMaxWidth and ShortcutManager.getMaxHeight return different
// (larger) values.
@@ -156,10 +163,16 @@
final List<String> enable = new ArrayList<>();
for (ShortcutInfo shortcut : mShortcutManager.getPinnedShortcuts()) {
-
final PersistableBundle extras = shortcut.getExtras();
+
+ if (!shortcut.isDynamic() || extras == null ||
+ extras.getInt(EXTRA_SHORTCUT_TYPE, SHORTCUT_TYPE_UNKNOWN) !=
+ SHORTCUT_TYPE_CONTACT_URI) {
+ continue;
+ }
+
// The contact ID may have changed but that's OK because it is just an optimization
- final long contactId = extras == null ? 0 : extras.getLong(Contacts._ID);
+ final long contactId = extras.getLong(Contacts._ID);
final ShortcutInfo update = createShortcutForUri(
Contacts.getLookupUri(contactId, shortcut.getId()));
@@ -256,6 +269,7 @@
}
final PersistableBundle extras = new PersistableBundle();
extras.putLong(Contacts._ID, id);
+ extras.putInt(EXTRA_SHORTCUT_TYPE, SHORTCUT_TYPE_CONTACT_URI);
final ShortcutInfo.Builder builder = new ShortcutInfo.Builder(mContext, lookupKey)
.setIntent(ImplicitIntentsUtil.getIntentForQuickContactLauncherShortcut(mContext,
@@ -416,7 +430,8 @@
final Flags flags = Flags.getInstance();
Log.d(TAG, "DyanmicShortcuts.initialize\nVERSION >= N_MR1? " +
(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) +
- "\nisJobScheduled? " + isJobScheduled(context) +
+ "\nisJobScheduled? " +
+ (CompatUtils.isLauncherShortcutCompatible() && isJobScheduled(context)) +
"\nminDelay=" +
flags.getInteger(Experiments.DYNAMIC_MIN_CONTENT_CHANGE_UPDATE_DELAY_MILLIS) +
"\nmaxDelay=" +