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