Debian Codegraph @

core/java/android/app/AppGlobals.java

raw symbols SCIP
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 android.app;
18
19 import android.compat.annotation.UnsupportedAppUsage;
20 import android.content.pm.IPackageManager;
21 import android.permission.IPermissionManager;
22
23 /**
24 * Special private access for certain globals related to a process.
25 * @hide
26 */
27 public class AppGlobals {
28 /**
29 * Return the first Application object made in the process.
30 * NOTE: Only works on the main thread.
31 */
32 @UnsupportedAppUsage
33 public static Application getInitialApplication() {
34 return ActivityThread.currentApplication();
35 }
36
37 /**
38 * Return the package name of the first .apk loaded into the process.
39 * NOTE: Only works on the main thread.
40 */
41 @UnsupportedAppUsage
42 public static String getInitialPackage() {
43 return ActivityThread.currentPackageName();
44 }
45
46 /**
47 * Return the raw interface to the package manager.
48 * @return The package manager.
49 */
50 @UnsupportedAppUsage
51 public static IPackageManager getPackageManager() {
52 return ActivityThread.getPackageManager();
53 }
54
55 /**
56 * Return the raw interface to the permission manager.
57 * @return The permission manager.
58 */
59 public static IPermissionManager getPermissionManager() {
60 return ActivityThread.getPermissionManager();
61 }
62
63 /**
64 * Gets the value of an integer core setting.
65 *
66 * @param key The setting key.
67 * @param defaultValue The setting default value.
68 * @return The core settings.
69 */
70 public static int getIntCoreSetting(String key, int defaultValue) {
71 ActivityThread currentActivityThread = ActivityThread.currentActivityThread();
72 if (currentActivityThread != null) {
73 return currentActivityThread.getIntCoreSetting(key, defaultValue);
74 } else {
75 return defaultValue;
76 }
77 }
78
79 /**
80 * Gets the value of a float core setting.
81 *
82 * @param key The setting key.
83 * @param defaultValue The setting default value.
84 * @return The core settings.
85 */
86 public static float getFloatCoreSetting(String key, float defaultValue) {
87 ActivityThread currentActivityThread = ActivityThread.currentActivityThread();
88 if (currentActivityThread != null) {
89 return currentActivityThread.getFloatCoreSetting(key, defaultValue);
90 } else {
91 return defaultValue;
92 }
93 }
94 }