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

Commit 4c62fc0e authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Very primitive wallpapers in a surface.

This is all of the basic pieces:

- The WallpaperService now creates a surface with the window manager for its
  contents.
- There is a simple service that displays a bitmap.
- The wallpaper manager takes care of starting and stopping the service.
- The window manager knows about wallpaper windows and how to layer them with
  the windows that want to be shown on top of wallpaper.

Lots and lots of issues remain, but at this point you can actually write a
wallpaper service, select it in the UI, and see it behind an activity.
parent 542040c5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -114,6 +114,8 @@ LOCAL_SRC_FILES += \
	core/java/android/os/IParentalControlCallback.aidl \
	core/java/android/os/IPermissionController.aidl \
	core/java/android/os/IPowerManager.aidl \
    core/java/android/service/wallpaper/IWallpaperConnection.aidl \
    core/java/android/service/wallpaper/IWallpaperEngine.aidl \
    core/java/android/service/wallpaper/IWallpaperService.aidl \
	core/java/android/text/IClipboard.aidl \
	core/java/android/view/accessibility/IAccessibilityManager.aidl \
+69 −56
Original line number Diff line number Diff line
@@ -177,6 +177,17 @@
 visibility="public"
>
</field>
<field name="BIND_WALLPAPER"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;android.permission.BIND_WALLPAPER&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="BLUETOOTH"
 type="java.lang.String"
 transient="false"
@@ -26763,8 +26774,8 @@
<exception name="IOException" type="java.io.IOException">
</exception>
</method>
<method name="get"
 return="android.graphics.drawable.Drawable"
<method name="getDesiredMinimumHeight"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
@@ -26774,7 +26785,7 @@
 visibility="public"
>
</method>
<method name="getDesiredMinimumHeight"
<method name="getDesiredMinimumWidth"
 return="int"
 abstract="false"
 native="false"
@@ -26785,8 +26796,8 @@
 visibility="public"
>
</method>
<method name="getDesiredMinimumWidth"
 return="int"
<method name="getDrawable"
 return="android.graphics.drawable.Drawable"
 abstract="false"
 native="false"
 synchronized="false"
@@ -26796,7 +26807,20 @@
 visibility="public"
>
</method>
<method name="peek"
<method name="getInstance"
 return="android.app.WallpaperManager"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
</method>
<method name="peekDrawable"
 return="android.graphics.drawable.Drawable"
 abstract="false"
 native="false"
@@ -26807,7 +26831,7 @@
 visibility="public"
>
</method>
<method name="set"
<method name="setBitmap"
 return="void"
 abstract="false"
 native="false"
@@ -26817,12 +26841,12 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="resid" type="int">
<parameter name="bitmap" type="android.graphics.Bitmap">
</parameter>
<exception name="IOException" type="java.io.IOException">
</exception>
</method>
<method name="set"
<method name="setResource"
 return="void"
 abstract="false"
 native="false"
@@ -26832,12 +26856,12 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="bitmap" type="android.graphics.Bitmap">
<parameter name="resid" type="int">
</parameter>
<exception name="IOException" type="java.io.IOException">
</exception>
</method>
<method name="set"
<method name="setStream"
 return="void"
 abstract="false"
 native="false"
@@ -26852,7 +26876,7 @@
<exception name="IOException" type="java.io.IOException">
</exception>
</method>
<method name="setDimensionHints"
<method name="suggestDesiredDimensions"
 return="void"
 abstract="false"
 native="false"
@@ -115993,50 +116017,6 @@
</implements>
</interface>
</package>
<package name="android.service.wallpaper"
>
<class name="WallpaperService"
 extends="android.app.Service"
 abstract="true"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<constructor name="WallpaperService"
 type="android.service.wallpaper.WallpaperService"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</constructor>
<method name="onBind"
 return="android.os.IBinder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="intent" type="android.content.Intent">
</parameter>
</method>
<field name="SERVICE_INTERFACE"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;android.service.wallpaper.WallpaperService&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
</class>
</package>
<package name="android.speech"
>
<class name="RecognizerIntent"
@@ -157363,6 +157343,28 @@
 visibility="public"
>
</field>
<field name="FLAG_SHOW_WALLPAPER"
 type="int"
 transient="false"
 volatile="false"
 value="1048576"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="FLAG_SHOW_WHEN_LOCKED"
 type="int"
 transient="false"
 volatile="false"
 value="524288"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="FLAG_TOUCHABLE_WHEN_WAKING"
 type="int"
 transient="false"
@@ -157913,6 +157915,17 @@
 visibility="public"
>
</field>
<field name="TYPE_WALLPAPER"
 type="int"
 transient="false"
 volatile="false"
 value="2013"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="alpha"
 type="float"
 transient="false"
