summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/wallpaper/testing/TestWallpaperPreferences.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/com/android/wallpaper/testing/TestWallpaperPreferences.java')
-rw-r--r--tests/src/com/android/wallpaper/testing/TestWallpaperPreferences.java457
1 files changed, 457 insertions, 0 deletions
diff --git a/tests/src/com/android/wallpaper/testing/TestWallpaperPreferences.java b/tests/src/com/android/wallpaper/testing/TestWallpaperPreferences.java
new file mode 100644
index 0000000..715e81b
--- /dev/null
+++ b/tests/src/com/android/wallpaper/testing/TestWallpaperPreferences.java
@@ -0,0 +1,457 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.wallpaper.testing;
+
+import androidx.annotation.Nullable;
+
+import com.android.wallpaper.module.WallpaperPreferences;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Test implementation of the WallpaperPreferences interface. Just keeps prefs in memory.
+ */
+public class TestWallpaperPreferences implements WallpaperPreferences {
+
+ @PresentationMode
+ private int mWallpaperPresentationMode;
+
+ private List<String> mHomeScreenAttributions;
+ private long mHomeScreenBitmapHashCode;
+ private int mHomeWallpaperManagerId;
+ private String mHomeScreenPackageName;
+ private String mHomeActionUrl;
+ private String mHomeBaseImageUrl;
+ private String mHomeCollectionId;
+ private String mHomeWallpaperRemoteId;
+
+ private List<String> mLockScreenAttributions;
+ private long mLockScreenBitmapHashCode;
+ private int mLockWallpaperManagerId;
+ private String mLockActionUrl;
+ private String mLockCollectionId;
+
+ private List<Long> mDailyRotations;
+ private long mDailyWallpaperEnabledTimestamp;
+ private long mLastDailyLogTimestamp;
+ private long mLastAppActiveTimestamp;
+ private int mLastDailyWallpaperRotationStatus;
+ private long mLastDailyWallpaperRotationStatusTimestamp;
+ private long mLastSyncTimestamp;
+ @PendingWallpaperSetStatus
+ private int mPendingWallpaperSetStatus;
+ @PendingDailyWallpaperUpdateStatus
+ private int mPendingDailyWallpaperUpdateStatus;
+ private int mNumDaysDailyRotationFailed;
+ private int mNumDaysDailyRotationNotAttempted;
+ private int mHomeWallpaperActionLabelRes;
+ private int mHomeWallpaperActionIconRes;
+ private int mLockWallpaperActionLabelRes;
+ private int mLockWallpaperActionIconRes;
+
+ public TestWallpaperPreferences() {
+ mWallpaperPresentationMode = WallpaperPreferences.PRESENTATION_MODE_STATIC;
+ mHomeScreenAttributions = Arrays.asList("Android wallpaper");
+ mHomeScreenBitmapHashCode = 0;
+ mHomeWallpaperManagerId = 0;
+
+ mLockScreenAttributions = Arrays.asList("Android wallpaper");
+ mLockScreenBitmapHashCode = 0;
+ mLockWallpaperManagerId = 0;
+
+ mDailyRotations = new ArrayList<>();
+ mDailyWallpaperEnabledTimestamp = -1;
+ mLastDailyLogTimestamp = -1;
+ mLastDailyWallpaperRotationStatus = -1;
+ mLastDailyWallpaperRotationStatusTimestamp = 0;
+ mLastSyncTimestamp = 0;
+ mPendingWallpaperSetStatus = WALLPAPER_SET_NOT_PENDING;
+ }
+
+ @Override
+ public int getWallpaperPresentationMode() {
+ return mWallpaperPresentationMode;
+ }
+
+ @Override
+ public void setWallpaperPresentationMode(@PresentationMode int presentationMode) {
+ mWallpaperPresentationMode = presentationMode;
+ }
+
+ @Override
+ public List<String> getHomeWallpaperAttributions() {
+ return mHomeScreenAttributions;
+ }
+
+ @Override
+ public void setHomeWallpaperAttributions(List<String> attributions) {
+ mHomeScreenAttributions = attributions;
+ }
+
+ @Override
+ public String getHomeWallpaperActionUrl() {
+ return mHomeActionUrl;
+ }
+
+ @Override
+ public void setHomeWallpaperActionUrl(String actionUrl) {
+ mHomeActionUrl = actionUrl;
+ }
+
+ @Override
+ public int getHomeWallpaperActionLabelRes() {
+ return mHomeWallpaperActionLabelRes;
+ }
+
+ @Override
+ public void setHomeWallpaperActionLabelRes(int resId) {
+ mHomeWallpaperActionLabelRes = resId;
+ }
+
+ @Override
+ public int getHomeWallpaperActionIconRes() {
+ return mHomeWallpaperActionIconRes;
+ }
+
+ @Override
+ public void setHomeWallpaperActionIconRes(int resId) {
+ mHomeWallpaperActionIconRes = resId;
+ }
+
+ @Override
+ public String getHomeWallpaperBaseImageUrl() {
+ return mHomeBaseImageUrl;
+ }
+
+ @Override
+ public void setHomeWallpaperBaseImageUrl(String baseImageUrl) {
+ mHomeBaseImageUrl = baseImageUrl;
+ }
+
+ @Override
+ public String getHomeWallpaperCollectionId() {
+ return mHomeCollectionId;
+ }
+
+ @Override
+ public void setHomeWallpaperCollectionId(String collectionId) {
+ mHomeCollectionId = collectionId;
+ }
+
+ @Override
+ public String getHomeWallpaperBackingFileName() {
+ return null;
+ }
+
+ @Override
+ public void setHomeWallpaperBackingFileName(String fileName) {
+
+ }
+
+ @Override
+ public void clearHomeWallpaperMetadata() {
+ mHomeScreenAttributions = null;
+ mWallpaperPresentationMode = WallpaperPreferences.PRESENTATION_MODE_STATIC;
+ mHomeScreenBitmapHashCode = 0;
+ mHomeScreenPackageName = null;
+ mHomeWallpaperManagerId = 0;
+ }
+
+ @Override
+ public long getHomeWallpaperHashCode() {
+ return mHomeScreenBitmapHashCode;
+ }
+
+ @Override
+ public void setHomeWallpaperHashCode(long hashCode) {
+ mHomeScreenBitmapHashCode = hashCode;
+ }
+
+ @Override
+ public String getHomeWallpaperPackageName() {
+ return mHomeScreenPackageName;
+ }
+
+ @Override
+ public void setHomeWallpaperPackageName(String packageName) {
+ mHomeScreenPackageName = packageName;
+ }
+
+ @Override
+ public int getHomeWallpaperManagerId() {
+ return mHomeWallpaperManagerId;
+ }
+
+ @Override
+ public void setHomeWallpaperManagerId(int homeWallpaperId) {
+ mHomeWallpaperManagerId = homeWallpaperId;
+ }
+
+ @Override
+ public String getHomeWallpaperRemoteId() {
+ return mHomeWallpaperRemoteId;
+ }
+
+ @Override
+ public void setHomeWallpaperRemoteId(String wallpaperRemoteId) {
+ mHomeWallpaperRemoteId = wallpaperRemoteId;
+ }
+
+ @Override
+ public List<String> getLockWallpaperAttributions() {
+ return mLockScreenAttributions;
+ }
+
+ @Override
+ public void setLockWallpaperAttributions(List<String> attributions) {
+ mLockScreenAttributions = attributions;
+ }
+
+ @Override
+ public String getLockWallpaperActionUrl() {
+ return mLockActionUrl;
+ }
+
+ @Override
+ public void setLockWallpaperActionUrl(String actionUrl) {
+ mLockActionUrl = actionUrl;
+ }
+
+ @Override
+ public int getLockWallpaperActionLabelRes() {
+ return mLockWallpaperActionLabelRes;
+ }
+
+ @Override
+ public void setLockWallpaperActionLabelRes(int resId) {
+ mLockWallpaperActionLabelRes = resId;
+ }
+
+ @Override
+ public int getLockWallpaperActionIconRes() {
+ return mLockWallpaperActionIconRes;
+ }
+
+ @Override
+ public void setLockWallpaperActionIconRes(int resId) {
+ mLockWallpaperActionIconRes = resId;
+ }
+
+ @Override
+ public String getLockWallpaperCollectionId() {
+ return mLockCollectionId;
+ }
+
+ @Override
+ public void setLockWallpaperCollectionId(String collectionId) {
+ mLockCollectionId = collectionId;
+ }
+
+ @Override
+ public String getLockWallpaperBackingFileName() {
+ return null;
+ }
+
+ @Override
+ public void setLockWallpaperBackingFileName(String fileName) {
+
+ }
+
+ @Override
+ public void clearLockWallpaperMetadata() {
+ mLockScreenAttributions = null;
+ mLockScreenBitmapHashCode = 0;
+ mLockWallpaperManagerId = 0;
+ }
+
+ @Override
+ public long getLockWallpaperHashCode() {
+ return mLockScreenBitmapHashCode;
+ }
+
+ @Override
+ public void setLockWallpaperHashCode(long hashCode) {
+ mLockScreenBitmapHashCode = hashCode;
+ }
+
+ @Override
+ public int getLockWallpaperId() {
+ return mLockWallpaperManagerId;
+ }
+
+ @Override
+ public void setLockWallpaperId(int lockWallpaperId) {
+ mLockWallpaperManagerId = lockWallpaperId;
+ }
+
+ @Override
+ public void addDailyRotation(long timestamp) {
+ mDailyRotations.add(timestamp);
+ }
+
+ @Override
+ public long getLastDailyRotationTimestamp() {
+ if (mDailyRotations.size() == 0) {
+ return -1;
+ }
+
+ return mDailyRotations.get(mDailyRotations.size() - 1);
+ }
+
+ @Override
+ public List<Long> getDailyRotationsInLastWeek() {
+ return mDailyRotations;
+ }
+
+ @Nullable
+ @Override
+ public List<Long> getDailyRotationsPreviousDay() {
+ return null;
+ }
+
+ @Override
+ public long getDailyWallpaperEnabledTimestamp() {
+ return mDailyWallpaperEnabledTimestamp;
+ }
+
+ @Override
+ public void setDailyWallpaperEnabledTimestamp(long timestamp) {
+ mDailyWallpaperEnabledTimestamp = timestamp;
+ }
+
+ @Override
+ public void clearDailyRotations() {
+ mDailyRotations.clear();
+ }
+
+ @Override
+ public long getLastDailyLogTimestamp() {
+ return mLastDailyLogTimestamp;
+ }
+
+ @Override
+ public void setLastDailyLogTimestamp(long timestamp) {
+ mLastDailyLogTimestamp = timestamp;
+ }
+
+ @Override
+ public long getLastAppActiveTimestamp() {
+ return mLastAppActiveTimestamp;
+ }
+
+ @Override
+ public void setLastAppActiveTimestamp(long timestamp) {
+ mLastAppActiveTimestamp = timestamp;
+ }
+
+ @Override
+ public void setDailyWallpaperRotationStatus(int status, long timestamp) {
+ mLastDailyWallpaperRotationStatus = status;
+ mLastDailyWallpaperRotationStatusTimestamp = timestamp;
+ }
+
+ @Override
+ public int getDailyWallpaperLastRotationStatus() {
+ return mLastDailyWallpaperRotationStatus;
+ }
+
+ @Override
+ public long getDailyWallpaperLastRotationStatusTimestamp() {
+ return mLastDailyWallpaperRotationStatusTimestamp;
+ }
+
+ @Override
+ public long getLastSyncTimestamp() {
+ return mLastSyncTimestamp;
+ }
+
+ @Override
+ public void setLastSyncTimestamp(long timestamp) {
+ mLastSyncTimestamp = timestamp;
+ }
+
+ @Override
+ public void setPendingWallpaperSetStatusSync(@PendingWallpaperSetStatus int setStatus) {
+ mPendingWallpaperSetStatus = setStatus;
+ }
+
+ @Override
+ public int getPendingWallpaperSetStatus() {
+ return mPendingWallpaperSetStatus;
+ }
+
+ @Override
+ public void setPendingWallpaperSetStatus(@PendingWallpaperSetStatus int setStatus) {
+ mPendingWallpaperSetStatus = setStatus;
+ }
+
+ @Override
+ public void setPendingDailyWallpaperUpdateStatusSync(
+ @PendingDailyWallpaperUpdateStatus int updateStatus) {
+ mPendingDailyWallpaperUpdateStatus = updateStatus;
+ }
+
+ @Override
+ public int getPendingDailyWallpaperUpdateStatus() {
+ return mPendingDailyWallpaperUpdateStatus;
+ }
+
+ @Override
+ public void setPendingDailyWallpaperUpdateStatus(
+ @PendingDailyWallpaperUpdateStatus int updateStatus) {
+ mPendingDailyWallpaperUpdateStatus = updateStatus;
+ }
+
+ @Override
+ public void incrementNumDaysDailyRotationFailed() {
+ mNumDaysDailyRotationFailed++;
+ }
+
+ @Override
+ public int getNumDaysDailyRotationFailed() {
+ return mNumDaysDailyRotationFailed;
+ }
+
+ public void setNumDaysDailyRotationFailed(int days) {
+ mNumDaysDailyRotationFailed = days;
+ }
+
+ @Override
+ public void resetNumDaysDailyRotationFailed() {
+ mNumDaysDailyRotationFailed = 0;
+ }
+
+ @Override
+ public void incrementNumDaysDailyRotationNotAttempted() {
+ mNumDaysDailyRotationNotAttempted++;
+ }
+
+ @Override
+ public int getNumDaysDailyRotationNotAttempted() {
+ return mNumDaysDailyRotationNotAttempted;
+ }
+
+ public void setNumDaysDailyRotationNotAttempted(int days) {
+ mNumDaysDailyRotationNotAttempted = days;
+ }
+
+ @Override
+ public void resetNumDaysDailyRotationNotAttempted() {
+ mNumDaysDailyRotationNotAttempted = 0;
+ }
+}