Migrate ColorExtractionService to JobService

IntentService cannot be run in the background, so moving to
JobService prevents us from crashing if the wallpaper is
changed while we aren't running.

Bug: 62065291
Change-Id: Ie0c887e36d0ced43a0b9ab8136bf55eb37697489
This commit is contained in:
Tony
2017-06-02 15:43:26 -07:00
parent 8b6ea60fac
commit 629a67c5ac
4 changed files with 73 additions and 32 deletions
@@ -18,8 +18,10 @@ package com.android.launcher3.dynamicui;
import android.annotation.TargetApi;
import android.app.WallpaperManager;
import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Build;
@@ -58,7 +60,11 @@ public class ExtractionUtils {
/** Starts the {@link ColorExtractionService} without checking the wallpaper id */
public static void startColorExtractionService(Context context) {
context.startService(new Intent(context, ColorExtractionService.class));
JobScheduler jobScheduler = (JobScheduler) context.getSystemService(
Context.JOB_SCHEDULER_SERVICE);
jobScheduler.schedule(new JobInfo.Builder(Utilities.COLOR_EXTRACTION_JOB_ID,
new ComponentName(context, ColorExtractionService.class))
.setMinimumLatency(0).build());
}
private static boolean hasWallpaperIdChanged(Context context) {