blob: 2b6db8b590f8cc8f6d36463d72a434db20c41332 [file] [log] [blame]
Dianne Hackborn01e4cfc2010-06-24 15:07:24 -07001/*
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
17package android.app;
18
19import android.content.pm.IPackageManager;
20
21/**
22 * Special private access for certain globals related to a process.
23 * @hide
24 */
25public class AppGlobals {
26 /**
27 * Return the first Application object made in the process.
28 * NOTE: Only works on the main thread.
29 */
30 public static Application getInitialApplication() {
31 return ActivityThread.currentApplication();
32 }
33
34 /**
35 * Return the package name of the first .apk loaded into the process.
36 * NOTE: Only works on the main thread.
37 */
38 public static String getInitialPackage() {
39 return ActivityThread.currentPackageName();
40 }
Svetoslav Ganov54d068e2011-03-02 12:58:40 -080041
Dianne Hackborn01e4cfc2010-06-24 15:07:24 -070042 /**
43 * Return the raw interface to the package manager.
Svetoslav Ganov54d068e2011-03-02 12:58:40 -080044 * @return The package manager.
Dianne Hackborn01e4cfc2010-06-24 15:07:24 -070045 */
46 public static IPackageManager getPackageManager() {
47 return ActivityThread.getPackageManager();
48 }
Svetoslav Ganov54d068e2011-03-02 12:58:40 -080049
50 /**
51 * Gets the value of an integer core setting.
52 *
53 * @param key The setting key.
54 * @param defaultValue The setting default value.
55 * @return The core settings.
56 */
57 public static int getIntCoreSetting(String key, int defaultValue) {
Svetoslav Ganov11e515c2011-03-03 12:55:52 -080058 ActivityThread currentActivityThread = ActivityThread.currentActivityThread();
59 if (currentActivityThread != null) {
60 return currentActivityThread.getIntCoreSetting(key, defaultValue);
61 } else {
62 return defaultValue;
63 }
Svetoslav Ganov54d068e2011-03-02 12:58:40 -080064 }
Dianne Hackborn01e4cfc2010-06-24 15:07:24 -070065}