• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.app.Notification;
20 import android.content.Context;
21 import android.content.res.Configuration;
22 import android.os.Bundle;
23 
24 import java.io.FileDescriptor;
25 import java.io.PrintWriter;
26 import java.util.Map;
27 import java.util.function.Function;
28 
29 public abstract class SystemUI implements SysUiServiceProvider {
30     public Context mContext;
31     public Map<Class<?>, Object> mComponents;
32 
start()33     public abstract void start();
34 
onConfigurationChanged(Configuration newConfig)35     protected void onConfigurationChanged(Configuration newConfig) {
36     }
37 
dump(FileDescriptor fd, PrintWriter pw, String[] args)38     public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
39     }
40 
onBootCompleted()41     protected void onBootCompleted() {
42     }
43 
44     @SuppressWarnings("unchecked")
getComponent(Class<T> interfaceType)45     public <T> T getComponent(Class<T> interfaceType) {
46         return (T) (mComponents != null ? mComponents.get(interfaceType) : null);
47     }
48 
putComponent(Class<T> interfaceType, C component)49     public <T, C extends T> void putComponent(Class<T> interfaceType, C component) {
50         if (mComponents != null) {
51             mComponents.put(interfaceType, component);
52         }
53     }
54 
overrideNotificationAppName(Context context, Notification.Builder n, boolean system)55     public static void overrideNotificationAppName(Context context, Notification.Builder n,
56             boolean system) {
57         final Bundle extras = new Bundle();
58         String appName = system
59                 ? context.getString(com.android.internal.R.string.notification_app_name_system)
60                 : context.getString(com.android.internal.R.string.notification_app_name_settings);
61         extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, appName);
62 
63         n.addExtras(extras);
64     }
65 
66     public interface Injector extends Function<Context, SystemUI> {
67     }
68 }
69