1 /*
2  * Copyright (C) 2010 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.systemui;
18 
19 import android.content.res.Configuration;
20 
21 import androidx.annotation.NonNull;
22 
23 import java.io.PrintWriter;
24 
25 /**
26  * Code that needs to be run when SystemUI is started.
27  *
28  * Which CoreStartable modules are loaded is controlled via the dagger graph. Bind them into the
29  * CoreStartable map with code such as:
30  *
31  *  <pre>
32  *  &#64;Binds
33  *  &#64;IntoMap
34  *  &#64;ClassKey(FoobarStartable::class)
35  *  abstract fun bind(impl: FoobarStartable): CoreStartable
36  *  </pre>
37  *
38  * @see SystemUIApplication#startServicesIfNeeded()
39  */
40 public interface CoreStartable extends Dumpable {
41 
42     /** Main entry point for implementations. Called shortly after SysUI startup. */
start()43     void start();
44 
45     /** Called when the device configuration changes. This will not be called before
46      * {@link #start()}, but it could be called before {@link #onBootCompleted()}.
47      *
48      * @see android.app.Application#onConfigurationChanged(Configuration)  */
onConfigurationChanged(Configuration newConfig)49     default void onConfigurationChanged(Configuration newConfig) {
50     }
51 
52     @Override
dump(@onNull PrintWriter pw, @NonNull String[] args)53     default void dump(@NonNull PrintWriter pw, @NonNull String[] args) {
54     }
55 
56     /** Called to determine if the dumpable should be registered as critical or normal priority */
isDumpCritical()57     default boolean isDumpCritical() {
58         return true;
59     }
60 
61     /** Called immediately after the system broadcasts
62      * {@link android.content.Intent#ACTION_LOCKED_BOOT_COMPLETED} or during SysUI startup if the
63      * property {@code sys.boot_completed} is already set to 1. The latter typically occurs when
64      * starting a new SysUI instance, such as when starting SysUI for a secondary user.
65      * {@link #onBootCompleted()} will never be called before {@link #start()}. */
onBootCompleted()66     default void onBootCompleted() {
67     }
68 }
69