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.plugins;
16 
17 import android.annotation.Nullable;
18 import android.app.PendingIntent;
19 import android.content.Intent;
20 import android.view.View;
21 
22 import com.android.systemui.plugins.annotations.ProvidesInterface;
23 
24 /**
25  * An interface to start activities. This is used as a callback from the views to
26  * {@link PhoneStatusBar} to allow custom handling for starting the activity, i.e. dismissing the
27  * Keyguard.
28  */
29 @ProvidesInterface(version = ActivityStarter.VERSION)
30 public interface ActivityStarter {
31     int VERSION = 2;
32 
startPendingIntentDismissingKeyguard(PendingIntent intent)33     void startPendingIntentDismissingKeyguard(PendingIntent intent);
34 
35     /**
36      * Similar to {@link #startPendingIntentDismissingKeyguard(PendingIntent)}, but allows
37      * you to specify the callback that is executed on the UI thread after the intent is sent.
38      */
startPendingIntentDismissingKeyguard(PendingIntent intent, Runnable intentSentUiThreadCallback)39     void startPendingIntentDismissingKeyguard(PendingIntent intent,
40             Runnable intentSentUiThreadCallback);
41 
42     /**
43      * Similar to {@link #startPendingIntentDismissingKeyguard(PendingIntent, Runnable)}, but also
44      * specifies an associated view that should be used for the activity launch animation.
45      */
startPendingIntentDismissingKeyguard(PendingIntent intent, Runnable intentSentUiThreadCallback, View associatedView)46     void startPendingIntentDismissingKeyguard(PendingIntent intent,
47             Runnable intentSentUiThreadCallback, View associatedView);
48 
49     /**
50      * The intent flag can be specified in startActivity().
51      */
startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade, int flags)52     void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade, int flags);
startActivity(Intent intent, boolean dismissShade)53     void startActivity(Intent intent, boolean dismissShade);
startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade)54     void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade);
startActivity(Intent intent, boolean dismissShade, Callback callback)55     void startActivity(Intent intent, boolean dismissShade, Callback callback);
postStartActivityDismissingKeyguard(Intent intent, int delay)56     void postStartActivityDismissingKeyguard(Intent intent, int delay);
postStartActivityDismissingKeyguard(PendingIntent intent)57     void postStartActivityDismissingKeyguard(PendingIntent intent);
postQSRunnableDismissingKeyguard(Runnable runnable)58     void postQSRunnableDismissingKeyguard(Runnable runnable);
59 
dismissKeyguardThenExecute(OnDismissAction action, @Nullable Runnable cancel, boolean afterKeyguardGone)60     void dismissKeyguardThenExecute(OnDismissAction action, @Nullable Runnable cancel,
61             boolean afterKeyguardGone);
62 
63     interface Callback {
onActivityStarted(int resultCode)64         void onActivityStarted(int resultCode);
65     }
66 
67     interface OnDismissAction {
68         /**
69          * @return {@code true} if the dismiss should be deferred
70          */
onDismiss()71         boolean onDismiss();
72     }
73 }
74