blob: e1b8dc839bdeb9e82aa5e56e2201c0957391cfad [file] [log] [blame]
Jason Monk9c7844c2017-01-18 15:21:53 -05001/*
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
Jason Monkec34da82017-02-24 15:57:05 -050020import com.android.systemui.plugins.ActivityStarter;
21
Jason Monk9c7844c2017-01-18 15:21:53 -050022/**
23 * Single common instance of ActivityStarter that can be gotten and referenced from anywhere, but
Jason Monk2a6ea9c2017-01-26 11:14:51 -050024 * delegates to an actual implementation such as StatusBar, assuming it exists.
Jason Monk9c7844c2017-01-18 15:21:53 -050025 */
26public class ActivityStarterDelegate implements ActivityStarter {
27
28 private ActivityStarter mActualStarter;
29
30 @Override
31 public void startPendingIntentDismissingKeyguard(PendingIntent intent) {
Jason Monk297c04e2018-08-23 17:16:59 -040032 if (mActualStarter == null) {
33 return;
34 }
Jason Monk9c7844c2017-01-18 15:21:53 -050035 mActualStarter.startPendingIntentDismissingKeyguard(intent);
36 }
37
38 @Override
39 public void startActivity(Intent intent, boolean dismissShade) {
Jason Monk297c04e2018-08-23 17:16:59 -040040 if (mActualStarter == null) {
41 return;
42 }
Jason Monk9c7844c2017-01-18 15:21:53 -050043 mActualStarter.startActivity(intent, dismissShade);
44 }
45
46 @Override
47 public void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade) {
Jason Monk297c04e2018-08-23 17:16:59 -040048 if (mActualStarter == null) {
49 return;
50 }
Jason Monk9c7844c2017-01-18 15:21:53 -050051 mActualStarter.startActivity(intent, onlyProvisioned, dismissShade);
52 }
53
54 @Override
55 public void startActivity(Intent intent, boolean dismissShade, Callback callback) {
Jason Monk297c04e2018-08-23 17:16:59 -040056 if (mActualStarter == null) {
57 return;
58 }
Jason Monk9c7844c2017-01-18 15:21:53 -050059 mActualStarter.startActivity(intent, dismissShade, callback);
60 }
61
62 @Override
63 public void postStartActivityDismissingKeyguard(Intent intent, int delay) {
Jason Monk297c04e2018-08-23 17:16:59 -040064 if (mActualStarter == null) {
65 return;
66 }
Jason Monk9c7844c2017-01-18 15:21:53 -050067 mActualStarter.postStartActivityDismissingKeyguard(intent, delay);
68 }
69
70 @Override
71 public void postStartActivityDismissingKeyguard(PendingIntent intent) {
Jason Monk297c04e2018-08-23 17:16:59 -040072 if (mActualStarter == null) {
73 return;
74 }
Jason Monk9c7844c2017-01-18 15:21:53 -050075 mActualStarter.postStartActivityDismissingKeyguard(intent);
76 }
77
78 @Override
79 public void postQSRunnableDismissingKeyguard(Runnable runnable) {
Jason Monk297c04e2018-08-23 17:16:59 -040080 if (mActualStarter == null) {
81 return;
82 }
Jason Monk9c7844c2017-01-18 15:21:53 -050083 mActualStarter.postQSRunnableDismissingKeyguard(runnable);
84 }
85
Jason Monk297c04e2018-08-23 17:16:59 -040086 @Override
87 public void dismissKeyguardThenExecute(OnDismissAction action, Runnable cancel,
88 boolean afterKeyguardGone) {
89 if (mActualStarter == null) {
90 return;
91 }
92 mActualStarter.dismissKeyguardThenExecute(action, cancel, afterKeyguardGone);
93 }
94
Jason Monk9c7844c2017-01-18 15:21:53 -050095 public void setActivityStarterImpl(ActivityStarter starter) {
96 mActualStarter = starter;
97 }
98}