Remove support for rotating live wallpaper
Bug:112267966
Change-Id: I3b75dcb462ca648d2a2dc7d7fe04d878cb8de4a6
diff --git a/src/com/android/wallpaper/model/WallpaperRotationInitializer.java b/src/com/android/wallpaper/model/WallpaperRotationInitializer.java
index ad9eef9..5797650 100755
--- a/src/com/android/wallpaper/model/WallpaperRotationInitializer.java
+++ b/src/com/android/wallpaper/model/WallpaperRotationInitializer.java
@@ -58,13 +58,6 @@
Listener listener);
/**
- * Returns whether the live wallpaper needs to be set to the device in order to be able to start
- * rotation or is already set but on home-only on N-MR2 or later, which means the user has the
- * option to pick a new destination preference.
- */
- boolean isNoBackupImageWallpaperPreviewNeeded(Context appContext);
-
- /**
* Gets the current state of the possible wallpaper rotation represented by this object.
*/
void fetchRotationInitializationState(Context context, RotationStateListener listener);
diff --git a/src/com/android/wallpaper/module/BaseWallpaperInjector.java b/src/com/android/wallpaper/module/BaseWallpaperInjector.java
index f8191fc..7f52823 100755
--- a/src/com/android/wallpaper/module/BaseWallpaperInjector.java
+++ b/src/com/android/wallpaper/module/BaseWallpaperInjector.java
@@ -39,7 +39,6 @@
private AlarmManagerWrapper mAlarmManagerWrapper;
private ExploreIntentChecker mExploreIntentChecker;
private SystemFeatureChecker mSystemFeatureChecker;
- private RotatingWallpaperComponentChecker mRotatingWallpaperComponentChecker;
private FormFactorChecker mFormFactorChecker;
private PackageStatusNotifier mPackageStatusNotifier;
private LiveWallpaperInfoFactory mLiveWallpaperInfoFactory;
@@ -161,14 +160,6 @@
}
@Override
- public synchronized RotatingWallpaperComponentChecker getRotatingWallpaperComponentChecker() {
- if (mRotatingWallpaperComponentChecker == null) {
- mRotatingWallpaperComponentChecker = new DefaultRotatingWallpaperComponentChecker();
- }
- return mRotatingWallpaperComponentChecker;
- }
-
- @Override
public synchronized FormFactorChecker getFormFactorChecker(Context context) {
if (mFormFactorChecker == null) {
mFormFactorChecker = new DefaultFormFactorChecker(context.getApplicationContext());
diff --git a/src/com/android/wallpaper/module/DefaultRotatingWallpaperComponentChecker.java b/src/com/android/wallpaper/module/DefaultRotatingWallpaperComponentChecker.java
deleted file mode 100755
index eddb6bf..0000000
--- a/src/com/android/wallpaper/module/DefaultRotatingWallpaperComponentChecker.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2017 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.module;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-
-/**
- * Default implementation of {@link RotatingWallpaperComponentChecker}.
- */
-public class DefaultRotatingWallpaperComponentChecker implements RotatingWallpaperComponentChecker {
-
- private static boolean isLiveWallpaperSupported(Context context) {
- return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LIVE_WALLPAPER);
- }
-
- @Override
- @RotatingWallpaperComponent
- public int getCurrentRotatingWallpaperComponent(Context context) {
- if (!isLiveWallpaperSupported(context)) {
- return ROTATING_WALLPAPER_COMPONENT_STATIC;
- }
-
- // If presentation mode is ROTATING but the live wallpaper is not set, then "legacy" rotation
- // from older APKs is in effect and the current rotating wallpaper component is a static WP.
- Injector injector = InjectorProvider.getInjector();
- WallpaperPreferences preferences = injector.getPreferences(context);
- LiveWallpaperStatusChecker liveWallpaperStatusChecker = injector
- .getLiveWallpaperStatusChecker(context);
- if (preferences.getWallpaperPresentationMode()
- == WallpaperPreferences.PRESENTATION_MODE_ROTATING
- && !liveWallpaperStatusChecker.isNoBackupImageWallpaperSet()) {
- return ROTATING_WALLPAPER_COMPONENT_STATIC;
- }
-
- return ROTATING_WALLPAPER_COMPONENT_LIVE;
- }
-
- @Override
- @RotatingWallpaperComponent
- public int getNextRotatingWallpaperComponent(Context context) {
- if (!isLiveWallpaperSupported(context)) {
- return ROTATING_WALLPAPER_COMPONENT_STATIC;
- }
-
- return ROTATING_WALLPAPER_COMPONENT_LIVE;
- }
-
- @Override
- @RotatingWallpaperSupport
- public int getRotatingWallpaperSupport(Context context) {
- FormFactorChecker formFactorChecker =
- InjectorProvider.getInjector().getFormFactorChecker(context);
-
- if (formFactorChecker.getFormFactor() == FormFactorChecker.FORM_FACTOR_DESKTOP) {
- return ROTATING_WALLPAPER_SUPPORT_SUPPORTED;
- }
-
- // While static daily rotation is supported on desktops, it isn't (yet?) supported on phones.
- // For phones which don't support live wallpapers thus we disallow daily rotation altogether.
- return isLiveWallpaperSupported(context) ? ROTATING_WALLPAPER_SUPPORT_SUPPORTED
- : ROTATING_WALLPAPER_SUPPORT_NOT_SUPPORTED;
- }
-}
diff --git a/src/com/android/wallpaper/module/DefaultWallpaperPersister.java b/src/com/android/wallpaper/module/DefaultWallpaperPersister.java
index e2c968c..27e4491 100755
--- a/src/com/android/wallpaper/module/DefaultWallpaperPersister.java
+++ b/src/com/android/wallpaper/module/DefaultWallpaperPersister.java
@@ -19,7 +19,6 @@
import android.app.Activity;
import android.app.WallpaperManager;
import android.content.Context;
-import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
@@ -32,6 +31,8 @@
import android.view.Display;
import android.view.WindowManager;
+import androidx.annotation.Nullable;
+
import com.android.wallpaper.asset.Asset;
import com.android.wallpaper.asset.Asset.BitmapReceiver;
import com.android.wallpaper.asset.Asset.DimensionsReceiver;
@@ -42,24 +43,16 @@
import com.android.wallpaper.compat.WallpaperManagerCompat;
import com.android.wallpaper.model.WallpaperInfo;
import com.android.wallpaper.module.BitmapCropper.Callback;
-import com.android.wallpaper.module.RotatingWallpaperComponentChecker.RotatingWallpaperComponent;
import com.android.wallpaper.util.BitmapTransformer;
-import com.android.wallpaper.util.DiskBasedLogger;
-import com.android.wallpaper.util.FileMover;
import com.android.wallpaper.util.ScreenSizeCalculator;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
-import androidx.annotation.Nullable;
-
/**
* Concrete implementation of WallpaperPersister which actually sets wallpapers to the system via
* the WallpaperManager.
@@ -71,11 +64,9 @@
private final Context mAppContext; // The application's context.
// Context that accesses files in device protected storage
- private final Context mDeviceProtectedContext;
private final WallpaperManager mWallpaperManager;
private final WallpaperManagerCompat mWallpaperManagerCompat;
private final WallpaperPreferences mWallpaperPreferences;
- private final RotatingWallpaperComponentChecker mRotatingWallpaperComponentChecker;
private final WallpaperChangedNotifier mWallpaperChangedNotifier;
private WallpaperInfo mWallpaperInfoInPreview;
@@ -83,21 +74,19 @@
@SuppressLint("ServiceCast")
public DefaultWallpaperPersister(Context context) {
mAppContext = context.getApplicationContext();
- mDeviceProtectedContext = mAppContext.createDeviceProtectedStorageContext();
// Retrieve WallpaperManager using Context#getSystemService instead of
// WallpaperManager#getInstance so it can be mocked out in test.
Injector injector = InjectorProvider.getInjector();
mWallpaperManager = (WallpaperManager) context.getSystemService(Context.WALLPAPER_SERVICE);
mWallpaperManagerCompat = injector.getWallpaperManagerCompat(context);
mWallpaperPreferences = injector.getPreferences(context);
- mRotatingWallpaperComponentChecker = injector.getRotatingWallpaperComponentChecker();
mWallpaperChangedNotifier = WallpaperChangedNotifier.getInstance();
}
@Override
public void setIndividualWallpaper(final WallpaperInfo wallpaper, Asset asset,
- @Nullable Rect cropRect, float scale, @Destination final int destination,
- final SetWallpaperCallback callback) {
+ @Nullable Rect cropRect, float scale, @Destination final int destination,
+ final SetWallpaperCallback callback) {
// Set wallpaper without downscaling directly from an input stream if there's no crop rect
// specified by the caller and the asset is streamable.
if (cropRect == null && asset instanceof StreamableAsset) {
@@ -149,7 +138,7 @@
@Override
public void setIndividualWallpaperWithPosition(Activity activity, WallpaperInfo wallpaper,
- @WallpaperPosition int wallpaperPosition, SetWallpaperCallback callback) {
+ @WallpaperPosition int wallpaperPosition, SetWallpaperCallback callback) {
Display display = ((WindowManager) mAppContext.getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
Point screenSize = ScreenSizeCalculator.getInstance().getScreenSize(display);
@@ -164,9 +153,10 @@
}
switch (wallpaperPosition) {
- // Crop out screen-sized center portion of the source image if it's larger than the screen
- // in both dimensions. Otherwise, decode the entire bitmap and fill the space around it to
- // fill a new screen-sized bitmap with plain black pixels.
+ // Crop out screen-sized center portion of the source image if it's larger
+ // than the screen
+ // in both dimensions. Otherwise, decode the entire bitmap and fill the space
+ // around it to fill a new screen-sized bitmap with plain black pixels.
case WALLPAPER_POSITION_CENTER:
setIndividualWallpaperWithCenterPosition(
wallpaper, asset, dimensions, screenSize, callback);
@@ -178,19 +168,22 @@
wallpaper, asset, dimensions, screenSize, callback);
break;
- // Decode full bitmap sized for screen and stretch it to fill the screen dimensions.
+ // Decode full bitmap sized for screen and stretch it to fill the screen
+ // dimensions.
case WALLPAPER_POSITION_STRETCH:
asset.decodeBitmap(screenSize.x, screenSize.y, new BitmapReceiver() {
@Override
public void onBitmapDecoded(@Nullable Bitmap bitmap) {
- setIndividualWallpaperStretch(wallpaper, bitmap, screenSize /* stretchSize */,
+ setIndividualWallpaperStretch(wallpaper, bitmap,
+ screenSize /* stretchSize */,
WallpaperPersister.DEST_BOTH, callback);
}
});
break;
default:
- Log.e(TAG, "Unsupported wallpaper position option specified: " + wallpaperPosition);
+ Log.e(TAG, "Unsupported wallpaper position option specified: "
+ + wallpaperPosition);
callback.onError(null);
}
}
@@ -208,7 +201,7 @@
* @param callback Callback used to notify original caller of wallpaper set operation result.
*/
private void setIndividualWallpaperWithCenterPosition(WallpaperInfo wallpaper, Asset asset,
- Point dimensions, Point screenSize, SetWallpaperCallback callback) {
+ Point dimensions, Point screenSize, SetWallpaperCallback callback) {
if (dimensions.x >= screenSize.x && dimensions.y >= screenSize.y) {
Rect cropRect = new Rect(
(dimensions.x - screenSize.x) / 2,
@@ -218,7 +211,8 @@
asset.decodeBitmapRegion(cropRect, screenSize.x, screenSize.y, new BitmapReceiver() {
@Override
public void onBitmapDecoded(@Nullable Bitmap bitmap) {
- setIndividualWallpaper(wallpaper, bitmap, WallpaperPersister.DEST_BOTH, callback);
+ setIndividualWallpaper(wallpaper, bitmap, WallpaperPersister.DEST_BOTH,
+ callback);
}
});
} else {
@@ -249,7 +243,7 @@
* @param callback Callback used to notify original caller of wallpaper set operation result.
*/
private void setIndividualWallpaperWithCenterCropPosition(WallpaperInfo wallpaper, Asset asset,
- Point dimensions, Point screenSize, SetWallpaperCallback callback) {
+ Point dimensions, Point screenSize, SetWallpaperCallback callback) {
float scale = Math.max((float) screenSize.x / dimensions.x,
(float) screenSize.y / dimensions.y);
@@ -276,7 +270,7 @@
* @param callback Called once the wallpaper was set or if an error occurred.
*/
private void setIndividualWallpaper(WallpaperInfo wallpaper, Bitmap croppedBitmap,
- @Destination int destination, SetWallpaperCallback callback) {
+ @Destination int destination, SetWallpaperCallback callback) {
SetWallpaperTask setWallpaperTask =
new SetWallpaperTask(wallpaper, croppedBitmap, destination, callback);
setWallpaperTask.execute();
@@ -287,15 +281,16 @@
*
* @param wallpaper Wallpaper model object.
* @param croppedBitmap Bitmap representing the individual wallpaper image.
- * @param fillSize Specifies the final bitmap size that should be set to WallpaperManager. This
- * final bitmap will show the visible area of the provided bitmap after applying a mask with
- * black background the source bitmap and centering. There may be black borders around the
- * original bitmap if it's smaller than the fillSize in one or both dimensions.
+ * @param fillSize Specifies the final bitmap size that should be set to WallpaperManager.
+ * This final bitmap will show the visible area of the provided bitmap
+ * after applying a mask with black background the source bitmap and
+ * centering. There may be black borders around the original bitmap if
+ * it's smaller than the fillSize in one or both dimensions.
* @param destination The destination - where to set the wallpaper to.
* @param callback Called once the wallpaper was set or if an error occurred.
*/
private void setIndividualWallpaperFill(WallpaperInfo wallpaper, Bitmap croppedBitmap,
- Point fillSize, @Destination int destination, SetWallpaperCallback callback) {
+ Point fillSize, @Destination int destination, SetWallpaperCallback callback) {
SetWallpaperTask setWallpaperTask =
new SetWallpaperTask(wallpaper, croppedBitmap, destination, callback);
setWallpaperTask.setFillSize(fillSize);
@@ -308,13 +303,14 @@
*
* @param wallpaper Wallpaper model object.
* @param croppedBitmap Bitmap representing the individual wallpaper image.
- * @param stretchSize Specifies the final size to which the the bitmap should be stretched prior
+ * @param stretchSize Specifies the final size to which the bitmap should be stretched
+ * prior
* to being set to the device.
* @param destination The destination - where to set the wallpaper to.
* @param callback Called once the wallpaper was set or if an error occurred.
*/
private void setIndividualWallpaperStretch(WallpaperInfo wallpaper, Bitmap croppedBitmap,
- Point stretchSize, @Destination int destination, SetWallpaperCallback callback) {
+ Point stretchSize, @Destination int destination, SetWallpaperCallback callback) {
SetWallpaperTask setWallpaperTask =
new SetWallpaperTask(wallpaper, croppedBitmap, destination, callback);
setWallpaperTask.setStretchSize(stretchSize);
@@ -330,7 +326,7 @@
* @param callback Called once the wallpaper was set or if an error occurred.
*/
private void setIndividualWallpaper(WallpaperInfo wallpaper, InputStream inputStream,
- @Destination int destination, SetWallpaperCallback callback) {
+ @Destination int destination, SetWallpaperCallback callback) {
SetWallpaperTask setWallpaperTask =
new SetWallpaperTask(wallpaper, inputStream, destination, callback);
setWallpaperTask.execute();
@@ -338,58 +334,31 @@
@Override
public boolean setWallpaperInRotation(Bitmap wallpaperBitmap, List<String> attributions,
- int actionLabelRes, int actionIconRes,
- String actionUrl, String collectionId) {
- @RotatingWallpaperComponent int rotatingWallpaperComponent = mRotatingWallpaperComponentChecker
- .getCurrentRotatingWallpaperComponent(mAppContext);
+ int actionLabelRes, int actionIconRes, String actionUrl, String collectionId) {
- switch (rotatingWallpaperComponent) {
- case RotatingWallpaperComponentChecker.ROTATING_WALLPAPER_COMPONENT_STATIC:
- return setWallpaperInRotationStatic(wallpaperBitmap, attributions, actionUrl,
- actionLabelRes, actionIconRes, collectionId);
- case RotatingWallpaperComponentChecker.ROTATING_WALLPAPER_COMPONENT_LIVE:
- return setWallpaperInRotationLive(wallpaperBitmap, attributions, actionUrl,
- actionLabelRes, actionIconRes, collectionId);
- default:
- Log.e(TAG, "Unknown rotating wallpaper component: " + rotatingWallpaperComponent);
- return false;
- }
+ return setWallpaperInRotationStatic(wallpaperBitmap, attributions, actionUrl,
+ actionLabelRes, actionIconRes, collectionId);
}
@Override
public int setWallpaperBitmapInNextRotation(Bitmap wallpaperBitmap) {
- @RotatingWallpaperComponent int rotatingWallpaperComponent = mRotatingWallpaperComponentChecker
- .getNextRotatingWallpaperComponent(mAppContext);
-
- switch (rotatingWallpaperComponent) {
- case RotatingWallpaperComponentChecker.ROTATING_WALLPAPER_COMPONENT_STATIC:
- return setWallpaperBitmapInRotationStatic(wallpaperBitmap);
- case RotatingWallpaperComponentChecker.ROTATING_WALLPAPER_COMPONENT_LIVE:
- boolean isSuccess = setWallpaperBitmapInRotationLive(wallpaperBitmap, true /* isPreview */);
- return isSuccess ? 1 : 0;
- default:
- Log.e(TAG, "Unknown rotating wallpaper component: " + rotatingWallpaperComponent);
- return 0;
- }
+ return setWallpaperBitmapInRotationStatic(wallpaperBitmap);
}
@Override
public boolean finalizeWallpaperForNextRotation(List<String> attributions, String actionUrl,
- int actionLabelRes, int actionIconRes,
- String collectionId, int wallpaperId) {
- @RotatingWallpaperComponent int rotatingWallpaperComponent =
- mRotatingWallpaperComponentChecker.getNextRotatingWallpaperComponent(mAppContext);
+ int actionLabelRes, int actionIconRes, String collectionId, int wallpaperId) {
return finalizeWallpaperForRotatingComponent(attributions, actionUrl, actionLabelRes,
- actionIconRes, collectionId, wallpaperId, rotatingWallpaperComponent);
+ actionIconRes, collectionId, wallpaperId);
}
/**
- * Sets wallpaper image and attributions when a static wallpaper is responsible for presenting the
+ * Sets wallpaper image and attributions when a static wallpaper is responsible for presenting
+ * the
* current "daily wallpaper".
*/
private boolean setWallpaperInRotationStatic(Bitmap wallpaperBitmap, List<String> attributions,
- String actionUrl, int actionLabelRes,
- int actionIconRes, String collectionId) {
+ String actionUrl, int actionLabelRes, int actionIconRes, String collectionId) {
final int wallpaperId = setWallpaperBitmapInRotationStatic(wallpaperBitmap);
if (wallpaperId == 0) {
@@ -397,8 +366,7 @@
}
return finalizeWallpaperForRotatingComponent(attributions, actionUrl, actionLabelRes,
- actionIconRes, collectionId, wallpaperId,
- RotatingWallpaperComponentChecker.ROTATING_WALLPAPER_COMPONENT_STATIC);
+ actionIconRes, collectionId, wallpaperId);
}
/**
@@ -413,83 +381,21 @@
int actionLabelRes,
int actionIconRes,
String collectionId,
- int wallpaperId,
- @RotatingWallpaperComponent int rotatingWallpaperComponent) {
+ int wallpaperId) {
mWallpaperPreferences.clearHomeWallpaperMetadata();
boolean isLockWallpaperSet = isSeparateLockScreenWallpaperSet();
- // Persist wallpaper IDs if the rotating wallpaper component is static and this device is
- // running Android N or later.
- if (rotatingWallpaperComponent
- == RotatingWallpaperComponentChecker.ROTATING_WALLPAPER_COMPONENT_STATIC) {
- if (BuildCompat.isAtLeastN()) {
- mWallpaperPreferences.setHomeWallpaperManagerId(wallpaperId);
+ // Persist wallpaper IDs if the rotating wallpaper component
+ mWallpaperPreferences.setHomeWallpaperManagerId(wallpaperId);
- // Only copy over wallpaper ID to lock wallpaper if no explicit lock wallpaper is set (so
- // metadata isn't lost if a user explicitly sets a home-only wallpaper).
- if (!isLockWallpaperSet) {
- mWallpaperPreferences.setLockWallpaperId(wallpaperId);
- }
- } else { // Pre-N but using static component
- // Compute bitmap hash code after setting the wallpaper because JPEG compression has likely
- // changed many pixels' color values. Forget the previously loaded wallpaper bitmap so that
- // WallpaperManager doesn't return the old wallpaper drawable.
- mWallpaperManager.forgetLoadedWallpaper();
- Bitmap bitmap = ((BitmapDrawable) mWallpaperManagerCompat.getDrawable()).getBitmap();
- long bitmapHash = BitmapUtils.generateHashCode(bitmap);
-
- mWallpaperPreferences.setHomeWallpaperHashCode(bitmapHash);
- }
- } else { // Live wallpaper rotating component.
-
- // Copy "preview" JPEG to "rotating" JPEG if the preview file exists.
- File rotatingWallpaper;
- try {
- rotatingWallpaper = moveToDeviceProtectedStorage(
- NoBackupImageWallpaper.PREVIEW_WALLPAPER_FILE_PATH,
- NoBackupImageWallpaper.ROTATING_WALLPAPER_FILE_PATH);
- } catch (Exception e) {
- DiskBasedLogger.e(
- TAG,
- "Unable to move preview to final file for rotating wallpaper " +
- "file (exception)" + e.toString(),
- mAppContext);
- return false;
- }
- if (rotatingWallpaper == null) {
- rotatingWallpaper = mDeviceProtectedContext.getFileStreamPath(
- NoBackupImageWallpaper.ROTATING_WALLPAPER_FILE_PATH);
- }
- try {
- FileInputStream fis = new FileInputStream(rotatingWallpaper.getAbsolutePath());
- Bitmap bitmap = BitmapFactory.decodeStream(fis);
- fis.close();
-
- if (bitmap != null) {
- long bitmapHash = BitmapUtils.generateHashCode(bitmap);
- mWallpaperPreferences.setHomeWallpaperHashCode(bitmapHash);
- } else {
- Log.e(TAG, "Unable to decode rotating wallpaper file");
- return false;
- }
- } catch (FileNotFoundException e) {
- Log.e(TAG, "Rotating wallpaper file not found at path: "
- + rotatingWallpaper.getAbsolutePath());
- e.printStackTrace();
- return false;
- } catch (IOException e) {
- Log.e(TAG, "IOException when closing FileInputStream " + e);
- return false;
- }
-
- mWallpaperChangedNotifier.notifyWallpaperChanged();
-
- // Send a broadcast to {@link RotatingWallpaperChangedReceiver} in the :live_wallpaper
- // process so the currently displayed wallpaper updates.
- notifyLiveWallpaperBitmapChanged();
+ // Only copy over wallpaper ID to lock wallpaper if no explicit lock wallpaper is set
+ // (so metadata isn't lost if a user explicitly sets a home-only wallpaper).
+ if (!isLockWallpaperSet) {
+ mWallpaperPreferences.setLockWallpaperId(wallpaperId);
}
+
mWallpaperPreferences.setHomeWallpaperAttributions(attributions);
mWallpaperPreferences.setHomeWallpaperActionUrl(actionUrl);
mWallpaperPreferences.setHomeWallpaperActionLabelRes(actionLabelRes);
@@ -498,11 +404,9 @@
mWallpaperPreferences.setHomeWallpaperBaseImageUrl(null);
mWallpaperPreferences.setHomeWallpaperCollectionId(collectionId);
- // Set metadata to lock screen also when the rotating wallpaper is a static one so if user sets
- // a home screen-only wallpaper later, these attributions will still be available.
- if (rotatingWallpaperComponent
- == RotatingWallpaperComponentChecker.ROTATING_WALLPAPER_COMPONENT_STATIC
- && !isLockWallpaperSet) {
+ // Set metadata to lock screen also when the rotating wallpaper so if user sets a home
+ // screen-only wallpaper later, these attributions will still be available.
+ if (!isLockWallpaperSet) {
mWallpaperPreferences.setLockWallpaperAttributions(attributions);
mWallpaperPreferences.setLockWallpaperActionUrl(actionUrl);
mWallpaperPreferences.setLockWallpaperActionLabelRes(actionLabelRes);
@@ -514,26 +418,6 @@
}
/**
- * Sets wallpaper image and attributions when a live wallpaper is responsible for presenting the
- * current "daily wallpaper".
- */
- private boolean setWallpaperInRotationLive(Bitmap wallpaperBitmap, List<String> attributions,
- String actionUrl, int actionLabelRes,
- int actionIconRes, String collectionId) {
-
- synchronized (RotatingWallpaperLockProvider.getInstance()) {
- if (!setWallpaperBitmapInRotationLive(wallpaperBitmap, false /* isPreview */)) {
- return false;
- }
-
- return finalizeWallpaperForRotatingComponent(attributions, actionUrl, actionLabelRes,
- actionIconRes, collectionId,
- 0 /* wallpaperId */,
- RotatingWallpaperComponentChecker.ROTATING_WALLPAPER_COMPONENT_LIVE);
- }
- }
-
- /**
* Sets a wallpaper in rotation as a static wallpaper to the {@link WallpaperManager} with the
* option allowBackup=false to save user data.
*
@@ -553,84 +437,6 @@
}
/**
- * Sets a wallpaper in rotation as a live wallpaper. Writes wallpaper bitmap to a file in internal
- * storage and sends a broadcast to the live wallpaper notifying it that rotating wallpaper image
- * data changed.
- *
- * @return whether the set wallpaper operation was successful.
- */
- private boolean setWallpaperBitmapInRotationLive(Bitmap wallpaperBitmap, boolean isPreview) {
- File pendingFile;
- try {
- pendingFile = File.createTempFile("rotating_pending", ".jpg", mAppContext.getFilesDir());
- } catch (IOException e) {
- Log.e(TAG, "Unable to create temp file for rotating wallpaper");
- return false;
- }
-
- FileOutputStream fos;
- try {
- fos = mAppContext.openFileOutput(pendingFile.getName(), Context.MODE_PRIVATE);
- } catch (FileNotFoundException e) {
- Log.e(TAG, "Unable to open file output stream for pending rotating wallpaper file");
- return false;
- }
-
- boolean compressedSuccessfully =
- wallpaperBitmap.compress(CompressFormat.JPEG, DEFAULT_COMPRESS_QUALITY, fos);
-
- // Close the file stream.
- try {
- fos.flush();
- fos.close();
- } catch (IOException e) {
- Log.e(TAG, "Unable to close FileOutputStream for pending rotating wallpaper file"
- + " (compress succeeded");
- return false;
- }
-
- if (compressedSuccessfully) {
- // Compressing/writing to disk succeeded, so move the pending file to the final location.
- try {
- if (isPreview) {
- if (!pendingFile.renameTo(mAppContext.getFileStreamPath(
- NoBackupImageWallpaper.PREVIEW_WALLPAPER_FILE_PATH))) {
- return false;
- }
- } else {
- moveToDeviceProtectedStorage(pendingFile.getName(),
- NoBackupImageWallpaper.ROTATING_WALLPAPER_FILE_PATH);
- }
- } catch (Exception e) {
- Log.e(TAG, "Unable to rename pending to final file for rotating wallpaper file"
- + " (exception)" + e.toString());
- return false;
- }
- } else {
- Log.e(TAG, "Unable to compress the wallpaper bitmap");
-
- // Delete the pending file since compressing/writing the image to disk failed.
- try {
- pendingFile.delete();
- } catch (SecurityException e) {
- Log.e(TAG, "Unable to delete pending rotating wallpaper file");
- return false;
- }
-
- return false;
- }
-
- mWallpaperChangedNotifier.notifyWallpaperChanged();
-
- // Send a broadcast to {@link RotatingWallpaperChangedReceiver} in the :live_wallpaper
- // process so the currently displayed wallpaper updates if the live wallpaper is set to the
- // device.
- notifyLiveWallpaperBitmapChanged();
-
- return true;
- }
-
- /**
* Sets a wallpaper bitmap to the {@link WallpaperManagerCompat}.
*
* @return an integer wallpaper ID. This is an actual wallpaper ID on N and later versions of
@@ -638,7 +444,7 @@
* operation was successful and zero if the operation encountered an error.
*/
private int setBitmapToWallpaperManagerCompat(Bitmap wallpaperBitmap, boolean allowBackup,
- int whichWallpaper) {
+ int whichWallpaper) {
ByteArrayOutputStream tmpOut = new ByteArrayOutputStream();
if (wallpaperBitmap.compress(CompressFormat.JPEG, DEFAULT_COMPRESS_QUALITY, tmpOut)) {
try {
@@ -668,9 +474,10 @@
}
private int setStreamToWallpaperManagerCompat(InputStream inputStream, boolean allowBackup,
- int whichWallpaper) {
+ int whichWallpaper) {
try {
- return mWallpaperManagerCompat.setStream(inputStream, null, allowBackup, whichWallpaper);
+ return mWallpaperManagerCompat.setStream(inputStream, null, allowBackup,
+ whichWallpaper);
} catch (IOException e) {
return 0;
}
@@ -688,7 +495,8 @@
mWallpaperInfoInPreview.getWallpaperComponent();
// If there is no live wallpaper set on the WallpaperManager or it doesn't match the
- // WallpaperInfo which was last previewed, then do nothing and nullify last previewed wallpaper.
+ // WallpaperInfo which was last previewed, then do nothing and nullify last previewed
+ // wallpaper.
if (currentWallpaperComponent == null || previewedWallpaperComponent == null
|| !currentWallpaperComponent.getPackageName()
.equals(previewedWallpaperComponent.getPackageName())) {
@@ -729,9 +537,9 @@
mWallpaperInfoInPreview.getWallpaperComponent();
mWallpaperPreferences.clearHomeWallpaperMetadata();
- // NOTE: We explicitly do not also clear the lock wallpaper metadata. Since the user may have
- // set the live wallpaper on the home screen only, we leave the lock wallpaper metadata intact.
- // If the user has set the live wallpaper for both home and lock screens, then the
+ // NOTE: We explicitly do not also clear the lock wallpaper metadata. Since the user may
+ // have set the live wallpaper on the home screen only, we leave the lock wallpaper metadata
+ // intact. If the user has set the live wallpaper for both home and lock screens, then the
// WallpaperRefresher will pick up on that and update the preferences later.
mWallpaperPreferences
.setHomeWallpaperAttributions(mWallpaperInfoInPreview.getAttributions(mAppContext));
@@ -744,36 +552,6 @@
mWallpaperPreferences.clearDailyRotations();
}
- /**
- * Notifies the :live_wallpaper process that the contents of the rotating live wallpaper bitmap
- * changed.
- */
- private void notifyLiveWallpaperBitmapChanged() {
- Intent intent = new Intent(mAppContext.getPackageName()
- + NoBackupImageWallpaper.ACTION_ROTATING_WALLPAPER_CHANGED);
- // Handled by a runtime-registered receiver in NoBackupImageWallpaper.
- intent.setPackage(mAppContext.getPackageName());
- mAppContext.sendBroadcast(intent);
- }
-
- /**
- * Moves a file from the app's files directory to the device content protected storage
- * directory.
- * @param srcFileName Name of the source file (just the name, no path). It's expected to be
- * located in {@link Context#getFilesDir()} for {@link #mAppContext}
- * @param dstFileName Name of the destination file (just the name, no path), which will be
- * located in {@link Context#getFilesDir()}
- * for {@link #mDeviceProtectedContext}
- * @return a {@link File} corresponding to the moved file in its new location, or null if
- * nothing was moved (because srcFileName didn't exist).
- */
- @Nullable
- private File moveToDeviceProtectedStorage(String srcFileName, String dstFileName)
- throws IOException {
- return FileMover.moveFileBetweenContexts(mAppContext, srcFileName, mDeviceProtectedContext,
- dstFileName);
- }
-
private class SetWallpaperTask extends AsyncTask<Void, Void, Boolean> {
private final WallpaperInfo mWallpaper;
@@ -793,7 +571,7 @@
private Point mStretchSize;
SetWallpaperTask(WallpaperInfo wallpaper, Bitmap bitmap, @Destination int destination,
- WallpaperPersister.SetWallpaperCallback callback) {
+ WallpaperPersister.SetWallpaperCallback callback) {
super();
mWallpaper = wallpaper;
mBitmap = bitmap;
@@ -806,7 +584,7 @@
* will close the InputStream once it is done with it.
*/
SetWallpaperTask(WallpaperInfo wallpaper, InputStream stream,
- @Destination int destination, WallpaperPersister.SetWallpaperCallback callback) {
+ @Destination int destination, WallpaperPersister.SetWallpaperCallback callback) {
mWallpaper = wallpaper;
mInputStream = stream;
mDestination = destination;
@@ -815,16 +593,18 @@
void setFillSize(Point fillSize) {
if (mStretchSize != null) {
- throw new IllegalArgumentException("Can't pass a fill size option if a stretch size is "
- + "already set.");
+ throw new IllegalArgumentException(
+ "Can't pass a fill size option if a stretch size is "
+ + "already set.");
}
mFillSize = fillSize;
}
void setStretchSize(Point stretchSize) {
if (mFillSize != null) {
- throw new IllegalArgumentException("Can't pass a stretch size option if a fill size is "
- + "already set.");
+ throw new IllegalArgumentException(
+ "Can't pass a stretch size option if a fill size is "
+ + "already set.");
}
mStretchSize = stretchSize;
}
@@ -841,16 +621,9 @@
| WallpaperManagerCompat.FLAG_LOCK;
}
- // NOTE: The rotating wallpaper component must be determined here, _before_ actually setting
- // the bitmap/stream on WallpaperManagerCompat, to ensure that the
- // RotatingWallpaperComponentChecker is doing its check while rotation is still enabled.
- // E.g., if "live wallpaper" is the component, then it needs to check while live wallpaper is
- // still set as the active wallpaper on the device. Otherwise, the checker would see a static
- // wallpaper is currently set and it would return the wrong value.
- @RotatingWallpaperComponent int currentRotatingWallpaperComponent =
- mRotatingWallpaperComponentChecker.getCurrentRotatingWallpaperComponent(mAppContext);
- boolean wasLockWallpaperSet = LockWallpaperStatusChecker.isLockWallpaperSet(mAppContext);
+ boolean wasLockWallpaperSet = LockWallpaperStatusChecker.isLockWallpaperSet(
+ mAppContext);
boolean allowBackup = mWallpaper.getBackupPermission() == WallpaperInfo.BACKUP_ALLOWED;
final int wallpaperId;
@@ -860,15 +633,20 @@
mBitmap = BitmapTransformer.applyFillTransformation(mBitmap, mFillSize);
}
if (mStretchSize != null) {
- mBitmap = Bitmap.createScaledBitmap(mBitmap, mStretchSize.x, mStretchSize.y, true);
+ mBitmap = Bitmap.createScaledBitmap(mBitmap, mStretchSize.x, mStretchSize.y,
+ true);
}
- wallpaperId = setBitmapToWallpaperManagerCompat(mBitmap, allowBackup, whichWallpaper);
+ wallpaperId = setBitmapToWallpaperManagerCompat(mBitmap, allowBackup,
+ whichWallpaper);
} else if (mInputStream != null) {
- wallpaperId = setStreamToWallpaperManagerCompat(mInputStream, allowBackup, whichWallpaper);
+ wallpaperId = setStreamToWallpaperManagerCompat(mInputStream, allowBackup,
+ whichWallpaper);
} else {
- Log.e(TAG, "Both the wallpaper bitmap and input stream are null so we're unable to set any "
- + "kind of wallpaper here.");
+ Log.e(TAG,
+ "Both the wallpaper bitmap and input stream are null so we're unable to "
+ + "set any "
+ + "kind of wallpaper here.");
wallpaperId = 0;
}
@@ -878,7 +656,7 @@
== WallpaperPreferences.PRESENTATION_MODE_ROTATING
&& !wasLockWallpaperSet
&& BuildCompat.isAtLeastN()) {
- copyRotatingWallpaperToLock(currentRotatingWallpaperComponent);
+ copyRotatingWallpaperToLock();
}
setImageWallpaperMetadata(mDestination, wallpaperId);
return true;
@@ -914,12 +692,8 @@
* Used to accommodate the case where a user had gone from a home+lock daily rotation to
* selecting a static wallpaper on home-only. The image and metadata that was previously
* rotating is now copied to the lock screen.
- *
- * @param currentRotatingWallpaperComponent The component in which rotating wallpapers were
- * presented.
*/
- private void copyRotatingWallpaperToLock(
- @RotatingWallpaperComponent int currentRotatingWallpaperComponent) {
+ private void copyRotatingWallpaperToLock() {
mWallpaperPreferences.setLockWallpaperAttributions(
mWallpaperPreferences.getHomeWallpaperAttributions());
@@ -935,41 +709,28 @@
// Set the lock wallpaper ID to what Android set it to, following its having
// copied the system wallpaper over to the lock screen when we changed from
// "both" to distinct system and lock screen wallpapers.
- if (currentRotatingWallpaperComponent
- == RotatingWallpaperComponentChecker.ROTATING_WALLPAPER_COMPONENT_STATIC) {
- mWallpaperPreferences.setLockWallpaperId(
- mWallpaperManagerCompat.getWallpaperId(WallpaperManagerCompat.FLAG_LOCK));
- } else {
- try {
- FileInputStream fileInputStream = mDeviceProtectedContext.openFileInput(
- NoBackupImageWallpaper.ROTATING_WALLPAPER_FILE_PATH);
- int lockWallpaperId = setStreamToWallpaperManagerCompat(
- fileInputStream, false /* allowBackup */, WallpaperManagerCompat.FLAG_LOCK);
- fileInputStream.close();
- mWallpaperPreferences.setLockWallpaperId(lockWallpaperId);
- } catch (FileNotFoundException e) {
- Log.e(TAG, "Couldn't copy over previously rotating wallpaper to lock screen.");
- } catch (IOException e) {
- Log.e(TAG, "IOException when closing the file input stream " + e);
- }
- }
+ mWallpaperPreferences.setLockWallpaperId(
+ mWallpaperManagerCompat.getWallpaperId(WallpaperManagerCompat.FLAG_LOCK));
+
}
/**
- * Sets the image wallpaper's metadata on SharedPreferences. This method is called after the set
- * wallpaper operation is successful.
+ * Sets the image wallpaper's metadata on SharedPreferences. This method is called after the
+ * set wallpaper operation is successful.
*
- * @param destination Which destination of wallpaper the metadata corresponds to (home screen,
- * lock screen, or both).
- * @param wallpaperId The ID of the static wallpaper returned by WallpaperManager, which on N
- * and later versions of Android uniquely identifies a wallpaper image.
+ * @param destination Which destination of wallpaper the metadata corresponds to (home
+ * screen, lock screen, or both).
+ * @param wallpaperId The ID of the static wallpaper returned by WallpaperManager, which
+ * on N and later versions of Android uniquely identifies a wallpaper
+ * image.
*/
private void setImageWallpaperMetadata(@Destination int destination, int wallpaperId) {
if (destination == DEST_HOME_SCREEN || destination == DEST_BOTH) {
mWallpaperPreferences.clearHomeWallpaperMetadata();
setImageWallpaperHomeMetadata(wallpaperId);
- // Reset presentation mode to STATIC if an individual wallpaper is set to the home screen
+ // Reset presentation mode to STATIC if an individual wallpaper is set to the
+ // home screen
// because rotation always affects at least the home screen.
mWallpaperPreferences.setWallpaperPresentationMode(
WallpaperPreferences.PRESENTATION_MODE_STATIC);
@@ -988,10 +749,11 @@
mWallpaperPreferences.setHomeWallpaperManagerId(homeWallpaperId);
}
- // Compute bitmap hash code after setting the wallpaper because JPEG compression has likely
- // changed many pixels' color values. Forget the previously loaded wallpaper bitmap so that
- // WallpaperManager doesn't return the old wallpaper drawable. Do this on N+ devices in
- // addition to saving the wallpaper ID for the purpose of backup & restore.
+ // Compute bitmap hash code after setting the wallpaper because JPEG compression has
+ // likely changed many pixels' color values. Forget the previously loaded wallpaper
+ // bitmap so that WallpaperManager doesn't return the old wallpaper drawable. Do this
+ // on N+ devices in addition to saving the wallpaper ID for the purpose of backup &
+ // restore.
mWallpaperManager.forgetLoadedWallpaper();
mBitmap = ((BitmapDrawable) mWallpaperManagerCompat.getDrawable()).getBitmap();
long bitmapHash = BitmapUtils.generateHashCode(mBitmap);
@@ -1023,9 +785,10 @@
mWallpaperPreferences.setLockWallpaperCollectionId(
mWallpaper.getCollectionId(mAppContext));
- // Save the lock wallpaper image's hash code as well for the sake of backup & restore because
- // WallpaperManager-generated IDs are specific to a physical device and cannot be used to
- // identify a wallpaper image on another device after restore is complete.
+ // Save the lock wallpaper image's hash code as well for the sake of backup & restore
+ // because WallpaperManager-generated IDs are specific to a physical device and
+ // cannot be used to identify a wallpaper image on another device after restore is
+ // complete.
saveLockWallpaperHashCode();
}
@@ -1051,7 +814,9 @@
try {
fileStream.close();
} catch (IOException e) {
- Log.e(TAG, "IO exception when closing the input stream for the lock screen WP.");
+ Log.e(TAG,
+ "IO exception when closing the input stream for the lock screen "
+ + "WP.");
}
}
}
diff --git a/src/com/android/wallpaper/module/Injector.java b/src/com/android/wallpaper/module/Injector.java
index 3afaeb4..1f59951 100755
--- a/src/com/android/wallpaper/module/Injector.java
+++ b/src/com/android/wallpaper/module/Injector.java
@@ -56,8 +56,6 @@
Requester getRequester(Context context);
- RotatingWallpaperComponentChecker getRotatingWallpaperComponentChecker();
-
SystemFeatureChecker getSystemFeatureChecker();
UserEventLogger getUserEventLogger(Context context);
diff --git a/src/com/android/wallpaper/module/RotatingWallpaperComponentChecker.java b/src/com/android/wallpaper/module/RotatingWallpaperComponentChecker.java
deleted file mode 100755
index 8a2908a..0000000
--- a/src/com/android/wallpaper/module/RotatingWallpaperComponentChecker.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2017 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.module;
-
-import android.content.Context;
-
-import androidx.annotation.IntDef;
-
-/**
- * Checks what component is responsible for presenting the rotating wallpaper image under the
- * device's launcher or keyguard for current and future rotations.
- */
-public interface RotatingWallpaperComponentChecker {
-
- int ROTATING_WALLPAPER_COMPONENT_LIVE = 1;
- int ROTATING_WALLPAPER_COMPONENT_STATIC = 2;
-
- int ROTATING_WALLPAPER_SUPPORT_NOT_SUPPORTED = 0;
- int ROTATING_WALLPAPER_SUPPORT_SUPPORTED = 1;
-
- /**
- * Returns the rotating wallpaper component for the current wallpaper rotation.
- */
- @RotatingWallpaperComponent
- int getCurrentRotatingWallpaperComponent(Context context);
-
- /**
- * Returns the rotating wallpaper component for future wallpaper rotations.
- */
- @RotatingWallpaperComponent
- int getNextRotatingWallpaperComponent(Context context);
-
- /**
- * Returns the support level for rotating wallpaper.
- */
- @RotatingWallpaperSupport
- int getRotatingWallpaperSupport(Context context);
-
- /**
- * Possible components for presenting the rotating wallpaper image.
- */
- @IntDef({
- ROTATING_WALLPAPER_COMPONENT_LIVE,
- ROTATING_WALLPAPER_COMPONENT_STATIC})
- @interface RotatingWallpaperComponent {
- }
-
- /**
- * Possible support levels for rotating wallpaper.
- */
- @IntDef({
- ROTATING_WALLPAPER_SUPPORT_NOT_SUPPORTED,
- ROTATING_WALLPAPER_SUPPORT_SUPPORTED})
- @interface RotatingWallpaperSupport {
- }
-}
diff --git a/src/com/android/wallpaper/picker/StartRotationDialogFragment.java b/src/com/android/wallpaper/picker/StartRotationDialogFragment.java
index d5fd017..f0e4dcd 100755
--- a/src/com/android/wallpaper/picker/StartRotationDialogFragment.java
+++ b/src/com/android/wallpaper/picker/StartRotationDialogFragment.java
@@ -29,8 +29,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-
-import androidx.appcompat.view.ContextThemeWrapper;
import androidx.fragment.app.DialogFragment;
import com.android.wallpaper.R;
@@ -42,29 +40,14 @@
*/
public class StartRotationDialogFragment extends DialogFragment {
private static final String KEY_IS_WIFI_ONLY_CHECKED = "key_is_wifi_only_checked";
- private static final String KEY_IS_LIVE_WALLPAPER_PREVIEW_NEEDED = "key_is_live_wallpaper_needed";
private static final boolean DEFAULT_IS_WIFI_ONLY = true;
private boolean mIsWifiOnlyChecked;
- private boolean mIsLiveWallpaperPreviewNeeded;
-
- public static StartRotationDialogFragment newInstance(boolean isLiveWallpaperPreviewNeeded) {
- StartRotationDialogFragment dialogFragment = new StartRotationDialogFragment();
- Bundle args = new Bundle();
- args.putBoolean(KEY_IS_LIVE_WALLPAPER_PREVIEW_NEEDED, isLiveWallpaperPreviewNeeded);
- dialogFragment.setArguments(args);
- return dialogFragment;
- }
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- Bundle args = getArguments();
- if (args != null) {
- mIsLiveWallpaperPreviewNeeded = args.getBoolean(KEY_IS_LIVE_WALLPAPER_PREVIEW_NEEDED);
- }
-
if (savedInstanceState == null) {
mIsWifiOnlyChecked = DEFAULT_IS_WIFI_ONLY;
} else {
@@ -117,14 +100,10 @@
}
private int getBodyTextResourceId() {
- return mIsLiveWallpaperPreviewNeeded
- ? R.string.start_rotation_dialog_body_live_wallpaper_needed
- : R.string.start_rotation_dialog_body;
+ return R.string.start_rotation_dialog_body;
}
private int getPositiveButtonTextResourceId() {
- return mIsLiveWallpaperPreviewNeeded
- ? R.string.start_rotation_dialog_continue
- : android.R.string.ok;
+ return android.R.string.ok;
}
}
diff --git a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
index db21da3..401634d 100755
--- a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
+++ b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
@@ -64,7 +64,6 @@
import com.android.wallpaper.module.Injector;
import com.android.wallpaper.module.InjectorProvider;
import com.android.wallpaper.module.PackageStatusNotifier;
-import com.android.wallpaper.module.RotatingWallpaperComponentChecker;
import com.android.wallpaper.module.WallpaperChangedNotifier;
import com.android.wallpaper.module.WallpaperPersister;
import com.android.wallpaper.module.WallpaperPersister.Destination;
@@ -116,7 +115,6 @@
WallpaperPreferences mWallpaperPreferences;
WallpaperChangedNotifier mWallpaperChangedNotifier;
- RotatingWallpaperComponentChecker mRotatingWallpaperComponentChecker;
RecyclerView mImageGrid;
IndividualAdapter mAdapter;
WallpaperCategory mCategory;
@@ -250,8 +248,6 @@
mWallpaperChangedNotifier = WallpaperChangedNotifier.getInstance();
mWallpaperChangedNotifier.registerListener(mWallpaperChangedListener);
- mRotatingWallpaperComponentChecker = injector.getRotatingWallpaperComponentChecker();
-
mFormFactor = injector.getFormFactorChecker(appContext).getFormFactor();
mPackageStatusNotifier = injector.getPackageStatusNotifier(appContext);
@@ -614,34 +610,33 @@
// app before the first wallpaper image in rotation finishes downloading.
Activity activity = getActivity();
- if (activity != null
- && mWallpaperRotationInitializer
- .isNoBackupImageWallpaperPreviewNeeded(appContext)) {
- ((IndividualPickerActivity) activity).showNoBackupImageWallpaperPreview();
- } else {
- if (mWallpaperRotationInitializer.startRotation(appContext)) {
- if (activity != null && mFormFactor == FormFactorChecker.FORM_FACTOR_MOBILE) {
- try {
- Toast.makeText(getActivity(), R.string.wallpaper_set_successfully_message,
- Toast.LENGTH_SHORT).show();
- } catch (NotFoundException e) {
- Log.e(TAG, "Could not show toast " + e);
- }
- activity.setResult(Activity.RESULT_OK);
- activity.finish();
- } else if (mFormFactor == FormFactorChecker.FORM_FACTOR_DESKTOP) {
- mAdapter.updateSelectedTile(SPECIAL_FIXED_TILE_ADAPTER_POSITION);
+ if (mWallpaperRotationInitializer.startRotation(appContext)) {
+ if (activity != null
+ && mFormFactor == FormFactorChecker.FORM_FACTOR_MOBILE) {
+ try {
+ Toast.makeText(getActivity(),
+ R.string.wallpaper_set_successfully_message,
+ Toast.LENGTH_SHORT).show();
+ } catch (NotFoundException e) {
+ Log.e(TAG, "Could not show toast " + e);
}
- } else { // Failed to start rotation.
- showStartRotationErrorDialog(networkPreference);
- if (mFormFactor == FormFactorChecker.FORM_FACTOR_DESKTOP) {
- DesktopRotationHolder rotationViewHolder =
- (DesktopRotationHolder) mImageGrid.findViewHolderForAdapterPosition(
- SPECIAL_FIXED_TILE_ADAPTER_POSITION);
- rotationViewHolder.setSelectionState(SelectableHolder.SELECTION_STATE_DESELECTED);
- }
+ activity.setResult(Activity.RESULT_OK);
+ activity.finish();
+ } else if (mFormFactor == FormFactorChecker.FORM_FACTOR_DESKTOP) {
+ mAdapter.updateSelectedTile(SPECIAL_FIXED_TILE_ADAPTER_POSITION);
+ }
+ } else { // Failed to start rotation.
+ showStartRotationErrorDialog(networkPreference);
+
+ if (mFormFactor == FormFactorChecker.FORM_FACTOR_DESKTOP) {
+ DesktopRotationHolder rotationViewHolder =
+ (DesktopRotationHolder)
+ mImageGrid.findViewHolderForAdapterPosition(
+ SPECIAL_FIXED_TILE_ADAPTER_POSITION);
+ rotationViewHolder.setSelectionState(
+ SelectableHolder.SELECTION_STATE_DESELECTED);
}
}
}
@@ -690,11 +685,7 @@
* Returns whether rotation is enabled for this category.
*/
boolean isRotationEnabled() {
- boolean isRotationSupported =
- mRotatingWallpaperComponentChecker.getRotatingWallpaperSupport(getContext())
- == RotatingWallpaperComponentChecker.ROTATING_WALLPAPER_SUPPORT_SUPPORTED;
-
- return isRotationSupported && mWallpaperRotationInitializer != null;
+ return mWallpaperRotationInitializer != null;
}
@Override
@@ -765,10 +756,7 @@
@Override
public void onClick(View v) {
- boolean isLiveWallpaperNeeded = mWallpaperRotationInitializer
- .isNoBackupImageWallpaperPreviewNeeded(getActivity().getApplicationContext());
- DialogFragment startRotationDialogFragment = StartRotationDialogFragment
- .newInstance(isLiveWallpaperNeeded);
+ DialogFragment startRotationDialogFragment = new StartRotationDialogFragment();
startRotationDialogFragment.setTargetFragment(
IndividualPickerFragment.this, UNUSED_REQUEST_CODE);
startRotationDialogFragment.show(getFragmentManager(), TAG_START_ROTATION_DIALOG);