+4 −4
Original line number Diff line number Diff line
@@ -514,12 +514,12 @@ class ApplicationContext extends Context {
    
    @Override
    public Drawable getWallpaper() {
        return getWallpaperManager().get();
        return getWallpaperManager().getDrawable();
    }

    @Override
    public Drawable peekWallpaper() {
        return getWallpaperManager().peek();
        return getWallpaperManager().peekDrawable();
    }

    @Override
@@ -534,12 +534,12 @@ class ApplicationContext extends Context {

    @Override
    public void setWallpaper(Bitmap bitmap) throws IOException  {
        getWallpaperManager().set(bitmap);
        getWallpaperManager().setBitmap(bitmap);
    }

    @Override
    public void setWallpaper(InputStream data) throws IOException {
        getWallpaperManager().set(data);
        getWallpaperManager().setStream(data);
    }

    @Override
+6 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.app;

import android.os.ParcelFileDescriptor;
import android.app.IWallpaperManagerCallback;
import android.content.ComponentName;

/** @hide */
interface IWallpaperManager {
@@ -27,6 +28,11 @@ interface IWallpaperManager {
     */
    ParcelFileDescriptor setWallpaper(String name);
    
    /**
     * Set the live wallpaper.
     */
    void setWallpaperComponent(in ComponentName name);
    
    /**
     * Get the wallpaper.
     */
+50 −13
Original line number Diff line number Diff line
/*
 * Copyright (C) 2009 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.content.Context;
@@ -21,6 +37,14 @@ public class WallpaperManager {
    private static String TAG = "WallpaperManager";
    private static boolean DEBUG = false;

    /**
     * Launch an activity for the user to pick the current global live
     * wallpaper.
     * @hide
     */
    public static final String ACTION_LIVE_WALLPAPER_CHOOSER
            = "android.service.wallpaper.LIVE_WALLPAPER_CHOOSER";
    
    private final Context mContext;
    
    static class Globals extends IWallpaperManagerCallback.Stub {
@@ -88,13 +112,26 @@ public class WallpaperManager {
    }

    /**
     * Like {@link #peek}, but always returns a valid Drawable.  If
     * Retrieve a WallpaperManager associated with the given Context.
     */
    public static WallpaperManager getInstance(Context context) {
        return (WallpaperManager)context.getSystemService(
                Context.WALLPAPER_SERVICE);
    }
    
    /** @hide */
    public IWallpaperManager getIWallpaperManager() {
        return getGlobals().mService;
    }
    
    /**
     * Like {@link #peekDrawable}, but always returns a valid Drawable.  If
     * no wallpaper is set, the system default wallpaper is returned.
     *
     * @return Returns a Drawable object that will draw the wallpaper.
     */
    public Drawable get() {
        Drawable dr = peek();
    public Drawable getDrawable() {
        Drawable dr = peekDrawable();
        return dr != null ? dr : Resources.getSystem().getDrawable(
                com.android.internal.R.drawable.default_wallpaper);
    }
@@ -108,7 +145,7 @@ public class WallpaperManager {
     * @return Returns a Drawable object that will draw the wallpaper or a
     * null pointer if these is none.
     */
    public Drawable peek() {
    public Drawable peekDrawable() {
        return getGlobals().peekWallpaper(mContext);
    }

@@ -123,7 +160,7 @@ public class WallpaperManager {
     * @throws IOException If an error occurs reverting to the default
     * wallpaper.
     */
    public void set(int resid) throws IOException {
    public void setResource(int resid) throws IOException {
        try {
            Resources resources = mContext.getResources();
            /* Set the wallpaper to the default values */
@@ -154,7 +191,7 @@ public class WallpaperManager {
     * @throws IOException If an error occurs reverting to the default
     * wallpaper.
     */
    public void set(Bitmap bitmap) throws IOException {
    public void setBitmap(Bitmap bitmap) throws IOException {
        try {
            ParcelFileDescriptor fd = getGlobals().mService.setWallpaper(null);
            if (fd == null) {
@@ -185,7 +222,7 @@ public class WallpaperManager {
     * @throws IOException If an error occurs reverting to the default
     * wallpaper.
     */
    public void set(InputStream data) throws IOException {
    public void setStream(InputStream data) throws IOException {
        try {
            ParcelFileDescriptor fd = getGlobals().mService.setWallpaper(null);
            if (fd == null) {
@@ -215,8 +252,8 @@ public class WallpaperManager {

    /**
     * Returns the desired minimum width for the wallpaper. Callers of
     * {@link #set(android.graphics.Bitmap)} or
     * {@link #set(java.io.InputStream)} should check this value
     * {@link #setBitmap(android.graphics.Bitmap)} or
     * {@link #setStream(java.io.InputStream)} should check this value
     * beforehand to make sure the supplied wallpaper respects the desired
     * minimum width.
     *
@@ -238,8 +275,8 @@ public class WallpaperManager {

    /**
     * Returns the desired minimum height for the wallpaper. Callers of
     * {@link #set(android.graphics.Bitmap)} or
     * {@link #set(java.io.InputStream)} should check this value
     * {@link #setBitmap(android.graphics.Bitmap)} or
     * {@link #setStream(java.io.InputStream)} should check this value
     * beforehand to make sure the supplied wallpaper respects the desired
     * minimum height.
     *
@@ -267,7 +304,7 @@ public class WallpaperManager {
     * @param minimumWidth Desired minimum width
     * @param minimumHeight Desired minimum height
     */
    public void setDimensionHints(int minimumWidth, int minimumHeight) {
    public void suggestDesiredDimensions(int minimumWidth, int minimumHeight) {
        try {
            getGlobals().mService.setDimensionHints(minimumWidth, minimumHeight);
        } catch (RemoteException e) {
@@ -283,6 +320,6 @@ public class WallpaperManager {
     * wallpaper.
     */
    public void clear() throws IOException {
        set(com.android.internal.R.drawable.default_wallpaper);
        setResource(com.android.internal.R.drawable.default_wallpaper);
    }
}
Loading