1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 * except in compliance with the License. You may obtain a copy of the License at
6 *
7 *      http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the
10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11 * KIND, either express or implied. See the License for the specific language governing
12 * permissions and limitations under the License.
13 */
14
15package com.android.systemui;
16
17import android.app.PendingIntent;
18import android.content.Intent;
19
20import com.android.systemui.plugins.ActivityStarter;
21
22/**
23 * Single common instance of ActivityStarter that can be gotten and referenced from anywhere, but
24 * delegates to an actual implementation such as StatusBar, assuming it exists.
25 */
26public class ActivityStarterDelegate implements ActivityStarter {
27
28    private ActivityStarter mActualStarter;
29
30    @Override
31    public void startPendingIntentDismissingKeyguard(PendingIntent intent) {
32        if (mActualStarter == null) return;
33        mActualStarter.startPendingIntentDismissingKeyguard(intent);
34    }
35
36    @Override
37    public void startActivity(Intent intent, boolean dismissShade) {
38        if (mActualStarter == null) return;
39        mActualStarter.startActivity(intent, dismissShade);
40    }
41
42    @Override
43    public void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade) {
44        if (mActualStarter == null) return;
45        mActualStarter.startActivity(intent, onlyProvisioned, dismissShade);
46    }
47
48    @Override
49    public void startActivity(Intent intent, boolean dismissShade, Callback callback) {
50        if (mActualStarter == null) return;
51        mActualStarter.startActivity(intent, dismissShade, callback);
52    }
53
54    @Override
55    public void postStartActivityDismissingKeyguard(Intent intent, int delay) {
56        if (mActualStarter == null) return;
57        mActualStarter.postStartActivityDismissingKeyguard(intent, delay);
58    }
59
60    @Override
61    public void postStartActivityDismissingKeyguard(PendingIntent intent) {
62        if (mActualStarter == null) return;
63        mActualStarter.postStartActivityDismissingKeyguard(intent);
64    }
65
66    @Override
67    public void postQSRunnableDismissingKeyguard(Runnable runnable) {
68        if (mActualStarter == null) return;
69        mActualStarter.postQSRunnableDismissingKeyguard(runnable);
70    }
71
72    public void setActivityStarterImpl(ActivityStarter starter) {
73        mActualStarter = starter;
74    }
75}
76