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

Commit 91ebd74d authored by Peter Kalauskas's avatar Peter Kalauskas
Browse files

Support single-user ImageWallpaper service

Bug: 206118673
Test: Manually check image wallpaper works for multi-user
Change-Id: Ic56fe799b2c6891f52db7a79348fdac4e0ef208b
parent b117df1d
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -609,6 +609,18 @@ public abstract class WallpaperService extends Service {
            }
        }

        /** @hide */
        public void setShowForAllUsers(boolean show) {
            mWindowPrivateFlags = show
                    ? (mWindowPrivateFlags
                        | WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS)
                    : (mWindowPrivateFlags
                        & ~WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS);
            if (mCreated) {
                updateSurface(false, false, false);
            }
        }

        /** {@hide} */
        @UnsupportedAppUsage
        public void setFixedSizeAllowed(boolean allowed) {
+1 −0
Original line number Diff line number Diff line
@@ -375,6 +375,7 @@
        </receiver>

        <service android:name=".ImageWallpaper"
                android:singleUser="true"
                android:permission="android.permission.BIND_WALLPAPER"
                android:exported="true" />

+1 −0
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ public class ImageWallpaper extends WallpaperService {
            mRenderer = getRendererInstance();
            setFixedSizeAllowed(true);
            updateSurfaceSize();
            setShowForAllUsers(true);

            mRenderer.setOnBitmapChanged(b -> {
                mLocalColorsToAdd.addAll(mColorAreas);
+3 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.app.WallpaperManager;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.os.UserHandle;
import android.util.Log;
import android.util.Size;

@@ -142,7 +143,8 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer {
            mRefCount.incrementAndGet();
            synchronized (mRefCount) {
                if (mBitmap == null) {
                    mBitmap = mWallpaperManager.getBitmap(false /* hardware */);
                    mBitmap = mWallpaperManager.getBitmapAsUser(UserHandle.USER_CURRENT,
                            false /* hardware */);
                    mWcgContent = mWallpaperManager.wallpaperSupportsWcg(
                            WallpaperManager.FLAG_SYSTEM);
                    mWallpaperManager.forgetLoadedWallpaper();