Add dynamic launcher shortcuts.
Currently the shortcuts are created for the top 3 contacts returned from
Contacts.CONTENT_STREQUENT_URI
Test:
Added unit tests for DynamicShortcuts but currently suppressed because they
require AndroidJUnitRunner
Manual:
* Use N_MR1 device with recent dogfood Nexus launcher installed.
* launch app
* star some contacts if needed
* press home
* long press launcher icon
* verify that starred contacts show in list of shortcuts
* unstar some contacts
* verify that shortcuts change
* pin a shortcut
* remove contact for pinned shortcut
* verify that pinned shortcut is disabled
* pin a shortcut
* change name of contact for pinned shortcut
* verify that name on pinned shortcut changes
Also prevent disambiguation dialog for other home screen shortcuts
Bug 30189449
Bug 31628994
Change-Id: Iace4b1c88b51ba1f7973c6f4ef90002fb92d0784
diff --git a/src/com/android/contacts/ContactsJobService.java b/src/com/android/contacts/ContactsJobService.java
new file mode 100644
index 0000000..c60a0a7
--- /dev/null
+++ b/src/com/android/contacts/ContactsJobService.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.contacts;
+
+import android.app.job.JobParameters;
+import android.app.job.JobService;
+
+/**
+ * Service to run {@link android.app.job.JobScheduler} jobs.
+ */
+public class ContactsJobService extends JobService {
+
+ public static final int DYNAMIC_SHORTCUTS_JOB_ID = 1;
+
+ @Override
+ public boolean onStartJob(JobParameters jobParameters) {
+ switch (jobParameters.getJobId()) {
+ case DYNAMIC_SHORTCUTS_JOB_ID:
+ DynamicShortcuts.updateFromJob(this, jobParameters);
+ return true;
+ default:
+ break;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean onStopJob(JobParameters jobParameters) {
+ return false;
+ }
+}