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

Commit 3fa5fe0a authored by Jay Aliomer's avatar Jay Aliomer
Browse files

Revert "Wallpaper Local color sampling"

Revert "Implement local color extraction"

Revert "Implement local color extraction"

Revert submission 13553866-wallpaper-local-color-extraction-sc-dev

Reason for revert: b/180490435 
Reverted Changes:
I5755525f9:Wallpaper Local color sampling
I5487881c0:Implement local color extraction
Icbab7c6c2:Implement local color extraction

Change-Id: I1cf02a24555167165959e5c4f0bd25b655bd6b6e
parent 9c12bcc5
Loading
Loading
Loading
Loading
+0 −27
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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 android.app;

import android.app.WallpaperColors;
import android.graphics.RectF;

/**
 * @hide
 */
oneway interface ILocalWallpaperColorConsumer {
    void onColorsChanged(in RectF area, in WallpaperColors colors);
}
 No newline at end of file
+0 −14
Original line number Diff line number Diff line
@@ -17,11 +17,9 @@
package android.app;

import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.app.IWallpaperManagerCallback;
import android.app.ILocalWallpaperColorConsumer;
import android.app.WallpaperInfo;
import android.content.ComponentName;
import android.app.WallpaperColors;
@@ -163,18 +161,6 @@ interface IWallpaperManager {
     */
    WallpaperColors getWallpaperColors(int which, int userId, int displayId);

    /**
    * @hide
    */
    void removeOnLocalColorsChangedListener(
            in ILocalWallpaperColorConsumer callback, int which, int userId, int displayId);

    /**
    * @hide
    */
    void addOnLocalColorsChangedListener(in ILocalWallpaperColorConsumer callback,
                                    in List<RectF> regions, int which, int userId, int displayId);

    /**
     * Register a callback to receive color updates from a display
     */
+0 −76
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ import android.os.RemoteException;
import android.os.StrictMode;
import android.os.SystemProperties;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
import android.util.Pair;
import android.view.Display;
@@ -108,8 +107,6 @@ public class WallpaperManager {
    private static boolean DEBUG = false;
    private float mWallpaperXStep = -1;
    private float mWallpaperYStep = -1;
    private static final @NonNull RectF LOCAL_COLOR_BOUNDS =
            new RectF(0, 0, 1, 1);

    /** {@hide} */
    private static final String PROP_WALLPAPER = "ro.config.wallpaper";
@@ -312,8 +309,6 @@ public class WallpaperManager {
        private int mCachedWallpaperUserId;
        private Bitmap mDefaultWallpaper;
        private Handler mMainLooperHandler;
        private ArrayMap<LocalWallpaperColorConsumer, ILocalWallpaperColorConsumer>
                mLocalColorCallbacks = new ArrayMap<>();

        Globals(IWallpaperManager service, Looper looper) {
            mService = service;
@@ -355,40 +350,6 @@ public class WallpaperManager {
            }
        }

        private ILocalWallpaperColorConsumer wrap(LocalWallpaperColorConsumer callback) {
            ILocalWallpaperColorConsumer callback2 = new ILocalWallpaperColorConsumer.Stub() {
                @Override
                public void onColorsChanged(RectF area, WallpaperColors colors) {
                    callback.onColorsChanged(area, colors);
                }
            };
            mLocalColorCallbacks.put(callback, callback2);
            return callback2;
        }

        public void addOnColorsChangedListener(@NonNull LocalWallpaperColorConsumer callback,
                @NonNull List<RectF> regions, int which, int userId, int displayId) {
            try {
                mService.addOnLocalColorsChangedListener(wrap(callback) , regions, which,
                                                         userId, displayId);
            } catch (RemoteException e) {
                // Can't get colors, connection lost.
            }
        }

        public void removeOnColorsChangedListener(
                @NonNull LocalWallpaperColorConsumer callback, int which, int userId,
                int displayId) {
            ILocalWallpaperColorConsumer callback2 = mLocalColorCallbacks.remove(callback);
            if (callback2 == null) return;
            try {
                mService.removeOnLocalColorsChangedListener(
                        callback2, which, userId, displayId);
            } catch (RemoteException e) {
                // Can't get colors, connection lost.
            }
        }

        /**
         * Stop listening to wallpaper color events.
         *
@@ -1095,29 +1056,6 @@ public class WallpaperManager {
        return sGlobals.getWallpaperColors(which, userId, mContext.getDisplayId());
    }

    /**
     * @hide
     */
    public void addOnColorsChangedListener(@NonNull LocalWallpaperColorConsumer callback,
            List<RectF> regions) throws IllegalArgumentException {
        for (RectF region : regions) {
            if (!LOCAL_COLOR_BOUNDS.contains(region)) {
                throw new IllegalArgumentException("Regions must be within bounds "
                        + LOCAL_COLOR_BOUNDS);
            }
        }
        sGlobals.addOnColorsChangedListener(callback, regions, FLAG_SYSTEM,
                                                 mContext.getUserId(), mContext.getDisplayId());
    }

    /**
     * @hide
     */
    public void removeOnColorsChangedListener(@NonNull LocalWallpaperColorConsumer callback) {
        sGlobals.removeOnColorsChangedListener(callback, FLAG_SYSTEM, mContext.getUserId(),
                mContext.getDisplayId());
    }

    /**
     * Version of {@link #getWallpaperFile(int)} that can access the wallpaper data
     * for a given user.  The caller must hold the INTERACT_ACROSS_USERS_FULL
@@ -2264,18 +2202,4 @@ public class WallpaperManager {
            onColorsChanged(colors, which);
        }
    }

    /**
     * Callback to update a consumer with a local color change
     * @hide
     */
    public interface LocalWallpaperColorConsumer {

        /**
         * Gets called when a color of an area gets updated
         * @param area
         * @param colors
         */
        void onColorsChanged(RectF area, WallpaperColors colors);
    }
}
+0 −96
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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 android.service.wallpaper;

import android.app.WallpaperColors;
import android.graphics.Bitmap;
import android.graphics.RectF;
import android.util.ArrayMap;
import android.util.ArraySet;

import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;

/**
 * This class represents a page of a launcher page used by the wallpaper
 * @hide
 */
public class EngineWindowPage {
    private Bitmap mScreenShot;
    private volatile long  mLastUpdateTime;
    private Set<RectF> mCallbackAreas = new ArraySet<>();
    private Map<RectF, WallpaperColors> mRectFColors = new ArrayMap<>();

    /** should be locked extrnally */
    public void addArea(RectF area) {
        mCallbackAreas.add(area);
    }

    /** should be locked extrnally */
    public void addWallpaperColors(RectF area, WallpaperColors colors) {
        mCallbackAreas.add(area);
        mRectFColors.put(area, colors);
    }

    /** get screenshot bitmap */
    public Bitmap getBitmap() {
        if (mScreenShot == null || mScreenShot.isRecycled()) return null;
        return mScreenShot;
    }

    /** remove callbacks for an area */
    public void removeArea(RectF area) {
        mCallbackAreas.remove(area);
        mRectFColors.remove(area);
    }

    /** set the last time the screenshot was updated */
    public void setLastUpdateTime(long lastUpdateTime) {
        mLastUpdateTime = lastUpdateTime;
    }

    /** get last screenshot time */
    public long getLastUpdateTime() {
        return mLastUpdateTime;
    }

    /** get colors for an area */
    public WallpaperColors getColors(RectF rect) {
        return mRectFColors.get(rect);
    }

    /** set the new bitmap version */
    public void setBitmap(Bitmap screenShot) {
        mScreenShot = screenShot;
    }

    /** get areas of interest */
    public Set<RectF> getAreas() {
        return mCallbackAreas;
    }

    /** run operations on this page */
    public synchronized void execSync(Consumer<EngineWindowPage> run) {
        run.accept(this);
    }

    /** nullify the area color */
    public void removeColor(RectF colorArea) {
        mRectFColors.remove(colorArea);
    }
}
+0 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package android.service.wallpaper;

import android.graphics.RectF;
import android.os.ParcelFileDescriptor;
import android.service.wallpaper.IWallpaperEngine;
import android.app.WallpaperColors;
@@ -29,5 +28,4 @@ interface IWallpaperConnection {
    void engineShown(IWallpaperEngine engine);
    ParcelFileDescriptor setWallpaper(String name);
    void onWallpaperColorsChanged(in WallpaperColors colors, int displayId);
    void onLocalWallpaperColorsChanged(in RectF area, in WallpaperColors colors, int displayId);
}
Loading