1 /* 2 * Copyright (C) 2017 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 com.android.wallpaper.module; 17 18 import android.app.WallpaperColors; 19 import android.app.WallpaperManager.SetWallpaperFlags; 20 import android.graphics.Bitmap; 21 import android.text.TextUtils; 22 23 import androidx.annotation.IntDef; 24 import androidx.annotation.NonNull; 25 import androidx.annotation.Nullable; 26 27 import com.android.wallpaper.model.LiveWallpaperInfo; 28 import com.android.wallpaper.model.StaticWallpaperMetadata; 29 import com.android.wallpaper.model.WallpaperInfo; 30 import com.android.wallpaper.module.WallpaperPersister.Destination; 31 32 import java.util.List; 33 34 /** 35 * Interface for persisting and retrieving wallpaper specific preferences. 36 */ 37 public interface WallpaperPreferences { 38 39 int PRESENTATION_MODE_STATIC = 1; 40 int PRESENTATION_MODE_ROTATING = 2; 41 int WALLPAPER_SET_NOT_PENDING = 0; 42 int WALLPAPER_SET_PENDING = 1; 43 int DAILY_WALLPAPER_UPDATE_NOT_PENDING = 0; 44 int DAILY_WALLPAPER_UPDATE_PENDING = 1; 45 46 /** 47 * Returns the wallpaper presentation mode. 48 */ 49 @PresentationMode getWallpaperPresentationMode()50 int getWallpaperPresentationMode(); 51 52 /** 53 * Sets the presentation mode of the current wallpaper. 54 */ setWallpaperPresentationMode(@resentationMode int presentationMode)55 void setWallpaperPresentationMode(@PresentationMode int presentationMode); 56 57 /** 58 * Returns the home attributions as a list. 59 */ getHomeWallpaperAttributions()60 List<String> getHomeWallpaperAttributions(); 61 62 /** 63 * Sets the attributions for the current home wallpaper. Clears existing attributions if any 64 * exist. 65 */ setHomeWallpaperAttributions(List<String> attributions)66 void setHomeWallpaperAttributions(List<String> attributions); 67 68 /** 69 * Returns the home wallpaper's action URL or null if there is none. 70 */ getHomeWallpaperActionUrl()71 String getHomeWallpaperActionUrl(); 72 73 /** 74 * Sets the home wallpaper's action URL. 75 */ setHomeWallpaperActionUrl(String actionUrl)76 void setHomeWallpaperActionUrl(String actionUrl); 77 78 /** 79 * Returns the resource id for the home wallpaper's action label. 80 */ getHomeWallpaperActionLabelRes()81 int getHomeWallpaperActionLabelRes(); 82 83 /** 84 * Sets the resource id for the home wallpaper's action label. 85 */ setHomeWallpaperActionLabelRes(int resId)86 void setHomeWallpaperActionLabelRes(int resId); 87 88 /** 89 * Returns the resource id for the home wallpaper's action icon. 90 */ getHomeWallpaperActionIconRes()91 int getHomeWallpaperActionIconRes(); 92 93 /** 94 * Sets the resource id for the home wallpaper's action icon. 95 */ setHomeWallpaperActionIconRes(int resId)96 void setHomeWallpaperActionIconRes(int resId); 97 98 /** 99 * Returns the home wallpaper's base image URL or if there is none. 100 */ getHomeWallpaperBaseImageUrl()101 String getHomeWallpaperBaseImageUrl(); 102 103 /** 104 * Sets the home wallpaper's base image URL. 105 */ setHomeWallpaperBaseImageUrl(String baseImageUrl)106 void setHomeWallpaperBaseImageUrl(String baseImageUrl); 107 108 /** 109 * Returns the home wallpaper's collection ID or null if there is none. 110 */ getHomeWallpaperCollectionId()111 String getHomeWallpaperCollectionId(); 112 113 /** 114 * Sets the home wallpaper's collection ID. 115 */ setHomeWallpaperCollectionId(String collectionId)116 void setHomeWallpaperCollectionId(String collectionId); 117 118 /** 119 * Returns the home wallpaper's backing file name if there's one or null. 120 */ getHomeWallpaperBackingFileName()121 String getHomeWallpaperBackingFileName(); 122 123 /** 124 * Sets the home wallpaper's backing file name 125 */ setHomeWallpaperBackingFileName(String fileName)126 void setHomeWallpaperBackingFileName(String fileName); 127 128 /** 129 * Removes all home metadata from SharedPreferences. 130 */ clearHomeWallpaperMetadata()131 void clearHomeWallpaperMetadata(); 132 133 /** 134 * Set homescreen static image wallpaper metadata to SharedPreferences. 135 */ setHomeStaticImageWallpaperMetadata(StaticWallpaperMetadata metadata)136 void setHomeStaticImageWallpaperMetadata(StaticWallpaperMetadata metadata); 137 138 /** 139 * Returns the home wallpaper's bitmap hash code or 0 if there is none. 140 */ getHomeWallpaperHashCode()141 long getHomeWallpaperHashCode(); 142 143 /** 144 * Sets the home wallpaper's bitmap hash code if it is an individual image. 145 */ setHomeWallpaperHashCode(long hashCode)146 void setHomeWallpaperHashCode(long hashCode); 147 148 /** 149 * Gets the home wallpaper's service name, which is present for live wallpapers. 150 */ getHomeWallpaperServiceName()151 String getHomeWallpaperServiceName(); 152 153 /** 154 * Sets the home wallpaper's service name, which is present for live wallpapers. 155 */ setHomeWallpaperServiceName(String serviceName)156 void setHomeWallpaperServiceName(String serviceName); 157 158 /** 159 * Gets the home wallpaper's ID, which is provided by WallpaperManager for static wallpapers. 160 */ getHomeWallpaperManagerId()161 int getHomeWallpaperManagerId(); 162 163 /** 164 * Sets the home wallpaper's ID, which is provided by WallpaperManager for static wallpapers. 165 */ setHomeWallpaperManagerId(int homeWallpaperId)166 void setHomeWallpaperManagerId(int homeWallpaperId); 167 168 /** 169 * Gets the home wallpaper's remote identifier. 170 */ getHomeWallpaperRemoteId()171 String getHomeWallpaperRemoteId(); 172 173 /** 174 * Sets the home wallpaper's remote identifier to SharedPreferences. This should be a string 175 * which uniquely identifies the currently set home wallpaper in the context of a remote wallpaper 176 * collection. 177 */ setHomeWallpaperRemoteId(String wallpaperRemoteId)178 void setHomeWallpaperRemoteId(String wallpaperRemoteId); 179 180 /** 181 * Gets the home wallpaper's identifier used to index into the list of recent wallpapers. 182 */ 183 @Nullable getHomeWallpaperRecentsKey()184 String getHomeWallpaperRecentsKey(); 185 186 /** 187 * Sets the home wallpaper's identifier used to index into the list of recent wallpapers. 188 */ setHomeWallpaperRecentsKey(String recentsKey)189 void setHomeWallpaperRecentsKey(String recentsKey); 190 191 /** 192 * Gets the home wallpaper's effects. 193 */ getHomeWallpaperEffects()194 String getHomeWallpaperEffects(); 195 196 /** 197 * Sets the home wallpaper's effects to SharedPreferences. 198 * 199 * @param wallpaperEffects The wallpaper effects. 200 */ setHomeWallpaperEffects(String wallpaperEffects)201 void setHomeWallpaperEffects(String wallpaperEffects); 202 203 /** 204 * Returns the lock wallpaper's action URL or null if there is none. 205 */ getLockWallpaperActionUrl()206 String getLockWallpaperActionUrl(); 207 208 /** 209 * Sets the lock wallpaper's action URL. 210 */ setLockWallpaperActionUrl(String actionUrl)211 void setLockWallpaperActionUrl(String actionUrl); 212 213 /** 214 * Returns the resource id for the lock wallpaper's action label. 215 */ getLockWallpaperActionLabelRes()216 int getLockWallpaperActionLabelRes(); 217 218 /** 219 * Sets the resource id for the lock wallpaper's action label. 220 */ setLockWallpaperActionLabelRes(int resId)221 void setLockWallpaperActionLabelRes(int resId); 222 223 /** 224 * Returns the resource id for the lock wallpaper's action icon. 225 */ getLockWallpaperActionIconRes()226 int getLockWallpaperActionIconRes(); 227 228 /** 229 * Sets the resource id for the lock wallpaper's action icon. 230 */ setLockWallpaperActionIconRes(int resId)231 void setLockWallpaperActionIconRes(int resId); 232 233 /** 234 * Returns the lock wallpaper's collection ID or null if there is none. 235 */ getLockWallpaperCollectionId()236 String getLockWallpaperCollectionId(); 237 238 /** 239 * Sets the lock wallpaper's collection ID. 240 */ setLockWallpaperCollectionId(String collectionId)241 void setLockWallpaperCollectionId(String collectionId); 242 243 /** 244 * Returns the home wallpaper's backing file name if there's one or null. 245 */ getLockWallpaperBackingFileName()246 String getLockWallpaperBackingFileName(); 247 248 /** 249 * Sets the home wallpaper's backing file name 250 */ setLockWallpaperBackingFileName(String fileName)251 void setLockWallpaperBackingFileName(String fileName); 252 253 /** 254 * Returns the lock screen attributions as a list. 255 */ getLockWallpaperAttributions()256 List<String> getLockWallpaperAttributions(); 257 258 /** 259 * Sets the attributions for the current lock screen wallpaper. Clears existing attributions if 260 * any exist. 261 * 262 * @param attributions 263 */ setLockWallpaperAttributions(List<String> attributions)264 void setLockWallpaperAttributions(List<String> attributions); 265 266 /** 267 * Removes all lock screen metadata from SharedPreferences. 268 */ clearLockWallpaperMetadata()269 void clearLockWallpaperMetadata(); 270 271 /** 272 * Set lockscreen static image wallpaper metadata to SharedPreferences. 273 */ setLockStaticImageWallpaperMetadata(StaticWallpaperMetadata metadata)274 void setLockStaticImageWallpaperMetadata(StaticWallpaperMetadata metadata); 275 276 /** 277 * Returns the lock screen wallpaper's bitmap hash code or 0 if there is none. 278 */ getLockWallpaperHashCode()279 long getLockWallpaperHashCode(); 280 281 /** 282 * Sets the lock screen wallpaper's bitmap hash code if it is an individual image. 283 */ setLockWallpaperHashCode(long hashCode)284 void setLockWallpaperHashCode(long hashCode); 285 286 /** 287 * Gets the lock wallpaper's service name, which is present for live wallpapers. 288 */ getLockWallpaperServiceName()289 String getLockWallpaperServiceName(); 290 291 /** 292 * Sets the lock wallpaper's service name, which is present for live wallpapers. 293 */ setLockWallpaperServiceName(String serviceName)294 void setLockWallpaperServiceName(String serviceName); 295 296 /** 297 * Gets the lock wallpaper's ID, which is provided by WallpaperManager for static wallpapers. 298 */ getLockWallpaperManagerId()299 int getLockWallpaperManagerId(); 300 301 /** 302 * Sets the lock wallpaper's ID, which is provided by WallpaperManager for static wallpapers. 303 */ setLockWallpaperManagerId(int lockWallpaperId)304 void setLockWallpaperManagerId(int lockWallpaperId); 305 306 /** 307 * Gets the lock wallpaper's remote identifier. 308 */ getLockWallpaperRemoteId()309 String getLockWallpaperRemoteId(); 310 311 /** 312 * Sets the lock wallpaper's remote identifier to SharedPreferences. This should be a string 313 * which uniquely identifies the currently set lock wallpaper in the context of a remote 314 * wallpaper collection. 315 */ setLockWallpaperRemoteId(String wallpaperRemoteId)316 void setLockWallpaperRemoteId(String wallpaperRemoteId); 317 318 /** 319 * Gets lock home wallpaper's identifier used to index into the list of recent wallpapers. 320 */ 321 @Nullable getLockWallpaperRecentsKey()322 String getLockWallpaperRecentsKey(); 323 324 /** 325 * Sets lock home wallpaper's identifier used to index into the list of recent wallpapers. 326 */ setLockWallpaperRecentsKey(String recentsKey)327 void setLockWallpaperRecentsKey(String recentsKey); 328 329 /** 330 * Gets the lock wallpaper's effects. 331 */ getLockWallpaperEffects()332 String getLockWallpaperEffects(); 333 334 /** 335 * Sets the lock wallpaper's effects to SharedPreferences. 336 * 337 * @param wallpaperEffects The wallpaper effects. 338 */ setLockWallpaperEffects(String wallpaperEffects)339 void setLockWallpaperEffects(String wallpaperEffects); 340 341 /** 342 * Persists the timestamp of a daily wallpaper rotation that just occurred. 343 */ addDailyRotation(long timestamp)344 void addDailyRotation(long timestamp); 345 346 /** 347 * Returns the timestamp of the last wallpaper daily rotation or -1 if there has never been a 348 * daily wallpaper rotation on the user's device. 349 */ getLastDailyRotationTimestamp()350 long getLastDailyRotationTimestamp(); 351 352 /** 353 * Gets a list of the daily rotation timestamps that occurred in the last week, from least 354 * recent at the start of the list to most recent at the end of the list. 355 * The timestamps are in milliseconds since Unix epoch. 356 * If daily rotation has been enabled for less than one week, returns null instead. 357 */ 358 @Nullable getDailyRotationsInLastWeek()359 List<Long> getDailyRotationsInLastWeek(); 360 361 /** 362 * Gets a list of the daily rotation timestamps that occurred the previous day (midnight to 363 * midnight in the user's timezone). Timestamps are in milliseconds since Unix epoch. Returns null 364 * if daily rotation was enabled earlier than midnight yesterday. 365 */ 366 @Nullable getDailyRotationsPreviousDay()367 List<Long> getDailyRotationsPreviousDay(); 368 369 /** 370 * Returns the daily wallpaper enabled timestamp in milliseconds since Unix epoch, or -1 if 371 * daily wallpaper is not currently enabled. 372 */ getDailyWallpaperEnabledTimestamp()373 long getDailyWallpaperEnabledTimestamp(); 374 375 /** 376 * Persists the timestamp when daily wallpaper feature was last enabled. 377 * 378 * @param timestamp Milliseconds since Unix epoch. 379 */ setDailyWallpaperEnabledTimestamp(long timestamp)380 void setDailyWallpaperEnabledTimestamp(long timestamp); 381 382 /** 383 * Clears the persisted daily rotation timestamps and the "daily wallpaper enabled" timestamp. 384 * Called if daily rotation is disabled. 385 */ clearDailyRotations()386 void clearDailyRotations(); 387 388 /** 389 * Returns the timestamp of the most recent daily logging event, in milliseconds since Unix 390 * epoch. Returns -1 if the very first daily logging event has not occurred yet. 391 */ getLastDailyLogTimestamp()392 long getLastDailyLogTimestamp(); 393 394 /** 395 * Sets the timestamp of the most recent daily logging event. 396 * 397 * @param timestamp Milliseconds since Unix epoch. 398 */ setLastDailyLogTimestamp(long timestamp)399 void setLastDailyLogTimestamp(long timestamp); 400 401 /** 402 * Returns the timestamp of the last time the app was noted to be active; i.e. the last time an 403 * activity entered the foreground (milliseconds since Unix epoch). 404 */ getLastAppActiveTimestamp()405 long getLastAppActiveTimestamp(); 406 407 /** 408 * Sets the timestamp of the last time the app was noted to be active; i.e. the last time an 409 * activity entered the foreground. 410 * 411 * @param timestamp Milliseconds since Unix epoch. 412 */ setLastAppActiveTimestamp(long timestamp)413 void setLastAppActiveTimestamp(long timestamp); 414 415 /** 416 * Sets the last rotation status for daily wallpapers with a timestamp. 417 * 418 * @param status Last status code of daily rotation. 419 * @param timestamp Milliseconds since Unix epoch. 420 */ setDailyWallpaperRotationStatus(int status, long timestamp)421 void setDailyWallpaperRotationStatus(int status, long timestamp); 422 423 /** 424 * Gets the last daily wallpapers rotation status or -1 if no rotation status has ever been 425 * persisted to preferences. 426 */ getDailyWallpaperLastRotationStatus()427 int getDailyWallpaperLastRotationStatus(); 428 429 /** 430 * Gets the timestamp of the last set daily wallpapers rotation status in milliseconds since the 431 * Unix epoch or 0 if no rotation status has ever been persisted to preferences. 432 */ getDailyWallpaperLastRotationStatusTimestamp()433 long getDailyWallpaperLastRotationStatusTimestamp(); 434 435 /** 436 * Gets the timestamp of the last time a sync occurred of wallpaper data to or from this device. 437 * Returns 0 if a sync has never occurred before. 438 */ getLastSyncTimestamp()439 long getLastSyncTimestamp(); 440 441 /** 442 * Sets the timestamp of the latest sync received or sent. 443 */ setLastSyncTimestamp(long timestamp)444 void setLastSyncTimestamp(long timestamp); 445 446 /** 447 * Sets the status of whether a wallpaper is currently pending being set (i.e., user tapped the 448 * UI to set a wallpaper but it has not yet been actually set on the device). Does so in a 449 * synchronous manner so a caller may be assured that the underlying store has been updated when 450 * this method returns. 451 */ setPendingWallpaperSetStatusSync(@endingWallpaperSetStatus int setStatus)452 void setPendingWallpaperSetStatusSync(@PendingWallpaperSetStatus int setStatus); 453 454 /** 455 * Gets the status of whether a wallpaper is currently pending being set. 456 */ 457 @PendingWallpaperSetStatus getPendingWallpaperSetStatus()458 int getPendingWallpaperSetStatus(); 459 460 /** 461 * Sets the status of whether a wallpaper is currently pending being set (i.e., user tapped the 462 * UI to set a wallpaper but it has not yet been actually set on the device). Does so in an 463 * asynchronous manner so writing the preference to the underlying store doesn't block the calling 464 * thread. 465 */ setPendingWallpaperSetStatus(@endingWallpaperSetStatus int setStatus)466 void setPendingWallpaperSetStatus(@PendingWallpaperSetStatus int setStatus); 467 468 /** 469 * Sets whether a daily wallpaper update is pending. Writes status to memory and also to disk 470 * before returning. 471 */ setPendingDailyWallpaperUpdateStatusSync( @endingDailyWallpaperUpdateStatus int updateStatus)472 void setPendingDailyWallpaperUpdateStatusSync( 473 @PendingDailyWallpaperUpdateStatus int updateStatus); 474 475 /** 476 * Returns whether a daily wallpaper update is pending. 477 */ 478 @PendingDailyWallpaperUpdateStatus getPendingDailyWallpaperUpdateStatus()479 int getPendingDailyWallpaperUpdateStatus(); 480 481 /** 482 * Sets whether a daily wallpaper update is pending. Writes status to memory immediately and to 483 * disk after returning. 484 */ setPendingDailyWallpaperUpdateStatus(@endingDailyWallpaperUpdateStatus int updateStatus)485 void setPendingDailyWallpaperUpdateStatus(@PendingDailyWallpaperUpdateStatus int updateStatus); 486 487 /** 488 * Increments the number of consecutive days daily rotation has failed. 489 */ incrementNumDaysDailyRotationFailed()490 void incrementNumDaysDailyRotationFailed(); 491 492 /** 493 * Gets the number of days daily rotation failed. 494 */ getNumDaysDailyRotationFailed()495 int getNumDaysDailyRotationFailed(); 496 497 /** 498 * Resets the consecutive number of days daily rotation failed to 0. 499 */ resetNumDaysDailyRotationFailed()500 void resetNumDaysDailyRotationFailed(); 501 502 /** 503 * Increments the number of consecutive days daily rotation was not attempted. 504 */ incrementNumDaysDailyRotationNotAttempted()505 void incrementNumDaysDailyRotationNotAttempted(); 506 507 /** 508 * Gets the number ofconsecutive days daily rotation was not attempted. 509 */ getNumDaysDailyRotationNotAttempted()510 int getNumDaysDailyRotationNotAttempted(); 511 512 /** 513 * Resets the consecutive number of days daily rotation was not attempted to 0. 514 */ resetNumDaysDailyRotationNotAttempted()515 void resetNumDaysDailyRotationNotAttempted(); 516 517 /** 518 * Return the count of wallpaper picker launch. 519 */ getAppLaunchCount()520 int getAppLaunchCount(); 521 522 /** 523 * Return the date for the first time to launch wallpaper picker. 524 */ getFirstLaunchDateSinceSetup()525 int getFirstLaunchDateSinceSetup(); 526 527 /** 528 * Increments the number of wallpaper picker launch. 529 */ incrementAppLaunched()530 void incrementAppLaunched(); 531 532 /** 533 * Returns the date for the first time to apply a wallpaper. 534 */ getFirstWallpaperApplyDateSinceSetup()535 int getFirstWallpaperApplyDateSinceSetup(); 536 537 /** 538 * Sets wallpapers colors of wallpaper's id. 539 * @param storedWallpaperId wallpaper id. 540 * @param wallpaperColors Colors extracted from an image via quantization. 541 */ storeWallpaperColors(String storedWallpaperId, WallpaperColors wallpaperColors)542 void storeWallpaperColors(String storedWallpaperId, WallpaperColors wallpaperColors); 543 544 /** 545 * Returns the wallpaper colors from wallpaper's id. 546 * @param storedWallpaperId wallpaper id. 547 */ getWallpaperColors(String storedWallpaperId)548 WallpaperColors getWallpaperColors(String storedWallpaperId); 549 550 /** 551 * Update currently set daily wallpaper info. 552 * 553 * @param destination The wallpaper destination, 1: home, 2: lockscreen, 3: both. 554 * @param collectionId wallpaper category. 555 * @param wallpaperId wallpaper id. 556 */ updateDailyWallpaperSet(@estination int destination, String collectionId, String wallpaperId)557 void updateDailyWallpaperSet(@Destination int destination, String collectionId, 558 String wallpaperId); 559 560 /** 561 * The possible wallpaper presentation modes, i.e., either "static" or "rotating". 562 */ 563 @IntDef({ 564 PRESENTATION_MODE_STATIC, 565 PRESENTATION_MODE_ROTATING}) 566 @interface PresentationMode { 567 } 568 569 /** 570 * Possible status of whether a wallpaper set operation is pending or not. 571 */ 572 @IntDef({ 573 WALLPAPER_SET_NOT_PENDING, 574 WALLPAPER_SET_PENDING}) 575 @interface PendingWallpaperSetStatus { 576 } 577 578 /** 579 * Possible status of whether a wallpaper set operation is pending or not. 580 */ 581 @IntDef({ 582 DAILY_WALLPAPER_UPDATE_NOT_PENDING, 583 DAILY_WALLPAPER_UPDATE_PENDING}) 584 @interface PendingDailyWallpaperUpdateStatus { 585 } 586 587 /** 588 * Stores the given live wallpaper in the recent wallpapers list 589 * @param which flag indicating the wallpaper destination 590 * @param wallpaperId unique identifier for this wallpaper 591 * @param wallpaper {@link LiveWallpaperInfo} for the applied wallpaper 592 * @param colors WallpaperColors to be used as placeholder for quickswitching 593 */ storeLatestWallpaper(@etWallpaperFlags int which, String wallpaperId, @NonNull LiveWallpaperInfo wallpaper, WallpaperColors colors)594 default void storeLatestWallpaper(@SetWallpaperFlags int which, String wallpaperId, 595 @NonNull LiveWallpaperInfo wallpaper, WallpaperColors colors) { 596 // Do nothing in the default case. 597 } 598 599 /** 600 * Stores the given static wallpaper data in the recent wallpapers list. 601 * @param which flag indicating the wallpaper destination 602 * @param wallpaperId unique identifier for this wallpaper 603 * @param wallpaper {@link WallpaperInfo} for the applied wallpaper 604 * @param croppedWallpaperBitmap wallpaper bitmap exactly as applied to WallaperManager 605 * @param colors WallpaperColors to be used as placeholder for quickswitching 606 */ storeLatestWallpaper(@etWallpaperFlags int which, String wallpaperId, @NonNull WallpaperInfo wallpaper, @NonNull Bitmap croppedWallpaperBitmap, WallpaperColors colors)607 default void storeLatestWallpaper(@SetWallpaperFlags int which, String wallpaperId, 608 @NonNull WallpaperInfo wallpaper, 609 @NonNull Bitmap croppedWallpaperBitmap, WallpaperColors colors) { 610 // Do nothing in the default case. 611 } 612 613 /** 614 * Stores the given static wallpaper data in the recent wallpapers list. 615 * @param which flag indicating the wallpaper destination 616 * @param wallpaperId unique identifier for this wallpaper 617 * @param attributions List of attribution items. 618 * @param actionUrl The action or "explore" URL for the wallpaper. 619 * @param collectionId identifier of this wallpaper's collection. 620 * @param croppedWallpaperBitmap wallpaper bitmap exactly as applied to WallaperManager 621 * @param colors {@link WallpaperColors} to be used as placeholder for quickswitching 622 */ storeLatestWallpaper( @etWallpaperFlags int which, String wallpaperId, List<String> attributions, String actionUrl, String collectionId, @NonNull Bitmap croppedWallpaperBitmap, WallpaperColors colors)623 default void storeLatestWallpaper( 624 @SetWallpaperFlags int which, 625 String wallpaperId, List<String> attributions, 626 String actionUrl, String collectionId, 627 @NonNull Bitmap croppedWallpaperBitmap, WallpaperColors colors) { 628 // Do nothing in the default case. 629 } 630 631 /** 632 * Generates a default key to look up a wallpaper in the list of recent wallpapers. 633 * 634 * <p>This key can be used as a fallback when {@link #getHomeWallpaperRecentsKey()} or 635 * {@link #getLockWallpaperRecentsKey()} return null. 636 * @param remoteId wallpaper's remote id 637 * @param hashCode wallpaper's hash code 638 * @return the recents key 639 */ 640 @Nullable generateRecentsKey(@ullable String remoteId, long hashCode)641 static String generateRecentsKey(@Nullable String remoteId, long hashCode) { 642 if (!TextUtils.isEmpty(remoteId)) { 643 return remoteId; 644 } else if (hashCode > 0) { 645 return String.valueOf(hashCode); 646 } else { 647 return null; 648 } 649 } 650 } 651