Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dbf4a9c2 authored by Christopher Tate's avatar Christopher Tate
Browse files

Don't synchronize inside getWallpaperColors()

Reading the current wallpaper's palette doesn't involve any state
inside the WallpaperManager instance, so there's no reason to
apply synchronization in the first place.  By doing so we were
inducing a great deal of lock contention, since the system side
of the operation can sometimes take a long time to execute.

Bug 63065764
Test: manual

Change-Id: I6f5f67a0819da23245a4ad5334f0942011467f7c
parent ce2ebd12
Loading
Loading
Loading
Loading
+10 −12
Original line number Diff line number Diff line
@@ -22,9 +22,9 @@ import android.annotation.Nullable;
import android.annotation.RawRes;
import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.SdkConstant.SdkConstantType;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -74,7 +74,6 @@ import java.io.InputStream;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -369,10 +368,10 @@ public class WallpaperManager {
        }

        WallpaperColors getWallpaperColors(int which) {
            synchronized (this) {
                if (which != FLAG_LOCK && which != FLAG_SYSTEM)
            if (which != FLAG_LOCK && which != FLAG_SYSTEM) {
                throw new IllegalArgumentException(
                            "which should be either FLAG_LOCK or FLAG_SYSTEM");
                        "Must request colors for exactly one kind of wallpaper");
            }

            try {
                return mService.getWallpaperColors(which);
@@ -381,7 +380,6 @@ public class WallpaperManager {
            }
            return null;
        }
        }

        public Bitmap peekWallpaperBitmap(Context context, boolean returnDefault,
                @SetWallpaperFlags int which) {