• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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 package android.app;
17 
18 import android.annotation.NonNull;
19 import android.content.ComponentName;
20 import android.content.Intent;
21 import android.graphics.Bitmap;
22 import android.graphics.Rect;
23 import android.graphics.drawable.Drawable;
24 import android.net.Uri;
25 import android.os.Bundle;
26 import android.os.Handler;
27 import android.os.IBinder;
28 import android.os.ParcelFileDescriptor;
29 import android.util.Log;
30 
31 import java.io.IOException;
32 import java.io.InputStream;
33 
34 /**
35  * A no-op implementation of {@link WallpaperManager}.
36  */
37 final class DisabledWallpaperManager extends WallpaperManager {
38 
39     private static final String TAG = DisabledWallpaperManager.class.getSimpleName();
40 
41     // Don't need to worry about synchronization
42     private static DisabledWallpaperManager sInstance;
43 
44     private static final boolean DEBUG = false;
45 
46     @NonNull
getInstance()47     static DisabledWallpaperManager getInstance() {
48         if (sInstance == null) {
49             sInstance = new DisabledWallpaperManager();
50         }
51         return sInstance;
52     }
53 
DisabledWallpaperManager()54     private DisabledWallpaperManager() {
55     }
56 
57     @Override
isWallpaperSupported()58     public boolean isWallpaperSupported() {
59         return false;
60     }
61 
62     @Override
isSetWallpaperAllowed()63     public boolean isSetWallpaperAllowed() {
64         return false;
65     }
66 
unsupported()67     private static <T> T unsupported() {
68         if (DEBUG) Log.w(TAG, "unsupported method called; returning null", new Exception());
69         return null;
70     }
71 
unsupportedBoolean()72     private static boolean unsupportedBoolean() {
73         if (DEBUG) Log.w(TAG, "unsupported method called; returning false", new Exception());
74         return false;
75     }
76 
77     @Override
getDrawable()78     public Drawable getDrawable() {
79         return unsupported();
80     }
81 
82     @Override
getBuiltInDrawable()83     public Drawable getBuiltInDrawable() {
84         return unsupported();
85     }
86 
87     @Override
getBuiltInDrawable(int which)88     public Drawable getBuiltInDrawable(int which) {
89         return unsupported();
90     }
91 
92     @Override
getBuiltInDrawable(int outWidth, int outHeight, boolean scaleToFit, float horizontalAlignment, float verticalAlignment)93     public Drawable getBuiltInDrawable(int outWidth, int outHeight, boolean scaleToFit,
94             float horizontalAlignment, float verticalAlignment) {
95         return unsupported();
96     }
97 
98     @Override
getBuiltInDrawable(int outWidth, int outHeight, boolean scaleToFit, float horizontalAlignment, float verticalAlignment, int which)99     public Drawable getBuiltInDrawable(int outWidth, int outHeight, boolean scaleToFit,
100             float horizontalAlignment, float verticalAlignment, int which) {
101         return unsupported();
102     }
103 
104     @Override
peekDrawable()105     public Drawable peekDrawable() {
106         return unsupported();
107     }
108 
109     @Override
getFastDrawable()110     public Drawable getFastDrawable() {
111         return unsupported();
112     }
113 
114     @Override
peekFastDrawable()115     public Drawable peekFastDrawable() {
116         return unsupported();
117     }
118 
119     @Override
getBitmap()120     public Bitmap getBitmap() {
121         return unsupported();
122     }
123 
124     @Override
getBitmap(boolean hardware)125     public Bitmap getBitmap(boolean hardware) {
126         return unsupported();
127     }
128 
129     @Override
getBitmapAsUser(int userId, boolean hardware)130     public Bitmap getBitmapAsUser(int userId, boolean hardware) {
131         return unsupported();
132     }
133 
134     @Override
getWallpaperFile(int which)135     public ParcelFileDescriptor getWallpaperFile(int which) {
136         return unsupported();
137     }
138 
139     @Override
addOnColorsChangedListener(OnColorsChangedListener listener, Handler handler)140     public void addOnColorsChangedListener(OnColorsChangedListener listener, Handler handler) {
141         unsupported();
142     }
143 
144     @Override
addOnColorsChangedListener(OnColorsChangedListener listener, Handler handler, int userId)145     public void addOnColorsChangedListener(OnColorsChangedListener listener, Handler handler,
146             int userId) {
147         unsupported();
148     }
149 
150     @Override
removeOnColorsChangedListener(OnColorsChangedListener callback)151     public void removeOnColorsChangedListener(OnColorsChangedListener callback) {
152         unsupported();
153     }
154 
155     @Override
removeOnColorsChangedListener(OnColorsChangedListener callback, int userId)156     public void removeOnColorsChangedListener(OnColorsChangedListener callback, int userId) {
157         unsupported();
158     }
159 
160     @Override
getWallpaperColors(int which)161     public WallpaperColors getWallpaperColors(int which) {
162         return unsupported();
163     }
164 
165     @Override
getWallpaperColors(int which, int userId)166     public WallpaperColors getWallpaperColors(int which, int userId) {
167         return unsupported();
168     }
169 
170     @Override
getWallpaperFile(int which, int userId)171     public ParcelFileDescriptor getWallpaperFile(int which, int userId) {
172         return unsupported();
173     }
174 
175     @Override
forgetLoadedWallpaper()176     public void forgetLoadedWallpaper() {
177         unsupported();
178     }
179 
180     @Override
getWallpaperInfo()181     public WallpaperInfo getWallpaperInfo() {
182         return unsupported();
183     }
184 
185     @Override
getWallpaperInfo(int userId)186     public WallpaperInfo getWallpaperInfo(int userId) {
187         return unsupported();
188     }
189 
190     @Override
getWallpaperId(int which)191     public int getWallpaperId(int which) {
192         return unsupported();
193     }
194 
195     @Override
getWallpaperIdForUser(int which, int userId)196     public int getWallpaperIdForUser(int which, int userId) {
197         return unsupported();
198     }
199 
200     @Override
getCropAndSetWallpaperIntent(Uri imageUri)201     public Intent getCropAndSetWallpaperIntent(Uri imageUri) {
202         return unsupported();
203     }
204 
205     @Override
setResource(int resid)206     public void setResource(int resid) throws IOException {
207         unsupported();
208     }
209 
210     @Override
setResource(int resid, int which)211     public int setResource(int resid, int which) throws IOException {
212         return unsupported();
213     }
214 
215     @Override
setBitmap(Bitmap bitmap)216     public void setBitmap(Bitmap bitmap) throws IOException {
217         unsupported();
218     }
219 
220     @Override
setBitmap(Bitmap fullImage, Rect visibleCropHint, boolean allowBackup)221     public int setBitmap(Bitmap fullImage, Rect visibleCropHint, boolean allowBackup)
222             throws IOException {
223         return unsupported();
224     }
225 
226     @Override
setBitmap(Bitmap fullImage, Rect visibleCropHint, boolean allowBackup, int which)227     public int setBitmap(Bitmap fullImage, Rect visibleCropHint, boolean allowBackup, int which)
228             throws IOException {
229         return unsupported();
230     }
231 
232     @Override
setBitmap(Bitmap fullImage, Rect visibleCropHint, boolean allowBackup, int which, int userId)233     public int setBitmap(Bitmap fullImage, Rect visibleCropHint, boolean allowBackup, int which,
234             int userId) throws IOException {
235         return unsupported();
236     }
237 
238     @Override
setStream(InputStream bitmapData)239     public void setStream(InputStream bitmapData) throws IOException {
240         unsupported();
241     }
242 
243     @Override
setStream(InputStream bitmapData, Rect visibleCropHint, boolean allowBackup)244     public int setStream(InputStream bitmapData, Rect visibleCropHint, boolean allowBackup)
245             throws IOException {
246         return unsupported();
247     }
248 
249     @Override
setStream(InputStream bitmapData, Rect visibleCropHint, boolean allowBackup, int which)250     public int setStream(InputStream bitmapData, Rect visibleCropHint, boolean allowBackup,
251             int which) throws IOException {
252         return unsupported();
253     }
254 
255     @Override
hasResourceWallpaper(int resid)256     public boolean hasResourceWallpaper(int resid) {
257         return unsupportedBoolean();
258     }
259 
260     @Override
getDesiredMinimumWidth()261     public int getDesiredMinimumWidth() {
262         return unsupported();
263     }
264 
265     @Override
getDesiredMinimumHeight()266     public int getDesiredMinimumHeight() {
267         return unsupported();
268     }
269 
270     @Override
suggestDesiredDimensions(int minimumWidth, int minimumHeight)271     public void suggestDesiredDimensions(int minimumWidth, int minimumHeight) {
272         unsupported();
273     }
274 
275     @Override
setDisplayPadding(Rect padding)276     public void setDisplayPadding(Rect padding) {
277         unsupported();
278     }
279 
280     @Override
setDisplayOffset(IBinder windowToken, int x, int y)281     public void setDisplayOffset(IBinder windowToken, int x, int y) {
282         unsupported();
283     }
284 
285     @Override
clearWallpaper()286     public void clearWallpaper() {
287         unsupported();
288     }
289 
290     @Override
clearWallpaper(int which, int userId)291     public void clearWallpaper(int which, int userId) {
292         unsupported();
293     }
294 
295     @Override
setWallpaperComponent(ComponentName name)296     public boolean setWallpaperComponent(ComponentName name) {
297         return unsupportedBoolean();
298     }
299 
300     @Override
setWallpaperComponent(ComponentName name, int userId)301     public boolean setWallpaperComponent(ComponentName name, int userId) {
302         return unsupportedBoolean();
303     }
304 
305     @Override
setWallpaperOffsets(IBinder windowToken, float xOffset, float yOffset)306     public void setWallpaperOffsets(IBinder windowToken, float xOffset, float yOffset) {
307         unsupported();
308     }
309 
310     @Override
setWallpaperOffsetSteps(float xStep, float yStep)311     public void setWallpaperOffsetSteps(float xStep, float yStep) {
312         unsupported();
313     }
314 
315     @Override
sendWallpaperCommand(IBinder windowToken, String action, int x, int y, int z, Bundle extras)316     public void sendWallpaperCommand(IBinder windowToken, String action, int x, int y, int z,
317             Bundle extras) {
318         unsupported();
319     }
320 
321     @Override
clearWallpaperOffsets(IBinder windowToken)322     public void clearWallpaperOffsets(IBinder windowToken) {
323         unsupported();
324     }
325 
326     @Override
clear()327     public void clear() throws IOException {
328         unsupported();
329     }
330 
331     @Override
clear(int which)332     public void clear(int which) throws IOException {
333         unsupported();
334     }
335 
336     @Override
isWallpaperBackupEligible(int which)337     public boolean isWallpaperBackupEligible(int which) {
338         return unsupportedBoolean();
339     }
340 
341     @Override
wallpaperSupportsWcg(int which)342     public boolean wallpaperSupportsWcg(int which) {
343         return unsupportedBoolean();
344     }
345 }
346