1adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate/*
2adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate * Copyright (C) 2014 The Android Open Source Project
3adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate *
4adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate * Licensed under the Apache License, Version 2.0 (the "License");
5adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate * you may not use this file except in compliance with the License.
6adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate * You may obtain a copy of the License at
7adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate *
8adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate *      http://www.apache.org/licenses/LICENSE-2.0
9adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate *
10adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate * Unless required by applicable law or agreed to in writing, software
11adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate * distributed under the License is distributed on an "AS IS" BASIS,
12adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate * See the License for the specific language governing permissions and
14adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate * limitations under the License.
15adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate */
16adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate
17adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tatepackage com.android.server;
18adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate
19adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tateimport java.util.List;
20adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate
21adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate/**
22adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate * Runtime bridge between the Backup Manager Service and the App Widget Service,
23adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate * since those two modules are intentionally decoupled for modularity.
24adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate *
25adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate * @hide
26adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate */
27adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tatepublic class AppWidgetBackupBridge {
28adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate    private static WidgetBackupProvider sAppWidgetService;
29adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate
30adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate    public static void register(WidgetBackupProvider instance) {
31adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate        sAppWidgetService = instance;
32adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate    }
33adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate
34adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate    public static List<String> getWidgetParticipants(int userId) {
35adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate        return (sAppWidgetService != null)
36adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate                ? sAppWidgetService.getWidgetParticipants(userId)
37adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate                : null;
38adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate    }
39adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate
40adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate    public static byte[] getWidgetState(String packageName, int userId) {
41adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate        return (sAppWidgetService != null)
42adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate                ? sAppWidgetService.getWidgetState(packageName, userId)
43adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate                : null;
44adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate    }
45adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate
46adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate    public static void restoreStarting(int userId) {
47adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate        if (sAppWidgetService != null) {
48adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate            sAppWidgetService.restoreStarting(userId);
49adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate        }
50adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate    }
51adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate
52adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate    public static void restoreWidgetState(String packageName, byte[] restoredState, int userId) {
53adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate        if (sAppWidgetService != null) {
54adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate            sAppWidgetService.restoreWidgetState(packageName, restoredState, userId);
55adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate        }
56adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate    }
57adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate
58adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate    public static void restoreFinished(int userId) {
59adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate        if (sAppWidgetService != null) {
60adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate            sAppWidgetService.restoreFinished(userId);
61adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate        }
62adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate    }
63adfe8b86e9178a553b6db9722340fa4ff5201cf1Christopher Tate}
64