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.content.Context;
19 
20 import androidx.annotation.Nullable;
21 
22 import com.android.wallpaper.model.WallpaperInfo;
23 import com.android.wallpaper.module.WallpaperPreferences.PresentationMode;
24 
25 /**
26  * Interface for factories which construct {@link WallpaperInfo} objects representing the device's
27  * currently set wallpapers.
28  */
29 public interface CurrentWallpaperInfoFactory {
30 
31     /**
32      * Constructs WallpaperInfo object(s) to represent the current home wallpaper and optionally the
33      * current lock wallpaper if device is running Android N or later and lock wallpaper is explicitly
34      * set.
35      *
36      * @param forceRefresh Whether the factory should ignore cached copies of the WallpaperInfo(s) and
37      *                     presentation mode that represent the currently-set wallpaper.
38      */
createCurrentWallpaperInfos(Context context, boolean forceRefresh, WallpaperInfoCallback callback)39     void createCurrentWallpaperInfos(Context context, boolean forceRefresh,
40             WallpaperInfoCallback callback);
41 
42     /**
43      * Clears cached wallpaper copies to let refresher load the latest wallpaper.
44      */
clearCurrentWallpaperInfos()45     void clearCurrentWallpaperInfos();
46 
47     /**
48      * Interface which clients may implement to receive current wallpaper {@link WallpaperInfo}
49      * objects constructed by the factory as well as the mode which describes their current
50      * presentation (i.e., daily rotation or static).
51      */
52     interface WallpaperInfoCallback {
onWallpaperInfoCreated(WallpaperInfo homeWallpaper, @Nullable WallpaperInfo lockWallpaper, @PresentationMode int presentationMode)53         void onWallpaperInfoCreated(WallpaperInfo homeWallpaper, @Nullable WallpaperInfo lockWallpaper,
54                                     @PresentationMode int presentationMode);
55     }
56 }
57