1 /*
2  * Copyright (C) 2014 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 
17 package com.android.server;
18 
19 import java.util.List;
20 
21 /**
22  * Runtime bridge between the Backup Manager Service and the App Widget Service,
23  * since those two modules are intentionally decoupled for modularity.
24  *
25  * @hide
26  */
27 public class AppWidgetBackupBridge {
28     private static WidgetBackupProvider sAppWidgetService;
29 
register(WidgetBackupProvider instance)30     public static void register(WidgetBackupProvider instance) {
31         sAppWidgetService = instance;
32     }
33 
getWidgetParticipants(int userId)34     public static List<String> getWidgetParticipants(int userId) {
35         return (sAppWidgetService != null)
36                 ? sAppWidgetService.getWidgetParticipants(userId)
37                 : null;
38     }
39 
getWidgetState(String packageName, int userId)40     public static byte[] getWidgetState(String packageName, int userId) {
41         return (sAppWidgetService != null)
42                 ? sAppWidgetService.getWidgetState(packageName, userId)
43                 : null;
44     }
45 
restoreStarting(int userId)46     public static void restoreStarting(int userId) {
47         if (sAppWidgetService != null) {
48             sAppWidgetService.restoreStarting(userId);
49         }
50     }
51 
restoreWidgetState(String packageName, byte[] restoredState, int userId)52     public static void restoreWidgetState(String packageName, byte[] restoredState, int userId) {
53         if (sAppWidgetService != null) {
54             sAppWidgetService.restoreWidgetState(packageName, restoredState, userId);
55         }
56     }
57 
restoreFinished(int userId)58     public static void restoreFinished(int userId) {
59         if (sAppWidgetService != null) {
60             sAppWidgetService.restoreFinished(userId);
61         }
62     }
63 }
64