1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.wm.shell.sysui;
18 
19 import android.content.Context;
20 import android.content.pm.UserInfo;
21 import android.content.res.Configuration;
22 import android.os.Bundle;
23 
24 import androidx.annotation.NonNull;
25 
26 import java.io.PrintWriter;
27 import java.util.List;
28 
29 /**
30  * General interface for notifying the Shell of common SysUI events like configuration or keyguard
31  * changes.
32  */
33 public interface ShellInterface {
34 
35     /**
36      * Initializes the shell state.
37      */
onInit()38     default void onInit() {}
39 
40     /**
41      * Notifies the Shell that the configuration has changed.
42      */
onConfigurationChanged(Configuration newConfiguration)43     default void onConfigurationChanged(Configuration newConfiguration) {}
44 
45     /**
46      * Notifies the Shell that the keyguard is showing (and if so, whether it is occluded) or not
47      * showing, and whether it is animating a dismiss.
48      */
onKeyguardVisibilityChanged(boolean visible, boolean occluded, boolean animatingDismiss)49     default void onKeyguardVisibilityChanged(boolean visible, boolean occluded,
50             boolean animatingDismiss) {}
51 
52     /**
53      * Notifies the Shell when the keyguard dismiss animation has finished.
54      */
onKeyguardDismissAnimationFinished()55     default void onKeyguardDismissAnimationFinished() {}
56 
57     /**
58      * Notifies the Shell when the user changes.
59      */
onUserChanged(int newUserId, @NonNull Context userContext)60     default void onUserChanged(int newUserId, @NonNull Context userContext) {}
61 
62     /**
63      * Notifies the Shell when a profile belonging to the user changes.
64      */
onUserProfilesChanged(@onNull List<UserInfo> profiles)65     default void onUserProfilesChanged(@NonNull List<UserInfo> profiles) {}
66 
67     /**
68      * Handles a shell command.
69      */
handleCommand(final String[] args, PrintWriter pw)70     default boolean handleCommand(final String[] args, PrintWriter pw) {
71         return false;
72     }
73 
74     /**
75      * Updates the given {@param bundle} with the set of exposed interfaces.
76      */
createExternalInterfaces(Bundle bundle)77     default void createExternalInterfaces(Bundle bundle) {}
78 
79     /**
80      * Dumps the shell state.
81      */
dump(PrintWriter pw)82     default void dump(PrintWriter pw) {}
83 }
84