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