Debian Codegraph @

core/java/android/os/SystemConfigManager.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2020 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 package android.os;
17
18 import android.Manifest;
19 import android.annotation.NonNull;
20 import android.annotation.RequiresPermission;
21 import android.annotation.SystemApi;
22 import android.annotation.SystemService;
23 import android.content.ComponentName;
24 import android.content.Context;
25 import android.util.ArraySet;
26 import android.util.Log;
27
28 import java.util.Collections;
29 import java.util.List;
30 import java.util.Map;
31 import java.util.Set;
32
33
34 /**
35 * Allows apps outside the system process to access various bits of configuration defined in
36 * /etc/sysconfig and its counterparts on OEM and vendor partitions.
37 *
38 * TODO: Intended for access by system mainline modules only. Marking as SystemApi until the
39 * module-only API surface is available.
40 * @hide
41 */
42 @SystemApi
43 @SystemService(Context.SYSTEM_CONFIG_SERVICE)
44 public class SystemConfigManager {
45 private static final String TAG = SystemConfigManager.class.getSimpleName();
46
47 private final ISystemConfig mInterface;
48
49 /** @hide **/
50 public SystemConfigManager() {
51 mInterface = ISystemConfig.Stub.asInterface(
52 ServiceManager.getService(Context.SYSTEM_CONFIG_SERVICE));
53 }
54
55 /**
56 * Returns a set of package names for carrier apps that are preinstalled on the device but
57 * should be disabled until the matching carrier's SIM is inserted into the device.
58 * @return A set of package names.
59 */
60 @RequiresPermission(Manifest.permission.READ_CARRIER_APP_INFO)
61 public @NonNull Set<String> getDisabledUntilUsedPreinstalledCarrierApps() {
62 try {
63 List<String> apps = mInterface.getDisabledUntilUsedPreinstalledCarrierApps();
64 return new ArraySet<>(apps);
65 } catch (RemoteException e) {
66 Log.e(TAG, "Caught remote exception");
67 return Collections.emptySet();
68 }
69 }
70
71 /**
72 * Returns a map that describes helper apps associated with carrier apps that, like the apps
73 * returned by {@link #getDisabledUntilUsedPreinstalledCarrierApps()}, should be disabled until
74 * the correct SIM is inserted into the device.
75 * @return A map with keys corresponding to package names returned by
76 * {@link #getDisabledUntilUsedPreinstalledCarrierApps()} and values as lists of package
77 * names of helper apps.
78 */
79 @RequiresPermission(Manifest.permission.READ_CARRIER_APP_INFO)
80 public @NonNull Map<String, List<String>>
81 getDisabledUntilUsedPreinstalledCarrierAssociatedApps() {
82 try {
83 return (Map<String, List<String>>)
84 mInterface.getDisabledUntilUsedPreinstalledCarrierAssociatedApps();
85 } catch (RemoteException e) {
86 Log.e(TAG, "Caught remote exception");
87 return Collections.emptyMap();
88 }
89 }
90
91 /**
92 * Returns a map that describes helper apps associated with carrier apps that, like the apps
93 * returned by {@link #getDisabledUntilUsedPreinstalledCarrierApps()}, should be disabled until
94 * the correct SIM is inserted into the device.
95 *
96 * <p>TODO(b/159069037) expose this and get rid of the other method that omits SDK version.
97 *
98 * @return A map with keys corresponding to package names returned by
99 * {@link #getDisabledUntilUsedPreinstalledCarrierApps()} and values as lists of package
100 * names of helper apps and the SDK versions when they were first added.
101 *
102 * @hide
103 */
104 @RequiresPermission(Manifest.permission.READ_CARRIER_APP_INFO)
105 public @NonNull Map<String, List<CarrierAssociatedAppEntry>>
106 getDisabledUntilUsedPreinstalledCarrierAssociatedAppEntries() {
107 try {
108 return (Map<String, List<CarrierAssociatedAppEntry>>)
109 mInterface.getDisabledUntilUsedPreinstalledCarrierAssociatedAppEntries();
110 } catch (RemoteException e) {
111 Log.e(TAG, "Caught remote exception", e);
112 return Collections.emptyMap();
113 }
114 }
115
116 /**
117 * Get uids which have been granted given permission in system configuration.
118 *
119 * The uids and assigning permissions are defined on data/etc/platform.xml
120 *
121 * @param permissionName The target permission.
122 * @return The uids have been granted given permission in system configuration.
123 */
124 @RequiresPermission(Manifest.permission.GET_RUNTIME_PERMISSIONS)
125 @NonNull
126 public int[] getSystemPermissionUids(@NonNull String permissionName) {
127 try {
128 return mInterface.getSystemPermissionUids(permissionName);
129 } catch (RemoteException e) {
130 throw e.rethrowFromSystemServer();
131 }
132 }
133
134 /**
135 * Get enabled component for a specific package
136 *
137 * @param packageName The target package.
138 * @return The enabled component
139 * {@hide}
140 */
141 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
142 @NonNull
143 public List<ComponentName> getEnabledComponentOverrides(@NonNull String packageName) {
144 try {
145 return mInterface.getEnabledComponentOverrides(packageName);
146 } catch (RemoteException e) {
147 throw e.rethrowFromSystemServer();
148 }
149 }
150 }