Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.service.wallpaper; |
| 18 | |
Santiago Etchebehere | 44a2831 | 2020-01-14 15:27:11 -0800 | [diff] [blame] | 19 | import android.annotation.FloatRange; |
Lucas Dupin | c40608c | 2017-04-14 18:33:08 -0700 | [diff] [blame] | 20 | import android.annotation.Nullable; |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 21 | import android.annotation.SdkConstant; |
| 22 | import android.annotation.SdkConstant.SdkConstantType; |
Lucas Dupin | 4c8c327 | 2018-11-06 17:47:48 -0800 | [diff] [blame] | 23 | import android.annotation.SystemApi; |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 24 | import android.app.Service; |
Lucas Dupin | 84b89d9 | 2017-05-09 12:16:19 -0700 | [diff] [blame] | 25 | import android.app.WallpaperColors; |
Lucas Dupin | 8f09a50 | 2018-07-27 16:47:45 +0800 | [diff] [blame] | 26 | import android.app.WallpaperInfo; |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 27 | import android.app.WallpaperManager; |
Artur Satayev | df43959 | 2019-12-10 17:47:53 +0000 | [diff] [blame] | 28 | import android.compat.annotation.UnsupportedAppUsage; |
wilsonshih | 8ccb9ce | 2018-12-04 11:44:31 +0800 | [diff] [blame] | 29 | import android.content.Context; |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 30 | import android.content.Intent; |
Lucas Dupin | 84b89d9 | 2017-05-09 12:16:19 -0700 | [diff] [blame] | 31 | import android.content.res.TypedArray; |
| 32 | import android.graphics.Bitmap; |
| 33 | import android.graphics.Canvas; |
Mathias Agopian | 62bf4a0 | 2010-09-08 16:32:27 -0700 | [diff] [blame] | 34 | import android.graphics.PixelFormat; |
Valerie Hau | 3036055 | 2020-01-14 16:12:01 -0800 | [diff] [blame] | 35 | import android.graphics.Point; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 36 | import android.graphics.Rect; |
Lucas Dupin | 84b89d9 | 2017-05-09 12:16:19 -0700 | [diff] [blame] | 37 | import android.graphics.drawable.Drawable; |
Jeff Brown | 3d110b2 | 2014-11-21 19:01:13 -0800 | [diff] [blame] | 38 | import android.hardware.display.DisplayManager; |
| 39 | import android.hardware.display.DisplayManager.DisplayListener; |
Mathew Inwood | 31755f9 | 2018-12-20 13:53:36 +0000 | [diff] [blame] | 40 | import android.os.Build; |
Dianne Hackborn | 7580493 | 2009-10-20 20:15:20 -0700 | [diff] [blame] | 41 | import android.os.Bundle; |
Lucas Dupin | 65b4765 | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 42 | import android.os.Handler; |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 43 | import android.os.IBinder; |
Dianne Hackborn | 19382ac | 2009-09-11 21:13:37 -0700 | [diff] [blame] | 44 | import android.os.Looper; |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 45 | import android.os.Message; |
| 46 | import android.os.RemoteException; |
Lucas Dupin | 65b4765 | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 47 | import android.os.SystemClock; |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 48 | import android.util.Log; |
Lucas Dupin | 84b89d9 | 2017-05-09 12:16:19 -0700 | [diff] [blame] | 49 | import android.util.MergedConfiguration; |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 50 | import android.view.Display; |
Adrian Roos | 5c6b622 | 2017-11-07 17:36:10 +0100 | [diff] [blame] | 51 | import android.view.DisplayCutout; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 52 | import android.view.Gravity; |
| 53 | import android.view.IWindowSession; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 54 | import android.view.InputChannel; |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 55 | import android.view.InputDevice; |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 56 | import android.view.InputEvent; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 57 | import android.view.InputEventReceiver; |
Tiger Huang | 0426a33 | 2020-03-29 01:17:08 +0800 | [diff] [blame^] | 58 | import android.view.InsetsSourceControl; |
wilsonshih | 8ccb9ce | 2018-12-04 11:44:31 +0800 | [diff] [blame] | 59 | import android.view.InsetsState; |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 60 | import android.view.MotionEvent; |
Robert Carr | 5fea55b | 2018-12-10 13:05:52 -0800 | [diff] [blame] | 61 | import android.view.SurfaceControl; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 62 | import android.view.SurfaceHolder; |
| 63 | import android.view.View; |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 64 | import android.view.ViewGroup; |
Lucas Dupin | 84b89d9 | 2017-05-09 12:16:19 -0700 | [diff] [blame] | 65 | import android.view.WindowInsets; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 66 | import android.view.WindowManager; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 67 | import android.view.WindowManagerGlobal; |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 68 | |
Lucas Dupin | 65b4765 | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 69 | import com.android.internal.annotations.VisibleForTesting; |
Lucas Dupin | 84b89d9 | 2017-05-09 12:16:19 -0700 | [diff] [blame] | 70 | import com.android.internal.os.HandlerCaller; |
| 71 | import com.android.internal.view.BaseIWindow; |
| 72 | import com.android.internal.view.BaseSurfaceHolder; |
| 73 | |
Dianne Hackborn | 527de8e | 2011-08-22 16:10:36 -0700 | [diff] [blame] | 74 | import java.io.FileDescriptor; |
| 75 | import java.io.PrintWriter; |
Dianne Hackborn | af1f42b | 2009-11-20 16:27:27 -0800 | [diff] [blame] | 76 | import java.util.ArrayList; |
wilsonshih | b72ff9c | 2019-03-21 17:27:02 +0800 | [diff] [blame] | 77 | import java.util.concurrent.atomic.AtomicBoolean; |
Lucas Dupin | 65b4765 | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 78 | import java.util.function.Supplier; |
Dianne Hackborn | af1f42b | 2009-11-20 16:27:27 -0800 | [diff] [blame] | 79 | |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 80 | /** |
| 81 | * A wallpaper service is responsible for showing a live wallpaper behind |
Dianne Hackborn | 23ef7b4 | 2009-11-18 18:20:39 -0800 | [diff] [blame] | 82 | * applications that would like to sit on top of it. This service object |
| 83 | * itself does very little -- its only purpose is to generate instances of |
Dianne Hackborn | e4260f4 | 2009-11-18 21:15:59 -0800 | [diff] [blame] | 84 | * {@link Engine} as needed. Implementing a wallpaper thus |
Dianne Hackborn | 23ef7b4 | 2009-11-18 18:20:39 -0800 | [diff] [blame] | 85 | * involves subclassing from this, subclassing an Engine implementation, |
| 86 | * and implementing {@link #onCreateEngine()} to return a new instance of |
| 87 | * your engine. |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 88 | */ |
| 89 | public abstract class WallpaperService extends Service { |
| 90 | /** |
| 91 | * The {@link Intent} that must be declared as handled by the service. |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 92 | * To be supported, the service must also require the |
| 93 | * {@link android.Manifest.permission#BIND_WALLPAPER} permission so |
| 94 | * that other applications can not abuse it. |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 95 | */ |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 96 | @SdkConstant(SdkConstantType.SERVICE_ACTION) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 97 | public static final String SERVICE_INTERFACE = |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 98 | "android.service.wallpaper.WallpaperService"; |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 99 | |
Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 100 | /** |
| 101 | * Name under which a WallpaperService component publishes information |
| 102 | * about itself. This meta-data must reference an XML resource containing |
| 103 | * a <code><{@link android.R.styleable#Wallpaper wallpaper}></code> |
| 104 | * tag. |
| 105 | */ |
| 106 | public static final String SERVICE_META_DATA = "android.service.wallpaper"; |
Craig Mautner | b1ef369 | 2012-11-16 17:31:04 -0800 | [diff] [blame] | 107 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 108 | static final String TAG = "WallpaperService"; |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 109 | static final boolean DEBUG = false; |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 110 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 111 | private static final int DO_ATTACH = 10; |
| 112 | private static final int DO_DETACH = 20; |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 113 | private static final int DO_SET_DESIRED_SIZE = 30; |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 114 | private static final int DO_SET_DISPLAY_PADDING = 40; |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 115 | private static final int DO_IN_AMBIENT_MODE = 50; |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 116 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 117 | private static final int MSG_UPDATE_SURFACE = 10000; |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 118 | private static final int MSG_VISIBILITY_CHANGED = 10010; |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 119 | private static final int MSG_WALLPAPER_OFFSETS = 10020; |
Dianne Hackborn | 7580493 | 2009-10-20 20:15:20 -0700 | [diff] [blame] | 120 | private static final int MSG_WALLPAPER_COMMAND = 10025; |
Mathew Inwood | e380737 | 2018-08-10 09:51:03 +0100 | [diff] [blame] | 121 | @UnsupportedAppUsage |
Dianne Hackborn | 7341d7a | 2009-08-14 11:37:52 -0700 | [diff] [blame] | 122 | private static final int MSG_WINDOW_RESIZED = 10030; |
Craig Mautner | 5702d4d | 2012-06-30 14:10:16 -0700 | [diff] [blame] | 123 | private static final int MSG_WINDOW_MOVED = 10035; |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 124 | private static final int MSG_TOUCH_EVENT = 10040; |
Lucas Dupin | 50ba991 | 2017-07-14 11:55:05 -0700 | [diff] [blame] | 125 | private static final int MSG_REQUEST_WALLPAPER_COLORS = 10050; |
Santiago Etchebehere | 44a2831 | 2020-01-14 15:27:11 -0800 | [diff] [blame] | 126 | private static final int MSG_SCALE = 10100; |
| 127 | |
Lucas Dupin | 65b4765 | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 128 | private static final int NOTIFY_COLORS_RATE_LIMIT_MS = 1000; |
| 129 | |
Dianne Hackborn | af1f42b | 2009-11-20 16:27:27 -0800 | [diff] [blame] | 130 | private final ArrayList<Engine> mActiveEngines |
| 131 | = new ArrayList<Engine>(); |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 132 | |
Dianne Hackborn | 7580493 | 2009-10-20 20:15:20 -0700 | [diff] [blame] | 133 | static final class WallpaperCommand { |
| 134 | String action; |
| 135 | int x; |
| 136 | int y; |
| 137 | int z; |
| 138 | Bundle extras; |
| 139 | boolean sync; |
| 140 | } |
wilsonshih | 81e10a7 | 2018-11-15 10:54:21 +0800 | [diff] [blame] | 141 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 142 | /** |
| 143 | * The actual implementation of a wallpaper. A wallpaper service may |
| 144 | * have multiple instances running (for example as a real wallpaper |
| 145 | * and as a preview), each of which is represented by its own Engine |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 146 | * instance. You must implement {@link WallpaperService#onCreateEngine()} |
| 147 | * to return your concrete Engine implementation. |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 148 | */ |
| 149 | public class Engine { |
| 150 | IWallpaperEngineWrapper mIWallpaperEngine; |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 151 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 152 | // Copies from mIWallpaperEngine. |
| 153 | HandlerCaller mCaller; |
| 154 | IWallpaperConnection mConnection; |
| 155 | IBinder mWindowToken; |
wilsonshih | 81e10a7 | 2018-11-15 10:54:21 +0800 | [diff] [blame] | 156 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 157 | boolean mInitializing = true; |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 158 | boolean mVisible; |
Dianne Hackborn | bcbcaa7 | 2009-09-10 10:54:46 -0700 | [diff] [blame] | 159 | boolean mReportedVisible; |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 160 | boolean mDestroyed; |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 161 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 162 | // Current window state. |
| 163 | boolean mCreated; |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 164 | boolean mSurfaceCreated; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 165 | boolean mIsCreating; |
| 166 | boolean mDrawingAllowed; |
Dianne Hackborn | 9e4e727 | 2011-08-30 14:06:51 -0700 | [diff] [blame] | 167 | boolean mOffsetsChanged; |
Jeff Sharkey | 35be756 | 2012-04-18 19:16:15 -0700 | [diff] [blame] | 168 | boolean mFixedSizeAllowed; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 169 | int mWidth; |
| 170 | int mHeight; |
| 171 | int mFormat; |
| 172 | int mType; |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 173 | int mCurWidth; |
| 174 | int mCurHeight; |
Santiago Etchebehere | 44a2831 | 2020-01-14 15:27:11 -0800 | [diff] [blame] | 175 | float mZoom = 0f; |
Lucas Dupin | 6155aa4 | 2018-09-05 11:15:52 -0700 | [diff] [blame] | 176 | int mWindowFlags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; |
Chet Haase | a8e5a2b | 2011-10-28 13:18:16 -0700 | [diff] [blame] | 177 | int mWindowPrivateFlags = |
| 178 | WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS; |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 179 | int mCurWindowFlags = mWindowFlags; |
Chet Haase | a8e5a2b | 2011-10-28 13:18:16 -0700 | [diff] [blame] | 180 | int mCurWindowPrivateFlags = mWindowPrivateFlags; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 181 | final Rect mVisibleInsets = new Rect(); |
| 182 | final Rect mWinFrame = new Rect(); |
| 183 | final Rect mContentInsets = new Rect(); |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 184 | final Rect mStableInsets = new Rect(); |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 185 | final Rect mDispatchedContentInsets = new Rect(); |
| 186 | final Rect mDispatchedStableInsets = new Rect(); |
| 187 | final Rect mFinalSystemInsets = new Rect(); |
| 188 | final Rect mFinalStableInsets = new Rect(); |
Jorim Jaggi | 2e95a48 | 2016-01-14 17:36:55 -0800 | [diff] [blame] | 189 | final Rect mBackdropFrame = new Rect(); |
Adrian Roos | 5c6b622 | 2017-11-07 17:36:10 +0100 | [diff] [blame] | 190 | final DisplayCutout.ParcelableWrapper mDisplayCutout = |
| 191 | new DisplayCutout.ParcelableWrapper(); |
| 192 | DisplayCutout mDispatchedDisplayCutout = DisplayCutout.NO_CUTOUT; |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 193 | final InsetsState mInsetsState = new InsetsState(); |
Tiger Huang | 0426a33 | 2020-03-29 01:17:08 +0800 | [diff] [blame^] | 194 | final InsetsSourceControl[] mTempControls = new InsetsSourceControl[0]; |
Andrii Kulian | 4460796 | 2017-03-16 11:06:24 -0700 | [diff] [blame] | 195 | final MergedConfiguration mMergedConfiguration = new MergedConfiguration(); |
Valerie Hau | 3036055 | 2020-01-14 16:12:01 -0800 | [diff] [blame] | 196 | private final Point mSurfaceSize = new Point(); |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 197 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 198 | final WindowManager.LayoutParams mLayout |
| 199 | = new WindowManager.LayoutParams(); |
| 200 | IWindowSession mSession; |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 201 | |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 202 | final Object mLock = new Object(); |
| 203 | boolean mOffsetMessageEnqueued; |
Mathew Inwood | 31755f9 | 2018-12-20 13:53:36 +0000 | [diff] [blame] | 204 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 205 | float mPendingXOffset; |
| 206 | float mPendingYOffset; |
Marco Nelissen | bf6956b | 2009-11-09 15:21:13 -0800 | [diff] [blame] | 207 | float mPendingXOffsetStep; |
| 208 | float mPendingYOffsetStep; |
Dianne Hackborn | 19382ac | 2009-09-11 21:13:37 -0700 | [diff] [blame] | 209 | boolean mPendingSync; |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 210 | MotionEvent mPendingMove; |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 211 | boolean mIsInAmbientMode; |
Jeff Brown | 3d110b2 | 2014-11-21 19:01:13 -0800 | [diff] [blame] | 212 | |
Lucas Dupin | 65b4765 | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 213 | // Needed for throttling onComputeColors. |
| 214 | private long mLastColorInvalidation; |
| 215 | private final Runnable mNotifyColorsChanged = this::notifyColorsChanged; |
Lucas Dupin | 416fe95 | 2017-08-14 10:58:40 -0700 | [diff] [blame] | 216 | private final Supplier<Long> mClockFunction; |
| 217 | private final Handler mHandler; |
Lucas Dupin | 65b4765 | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 218 | |
wilsonshih | 8ccb9ce | 2018-12-04 11:44:31 +0800 | [diff] [blame] | 219 | private Display mDisplay; |
| 220 | private Context mDisplayContext; |
Filip Gruszczynski | 4544b92 | 2015-04-16 13:18:58 -0700 | [diff] [blame] | 221 | private int mDisplayState; |
Jeff Brown | 3d110b2 | 2014-11-21 19:01:13 -0800 | [diff] [blame] | 222 | |
Robert Carr | 5fea55b | 2018-12-10 13:05:52 -0800 | [diff] [blame] | 223 | SurfaceControl mSurfaceControl = new SurfaceControl(); |
| 224 | |
Robert Carr | 2e20bcd | 2020-01-22 13:32:38 -0800 | [diff] [blame] | 225 | // Unused relayout out-param |
| 226 | SurfaceControl mTmpSurfaceControl = new SurfaceControl(); |
| 227 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 228 | final BaseSurfaceHolder mSurfaceHolder = new BaseSurfaceHolder() { |
Mathias Agopian | 62bf4a0 | 2010-09-08 16:32:27 -0700 | [diff] [blame] | 229 | { |
Jeff Brown | 2457237 | 2011-06-09 19:05:15 -0700 | [diff] [blame] | 230 | mRequestedFormat = PixelFormat.RGBX_8888; |
Mathias Agopian | 62bf4a0 | 2010-09-08 16:32:27 -0700 | [diff] [blame] | 231 | } |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 232 | |
| 233 | @Override |
| 234 | public boolean onAllowLockCanvas() { |
| 235 | return mDrawingAllowed; |
| 236 | } |
| 237 | |
| 238 | @Override |
| 239 | public void onRelayoutContainer() { |
| 240 | Message msg = mCaller.obtainMessage(MSG_UPDATE_SURFACE); |
| 241 | mCaller.sendMessage(msg); |
| 242 | } |
| 243 | |
| 244 | @Override |
| 245 | public void onUpdateSurface() { |
| 246 | Message msg = mCaller.obtainMessage(MSG_UPDATE_SURFACE); |
| 247 | mCaller.sendMessage(msg); |
| 248 | } |
| 249 | |
| 250 | public boolean isCreating() { |
| 251 | return mIsCreating; |
| 252 | } |
| 253 | |
Dianne Hackborn | a48a37f | 2011-02-01 16:30:38 -0800 | [diff] [blame] | 254 | @Override |
| 255 | public void setFixedSize(int width, int height) { |
Jeff Sharkey | 35be756 | 2012-04-18 19:16:15 -0700 | [diff] [blame] | 256 | if (!mFixedSizeAllowed) { |
Dianne Hackborn | a48a37f | 2011-02-01 16:30:38 -0800 | [diff] [blame] | 257 | // Regular apps can't do this. It can only work for |
| 258 | // certain designs of window animations, so you can't |
| 259 | // rely on it. |
| 260 | throw new UnsupportedOperationException( |
| 261 | "Wallpapers currently only support sizing from layout"); |
| 262 | } |
Michael Jurka | b8f939f | 2011-02-01 20:50:30 -0800 | [diff] [blame] | 263 | super.setFixedSize(width, height); |
Dianne Hackborn | a48a37f | 2011-02-01 16:30:38 -0800 | [diff] [blame] | 264 | } |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 265 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 266 | public void setKeepScreenOn(boolean screenOn) { |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 267 | throw new UnsupportedOperationException( |
| 268 | "Wallpapers do not support keep screen on"); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 269 | } |
Filip Gruszczynski | 4544b92 | 2015-04-16 13:18:58 -0700 | [diff] [blame] | 270 | |
John Reck | 6bc7014 | 2016-10-26 16:49:17 -0700 | [diff] [blame] | 271 | private void prepareToDraw() { |
Filip Gruszczynski | 4544b92 | 2015-04-16 13:18:58 -0700 | [diff] [blame] | 272 | if (mDisplayState == Display.STATE_DOZE |
| 273 | || mDisplayState == Display.STATE_DOZE_SUSPEND) { |
| 274 | try { |
| 275 | mSession.pokeDrawLock(mWindow); |
| 276 | } catch (RemoteException e) { |
| 277 | // System server died, can be ignored. |
| 278 | } |
| 279 | } |
John Reck | 6bc7014 | 2016-10-26 16:49:17 -0700 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | @Override |
| 283 | public Canvas lockCanvas() { |
| 284 | prepareToDraw(); |
Filip Gruszczynski | 4544b92 | 2015-04-16 13:18:58 -0700 | [diff] [blame] | 285 | return super.lockCanvas(); |
| 286 | } |
John Reck | 6bc7014 | 2016-10-26 16:49:17 -0700 | [diff] [blame] | 287 | |
| 288 | @Override |
| 289 | public Canvas lockCanvas(Rect dirty) { |
| 290 | prepareToDraw(); |
| 291 | return super.lockCanvas(dirty); |
| 292 | } |
| 293 | |
| 294 | @Override |
| 295 | public Canvas lockHardwareCanvas() { |
| 296 | prepareToDraw(); |
| 297 | return super.lockHardwareCanvas(); |
| 298 | } |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 299 | }; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 300 | |
| 301 | final class WallpaperInputEventReceiver extends InputEventReceiver { |
| 302 | public WallpaperInputEventReceiver(InputChannel inputChannel, Looper looper) { |
| 303 | super(inputChannel, looper); |
| 304 | } |
| 305 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 306 | @Override |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 307 | public void onInputEvent(InputEvent event) { |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 308 | boolean handled = false; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 309 | try { |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 310 | if (event instanceof MotionEvent |
| 311 | && (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 312 | MotionEvent dup = MotionEvent.obtainNoHistory((MotionEvent)event); |
| 313 | dispatchPointer(dup); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 314 | handled = true; |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 315 | } |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 316 | } finally { |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 317 | finishInputEvent(event, handled); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 318 | } |
| 319 | } |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 320 | } |
| 321 | WallpaperInputEventReceiver mInputEventReceiver; |
| 322 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 323 | final BaseIWindow mWindow = new BaseIWindow() { |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 324 | @Override |
Jorim Jaggi | f081f06 | 2019-10-24 16:24:54 +0200 | [diff] [blame] | 325 | public void resized(Rect frame, Rect contentInsets, |
| 326 | Rect visibleInsets, Rect stableInsets, boolean reportDraw, |
Andrii Kulian | 4460796 | 2017-03-16 11:06:24 -0700 | [diff] [blame] | 327 | MergedConfiguration mergedConfiguration, Rect backDropRect, boolean forceLayout, |
Brad Stenning | e057369 | 2019-03-11 13:52:46 -0700 | [diff] [blame] | 328 | boolean alwaysConsumeSystemBars, int displayId, |
Adrian Roos | 5c6b622 | 2017-11-07 17:36:10 +0100 | [diff] [blame] | 329 | DisplayCutout.ParcelableWrapper displayCutout) { |
Jorim Jaggi | f081f06 | 2019-10-24 16:24:54 +0200 | [diff] [blame] | 330 | Message msg = mCaller.obtainMessageI(MSG_WINDOW_RESIZED, |
| 331 | reportDraw ? 1 : 0); |
Dianne Hackborn | 7341d7a | 2009-08-14 11:37:52 -0700 | [diff] [blame] | 332 | mCaller.sendMessage(msg); |
| 333 | } |
Craig Mautner | 5702d4d | 2012-06-30 14:10:16 -0700 | [diff] [blame] | 334 | |
| 335 | @Override |
| 336 | public void moved(int newX, int newY) { |
| 337 | Message msg = mCaller.obtainMessageII(MSG_WINDOW_MOVED, newX, newY); |
| 338 | mCaller.sendMessage(msg); |
| 339 | } |
| 340 | |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 341 | @Override |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 342 | public void dispatchAppVisibility(boolean visible) { |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 343 | // We don't do this in preview mode; we'll let the preview |
| 344 | // activity tell us when to run. |
| 345 | if (!mIWallpaperEngine.mIsPreview) { |
| 346 | Message msg = mCaller.obtainMessageI(MSG_VISIBILITY_CHANGED, |
| 347 | visible ? 1 : 0); |
| 348 | mCaller.sendMessage(msg); |
| 349 | } |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 350 | } |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 351 | |
| 352 | @Override |
Marco Nelissen | bf6956b | 2009-11-09 15:21:13 -0800 | [diff] [blame] | 353 | public void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep, |
Lucas Dupin | 13f4b8a | 2020-02-19 13:41:52 -0800 | [diff] [blame] | 354 | float zoom, boolean sync) { |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 355 | synchronized (mLock) { |
Dianne Hackborn | 19382ac | 2009-09-11 21:13:37 -0700 | [diff] [blame] | 356 | if (DEBUG) Log.v(TAG, "Dispatch wallpaper offsets: " + x + ", " + y); |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 357 | mPendingXOffset = x; |
| 358 | mPendingYOffset = y; |
Marco Nelissen | bf6956b | 2009-11-09 15:21:13 -0800 | [diff] [blame] | 359 | mPendingXOffsetStep = xStep; |
| 360 | mPendingYOffsetStep = yStep; |
Dianne Hackborn | 19382ac | 2009-09-11 21:13:37 -0700 | [diff] [blame] | 361 | if (sync) { |
| 362 | mPendingSync = true; |
| 363 | } |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 364 | if (!mOffsetMessageEnqueued) { |
| 365 | mOffsetMessageEnqueued = true; |
| 366 | Message msg = mCaller.obtainMessage(MSG_WALLPAPER_OFFSETS); |
| 367 | mCaller.sendMessage(msg); |
| 368 | } |
Lucas Dupin | 13f4b8a | 2020-02-19 13:41:52 -0800 | [diff] [blame] | 369 | Message msg = mCaller.obtainMessageI(MSG_SCALE, Float.floatToIntBits(zoom)); |
| 370 | mCaller.sendMessage(msg); |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 371 | } |
| 372 | } |
Craig Mautner | 5702d4d | 2012-06-30 14:10:16 -0700 | [diff] [blame] | 373 | |
| 374 | @Override |
Dianne Hackborn | 7580493 | 2009-10-20 20:15:20 -0700 | [diff] [blame] | 375 | public void dispatchWallpaperCommand(String action, int x, int y, |
| 376 | int z, Bundle extras, boolean sync) { |
| 377 | synchronized (mLock) { |
| 378 | if (DEBUG) Log.v(TAG, "Dispatch wallpaper command: " + x + ", " + y); |
| 379 | WallpaperCommand cmd = new WallpaperCommand(); |
| 380 | cmd.action = action; |
| 381 | cmd.x = x; |
| 382 | cmd.y = y; |
| 383 | cmd.z = z; |
| 384 | cmd.extras = extras; |
| 385 | cmd.sync = sync; |
| 386 | Message msg = mCaller.obtainMessage(MSG_WALLPAPER_COMMAND); |
| 387 | msg.obj = cmd; |
| 388 | mCaller.sendMessage(msg); |
| 389 | } |
| 390 | } |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 391 | }; |
Lucas Dupin | 416fe95 | 2017-08-14 10:58:40 -0700 | [diff] [blame] | 392 | |
| 393 | /** |
| 394 | * Default constructor |
| 395 | */ |
| 396 | public Engine() { |
| 397 | this(SystemClock::elapsedRealtime, Handler.getMain()); |
| 398 | } |
| 399 | |
| 400 | /** |
| 401 | * Constructor used for test purposes. |
| 402 | * |
| 403 | * @param clockFunction Supplies current times in millis. |
| 404 | * @param handler Used for posting/deferring asynchronous calls. |
| 405 | * @hide |
| 406 | */ |
| 407 | @VisibleForTesting |
| 408 | public Engine(Supplier<Long> clockFunction, Handler handler) { |
| 409 | mClockFunction = clockFunction; |
| 410 | mHandler = handler; |
| 411 | } |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 412 | |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 413 | /** |
| 414 | * Provides access to the surface in which this wallpaper is drawn. |
| 415 | */ |
| 416 | public SurfaceHolder getSurfaceHolder() { |
| 417 | return mSurfaceHolder; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 418 | } |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 419 | |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 420 | /** |
| 421 | * Convenience for {@link WallpaperManager#getDesiredMinimumWidth() |
| 422 | * WallpaperManager.getDesiredMinimumWidth()}, returning the width |
| 423 | * that the system would like this wallpaper to run in. |
| 424 | */ |
| 425 | public int getDesiredMinimumWidth() { |
| 426 | return mIWallpaperEngine.mReqWidth; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 427 | } |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 428 | |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 429 | /** |
| 430 | * Convenience for {@link WallpaperManager#getDesiredMinimumHeight() |
| 431 | * WallpaperManager.getDesiredMinimumHeight()}, returning the height |
| 432 | * that the system would like this wallpaper to run in. |
| 433 | */ |
| 434 | public int getDesiredMinimumHeight() { |
| 435 | return mIWallpaperEngine.mReqHeight; |
| 436 | } |
wilsonshih | 81e10a7 | 2018-11-15 10:54:21 +0800 | [diff] [blame] | 437 | |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 438 | /** |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 439 | * Return whether the wallpaper is currently visible to the user, |
| 440 | * this is the last value supplied to |
| 441 | * {@link #onVisibilityChanged(boolean)}. |
| 442 | */ |
| 443 | public boolean isVisible() { |
Dianne Hackborn | bcbcaa7 | 2009-09-10 10:54:46 -0700 | [diff] [blame] | 444 | return mReportedVisible; |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 445 | } |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 446 | |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 447 | /** |
Dianne Hackborn | 3be63c0 | 2009-08-20 19:31:38 -0700 | [diff] [blame] | 448 | * Returns true if this engine is running in preview mode -- that is, |
| 449 | * it is being shown to the user before they select it as the actual |
| 450 | * wallpaper. |
| 451 | */ |
| 452 | public boolean isPreview() { |
| 453 | return mIWallpaperEngine.mIsPreview; |
| 454 | } |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 455 | |
| 456 | /** |
| 457 | * Returns true if this engine is running in ambient mode -- that is, |
Lucas Dupin | 8f09a50 | 2018-07-27 16:47:45 +0800 | [diff] [blame] | 458 | * it is being shown in low power mode, on always on display. |
Lucas Dupin | 4c8c327 | 2018-11-06 17:47:48 -0800 | [diff] [blame] | 459 | * @hide |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 460 | */ |
Lucas Dupin | 4c8c327 | 2018-11-06 17:47:48 -0800 | [diff] [blame] | 461 | @SystemApi |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 462 | public boolean isInAmbientMode() { |
| 463 | return mIsInAmbientMode; |
| 464 | } |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 465 | |
Dianne Hackborn | 3be63c0 | 2009-08-20 19:31:38 -0700 | [diff] [blame] | 466 | /** |
Lucas Dupin | 13f4b8a | 2020-02-19 13:41:52 -0800 | [diff] [blame] | 467 | * This will be called when the wallpaper is first started. If true is returned, the system |
| 468 | * will zoom in the wallpaper by default and zoom it out as the user interacts, |
| 469 | * to create depth. Otherwise, zoom will have to be handled manually |
| 470 | * in {@link #onZoomChanged(float)}. |
| 471 | * |
| 472 | * @hide |
| 473 | */ |
| 474 | public boolean shouldZoomOutWallpaper() { |
| 475 | return false; |
| 476 | } |
| 477 | |
| 478 | /** |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 479 | * Control whether this wallpaper will receive raw touch events |
| 480 | * from the window manager as the user interacts with the window |
| 481 | * that is currently displaying the wallpaper. By default they |
| 482 | * are turned off. If enabled, the events will be received in |
| 483 | * {@link #onTouchEvent(MotionEvent)}. |
| 484 | */ |
| 485 | public void setTouchEventsEnabled(boolean enabled) { |
| 486 | mWindowFlags = enabled |
| 487 | ? (mWindowFlags&~WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE) |
| 488 | : (mWindowFlags|WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); |
| 489 | if (mCreated) { |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 490 | updateSurface(false, false, false); |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 491 | } |
| 492 | } |
Chet Haase | a8e5a2b | 2011-10-28 13:18:16 -0700 | [diff] [blame] | 493 | |
| 494 | /** |
| 495 | * Control whether this wallpaper will receive notifications when the wallpaper |
| 496 | * has been scrolled. By default, wallpapers will receive notifications, although |
| 497 | * the default static image wallpapers do not. It is a performance optimization to |
| 498 | * set this to false. |
| 499 | * |
| 500 | * @param enabled whether the wallpaper wants to receive offset notifications |
| 501 | */ |
| 502 | public void setOffsetNotificationsEnabled(boolean enabled) { |
| 503 | mWindowPrivateFlags = enabled |
| 504 | ? (mWindowPrivateFlags | |
| 505 | WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS) |
| 506 | : (mWindowPrivateFlags & |
| 507 | ~WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS); |
| 508 | if (mCreated) { |
| 509 | updateSurface(false, false, false); |
| 510 | } |
| 511 | } |
Jeff Sharkey | 35be756 | 2012-04-18 19:16:15 -0700 | [diff] [blame] | 512 | |
| 513 | /** {@hide} */ |
Mathew Inwood | e380737 | 2018-08-10 09:51:03 +0100 | [diff] [blame] | 514 | @UnsupportedAppUsage |
Jeff Sharkey | 35be756 | 2012-04-18 19:16:15 -0700 | [diff] [blame] | 515 | public void setFixedSizeAllowed(boolean allowed) { |
| 516 | mFixedSizeAllowed = allowed; |
| 517 | } |
| 518 | |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 519 | /** |
Santiago Etchebehere | 44a2831 | 2020-01-14 15:27:11 -0800 | [diff] [blame] | 520 | * Returns the current scale of the surface |
| 521 | * @hide |
| 522 | */ |
| 523 | @VisibleForTesting |
| 524 | public float getZoom() { |
| 525 | return mZoom; |
| 526 | } |
| 527 | |
| 528 | /** |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 529 | * Called once to initialize the engine. After returning, the |
| 530 | * engine's surface will be created by the framework. |
| 531 | */ |
| 532 | public void onCreate(SurfaceHolder surfaceHolder) { |
| 533 | } |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 534 | |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 535 | /** |
| 536 | * Called right before the engine is going away. After this the |
| 537 | * surface will be destroyed and this Engine object is no longer |
| 538 | * valid. |
| 539 | */ |
| 540 | public void onDestroy() { |
| 541 | } |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 542 | |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 543 | /** |
| 544 | * Called to inform you of the wallpaper becoming visible or |
| 545 | * hidden. <em>It is very important that a wallpaper only use |
| 546 | * CPU while it is visible.</em>. |
| 547 | */ |
| 548 | public void onVisibilityChanged(boolean visible) { |
| 549 | } |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 550 | |
| 551 | /** |
| 552 | * Called with the current insets that are in effect for the wallpaper. |
| 553 | * This gives you the part of the overall wallpaper surface that will |
| 554 | * generally be visible to the user (ignoring position offsets applied to it). |
| 555 | * |
| 556 | * @param insets Insets to apply. |
| 557 | */ |
| 558 | public void onApplyWindowInsets(WindowInsets insets) { |
| 559 | } |
| 560 | |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 561 | /** |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 562 | * Called as the user performs touch-screen interaction with the |
| 563 | * window that is currently showing this wallpaper. Note that the |
| 564 | * events you receive here are driven by the actual application the |
Marco Nelissen | ae87bd0 | 2009-09-17 09:44:43 -0700 | [diff] [blame] | 565 | * user is interacting with, so if it is slow you will get fewer |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 566 | * move events. |
| 567 | */ |
| 568 | public void onTouchEvent(MotionEvent event) { |
| 569 | } |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 570 | |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 571 | /** |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 572 | * Called to inform you of the wallpaper's offsets changing |
| 573 | * within its contain, corresponding to the container's |
| 574 | * call to {@link WallpaperManager#setWallpaperOffsets(IBinder, float, float) |
| 575 | * WallpaperManager.setWallpaperOffsets()}. |
| 576 | */ |
| 577 | public void onOffsetsChanged(float xOffset, float yOffset, |
Marco Nelissen | bf6956b | 2009-11-09 15:21:13 -0800 | [diff] [blame] | 578 | float xOffsetStep, float yOffsetStep, |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 579 | int xPixelOffset, int yPixelOffset) { |
| 580 | } |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 581 | |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 582 | /** |
Dianne Hackborn | 7580493 | 2009-10-20 20:15:20 -0700 | [diff] [blame] | 583 | * Process a command that was sent to the wallpaper with |
Dianne Hackborn | 13bf8260 | 2009-11-05 21:45:51 -0800 | [diff] [blame] | 584 | * {@link WallpaperManager#sendWallpaperCommand}. |
Dianne Hackborn | 7580493 | 2009-10-20 20:15:20 -0700 | [diff] [blame] | 585 | * The default implementation does nothing, and always returns null |
| 586 | * as the result. |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 587 | * |
Dianne Hackborn | 7580493 | 2009-10-20 20:15:20 -0700 | [diff] [blame] | 588 | * @param action The name of the command to perform. This tells you |
| 589 | * what to do and how to interpret the rest of the arguments. |
| 590 | * @param x Generic integer parameter. |
| 591 | * @param y Generic integer parameter. |
| 592 | * @param z Generic integer parameter. |
| 593 | * @param extras Any additional parameters. |
| 594 | * @param resultRequested If true, the caller is requesting that |
| 595 | * a result, appropriate for the command, be returned back. |
| 596 | * @return If returning a result, create a Bundle and place the |
| 597 | * result data in to it. Otherwise return null. |
| 598 | */ |
| 599 | public Bundle onCommand(String action, int x, int y, int z, |
| 600 | Bundle extras, boolean resultRequested) { |
| 601 | return null; |
| 602 | } |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 603 | |
Dianne Hackborn | 7580493 | 2009-10-20 20:15:20 -0700 | [diff] [blame] | 604 | /** |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 605 | * Called when the device enters or exits ambient mode. |
| 606 | * |
| 607 | * @param inAmbientMode {@code true} if in ambient mode. |
Lucas Dupin | 4c8c327 | 2018-11-06 17:47:48 -0800 | [diff] [blame] | 608 | * @param animationDuration How long the transition animation to change the ambient state |
| 609 | * should run, in milliseconds. If 0 is passed as the argument |
| 610 | * here, the state should be switched immediately. |
Lucas Dupin | 8f09a50 | 2018-07-27 16:47:45 +0800 | [diff] [blame] | 611 | * |
| 612 | * @see #isInAmbientMode() |
| 613 | * @see WallpaperInfo#supportsAmbientMode() |
Lucas Dupin | 4c8c327 | 2018-11-06 17:47:48 -0800 | [diff] [blame] | 614 | * @hide |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 615 | */ |
Lucas Dupin | 4c8c327 | 2018-11-06 17:47:48 -0800 | [diff] [blame] | 616 | @SystemApi |
| 617 | public void onAmbientModeChanged(boolean inAmbientMode, long animationDuration) { |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | /** |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 621 | * Called when an application has changed the desired virtual size of |
| 622 | * the wallpaper. |
| 623 | */ |
| 624 | public void onDesiredSizeChanged(int desiredWidth, int desiredHeight) { |
| 625 | } |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 626 | |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 627 | /** |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 628 | * Convenience for {@link SurfaceHolder.Callback#surfaceChanged |
| 629 | * SurfaceHolder.Callback.surfaceChanged()}. |
| 630 | */ |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 631 | public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) { |
| 632 | } |
| 633 | |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 634 | /** |
Dianne Hackborn | 1d28f9c | 2010-07-13 20:38:06 -0700 | [diff] [blame] | 635 | * Convenience for {@link SurfaceHolder.Callback2#surfaceRedrawNeeded |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 636 | * SurfaceHolder.Callback.surfaceRedrawNeeded()}. |
| 637 | */ |
| 638 | public void onSurfaceRedrawNeeded(SurfaceHolder holder) { |
| 639 | } |
| 640 | |
| 641 | /** |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 642 | * Convenience for {@link SurfaceHolder.Callback#surfaceCreated |
| 643 | * SurfaceHolder.Callback.surfaceCreated()}. |
| 644 | */ |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 645 | public void onSurfaceCreated(SurfaceHolder holder) { |
| 646 | } |
| 647 | |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 648 | /** |
| 649 | * Convenience for {@link SurfaceHolder.Callback#surfaceDestroyed |
| 650 | * SurfaceHolder.Callback.surfaceDestroyed()}. |
| 651 | */ |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 652 | public void onSurfaceDestroyed(SurfaceHolder holder) { |
| 653 | } |
Lucas Dupin | c40608c | 2017-04-14 18:33:08 -0700 | [diff] [blame] | 654 | |
| 655 | /** |
Santiago Etchebehere | 44a2831 | 2020-01-14 15:27:11 -0800 | [diff] [blame] | 656 | * Called when the zoom level of the wallpaper changed. |
| 657 | * This method will be called with the initial zoom level when the surface is created. |
| 658 | * |
| 659 | * @param zoom the zoom level, between 0 indicating fully zoomed in and 1 indicating fully |
| 660 | * zoomed out. |
| 661 | */ |
| 662 | public void onZoomChanged(@FloatRange(from = 0f, to = 1f) float zoom) { |
| 663 | } |
| 664 | |
| 665 | /** |
Lucas Dupin | c40608c | 2017-04-14 18:33:08 -0700 | [diff] [blame] | 666 | * Notifies the engine that wallpaper colors changed significantly. |
Lucas Dupin | 98eabbd | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 667 | * This will trigger a {@link #onComputeColors()} call. |
Lucas Dupin | c40608c | 2017-04-14 18:33:08 -0700 | [diff] [blame] | 668 | */ |
Lucas Dupin | 98eabbd | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 669 | public void notifyColorsChanged() { |
Lucas Dupin | 65b4765 | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 670 | final long now = mClockFunction.get(); |
Lucas Dupin | 65b4765 | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 671 | if (now - mLastColorInvalidation < NOTIFY_COLORS_RATE_LIMIT_MS) { |
| 672 | Log.w(TAG, "This call has been deferred. You should only call " |
| 673 | + "notifyColorsChanged() once every " |
| 674 | + (NOTIFY_COLORS_RATE_LIMIT_MS / 1000f) + " seconds."); |
Lucas Dupin | 416fe95 | 2017-08-14 10:58:40 -0700 | [diff] [blame] | 675 | if (!mHandler.hasCallbacks(mNotifyColorsChanged)) { |
| 676 | mHandler.postDelayed(mNotifyColorsChanged, NOTIFY_COLORS_RATE_LIMIT_MS); |
Lucas Dupin | 65b4765 | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 677 | } |
| 678 | return; |
| 679 | } |
| 680 | mLastColorInvalidation = now; |
Lucas Dupin | 416fe95 | 2017-08-14 10:58:40 -0700 | [diff] [blame] | 681 | mHandler.removeCallbacks(mNotifyColorsChanged); |
Lucas Dupin | 65b4765 | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 682 | |
Lucas Dupin | ea1fb1e | 2017-04-05 17:39:44 -0700 | [diff] [blame] | 683 | try { |
Lucas Dupin | 65b4765 | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 684 | final WallpaperColors newColors = onComputeColors(); |
| 685 | if (mConnection != null) { |
wilsonshih | 36597d4 | 2018-12-05 18:56:39 +0800 | [diff] [blame] | 686 | mConnection.onWallpaperColorsChanged(newColors, mDisplay.getDisplayId()); |
Lucas Dupin | 65b4765 | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 687 | } else { |
| 688 | Log.w(TAG, "Can't notify system because wallpaper connection " |
| 689 | + "was not established."); |
| 690 | } |
Lucas Dupin | ea1fb1e | 2017-04-05 17:39:44 -0700 | [diff] [blame] | 691 | } catch (RemoteException e) { |
Lucas Dupin | 65b4765 | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 692 | Log.w(TAG, "Can't notify system because wallpaper connection was lost.", e); |
Lucas Dupin | ea1fb1e | 2017-04-05 17:39:44 -0700 | [diff] [blame] | 693 | } |
Lucas Dupin | c40608c | 2017-04-14 18:33:08 -0700 | [diff] [blame] | 694 | } |
| 695 | |
| 696 | /** |
Lucas Dupin | 98eabbd | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 697 | * Called by the system when it needs to know what colors the wallpaper is using. |
Lucas Dupin | 65b4765 | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 698 | * You might return null if no color information is available at the moment. |
| 699 | * In that case you might want to call {@link #notifyColorsChanged()} when |
| 700 | * color information becomes available. |
Lucas Dupin | 84b89d9 | 2017-05-09 12:16:19 -0700 | [diff] [blame] | 701 | * <p> |
Lucas Dupin | 98eabbd | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 702 | * The simplest way of creating a {@link android.app.WallpaperColors} object is by using |
Lucas Dupin | 84b89d9 | 2017-05-09 12:16:19 -0700 | [diff] [blame] | 703 | * {@link android.app.WallpaperColors#fromBitmap(Bitmap)} or |
| 704 | * {@link android.app.WallpaperColors#fromDrawable(Drawable)}, but you can also specify |
Lucas Dupin | 98eabbd | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 705 | * your main colors by constructing a {@link android.app.WallpaperColors} object manually. |
Lucas Dupin | c40608c | 2017-04-14 18:33:08 -0700 | [diff] [blame] | 706 | * |
Lucas Dupin | 84b89d9 | 2017-05-09 12:16:19 -0700 | [diff] [blame] | 707 | * @return Wallpaper colors. |
Lucas Dupin | c40608c | 2017-04-14 18:33:08 -0700 | [diff] [blame] | 708 | */ |
Lucas Dupin | 98eabbd | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 709 | public @Nullable WallpaperColors onComputeColors() { |
Lucas Dupin | c40608c | 2017-04-14 18:33:08 -0700 | [diff] [blame] | 710 | return null; |
| 711 | } |
Lucas Dupin | ea1fb1e | 2017-04-05 17:39:44 -0700 | [diff] [blame] | 712 | |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 713 | /** |
| 714 | * Sets internal engine state. Only for testing. |
| 715 | * @param created {@code true} or {@code false}. |
| 716 | * @hide |
| 717 | */ |
| 718 | @VisibleForTesting |
| 719 | public void setCreated(boolean created) { |
| 720 | mCreated = created; |
| 721 | } |
| 722 | |
Dianne Hackborn | 527de8e | 2011-08-22 16:10:36 -0700 | [diff] [blame] | 723 | protected void dump(String prefix, FileDescriptor fd, PrintWriter out, String[] args) { |
| 724 | out.print(prefix); out.print("mInitializing="); out.print(mInitializing); |
| 725 | out.print(" mDestroyed="); out.println(mDestroyed); |
| 726 | out.print(prefix); out.print("mVisible="); out.print(mVisible); |
Dianne Hackborn | 527de8e | 2011-08-22 16:10:36 -0700 | [diff] [blame] | 727 | out.print(" mReportedVisible="); out.println(mReportedVisible); |
Jeff Brown | 3d110b2 | 2014-11-21 19:01:13 -0800 | [diff] [blame] | 728 | out.print(prefix); out.print("mDisplay="); out.println(mDisplay); |
Dianne Hackborn | 527de8e | 2011-08-22 16:10:36 -0700 | [diff] [blame] | 729 | out.print(prefix); out.print("mCreated="); out.print(mCreated); |
| 730 | out.print(" mSurfaceCreated="); out.print(mSurfaceCreated); |
| 731 | out.print(" mIsCreating="); out.print(mIsCreating); |
| 732 | out.print(" mDrawingAllowed="); out.println(mDrawingAllowed); |
| 733 | out.print(prefix); out.print("mWidth="); out.print(mWidth); |
| 734 | out.print(" mCurWidth="); out.print(mCurWidth); |
| 735 | out.print(" mHeight="); out.print(mHeight); |
| 736 | out.print(" mCurHeight="); out.println(mCurHeight); |
| 737 | out.print(prefix); out.print("mType="); out.print(mType); |
| 738 | out.print(" mWindowFlags="); out.print(mWindowFlags); |
| 739 | out.print(" mCurWindowFlags="); out.println(mCurWindowFlags); |
Dianne Hackborn | d052a94 | 2014-11-21 15:23:13 -0800 | [diff] [blame] | 740 | out.print(prefix); out.print("mWindowPrivateFlags="); out.print(mWindowPrivateFlags); |
Chet Haase | a8e5a2b | 2011-10-28 13:18:16 -0700 | [diff] [blame] | 741 | out.print(" mCurWindowPrivateFlags="); out.println(mCurWindowPrivateFlags); |
Dianne Hackborn | 527de8e | 2011-08-22 16:10:36 -0700 | [diff] [blame] | 742 | out.print(prefix); out.print("mVisibleInsets="); |
| 743 | out.print(mVisibleInsets.toShortString()); |
| 744 | out.print(" mWinFrame="); out.print(mWinFrame.toShortString()); |
| 745 | out.print(" mContentInsets="); out.println(mContentInsets.toShortString()); |
Andrii Kulian | 4460796 | 2017-03-16 11:06:24 -0700 | [diff] [blame] | 746 | out.print(prefix); out.print("mConfiguration="); |
| 747 | out.println(mMergedConfiguration.getMergedConfiguration()); |
Dianne Hackborn | 527de8e | 2011-08-22 16:10:36 -0700 | [diff] [blame] | 748 | out.print(prefix); out.print("mLayout="); out.println(mLayout); |
Santiago Etchebehere | 44a2831 | 2020-01-14 15:27:11 -0800 | [diff] [blame] | 749 | out.print(prefix); out.print("mZoom="); out.println(mZoom); |
Dianne Hackborn | 527de8e | 2011-08-22 16:10:36 -0700 | [diff] [blame] | 750 | synchronized (mLock) { |
| 751 | out.print(prefix); out.print("mPendingXOffset="); out.print(mPendingXOffset); |
| 752 | out.print(" mPendingXOffset="); out.println(mPendingXOffset); |
| 753 | out.print(prefix); out.print("mPendingXOffsetStep="); |
| 754 | out.print(mPendingXOffsetStep); |
| 755 | out.print(" mPendingXOffsetStep="); out.println(mPendingXOffsetStep); |
| 756 | out.print(prefix); out.print("mOffsetMessageEnqueued="); |
| 757 | out.print(mOffsetMessageEnqueued); |
| 758 | out.print(" mPendingSync="); out.println(mPendingSync); |
| 759 | if (mPendingMove != null) { |
| 760 | out.print(prefix); out.print("mPendingMove="); out.println(mPendingMove); |
| 761 | } |
| 762 | } |
| 763 | } |
| 764 | |
Santiago Etchebehere | 44a2831 | 2020-01-14 15:27:11 -0800 | [diff] [blame] | 765 | /** |
| 766 | * Set the wallpaper zoom to the given value. This value will be ignored when in ambient |
| 767 | * mode (and zoom will be reset to 0). |
| 768 | * @hide |
| 769 | * @param zoom between 0 and 1 (inclusive) indicating fully zoomed in to fully zoomed out |
| 770 | * respectively. |
| 771 | */ |
| 772 | @VisibleForTesting |
| 773 | public void setZoom(float zoom) { |
| 774 | if (DEBUG) { |
| 775 | Log.v(TAG, "set zoom received: " + zoom); |
| 776 | } |
| 777 | boolean updated = false; |
| 778 | synchronized (mLock) { |
| 779 | if (DEBUG) { |
| 780 | Log.v(TAG, "mZoom: " + mZoom + " updated: " + zoom); |
| 781 | } |
| 782 | if (mIsInAmbientMode) { |
| 783 | mZoom = 0; |
| 784 | } |
| 785 | if (Float.compare(zoom, mZoom) != 0) { |
| 786 | mZoom = zoom; |
| 787 | updated = true; |
| 788 | } |
| 789 | } |
| 790 | if (DEBUG) Log.v(TAG, "setZoom updated? " + updated); |
| 791 | if (updated && !mDestroyed) { |
| 792 | onZoomChanged(mZoom); |
| 793 | } |
| 794 | } |
| 795 | |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 796 | private void dispatchPointer(MotionEvent event) { |
Jeff Brown | 33bbfd2 | 2011-02-24 20:55:35 -0800 | [diff] [blame] | 797 | if (event.isTouchEvent()) { |
| 798 | synchronized (mLock) { |
| 799 | if (event.getAction() == MotionEvent.ACTION_MOVE) { |
| 800 | mPendingMove = event; |
| 801 | } else { |
| 802 | mPendingMove = null; |
| 803 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 804 | } |
Jeff Brown | 33bbfd2 | 2011-02-24 20:55:35 -0800 | [diff] [blame] | 805 | Message msg = mCaller.obtainMessageO(MSG_TOUCH_EVENT, event); |
| 806 | mCaller.sendMessage(msg); |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 807 | } else { |
| 808 | event.recycle(); |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 809 | } |
| 810 | } |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 811 | |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 812 | void updateSurface(boolean forceRelayout, boolean forceReport, boolean redrawNeeded) { |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 813 | if (mDestroyed) { |
| 814 | Log.w(TAG, "Ignoring updateSurface: destroyed"); |
| 815 | } |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 816 | |
| 817 | boolean fixedSize = false; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 818 | int myWidth = mSurfaceHolder.getRequestedWidth(); |
Romain Guy | 980a938 | 2010-01-08 15:06:28 -0800 | [diff] [blame] | 819 | if (myWidth <= 0) myWidth = ViewGroup.LayoutParams.MATCH_PARENT; |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 820 | else fixedSize = true; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 821 | int myHeight = mSurfaceHolder.getRequestedHeight(); |
Romain Guy | 980a938 | 2010-01-08 15:06:28 -0800 | [diff] [blame] | 822 | if (myHeight <= 0) myHeight = ViewGroup.LayoutParams.MATCH_PARENT; |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 823 | else fixedSize = true; |
| 824 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 825 | final boolean creating = !mCreated; |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 826 | final boolean surfaceCreating = !mSurfaceCreated; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 827 | final boolean formatChanged = mFormat != mSurfaceHolder.getRequestedFormat(); |
Dianne Hackborn | 7341d7a | 2009-08-14 11:37:52 -0700 | [diff] [blame] | 828 | boolean sizeChanged = mWidth != myWidth || mHeight != myHeight; |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 829 | boolean insetsChanged = !mCreated; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 830 | final boolean typeChanged = mType != mSurfaceHolder.getRequestedType(); |
Chet Haase | a8e5a2b | 2011-10-28 13:18:16 -0700 | [diff] [blame] | 831 | final boolean flagsChanged = mCurWindowFlags != mWindowFlags || |
| 832 | mCurWindowPrivateFlags != mWindowPrivateFlags; |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 833 | if (forceRelayout || creating || surfaceCreating || formatChanged || sizeChanged |
Dianne Hackborn | bce0cbb | 2012-10-05 11:06:53 -0700 | [diff] [blame] | 834 | || typeChanged || flagsChanged || redrawNeeded |
| 835 | || !mIWallpaperEngine.mShownReported) { |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 836 | |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 837 | if (DEBUG) Log.v(TAG, "Changes: creating=" + creating |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 838 | + " format=" + formatChanged + " size=" + sizeChanged); |
| 839 | |
| 840 | try { |
| 841 | mWidth = myWidth; |
| 842 | mHeight = myHeight; |
| 843 | mFormat = mSurfaceHolder.getRequestedFormat(); |
| 844 | mType = mSurfaceHolder.getRequestedType(); |
| 845 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 846 | mLayout.x = 0; |
| 847 | mLayout.y = 0; |
Valentin Iftime | 6239e53 | 2018-08-24 17:17:26 +0200 | [diff] [blame] | 848 | |
Vadim Caen | b46f923 | 2020-02-14 17:54:39 +0100 | [diff] [blame] | 849 | mLayout.width = myWidth; |
| 850 | mLayout.height = myHeight; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 851 | mLayout.format = mFormat; |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 852 | |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 853 | mCurWindowFlags = mWindowFlags; |
| 854 | mLayout.flags = mWindowFlags |
| 855 | | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
Jorim Jaggi | 526505d | 2016-05-24 00:29:19 -0700 | [diff] [blame] | 856 | | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 857 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
Lucas Dupin | 6155aa4 | 2018-09-05 11:15:52 -0700 | [diff] [blame] | 858 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; |
Chet Haase | a8e5a2b | 2011-10-28 13:18:16 -0700 | [diff] [blame] | 859 | mCurWindowPrivateFlags = mWindowPrivateFlags; |
| 860 | mLayout.privateFlags = mWindowPrivateFlags; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 861 | |
| 862 | mLayout.memoryType = mType; |
| 863 | mLayout.token = mWindowToken; |
| 864 | |
| 865 | if (!mCreated) { |
Filip Gruszczynski | d66ba06 | 2015-03-23 12:59:02 -0700 | [diff] [blame] | 866 | // Retrieve watch round info |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 867 | TypedArray windowStyle = obtainStyledAttributes( |
| 868 | com.android.internal.R.styleable.Window); |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 869 | windowStyle.recycle(); |
| 870 | |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 871 | // Add window |
Dianne Hackborn | 3be63c0 | 2009-08-20 19:31:38 -0700 | [diff] [blame] | 872 | mLayout.type = mIWallpaperEngine.mWindowType; |
Fabrice Di Meglio | aac0d4e | 2012-07-19 19:21:26 -0700 | [diff] [blame] | 873 | mLayout.gravity = Gravity.START|Gravity.TOP; |
Tiger Huang | 5272444 | 2020-01-20 21:38:42 +0800 | [diff] [blame] | 874 | mLayout.setFitInsetsTypes(0 /* types */); |
Dianne Hackborn | 0586a1b | 2009-09-06 21:08:27 -0700 | [diff] [blame] | 875 | mLayout.setTitle(WallpaperService.this.getClass().getName()); |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 876 | mLayout.windowAnimations = |
| 877 | com.android.internal.R.style.Animation_Wallpaper; |
Arthur Hung | 12a06ce | 2019-07-22 15:35:17 +0800 | [diff] [blame] | 878 | InputChannel inputChannel = new InputChannel(); |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 879 | |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 880 | if (mSession.addToDisplay(mWindow, mWindow.mSeq, mLayout, View.VISIBLE, |
wilsonshih | de93f49 | 2018-11-01 21:23:40 +0800 | [diff] [blame] | 881 | mDisplay.getDisplayId(), mWinFrame, mContentInsets, mStableInsets, |
Jorim Jaggi | f081f06 | 2019-10-24 16:24:54 +0200 | [diff] [blame] | 882 | mDisplayCutout, inputChannel, |
Tiger Huang | 0426a33 | 2020-03-29 01:17:08 +0800 | [diff] [blame^] | 883 | mInsetsState, mTempControls) < 0) { |
Mattias Petersson | d9463f5 | 2011-01-12 15:38:55 +0100 | [diff] [blame] | 884 | Log.w(TAG, "Failed to add window while updating wallpaper surface."); |
| 885 | return; |
| 886 | } |
Lucas Dupin | 13f4b8a | 2020-02-19 13:41:52 -0800 | [diff] [blame] | 887 | mSession.setShouldZoomOutWallpaper(mWindow, shouldZoomOutWallpaper()); |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 888 | mCreated = true; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 889 | |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 890 | mInputEventReceiver = new WallpaperInputEventReceiver( |
Arthur Hung | 12a06ce | 2019-07-22 15:35:17 +0800 | [diff] [blame] | 891 | inputChannel, Looper.myLooper()); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 892 | } |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 893 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 894 | mSurfaceHolder.mSurfaceLock.lock(); |
| 895 | mDrawingAllowed = true; |
| 896 | |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 897 | if (!fixedSize) { |
| 898 | mLayout.surfaceInsets.set(mIWallpaperEngine.mDisplayPadding); |
| 899 | } else { |
| 900 | mLayout.surfaceInsets.set(0, 0, 0, 0); |
| 901 | } |
Valerie Hau | 3036055 | 2020-01-14 16:12:01 -0800 | [diff] [blame] | 902 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 903 | final int relayoutResult = mSession.relayout( |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 904 | mWindow, mWindow.mSeq, mLayout, mWidth, mHeight, |
Jorim Jaggi | f081f06 | 2019-10-24 16:24:54 +0200 | [diff] [blame] | 905 | View.VISIBLE, 0, -1, mWinFrame, mContentInsets, |
| 906 | mVisibleInsets, mStableInsets, mBackdropFrame, |
Robert Carr | 5fea55b | 2018-12-10 13:05:52 -0800 | [diff] [blame] | 907 | mDisplayCutout, mMergedConfiguration, mSurfaceControl, |
Tiger Huang | 0426a33 | 2020-03-29 01:17:08 +0800 | [diff] [blame^] | 908 | mInsetsState, mTempControls, mSurfaceSize, mTmpSurfaceControl); |
Robert Carr | 5fea55b | 2018-12-10 13:05:52 -0800 | [diff] [blame] | 909 | if (mSurfaceControl.isValid()) { |
| 910 | mSurfaceHolder.mSurface.copyFrom(mSurfaceControl); |
| 911 | mSurfaceControl.release(); |
| 912 | } |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 913 | |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 914 | if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 915 | + ", frame=" + mWinFrame); |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 916 | |
Adrian Roos | 2ae3805 | 2014-12-09 17:03:01 +0000 | [diff] [blame] | 917 | int w = mWinFrame.width(); |
| 918 | int h = mWinFrame.height(); |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 919 | |
| 920 | if (!fixedSize) { |
| 921 | final Rect padding = mIWallpaperEngine.mDisplayPadding; |
Jorim Jaggi | f081f06 | 2019-10-24 16:24:54 +0200 | [diff] [blame] | 922 | w += padding.left + padding.right; |
| 923 | h += padding.top + padding.bottom; |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 924 | mContentInsets.left += padding.left; |
| 925 | mContentInsets.top += padding.top; |
| 926 | mContentInsets.right += padding.right; |
| 927 | mContentInsets.bottom += padding.bottom; |
| 928 | mStableInsets.left += padding.left; |
| 929 | mStableInsets.top += padding.top; |
| 930 | mStableInsets.right += padding.right; |
| 931 | mStableInsets.bottom += padding.bottom; |
Adrian Roos | 5c6b622 | 2017-11-07 17:36:10 +0100 | [diff] [blame] | 932 | mDisplayCutout.set(mDisplayCutout.get().inset(-padding.left, -padding.top, |
| 933 | -padding.right, -padding.bottom)); |
Valentin Iftime | 6239e53 | 2018-08-24 17:17:26 +0200 | [diff] [blame] | 934 | } else { |
| 935 | w = myWidth; |
| 936 | h = myHeight; |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 937 | } |
| 938 | |
Dianne Hackborn | 7341d7a | 2009-08-14 11:37:52 -0700 | [diff] [blame] | 939 | if (mCurWidth != w) { |
| 940 | sizeChanged = true; |
| 941 | mCurWidth = w; |
| 942 | } |
Dianne Hackborn | 7341d7a | 2009-08-14 11:37:52 -0700 | [diff] [blame] | 943 | if (mCurHeight != h) { |
| 944 | sizeChanged = true; |
| 945 | mCurHeight = h; |
| 946 | } |
Jeff Brown | 30bc34f | 2011-01-25 12:56:56 -0800 | [diff] [blame] | 947 | |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 948 | if (DEBUG) { |
| 949 | Log.v(TAG, "Wallpaper size has changed: (" + mCurWidth + ", " + mCurHeight); |
| 950 | } |
| 951 | |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 952 | insetsChanged |= !mDispatchedContentInsets.equals(mContentInsets); |
| 953 | insetsChanged |= !mDispatchedStableInsets.equals(mStableInsets); |
Adrian Roos | 5c6b622 | 2017-11-07 17:36:10 +0100 | [diff] [blame] | 954 | insetsChanged |= !mDispatchedDisplayCutout.equals(mDisplayCutout.get()); |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 955 | |
Jeff Brown | 30bc34f | 2011-01-25 12:56:56 -0800 | [diff] [blame] | 956 | mSurfaceHolder.setSurfaceFrameSize(w, h); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 957 | mSurfaceHolder.mSurfaceLock.unlock(); |
| 958 | |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 959 | if (!mSurfaceHolder.mSurface.isValid()) { |
| 960 | reportSurfaceDestroyed(); |
| 961 | if (DEBUG) Log.v(TAG, "Layout: Surface destroyed"); |
| 962 | return; |
| 963 | } |
Dianne Hackborn | 9e4e727 | 2011-08-30 14:06:51 -0700 | [diff] [blame] | 964 | |
| 965 | boolean didSurface = false; |
| 966 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 967 | try { |
Dianne Hackborn | dc8a7f6 | 2010-05-10 11:29:34 -0700 | [diff] [blame] | 968 | mSurfaceHolder.ungetCallbacks(); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 969 | |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 970 | if (surfaceCreating) { |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 971 | mIsCreating = true; |
Dianne Hackborn | 9e4e727 | 2011-08-30 14:06:51 -0700 | [diff] [blame] | 972 | didSurface = true; |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 973 | if (DEBUG) Log.v(TAG, "onSurfaceCreated(" |
| 974 | + mSurfaceHolder + "): " + this); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 975 | onSurfaceCreated(mSurfaceHolder); |
Dianne Hackborn | dc8a7f6 | 2010-05-10 11:29:34 -0700 | [diff] [blame] | 976 | SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks(); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 977 | if (callbacks != null) { |
| 978 | for (SurfaceHolder.Callback c : callbacks) { |
| 979 | c.surfaceCreated(mSurfaceHolder); |
| 980 | } |
| 981 | } |
| 982 | } |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 983 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 984 | redrawNeeded |= creating || (relayoutResult |
| 985 | & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0; |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 986 | |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 987 | if (forceReport || creating || surfaceCreating |
| 988 | || formatChanged || sizeChanged) { |
Dianne Hackborn | cbf1504 | 2009-08-18 18:29:09 -0700 | [diff] [blame] | 989 | if (DEBUG) { |
| 990 | RuntimeException e = new RuntimeException(); |
| 991 | e.fillInStackTrace(); |
| 992 | Log.w(TAG, "forceReport=" + forceReport + " creating=" + creating |
| 993 | + " formatChanged=" + formatChanged |
| 994 | + " sizeChanged=" + sizeChanged, e); |
| 995 | } |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 996 | if (DEBUG) Log.v(TAG, "onSurfaceChanged(" |
| 997 | + mSurfaceHolder + ", " + mFormat |
| 998 | + ", " + mCurWidth + ", " + mCurHeight |
| 999 | + "): " + this); |
Dianne Hackborn | 9e4e727 | 2011-08-30 14:06:51 -0700 | [diff] [blame] | 1000 | didSurface = true; |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 1001 | onSurfaceChanged(mSurfaceHolder, mFormat, |
| 1002 | mCurWidth, mCurHeight); |
Dianne Hackborn | dc8a7f6 | 2010-05-10 11:29:34 -0700 | [diff] [blame] | 1003 | SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks(); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1004 | if (callbacks != null) { |
| 1005 | for (SurfaceHolder.Callback c : callbacks) { |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 1006 | c.surfaceChanged(mSurfaceHolder, mFormat, |
| 1007 | mCurWidth, mCurHeight); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1008 | } |
| 1009 | } |
| 1010 | } |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 1011 | |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1012 | if (insetsChanged) { |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1013 | mDispatchedContentInsets.set(mContentInsets); |
| 1014 | mDispatchedStableInsets.set(mStableInsets); |
Adrian Roos | 5c6b622 | 2017-11-07 17:36:10 +0100 | [diff] [blame] | 1015 | mDispatchedDisplayCutout = mDisplayCutout.get(); |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1016 | mFinalStableInsets.set(mDispatchedStableInsets); |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1017 | WindowInsets insets = new WindowInsets(mFinalSystemInsets, |
Jorim Jaggi | 297985a | 2018-11-30 17:24:58 +0100 | [diff] [blame] | 1018 | mFinalStableInsets, |
Adrian Roos | d4970af | 2017-11-10 15:48:01 +0100 | [diff] [blame] | 1019 | getResources().getConfiguration().isScreenRound(), false, |
Adrian Roos | 5c6b622 | 2017-11-07 17:36:10 +0100 | [diff] [blame] | 1020 | mDispatchedDisplayCutout); |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 1021 | if (DEBUG) { |
| 1022 | Log.v(TAG, "dispatching insets=" + insets); |
| 1023 | } |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1024 | onApplyWindowInsets(insets); |
| 1025 | } |
| 1026 | |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 1027 | if (redrawNeeded) { |
| 1028 | onSurfaceRedrawNeeded(mSurfaceHolder); |
| 1029 | SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks(); |
| 1030 | if (callbacks != null) { |
| 1031 | for (SurfaceHolder.Callback c : callbacks) { |
| 1032 | if (c instanceof SurfaceHolder.Callback2) { |
| 1033 | ((SurfaceHolder.Callback2)c).surfaceRedrawNeeded( |
| 1034 | mSurfaceHolder); |
| 1035 | } |
| 1036 | } |
| 1037 | } |
| 1038 | } |
| 1039 | |
Dianne Hackborn | 9e4e727 | 2011-08-30 14:06:51 -0700 | [diff] [blame] | 1040 | if (didSurface && !mReportedVisible) { |
| 1041 | // This wallpaper is currently invisible, but its |
| 1042 | // surface has changed. At this point let's tell it |
| 1043 | // again that it is invisible in case the report about |
| 1044 | // the surface caused it to start running. We really |
| 1045 | // don't want wallpapers running when not visible. |
| 1046 | if (mIsCreating) { |
| 1047 | // Some wallpapers will ignore this call if they |
| 1048 | // had previously been told they were invisble, |
| 1049 | // so if we are creating a new surface then toggle |
| 1050 | // the state to get them to notice. |
| 1051 | if (DEBUG) Log.v(TAG, "onVisibilityChanged(true) at surface: " |
| 1052 | + this); |
| 1053 | onVisibilityChanged(true); |
| 1054 | } |
| 1055 | if (DEBUG) Log.v(TAG, "onVisibilityChanged(false) at surface: " |
| 1056 | + this); |
| 1057 | onVisibilityChanged(false); |
| 1058 | } |
| 1059 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1060 | } finally { |
| 1061 | mIsCreating = false; |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 1062 | mSurfaceCreated = true; |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 1063 | if (redrawNeeded) { |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 1064 | mSession.finishDrawing(mWindow, null /* postDrawTransaction */); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1065 | } |
Dianne Hackborn | bce0cbb | 2012-10-05 11:06:53 -0700 | [diff] [blame] | 1066 | mIWallpaperEngine.reportShown(); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1067 | } |
| 1068 | } catch (RemoteException ex) { |
| 1069 | } |
| 1070 | if (DEBUG) Log.v( |
| 1071 | TAG, "Layout: x=" + mLayout.x + " y=" + mLayout.y + |
| 1072 | " w=" + mLayout.width + " h=" + mLayout.height); |
| 1073 | } |
| 1074 | } |
Lucas Dupin | 65b4765 | 2017-07-19 17:32:26 -0700 | [diff] [blame] | 1075 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1076 | void attach(IWallpaperEngineWrapper wrapper) { |
Dianne Hackborn | cbf1504 | 2009-08-18 18:29:09 -0700 | [diff] [blame] | 1077 | if (DEBUG) Log.v(TAG, "attach: " + this + " wrapper=" + wrapper); |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1078 | if (mDestroyed) { |
| 1079 | return; |
| 1080 | } |
wilsonshih | de93f49 | 2018-11-01 21:23:40 +0800 | [diff] [blame] | 1081 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1082 | mIWallpaperEngine = wrapper; |
| 1083 | mCaller = wrapper.mCaller; |
| 1084 | mConnection = wrapper.mConnection; |
| 1085 | mWindowToken = wrapper.mWindowToken; |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1086 | mSurfaceHolder.setSizeFromLayout(); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1087 | mInitializing = true; |
Jeff Brown | f9e989d | 2013-04-04 23:04:03 -0700 | [diff] [blame] | 1088 | mSession = WindowManagerGlobal.getWindowSession(); |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 1089 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1090 | mWindow.setSession(mSession); |
Dianne Hackborn | 9fe6cb5 | 2011-09-09 13:02:43 -0700 | [diff] [blame] | 1091 | |
Filip Gruszczynski | 4544b92 | 2015-04-16 13:18:58 -0700 | [diff] [blame] | 1092 | mLayout.packageName = getPackageName(); |
wilsonshih | 81e10a7 | 2018-11-15 10:54:21 +0800 | [diff] [blame] | 1093 | mIWallpaperEngine.mDisplayManager.registerDisplayListener(mDisplayListener, |
| 1094 | mCaller.getHandler()); |
| 1095 | mDisplay = mIWallpaperEngine.mDisplay; |
wilsonshih | 8ccb9ce | 2018-12-04 11:44:31 +0800 | [diff] [blame] | 1096 | mDisplayContext = createDisplayContext(mDisplay); |
Filip Gruszczynski | 4544b92 | 2015-04-16 13:18:58 -0700 | [diff] [blame] | 1097 | mDisplayState = mDisplay.getState(); |
Dianne Hackborn | 9fe6cb5 | 2011-09-09 13:02:43 -0700 | [diff] [blame] | 1098 | |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1099 | if (DEBUG) Log.v(TAG, "onCreate(): " + this); |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 1100 | onCreate(mSurfaceHolder); |
wilsonshih | 81e10a7 | 2018-11-15 10:54:21 +0800 | [diff] [blame] | 1101 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1102 | mInitializing = false; |
wilsonshih | 81e10a7 | 2018-11-15 10:54:21 +0800 | [diff] [blame] | 1103 | |
Dianne Hackborn | 9e4e727 | 2011-08-30 14:06:51 -0700 | [diff] [blame] | 1104 | mReportedVisible = false; |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 1105 | updateSurface(false, false, false); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1106 | } |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1107 | |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 1108 | /** |
wilsonshih | 8ccb9ce | 2018-12-04 11:44:31 +0800 | [diff] [blame] | 1109 | * The {@link Context} with resources that match the current display the wallpaper is on. |
| 1110 | * For multiple display environment, multiple engines can be created to render on each |
| 1111 | * display, but these displays may have different densities. Use this context to get the |
| 1112 | * corresponding resources for currently display, avoiding the context of the service. |
wilsonshih | fd058f6 | 2019-02-13 15:57:06 +0800 | [diff] [blame] | 1113 | * <p> |
| 1114 | * The display context will never be {@code null} after |
| 1115 | * {@link Engine#onCreate(SurfaceHolder)} has been called. |
wilsonshih | 8ccb9ce | 2018-12-04 11:44:31 +0800 | [diff] [blame] | 1116 | * |
| 1117 | * @return A {@link Context} for current display. |
| 1118 | */ |
wilsonshih | fd058f6 | 2019-02-13 15:57:06 +0800 | [diff] [blame] | 1119 | @Nullable |
wilsonshih | 8ccb9ce | 2018-12-04 11:44:31 +0800 | [diff] [blame] | 1120 | public Context getDisplayContext() { |
| 1121 | return mDisplayContext; |
| 1122 | } |
| 1123 | |
| 1124 | /** |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 1125 | * Executes life cycle event and updates internal ambient mode state based on |
| 1126 | * message sent from handler. |
| 1127 | * |
Lucas Dupin | 660d573 | 2017-12-19 10:05:19 -0800 | [diff] [blame] | 1128 | * @param inAmbientMode {@code true} if in ambient mode. |
Lucas Dupin | 4c8c327 | 2018-11-06 17:47:48 -0800 | [diff] [blame] | 1129 | * @param animationDuration For how long the transition will last, in ms. |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 1130 | * @hide |
| 1131 | */ |
| 1132 | @VisibleForTesting |
Lucas Dupin | 4c8c327 | 2018-11-06 17:47:48 -0800 | [diff] [blame] | 1133 | public void doAmbientModeChanged(boolean inAmbientMode, long animationDuration) { |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 1134 | if (!mDestroyed) { |
| 1135 | if (DEBUG) { |
Lucas Dupin | 660d573 | 2017-12-19 10:05:19 -0800 | [diff] [blame] | 1136 | Log.v(TAG, "onAmbientModeChanged(" + inAmbientMode + ", " |
Lucas Dupin | 4c8c327 | 2018-11-06 17:47:48 -0800 | [diff] [blame] | 1137 | + animationDuration + "): " + this); |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 1138 | } |
| 1139 | mIsInAmbientMode = inAmbientMode; |
| 1140 | if (mCreated) { |
Lucas Dupin | 4c8c327 | 2018-11-06 17:47:48 -0800 | [diff] [blame] | 1141 | onAmbientModeChanged(inAmbientMode, animationDuration); |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 1142 | } |
| 1143 | } |
| 1144 | } |
| 1145 | |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1146 | void doDesiredSizeChanged(int desiredWidth, int desiredHeight) { |
| 1147 | if (!mDestroyed) { |
| 1148 | if (DEBUG) Log.v(TAG, "onDesiredSizeChanged(" |
| 1149 | + desiredWidth + "," + desiredHeight + "): " + this); |
Joe Onorato | dcfae5c | 2010-10-28 18:03:23 -0700 | [diff] [blame] | 1150 | mIWallpaperEngine.mReqWidth = desiredWidth; |
| 1151 | mIWallpaperEngine.mReqHeight = desiredHeight; |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1152 | onDesiredSizeChanged(desiredWidth, desiredHeight); |
Dianne Hackborn | 9e4e727 | 2011-08-30 14:06:51 -0700 | [diff] [blame] | 1153 | doOffsetsChanged(true); |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1154 | } |
| 1155 | } |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1156 | |
| 1157 | void doDisplayPaddingChanged(Rect padding) { |
| 1158 | if (!mDestroyed) { |
| 1159 | if (DEBUG) Log.v(TAG, "onDisplayPaddingChanged(" + padding + "): " + this); |
| 1160 | if (!mIWallpaperEngine.mDisplayPadding.equals(padding)) { |
| 1161 | mIWallpaperEngine.mDisplayPadding.set(padding); |
| 1162 | updateSurface(true, false, false); |
| 1163 | } |
| 1164 | } |
| 1165 | } |
| 1166 | |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1167 | void doVisibilityChanged(boolean visible) { |
Dianne Hackborn | af1f42b | 2009-11-20 16:27:27 -0800 | [diff] [blame] | 1168 | if (!mDestroyed) { |
| 1169 | mVisible = visible; |
| 1170 | reportVisibility(); |
| 1171 | } |
Dianne Hackborn | bcbcaa7 | 2009-09-10 10:54:46 -0700 | [diff] [blame] | 1172 | } |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1173 | |
Dianne Hackborn | bcbcaa7 | 2009-09-10 10:54:46 -0700 | [diff] [blame] | 1174 | void reportVisibility() { |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1175 | if (!mDestroyed) { |
Filip Gruszczynski | 4544b92 | 2015-04-16 13:18:58 -0700 | [diff] [blame] | 1176 | mDisplayState = mDisplay == null ? Display.STATE_UNKNOWN : mDisplay.getState(); |
| 1177 | boolean visible = mVisible && mDisplayState != Display.STATE_OFF; |
Dianne Hackborn | bcbcaa7 | 2009-09-10 10:54:46 -0700 | [diff] [blame] | 1178 | if (mReportedVisible != visible) { |
| 1179 | mReportedVisible = visible; |
| 1180 | if (DEBUG) Log.v(TAG, "onVisibilityChanged(" + visible |
| 1181 | + "): " + this); |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 1182 | if (visible) { |
| 1183 | // If becoming visible, in preview mode the surface |
| 1184 | // may have been destroyed so now we need to make |
| 1185 | // sure it is re-created. |
Dianne Hackborn | 9e4e727 | 2011-08-30 14:06:51 -0700 | [diff] [blame] | 1186 | doOffsetsChanged(false); |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 1187 | updateSurface(false, false, false); |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 1188 | } |
Dianne Hackborn | bcbcaa7 | 2009-09-10 10:54:46 -0700 | [diff] [blame] | 1189 | onVisibilityChanged(visible); |
| 1190 | } |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1191 | } |
| 1192 | } |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 1193 | |
Dianne Hackborn | 9e4e727 | 2011-08-30 14:06:51 -0700 | [diff] [blame] | 1194 | void doOffsetsChanged(boolean always) { |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1195 | if (mDestroyed) { |
| 1196 | return; |
| 1197 | } |
Dianne Hackborn | 9e4e727 | 2011-08-30 14:06:51 -0700 | [diff] [blame] | 1198 | |
| 1199 | if (!always && !mOffsetsChanged) { |
| 1200 | return; |
| 1201 | } |
| 1202 | |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1203 | float xOffset; |
| 1204 | float yOffset; |
Marco Nelissen | bf6956b | 2009-11-09 15:21:13 -0800 | [diff] [blame] | 1205 | float xOffsetStep; |
| 1206 | float yOffsetStep; |
Dianne Hackborn | 19382ac | 2009-09-11 21:13:37 -0700 | [diff] [blame] | 1207 | boolean sync; |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1208 | synchronized (mLock) { |
| 1209 | xOffset = mPendingXOffset; |
| 1210 | yOffset = mPendingYOffset; |
Marco Nelissen | bf6956b | 2009-11-09 15:21:13 -0800 | [diff] [blame] | 1211 | xOffsetStep = mPendingXOffsetStep; |
| 1212 | yOffsetStep = mPendingYOffsetStep; |
Dianne Hackborn | 19382ac | 2009-09-11 21:13:37 -0700 | [diff] [blame] | 1213 | sync = mPendingSync; |
| 1214 | mPendingSync = false; |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1215 | mOffsetMessageEnqueued = false; |
| 1216 | } |
Dianne Hackborn | 9e4e727 | 2011-08-30 14:06:51 -0700 | [diff] [blame] | 1217 | |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 1218 | if (mSurfaceCreated) { |
Dianne Hackborn | 9e4e727 | 2011-08-30 14:06:51 -0700 | [diff] [blame] | 1219 | if (mReportedVisible) { |
| 1220 | if (DEBUG) Log.v(TAG, "Offsets change in " + this |
| 1221 | + ": " + xOffset + "," + yOffset); |
| 1222 | final int availw = mIWallpaperEngine.mReqWidth-mCurWidth; |
| 1223 | final int xPixels = availw > 0 ? -(int)(availw*xOffset+.5f) : 0; |
| 1224 | final int availh = mIWallpaperEngine.mReqHeight-mCurHeight; |
| 1225 | final int yPixels = availh > 0 ? -(int)(availh*yOffset+.5f) : 0; |
| 1226 | onOffsetsChanged(xOffset, yOffset, xOffsetStep, yOffsetStep, xPixels, yPixels); |
| 1227 | } else { |
| 1228 | mOffsetsChanged = true; |
| 1229 | } |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 1230 | } |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 1231 | |
Dianne Hackborn | 19382ac | 2009-09-11 21:13:37 -0700 | [diff] [blame] | 1232 | if (sync) { |
| 1233 | try { |
| 1234 | if (DEBUG) Log.v(TAG, "Reporting offsets change complete"); |
| 1235 | mSession.wallpaperOffsetsComplete(mWindow.asBinder()); |
| 1236 | } catch (RemoteException e) { |
| 1237 | } |
| 1238 | } |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1239 | } |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 1240 | |
Dianne Hackborn | 7580493 | 2009-10-20 20:15:20 -0700 | [diff] [blame] | 1241 | void doCommand(WallpaperCommand cmd) { |
| 1242 | Bundle result; |
| 1243 | if (!mDestroyed) { |
| 1244 | result = onCommand(cmd.action, cmd.x, cmd.y, cmd.z, |
| 1245 | cmd.extras, cmd.sync); |
| 1246 | } else { |
| 1247 | result = null; |
| 1248 | } |
| 1249 | if (cmd.sync) { |
| 1250 | try { |
| 1251 | if (DEBUG) Log.v(TAG, "Reporting command complete"); |
| 1252 | mSession.wallpaperCommandComplete(mWindow.asBinder(), result); |
| 1253 | } catch (RemoteException e) { |
| 1254 | } |
| 1255 | } |
| 1256 | } |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 1257 | |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 1258 | void reportSurfaceDestroyed() { |
| 1259 | if (mSurfaceCreated) { |
| 1260 | mSurfaceCreated = false; |
Dianne Hackborn | dc8a7f6 | 2010-05-10 11:29:34 -0700 | [diff] [blame] | 1261 | mSurfaceHolder.ungetCallbacks(); |
| 1262 | SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks(); |
| 1263 | if (callbacks != null) { |
| 1264 | for (SurfaceHolder.Callback c : callbacks) { |
| 1265 | c.surfaceDestroyed(mSurfaceHolder); |
| 1266 | } |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1267 | } |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1268 | if (DEBUG) Log.v(TAG, "onSurfaceDestroyed(" |
| 1269 | + mSurfaceHolder + "): " + this); |
| 1270 | onSurfaceDestroyed(mSurfaceHolder); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1271 | } |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 1272 | } |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 1273 | |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 1274 | void detach() { |
| 1275 | if (mDestroyed) { |
| 1276 | return; |
| 1277 | } |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 1278 | |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 1279 | mDestroyed = true; |
Jeff Brown | 3d110b2 | 2014-11-21 19:01:13 -0800 | [diff] [blame] | 1280 | |
wilsonshih | 81e10a7 | 2018-11-15 10:54:21 +0800 | [diff] [blame] | 1281 | if (mIWallpaperEngine.mDisplayManager != null) { |
| 1282 | mIWallpaperEngine.mDisplayManager.unregisterDisplayListener(mDisplayListener); |
Jeff Brown | 3d110b2 | 2014-11-21 19:01:13 -0800 | [diff] [blame] | 1283 | } |
| 1284 | |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 1285 | if (mVisible) { |
| 1286 | mVisible = false; |
| 1287 | if (DEBUG) Log.v(TAG, "onVisibilityChanged(false): " + this); |
| 1288 | onVisibilityChanged(false); |
| 1289 | } |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 1290 | |
Dianne Hackborn | 18ee31e | 2010-04-27 15:54:02 -0700 | [diff] [blame] | 1291 | reportSurfaceDestroyed(); |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 1292 | |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1293 | if (DEBUG) Log.v(TAG, "onDestroy(): " + this); |
| 1294 | onDestroy(); |
Jeff Brown | 3d110b2 | 2014-11-21 19:01:13 -0800 | [diff] [blame] | 1295 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1296 | if (mCreated) { |
| 1297 | try { |
Dianne Hackborn | ba3e31d | 2010-04-22 18:59:03 -0700 | [diff] [blame] | 1298 | if (DEBUG) Log.v(TAG, "Removing window and destroying surface " |
| 1299 | + mSurfaceHolder.getSurface() + " of: " + this); |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 1300 | |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 1301 | if (mInputEventReceiver != null) { |
| 1302 | mInputEventReceiver.dispose(); |
| 1303 | mInputEventReceiver = null; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1304 | } |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 1305 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1306 | mSession.remove(mWindow); |
| 1307 | } catch (RemoteException e) { |
| 1308 | } |
Dianne Hackborn | 0586a1b | 2009-09-06 21:08:27 -0700 | [diff] [blame] | 1309 | mSurfaceHolder.mSurface.release(); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1310 | mCreated = false; |
| 1311 | } |
| 1312 | } |
Jeff Brown | 3d110b2 | 2014-11-21 19:01:13 -0800 | [diff] [blame] | 1313 | |
| 1314 | private final DisplayListener mDisplayListener = new DisplayListener() { |
| 1315 | @Override |
| 1316 | public void onDisplayChanged(int displayId) { |
| 1317 | if (mDisplay.getDisplayId() == displayId) { |
| 1318 | reportVisibility(); |
| 1319 | } |
| 1320 | } |
| 1321 | |
| 1322 | @Override |
| 1323 | public void onDisplayRemoved(int displayId) { |
| 1324 | } |
| 1325 | |
| 1326 | @Override |
| 1327 | public void onDisplayAdded(int displayId) { |
| 1328 | } |
| 1329 | }; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1330 | } |
Jeff Brown | 3d110b2 | 2014-11-21 19:01:13 -0800 | [diff] [blame] | 1331 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1332 | class IWallpaperEngineWrapper extends IWallpaperEngine.Stub |
| 1333 | implements HandlerCaller.Callback { |
| 1334 | private final HandlerCaller mCaller; |
| 1335 | |
| 1336 | final IWallpaperConnection mConnection; |
| 1337 | final IBinder mWindowToken; |
Dianne Hackborn | 3be63c0 | 2009-08-20 19:31:38 -0700 | [diff] [blame] | 1338 | final int mWindowType; |
| 1339 | final boolean mIsPreview; |
Dianne Hackborn | bce0cbb | 2012-10-05 11:06:53 -0700 | [diff] [blame] | 1340 | boolean mShownReported; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1341 | int mReqWidth; |
| 1342 | int mReqHeight; |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1343 | final Rect mDisplayPadding = new Rect(); |
wilsonshih | 81e10a7 | 2018-11-15 10:54:21 +0800 | [diff] [blame] | 1344 | final int mDisplayId; |
| 1345 | final DisplayManager mDisplayManager; |
| 1346 | final Display mDisplay; |
wilsonshih | b72ff9c | 2019-03-21 17:27:02 +0800 | [diff] [blame] | 1347 | private final AtomicBoolean mDetached = new AtomicBoolean(); |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1348 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1349 | Engine mEngine; |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1350 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1351 | IWallpaperEngineWrapper(WallpaperService context, |
| 1352 | IWallpaperConnection conn, IBinder windowToken, |
wilsonshih | de93f49 | 2018-11-01 21:23:40 +0800 | [diff] [blame] | 1353 | int windowType, boolean isPreview, int reqWidth, int reqHeight, Rect padding, |
| 1354 | int displayId) { |
Mita Yun | aa8dc2e | 2012-12-10 18:32:03 -0800 | [diff] [blame] | 1355 | mCaller = new HandlerCaller(context, context.getMainLooper(), this, true); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1356 | mConnection = conn; |
| 1357 | mWindowToken = windowToken; |
Dianne Hackborn | 3be63c0 | 2009-08-20 19:31:38 -0700 | [diff] [blame] | 1358 | mWindowType = windowType; |
| 1359 | mIsPreview = isPreview; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1360 | mReqWidth = reqWidth; |
| 1361 | mReqHeight = reqHeight; |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1362 | mDisplayPadding.set(padding); |
wilsonshih | de93f49 | 2018-11-01 21:23:40 +0800 | [diff] [blame] | 1363 | mDisplayId = displayId; |
wilsonshih | 81e10a7 | 2018-11-15 10:54:21 +0800 | [diff] [blame] | 1364 | |
| 1365 | // Create a display context before onCreateEngine. |
| 1366 | mDisplayManager = getSystemService(DisplayManager.class); |
| 1367 | mDisplay = mDisplayManager.getDisplay(mDisplayId); |
| 1368 | |
| 1369 | if (mDisplay == null) { |
| 1370 | // Ignore this engine. |
| 1371 | throw new IllegalArgumentException("Cannot find display with id" + mDisplayId); |
| 1372 | } |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1373 | Message msg = mCaller.obtainMessage(DO_ATTACH); |
| 1374 | mCaller.sendMessage(msg); |
| 1375 | } |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1376 | |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1377 | public void setDesiredSize(int width, int height) { |
| 1378 | Message msg = mCaller.obtainMessageII(DO_SET_DESIRED_SIZE, width, height); |
| 1379 | mCaller.sendMessage(msg); |
| 1380 | } |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1381 | |
| 1382 | public void setDisplayPadding(Rect padding) { |
| 1383 | Message msg = mCaller.obtainMessageO(DO_SET_DISPLAY_PADDING, padding); |
| 1384 | mCaller.sendMessage(msg); |
| 1385 | } |
| 1386 | |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1387 | public void setVisibility(boolean visible) { |
| 1388 | Message msg = mCaller.obtainMessageI(MSG_VISIBILITY_CHANGED, |
| 1389 | visible ? 1 : 0); |
| 1390 | mCaller.sendMessage(msg); |
| 1391 | } |
| 1392 | |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 1393 | @Override |
Lucas Dupin | 4c8c327 | 2018-11-06 17:47:48 -0800 | [diff] [blame] | 1394 | public void setInAmbientMode(boolean inAmbientDisplay, long animationDuration) |
Lucas Dupin | 660d573 | 2017-12-19 10:05:19 -0800 | [diff] [blame] | 1395 | throws RemoteException { |
Lucas Dupin | 4c8c327 | 2018-11-06 17:47:48 -0800 | [diff] [blame] | 1396 | Message msg = mCaller.obtainMessageIO(DO_IN_AMBIENT_MODE, inAmbientDisplay ? 1 : 0, |
| 1397 | animationDuration); |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 1398 | mCaller.sendMessage(msg); |
| 1399 | } |
| 1400 | |
Dianne Hackborn | 6adba24 | 2009-11-10 11:10:09 -0800 | [diff] [blame] | 1401 | public void dispatchPointer(MotionEvent event) { |
| 1402 | if (mEngine != null) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1403 | mEngine.dispatchPointer(event); |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 1404 | } else { |
| 1405 | event.recycle(); |
Dianne Hackborn | 6adba24 | 2009-11-10 11:10:09 -0800 | [diff] [blame] | 1406 | } |
| 1407 | } |
Jeff Brown | 9f3bdfe | 2010-10-13 06:01:27 -0700 | [diff] [blame] | 1408 | |
| 1409 | public void dispatchWallpaperCommand(String action, int x, int y, |
| 1410 | int z, Bundle extras) { |
| 1411 | if (mEngine != null) { |
| 1412 | mEngine.mWindow.dispatchWallpaperCommand(action, x, y, z, extras, false); |
| 1413 | } |
| 1414 | } |
| 1415 | |
Santiago Etchebehere | 44a2831 | 2020-01-14 15:27:11 -0800 | [diff] [blame] | 1416 | public void setZoomOut(float scale) { |
| 1417 | Message msg = mCaller.obtainMessageI(MSG_SCALE, Float.floatToIntBits(scale)); |
| 1418 | mCaller.sendMessage(msg); |
| 1419 | } |
| 1420 | |
Dianne Hackborn | bce0cbb | 2012-10-05 11:06:53 -0700 | [diff] [blame] | 1421 | public void reportShown() { |
| 1422 | if (!mShownReported) { |
| 1423 | mShownReported = true; |
| 1424 | try { |
| 1425 | mConnection.engineShown(this); |
| 1426 | } catch (RemoteException e) { |
| 1427 | Log.w(TAG, "Wallpaper host disappeared", e); |
| 1428 | return; |
| 1429 | } |
| 1430 | } |
| 1431 | } |
| 1432 | |
Lucas Dupin | 50ba991 | 2017-07-14 11:55:05 -0700 | [diff] [blame] | 1433 | public void requestWallpaperColors() { |
| 1434 | Message msg = mCaller.obtainMessage(MSG_REQUEST_WALLPAPER_COLORS); |
| 1435 | mCaller.sendMessage(msg); |
| 1436 | } |
| 1437 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1438 | public void destroy() { |
| 1439 | Message msg = mCaller.obtainMessage(DO_DETACH); |
| 1440 | mCaller.sendMessage(msg); |
| 1441 | } |
| 1442 | |
wilsonshih | b72ff9c | 2019-03-21 17:27:02 +0800 | [diff] [blame] | 1443 | public void detach() { |
| 1444 | mDetached.set(true); |
| 1445 | } |
| 1446 | |
| 1447 | private void doDetachEngine() { |
| 1448 | mActiveEngines.remove(mEngine); |
| 1449 | mEngine.detach(); |
| 1450 | } |
| 1451 | |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 1452 | @Override |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1453 | public void executeMessage(Message message) { |
wilsonshih | b72ff9c | 2019-03-21 17:27:02 +0800 | [diff] [blame] | 1454 | if (mDetached.get()) { |
| 1455 | if (mActiveEngines.contains(mEngine)) { |
| 1456 | doDetachEngine(); |
| 1457 | } |
| 1458 | return; |
| 1459 | } |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1460 | switch (message.what) { |
| 1461 | case DO_ATTACH: { |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1462 | try { |
wilsonshih | de93f49 | 2018-11-01 21:23:40 +0800 | [diff] [blame] | 1463 | mConnection.attachEngine(this, mDisplayId); |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1464 | } catch (RemoteException e) { |
| 1465 | Log.w(TAG, "Wallpaper host disappeared", e); |
| 1466 | return; |
| 1467 | } |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1468 | Engine engine = onCreateEngine(); |
| 1469 | mEngine = engine; |
Dianne Hackborn | af1f42b | 2009-11-20 16:27:27 -0800 | [diff] [blame] | 1470 | mActiveEngines.add(engine); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1471 | engine.attach(this); |
| 1472 | return; |
| 1473 | } |
| 1474 | case DO_DETACH: { |
wilsonshih | b72ff9c | 2019-03-21 17:27:02 +0800 | [diff] [blame] | 1475 | doDetachEngine(); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1476 | return; |
| 1477 | } |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1478 | case DO_SET_DESIRED_SIZE: { |
| 1479 | mEngine.doDesiredSizeChanged(message.arg1, message.arg2); |
| 1480 | return; |
| 1481 | } |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1482 | case DO_SET_DISPLAY_PADDING: { |
| 1483 | mEngine.doDisplayPaddingChanged((Rect) message.obj); |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 1484 | return; |
| 1485 | } |
| 1486 | case DO_IN_AMBIENT_MODE: { |
Lucas Dupin | 4c8c327 | 2018-11-06 17:47:48 -0800 | [diff] [blame] | 1487 | mEngine.doAmbientModeChanged(message.arg1 != 0, (Long) message.obj); |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 1488 | return; |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 1489 | } |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1490 | case MSG_UPDATE_SURFACE: |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 1491 | mEngine.updateSurface(true, false, false); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1492 | break; |
Santiago Etchebehere | 44a2831 | 2020-01-14 15:27:11 -0800 | [diff] [blame] | 1493 | case MSG_SCALE: |
| 1494 | mEngine.setZoom(Float.intBitsToFloat(message.arg1)); |
| 1495 | break; |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 1496 | case MSG_VISIBILITY_CHANGED: |
| 1497 | if (DEBUG) Log.v(TAG, "Visibility change in " + mEngine |
| 1498 | + ": " + message.arg1); |
Dianne Hackborn | 284ac93 | 2009-08-28 10:34:25 -0700 | [diff] [blame] | 1499 | mEngine.doVisibilityChanged(message.arg1 != 0); |
Dianne Hackborn | 759a39e | 2009-08-09 17:20:27 -0700 | [diff] [blame] | 1500 | break; |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 1501 | case MSG_WALLPAPER_OFFSETS: { |
Dianne Hackborn | 9e4e727 | 2011-08-30 14:06:51 -0700 | [diff] [blame] | 1502 | mEngine.doOffsetsChanged(true); |
Dianne Hackborn | 72c82ab | 2009-08-11 21:13:54 -0700 | [diff] [blame] | 1503 | } break; |
Dianne Hackborn | 7580493 | 2009-10-20 20:15:20 -0700 | [diff] [blame] | 1504 | case MSG_WALLPAPER_COMMAND: { |
| 1505 | WallpaperCommand cmd = (WallpaperCommand)message.obj; |
| 1506 | mEngine.doCommand(cmd); |
| 1507 | } break; |
Dianne Hackborn | 7341d7a | 2009-08-14 11:37:52 -0700 | [diff] [blame] | 1508 | case MSG_WINDOW_RESIZED: { |
| 1509 | final boolean reportDraw = message.arg1 != 0; |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 1510 | mEngine.updateSurface(true, false, reportDraw); |
Dianne Hackborn | 9e4e727 | 2011-08-30 14:06:51 -0700 | [diff] [blame] | 1511 | mEngine.doOffsetsChanged(true); |
Dianne Hackborn | 7341d7a | 2009-08-14 11:37:52 -0700 | [diff] [blame] | 1512 | } break; |
Craig Mautner | 5702d4d | 2012-06-30 14:10:16 -0700 | [diff] [blame] | 1513 | case MSG_WINDOW_MOVED: { |
| 1514 | // Do nothing. What does it mean for a Wallpaper to move? |
| 1515 | } break; |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 1516 | case MSG_TOUCH_EVENT: { |
Jeff Brown | 840db1f | 2010-10-21 17:36:54 -0700 | [diff] [blame] | 1517 | boolean skip = false; |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 1518 | MotionEvent ev = (MotionEvent)message.obj; |
Jeff Brown | 840db1f | 2010-10-21 17:36:54 -0700 | [diff] [blame] | 1519 | if (ev.getAction() == MotionEvent.ACTION_MOVE) { |
| 1520 | synchronized (mEngine.mLock) { |
| 1521 | if (mEngine.mPendingMove == ev) { |
| 1522 | mEngine.mPendingMove = null; |
| 1523 | } else { |
| 1524 | // this is not the motion event we are looking for.... |
| 1525 | skip = true; |
| 1526 | } |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 1527 | } |
| 1528 | } |
Jeff Brown | 840db1f | 2010-10-21 17:36:54 -0700 | [diff] [blame] | 1529 | if (!skip) { |
| 1530 | if (DEBUG) Log.v(TAG, "Delivering touch event: " + ev); |
| 1531 | mEngine.onTouchEvent(ev); |
| 1532 | } |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 1533 | ev.recycle(); |
| 1534 | } break; |
Lucas Dupin | 50ba991 | 2017-07-14 11:55:05 -0700 | [diff] [blame] | 1535 | case MSG_REQUEST_WALLPAPER_COLORS: { |
| 1536 | if (mConnection == null) { |
| 1537 | break; |
| 1538 | } |
| 1539 | try { |
wilsonshih | 36597d4 | 2018-12-05 18:56:39 +0800 | [diff] [blame] | 1540 | mConnection.onWallpaperColorsChanged(mEngine.onComputeColors(), mDisplayId); |
Lucas Dupin | 50ba991 | 2017-07-14 11:55:05 -0700 | [diff] [blame] | 1541 | } catch (RemoteException e) { |
| 1542 | // Connection went away, nothing to do in here. |
| 1543 | } |
| 1544 | } break; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1545 | default : |
| 1546 | Log.w(TAG, "Unknown message type " + message.what); |
| 1547 | } |
| 1548 | } |
| 1549 | } |
| 1550 | |
| 1551 | /** |
| 1552 | * Implements the internal {@link IWallpaperService} interface to convert |
| 1553 | * incoming calls to it back to calls on an {@link WallpaperService}. |
| 1554 | */ |
| 1555 | class IWallpaperServiceWrapper extends IWallpaperService.Stub { |
| 1556 | private final WallpaperService mTarget; |
wilsonshih | b72ff9c | 2019-03-21 17:27:02 +0800 | [diff] [blame] | 1557 | private IWallpaperEngineWrapper mEngineWrapper; |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1558 | |
| 1559 | public IWallpaperServiceWrapper(WallpaperService context) { |
| 1560 | mTarget = context; |
| 1561 | } |
| 1562 | |
Craig Mautner | b1ef369 | 2012-11-16 17:31:04 -0800 | [diff] [blame] | 1563 | @Override |
Dianne Hackborn | 3be63c0 | 2009-08-20 19:31:38 -0700 | [diff] [blame] | 1564 | public void attach(IWallpaperConnection conn, IBinder windowToken, |
wilsonshih | de93f49 | 2018-11-01 21:23:40 +0800 | [diff] [blame] | 1565 | int windowType, boolean isPreview, int reqWidth, int reqHeight, Rect padding, |
| 1566 | int displayId) { |
wilsonshih | b72ff9c | 2019-03-21 17:27:02 +0800 | [diff] [blame] | 1567 | mEngineWrapper = new IWallpaperEngineWrapper(mTarget, conn, windowToken, |
wilsonshih | de93f49 | 2018-11-01 21:23:40 +0800 | [diff] [blame] | 1568 | windowType, isPreview, reqWidth, reqHeight, padding, displayId); |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1569 | } |
wilsonshih | b72ff9c | 2019-03-21 17:27:02 +0800 | [diff] [blame] | 1570 | |
| 1571 | @Override |
| 1572 | public void detach() { |
| 1573 | mEngineWrapper.detach(); |
| 1574 | } |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1575 | } |
Craig Mautner | b1ef369 | 2012-11-16 17:31:04 -0800 | [diff] [blame] | 1576 | |
Dianne Hackborn | af1f42b | 2009-11-20 16:27:27 -0800 | [diff] [blame] | 1577 | @Override |
| 1578 | public void onCreate() { |
| 1579 | super.onCreate(); |
| 1580 | } |
| 1581 | |
| 1582 | @Override |
| 1583 | public void onDestroy() { |
| 1584 | super.onDestroy(); |
| 1585 | for (int i=0; i<mActiveEngines.size(); i++) { |
| 1586 | mActiveEngines.get(i).detach(); |
| 1587 | } |
| 1588 | mActiveEngines.clear(); |
| 1589 | } |
| 1590 | |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1591 | /** |
| 1592 | * Implement to return the implementation of the internal accessibility |
| 1593 | * service interface. Subclasses should not override. |
| 1594 | */ |
| 1595 | @Override |
| 1596 | public final IBinder onBind(Intent intent) { |
| 1597 | return new IWallpaperServiceWrapper(this); |
| 1598 | } |
Craig Mautner | b1ef369 | 2012-11-16 17:31:04 -0800 | [diff] [blame] | 1599 | |
Dianne Hackborn | 23ef7b4 | 2009-11-18 18:20:39 -0800 | [diff] [blame] | 1600 | /** |
| 1601 | * Must be implemented to return a new instance of the wallpaper's engine. |
| 1602 | * Note that multiple instances may be active at the same time, such as |
| 1603 | * when the wallpaper is currently set as the active wallpaper and the user |
| 1604 | * is in the wallpaper picker viewing a preview of it as well. |
| 1605 | */ |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1606 | public abstract Engine onCreateEngine(); |
Dianne Hackborn | 527de8e | 2011-08-22 16:10:36 -0700 | [diff] [blame] | 1607 | |
| 1608 | @Override |
| 1609 | protected void dump(FileDescriptor fd, PrintWriter out, String[] args) { |
| 1610 | out.print("State of wallpaper "); out.print(this); out.println(":"); |
| 1611 | for (int i=0; i<mActiveEngines.size(); i++) { |
| 1612 | Engine engine = mActiveEngines.get(i); |
| 1613 | out.print(" Engine "); out.print(engine); out.println(":"); |
| 1614 | engine.dump(" ", fd, out, args); |
| 1615 | } |
| 1616 | } |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1617 | } |