Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 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 | |
| 15 | package com.android.systemui; |
| 16 | |
| 17 | import android.app.PendingIntent; |
| 18 | import android.content.Intent; |
| 19 | |
Jason Monk | ec34da8 | 2017-02-24 15:57:05 -0500 | [diff] [blame] | 20 | import com.android.systemui.plugins.ActivityStarter; |
| 21 | |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 22 | /** |
| 23 | * Single common instance of ActivityStarter that can be gotten and referenced from anywhere, but |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 24 | * delegates to an actual implementation such as StatusBar, assuming it exists. |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 25 | */ |
| 26 | public class ActivityStarterDelegate implements ActivityStarter { |
| 27 | |
| 28 | private ActivityStarter mActualStarter; |
| 29 | |
| 30 | @Override |
| 31 | public void startPendingIntentDismissingKeyguard(PendingIntent intent) { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 32 | if (mActualStarter == null) { |
| 33 | return; |
| 34 | } |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 35 | mActualStarter.startPendingIntentDismissingKeyguard(intent); |
| 36 | } |
| 37 | |
| 38 | @Override |
| 39 | public void startActivity(Intent intent, boolean dismissShade) { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 40 | if (mActualStarter == null) { |
| 41 | return; |
| 42 | } |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 43 | mActualStarter.startActivity(intent, dismissShade); |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade) { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 48 | if (mActualStarter == null) { |
| 49 | return; |
| 50 | } |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 51 | mActualStarter.startActivity(intent, onlyProvisioned, dismissShade); |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public void startActivity(Intent intent, boolean dismissShade, Callback callback) { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 56 | if (mActualStarter == null) { |
| 57 | return; |
| 58 | } |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 59 | mActualStarter.startActivity(intent, dismissShade, callback); |
| 60 | } |
| 61 | |
| 62 | @Override |
| 63 | public void postStartActivityDismissingKeyguard(Intent intent, int delay) { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 64 | if (mActualStarter == null) { |
| 65 | return; |
| 66 | } |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 67 | mActualStarter.postStartActivityDismissingKeyguard(intent, delay); |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public void postStartActivityDismissingKeyguard(PendingIntent intent) { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 72 | if (mActualStarter == null) { |
| 73 | return; |
| 74 | } |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 75 | mActualStarter.postStartActivityDismissingKeyguard(intent); |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public void postQSRunnableDismissingKeyguard(Runnable runnable) { |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 80 | if (mActualStarter == null) { |
| 81 | return; |
| 82 | } |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 83 | mActualStarter.postQSRunnableDismissingKeyguard(runnable); |
| 84 | } |
| 85 | |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 86 | @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 Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 95 | public void setActivityStarterImpl(ActivityStarter starter) { |
| 96 | mActualStarter = starter; |
| 97 | } |
| 98 | } |