• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.animation.ActivityLaunchAnimator;
23 import com.android.systemui.plugins.annotations.ProvidesInterface;
24 
25 /**
26  * An interface to start activities. This is used as a callback from the views to
27  * {@link PhoneStatusBar} to allow custom handling for starting the activity, i.e. dismissing the
28  * Keyguard.
29  */
30 @ProvidesInterface(version = ActivityStarter.VERSION)
31 public interface ActivityStarter {
32     int VERSION = 2;
33 
startPendingIntentDismissingKeyguard(PendingIntent intent)34     void startPendingIntentDismissingKeyguard(PendingIntent intent);
35 
36     /**
37      * Similar to {@link #startPendingIntentDismissingKeyguard(PendingIntent)}, but allows
38      * you to specify the callback that is executed on the UI thread after the intent is sent.
39      */
startPendingIntentDismissingKeyguard(PendingIntent intent, Runnable intentSentUiThreadCallback)40     void startPendingIntentDismissingKeyguard(PendingIntent intent,
41             Runnable intentSentUiThreadCallback);
42 
43     /**
44      * Similar to {@link #startPendingIntentDismissingKeyguard(PendingIntent, Runnable)}, but also
45      * specifies an associated view that should be used for the activity launch animation.
46      */
startPendingIntentDismissingKeyguard(PendingIntent intent, Runnable intentSentUiThreadCallback, @Nullable View associatedView)47     void startPendingIntentDismissingKeyguard(PendingIntent intent,
48             Runnable intentSentUiThreadCallback, @Nullable View associatedView);
49 
50     /**
51      * Similar to {@link #startPendingIntentDismissingKeyguard(PendingIntent, Runnable)}, but also
52      * specifies an animation controller that should be used for the activity launch animation.
53      */
startPendingIntentDismissingKeyguard(PendingIntent intent, Runnable intentSentUiThreadCallback, @Nullable ActivityLaunchAnimator.Controller animationController)54     void startPendingIntentDismissingKeyguard(PendingIntent intent,
55             Runnable intentSentUiThreadCallback,
56             @Nullable ActivityLaunchAnimator.Controller animationController);
57 
58     /**
59      * The intent flag can be specified in startActivity().
60      */
startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade, int flags)61     void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade, int flags);
startActivity(Intent intent, boolean dismissShade)62     void startActivity(Intent intent, boolean dismissShade);
startActivity(Intent intent, boolean dismissShade, @Nullable ActivityLaunchAnimator.Controller animationController)63     void startActivity(Intent intent, boolean dismissShade,
64             @Nullable ActivityLaunchAnimator.Controller animationController);
startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade)65     void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade);
startActivity(Intent intent, boolean dismissShade, Callback callback)66     void startActivity(Intent intent, boolean dismissShade, Callback callback);
postStartActivityDismissingKeyguard(Intent intent, int delay)67     void postStartActivityDismissingKeyguard(Intent intent, int delay);
postStartActivityDismissingKeyguard(Intent intent, int delay, @Nullable ActivityLaunchAnimator.Controller animationController)68     void postStartActivityDismissingKeyguard(Intent intent, int delay,
69             @Nullable ActivityLaunchAnimator.Controller animationController);
postStartActivityDismissingKeyguard(PendingIntent intent)70     void postStartActivityDismissingKeyguard(PendingIntent intent);
71 
72     /**
73      * Similar to {@link #postStartActivityDismissingKeyguard(PendingIntent)}, but also specifies an
74      * animation controller that should be used for the activity launch animation.
75      */
postStartActivityDismissingKeyguard(PendingIntent intent, @Nullable ActivityLaunchAnimator.Controller animationController)76     void postStartActivityDismissingKeyguard(PendingIntent intent,
77             @Nullable ActivityLaunchAnimator.Controller animationController);
78 
postQSRunnableDismissingKeyguard(Runnable runnable)79     void postQSRunnableDismissingKeyguard(Runnable runnable);
80 
dismissKeyguardThenExecute(OnDismissAction action, @Nullable Runnable cancel, boolean afterKeyguardGone)81     void dismissKeyguardThenExecute(OnDismissAction action, @Nullable Runnable cancel,
82             boolean afterKeyguardGone);
83 
84     interface Callback {
onActivityStarted(int resultCode)85         void onActivityStarted(int resultCode);
86     }
87 
88     interface OnDismissAction {
89         /**
90          * @return {@code true} if the dismiss should be deferred. When returning true, make sure to
91          *         call {@link com.android.keyguard.ViewMediatorCallback#readyForKeyguardDone()}
92          *         *after* returning to start hiding the keyguard.
93          */
onDismiss()94         boolean onDismiss();
95 
96         /**
97          * Whether running this action when we are locked will start an animation on the keyguard.
98          */
willRunAnimationOnKeyguard()99         default boolean willRunAnimationOnKeyguard() {
100             return false;
101         }
102     }
103 }
104