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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user