blob: f294b320fd452b7daa71b793497e91fff4c4225f [file] [log] [blame]
Kenny Rootcf0b38c2011-03-22 14:17:59 -07001/*
2 * Copyright (C) 2011 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 com.android.server.pm;
18
19import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
20import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
21import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
22
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -080023import android.content.pm.IntentFilterVerificationInfo;
24import android.content.pm.PackageManager;
Dianne Hackborn7767eac2012-08-23 18:25:40 -070025import android.content.pm.PackageUserState;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -070026import android.os.storage.VolumeInfo;
Jeff Sharkey9f837a92014-10-24 12:07:24 -070027import android.util.ArraySet;
Amith Yamasani483f3b02012-03-13 16:08:00 -070028import android.util.SparseArray;
Kenny Rootcf0b38c2011-03-22 14:17:59 -070029
30import java.io.File;
Kenny Rootcf0b38c2011-03-22 14:17:59 -070031
32/**
33 * Settings base class for pending and resolved classes.
34 */
Svetoslavc6d1c342015-02-26 14:44:43 -080035abstract class PackageSettingBase extends SettingBase {
Kenny Rootcf0b38c2011-03-22 14:17:59 -070036 /**
37 * Indicates the state of installation. Used by PackageManager to figure out
38 * incomplete installations. Say a package is being installed (the state is
39 * set to PKG_INSTALL_INCOMPLETE) and remains so till the package
40 * installation is successful or unsuccessful in which case the
41 * PackageManager will no longer maintain state information associated with
42 * the package. If some exception(like device freeze or battery being pulled
43 * out) occurs during installation of a package, the PackageManager needs
44 * this information to clean up the previously failed installation.
45 */
46 static final int PKG_INSTALL_COMPLETE = 1;
47 static final int PKG_INSTALL_INCOMPLETE = 0;
48
49 final String name;
50 final String realName;
Jeff Sharkey57dcf5b2014-06-18 17:46:05 -070051
52 /**
53 * Path where this package was found on disk. For monolithic packages
54 * this is path to single base APK file; for cluster packages this is
55 * path to the cluster directory.
56 */
Kenny Rootcf0b38c2011-03-22 14:17:59 -070057 File codePath;
58 String codePathString;
59 File resourcePath;
60 String resourcePathString;
Narayan Kamathff110bd2014-07-04 18:30:45 +010061
62 /**
Jeff Sharkey84f12942014-07-10 17:48:11 -070063 * The path under which native libraries have been unpacked. This path is
64 * always derived at runtime, and is only stored here for cleanup when a
65 * package is uninstalled.
Narayan Kamathff110bd2014-07-04 18:30:45 +010066 */
Jeff Sharkey84f12942014-07-10 17:48:11 -070067 @Deprecated
Narayan Kamathff110bd2014-07-04 18:30:45 +010068 String legacyNativeLibraryPathString;
69
Narayan Kamath4903f642014-08-11 13:33:45 +010070 /**
71 * The primary CPU abi for this package. This value is regenerated at every
72 * boot scan.
73 */
Narayan Kamathff110bd2014-07-04 18:30:45 +010074 String primaryCpuAbiString;
Narayan Kamath4903f642014-08-11 13:33:45 +010075
76 /**
77 * The secondary CPU abi for this package. This value is regenerated at every
78 * boot scan.
79 */
Narayan Kamathff110bd2014-07-04 18:30:45 +010080 String secondaryCpuAbiString;
Narayan Kamath4903f642014-08-11 13:33:45 +010081
82 /**
83 * The install time CPU override, if any. This value is written at install time
84 * and doesn't change during the life of an install. If non-null,
85 * {@code primaryCpuAbiString} will contain the same value.
86 */
87 String cpuAbiOverrideString;
88
Kenny Rootcf0b38c2011-03-22 14:17:59 -070089 long timeStamp;
90 long firstInstallTime;
91 long lastUpdateTime;
92 int versionCode;
93
94 boolean uidError;
95
96 PackageSignatures signatures = new PackageSignatures();
97
Svetoslavcf959f62015-03-26 20:53:34 -070098 boolean installPermissionsFixed;
Kenny Rootcf0b38c2011-03-22 14:17:59 -070099
Geremy Condraf1bcca82013-01-07 22:35:24 -0800100 PackageKeySetData keySetData = new PackageKeySetData();
101
Dianne Hackborn4a9f0712012-10-02 15:29:06 -0700102 private static final PackageUserState DEFAULT_USER_STATE = new PackageUserState();
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700103
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700104 // Whether this package is currently stopped, thus can not be
105 // started until explicitly launched by the user.
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700106 private final SparseArray<PackageUserState> userState = new SparseArray<PackageUserState>();
Amith Yamasani483f3b02012-03-13 16:08:00 -0700107
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700108 int installStatus = PKG_INSTALL_COMPLETE;
109
110 PackageSettingBase origPackage;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700111
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700112 /** Package name of the app that installed this package */
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700113 String installerPackageName;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700114 /** UUID of {@link VolumeInfo} hosting this app */
115 String volumeUuid;
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800116
117 IntentFilterVerificationInfo verificationInfo;
118
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700119 PackageSettingBase(String name, String realName, File codePath, File resourcePath,
Narayan Kamathff110bd2014-07-04 18:30:45 +0100120 String legacyNativeLibraryPathString, String primaryCpuAbiString,
Narayan Kamath4903f642014-08-11 13:33:45 +0100121 String secondaryCpuAbiString, String cpuAbiOverrideString,
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800122 int pVersionCode, int pkgFlags, int pkgPrivateFlags) {
123 super(pkgFlags, pkgPrivateFlags);
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700124 this.name = name;
125 this.realName = realName;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100126 init(codePath, resourcePath, legacyNativeLibraryPathString, primaryCpuAbiString,
Narayan Kamath4903f642014-08-11 13:33:45 +0100127 secondaryCpuAbiString, cpuAbiOverrideString, pVersionCode);
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700128 }
129
130 /**
131 * New instance of PackageSetting with one-level-deep cloning.
132 */
133 @SuppressWarnings("unchecked")
134 PackageSettingBase(PackageSettingBase base) {
135 super(base);
136
137 name = base.name;
138 realName = base.realName;
139 codePath = base.codePath;
140 codePathString = base.codePathString;
141 resourcePath = base.resourcePath;
142 resourcePathString = base.resourcePathString;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100143 legacyNativeLibraryPathString = base.legacyNativeLibraryPathString;
144 primaryCpuAbiString = base.primaryCpuAbiString;
145 secondaryCpuAbiString = base.secondaryCpuAbiString;
Narayan Kamath4903f642014-08-11 13:33:45 +0100146 cpuAbiOverrideString = base.cpuAbiOverrideString;
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700147 timeStamp = base.timeStamp;
148 firstInstallTime = base.firstInstallTime;
149 lastUpdateTime = base.lastUpdateTime;
150 versionCode = base.versionCode;
151
152 uidError = base.uidError;
153
154 signatures = new PackageSignatures(base.signatures);
155
Svetoslavcf959f62015-03-26 20:53:34 -0700156 installPermissionsFixed = base.installPermissionsFixed;
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700157 userState.clear();
158 for (int i=0; i<base.userState.size(); i++) {
159 userState.put(base.userState.keyAt(i),
160 new PackageUserState(base.userState.valueAt(i)));
161 }
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700162 installStatus = base.installStatus;
163
164 origPackage = base.origPackage;
165
166 installerPackageName = base.installerPackageName;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700167 volumeUuid = base.volumeUuid;
Geremy Condraf1bcca82013-01-07 22:35:24 -0800168
169 keySetData = new PackageKeySetData(base.keySetData);
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700170 }
171
Narayan Kamathff110bd2014-07-04 18:30:45 +0100172 void init(File codePath, File resourcePath, String legacyNativeLibraryPathString,
Narayan Kamath4903f642014-08-11 13:33:45 +0100173 String primaryCpuAbiString, String secondaryCpuAbiString,
174 String cpuAbiOverrideString, int pVersionCode) {
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700175 this.codePath = codePath;
176 this.codePathString = codePath.toString();
177 this.resourcePath = resourcePath;
178 this.resourcePathString = resourcePath.toString();
Narayan Kamathff110bd2014-07-04 18:30:45 +0100179 this.legacyNativeLibraryPathString = legacyNativeLibraryPathString;
180 this.primaryCpuAbiString = primaryCpuAbiString;
181 this.secondaryCpuAbiString = secondaryCpuAbiString;
Narayan Kamath4903f642014-08-11 13:33:45 +0100182 this.cpuAbiOverrideString = cpuAbiOverrideString;
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700183 this.versionCode = pVersionCode;
184 }
185
186 public void setInstallerPackageName(String packageName) {
187 installerPackageName = packageName;
188 }
189
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700190 public String getInstallerPackageName() {
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700191 return installerPackageName;
192 }
193
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700194 public void setVolumeUuid(String volumeUuid) {
195 this.volumeUuid = volumeUuid;
196 }
197
198 public String getVolumeUuid() {
199 return volumeUuid;
200 }
201
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700202 public void setInstallStatus(int newStatus) {
203 installStatus = newStatus;
204 }
205
206 public int getInstallStatus() {
207 return installStatus;
208 }
209
210 public void setTimeStamp(long newStamp) {
211 timeStamp = newStamp;
212 }
213
214 /**
215 * Make a shallow copy of this package settings.
216 */
217 public void copyFrom(PackageSettingBase base) {
Svet Ganovd5752bd2015-03-25 22:57:39 -0700218 setPermissionsUpdatedForUserIds(base.getPermissionsUpdatedForUserIds());
Svet Ganov37f05182015-03-31 16:52:11 -0700219 mPermissionsState.copyFrom(base.mPermissionsState);
Narayan Kamathff110bd2014-07-04 18:30:45 +0100220 primaryCpuAbiString = base.primaryCpuAbiString;
221 secondaryCpuAbiString = base.secondaryCpuAbiString;
Narayan Kamath4903f642014-08-11 13:33:45 +0100222 cpuAbiOverrideString = base.cpuAbiOverrideString;
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700223 timeStamp = base.timeStamp;
224 firstInstallTime = base.firstInstallTime;
225 lastUpdateTime = base.lastUpdateTime;
226 signatures = base.signatures;
Svetoslavcf959f62015-03-26 20:53:34 -0700227 installPermissionsFixed = base.installPermissionsFixed;
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700228 userState.clear();
229 for (int i=0; i<base.userState.size(); i++) {
230 userState.put(base.userState.keyAt(i), base.userState.valueAt(i));
231 }
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700232 installStatus = base.installStatus;
Geremy Condraf1bcca82013-01-07 22:35:24 -0800233 keySetData = base.keySetData;
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800234 verificationInfo = base.verificationInfo;
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700235 }
236
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700237 private PackageUserState modifyUserState(int userId) {
238 PackageUserState state = userState.get(userId);
239 if (state == null) {
Dianne Hackborn4a9f0712012-10-02 15:29:06 -0700240 state = new PackageUserState();
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700241 userState.put(userId, state);
242 }
243 return state;
244 }
245
246 public PackageUserState readUserState(int userId) {
247 PackageUserState state = userState.get(userId);
Dianne Hackbornd4ac8d72012-09-27 23:20:10 -0700248 if (state != null) {
249 return state;
250 }
Dianne Hackborn4a9f0712012-10-02 15:29:06 -0700251 return DEFAULT_USER_STATE;
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700252 }
253
Dianne Hackborn3fa3c28a2013-03-26 16:15:41 -0700254 void setEnabled(int state, int userId, String callingPackage) {
255 PackageUserState st = modifyUserState(userId);
256 st.enabled = state;
257 st.lastDisableAppCaller = callingPackage;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700258 }
259
260 int getEnabled(int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700261 return readUserState(userId).enabled;
262 }
263
Dianne Hackborn3fa3c28a2013-03-26 16:15:41 -0700264 String getLastDisabledAppCaller(int userId) {
265 return readUserState(userId).lastDisableAppCaller;
266 }
267
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700268 void setInstalled(boolean inst, int userId) {
269 modifyUserState(userId).installed = inst;
270 }
271
272 boolean getInstalled(int userId) {
273 return readUserState(userId).installed;
274 }
275
276 boolean isAnyInstalled(int[] users) {
277 for (int user: users) {
278 if (readUserState(user).installed) {
279 return true;
280 }
281 }
282 return false;
283 }
284
Dianne Hackborn786b4402012-08-27 15:14:02 -0700285 int[] queryInstalledUsers(int[] users, boolean installed) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700286 int num = 0;
287 for (int user : users) {
Dianne Hackborn786b4402012-08-27 15:14:02 -0700288 if (getInstalled(user) == installed) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700289 num++;
290 }
291 }
292 int[] res = new int[num];
293 num = 0;
294 for (int user : users) {
Dianne Hackborn786b4402012-08-27 15:14:02 -0700295 if (getInstalled(user) == installed) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700296 res[num] = user;
297 num++;
298 }
299 }
300 return res;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700301 }
302
303 boolean getStopped(int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700304 return readUserState(userId).stopped;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700305 }
306
307 void setStopped(boolean stop, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700308 modifyUserState(userId).stopped = stop;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700309 }
310
311 boolean getNotLaunched(int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700312 return readUserState(userId).notLaunched;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700313 }
314
315 void setNotLaunched(boolean stop, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700316 modifyUserState(userId).notLaunched = stop;
317 }
318
Amith Yamasanie5bcff62014-07-19 15:44:09 -0700319 boolean getHidden(int userId) {
320 return readUserState(userId).hidden;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700321 }
322
Amith Yamasanie5bcff62014-07-19 15:44:09 -0700323 void setHidden(boolean hidden, int userId) {
324 modifyUserState(userId).hidden = hidden;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700325 }
326
Kenny Guyc13053b2014-05-29 14:17:17 +0100327 boolean getBlockUninstall(int userId) {
328 return readUserState(userId).blockUninstall;
329 }
330
331 void setBlockUninstall(boolean blockUninstall, int userId) {
332 modifyUserState(userId).blockUninstall = blockUninstall;
333 }
334
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700335 void setUserState(int userId, int enabled, boolean installed, boolean stopped,
Amith Yamasanie5bcff62014-07-19 15:44:09 -0700336 boolean notLaunched, boolean hidden,
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700337 String lastDisableAppCaller, ArraySet<String> enabledComponents,
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800338 ArraySet<String> disabledComponents, boolean blockUninstall, int domainVerifState) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700339 PackageUserState state = modifyUserState(userId);
340 state.enabled = enabled;
341 state.installed = installed;
342 state.stopped = stopped;
343 state.notLaunched = notLaunched;
Amith Yamasanie5bcff62014-07-19 15:44:09 -0700344 state.hidden = hidden;
Dianne Hackborn3fa3c28a2013-03-26 16:15:41 -0700345 state.lastDisableAppCaller = lastDisableAppCaller;
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700346 state.enabledComponents = enabledComponents;
347 state.disabledComponents = disabledComponents;
Kenny Guyc13053b2014-05-29 14:17:17 +0100348 state.blockUninstall = blockUninstall;
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800349 state.domainVerificationStatus = domainVerifState;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700350 }
351
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700352 ArraySet<String> getEnabledComponents(int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700353 return readUserState(userId).enabledComponents;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700354 }
355
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700356 ArraySet<String> getDisabledComponents(int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700357 return readUserState(userId).disabledComponents;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700358 }
359
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700360 void setEnabledComponents(ArraySet<String> components, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700361 modifyUserState(userId).enabledComponents = components;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700362 }
363
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700364 void setDisabledComponents(ArraySet<String> components, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700365 modifyUserState(userId).disabledComponents = components;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700366 }
367
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700368 void setEnabledComponentsCopy(ArraySet<String> components, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700369 modifyUserState(userId).enabledComponents = components != null
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700370 ? new ArraySet<String>(components) : null;
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700371 }
372
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700373 void setDisabledComponentsCopy(ArraySet<String> components, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700374 modifyUserState(userId).disabledComponents = components != null
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700375 ? new ArraySet<String>(components) : null;
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700376 }
377
378 PackageUserState modifyUserStateComponents(int userId, boolean disabled, boolean enabled) {
379 PackageUserState state = modifyUserState(userId);
380 if (disabled && state.disabledComponents == null) {
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700381 state.disabledComponents = new ArraySet<String>(1);
Amith Yamasani483f3b02012-03-13 16:08:00 -0700382 }
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700383 if (enabled && state.enabledComponents == null) {
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700384 state.enabledComponents = new ArraySet<String>(1);
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700385 }
386 return state;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700387 }
388
389 void addDisabledComponent(String componentClassName, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700390 modifyUserStateComponents(userId, true, false).disabledComponents.add(componentClassName);
Amith Yamasani483f3b02012-03-13 16:08:00 -0700391 }
392
393 void addEnabledComponent(String componentClassName, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700394 modifyUserStateComponents(userId, false, true).enabledComponents.add(componentClassName);
Amith Yamasani483f3b02012-03-13 16:08:00 -0700395 }
396
397 boolean enableComponentLPw(String componentClassName, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700398 PackageUserState state = modifyUserStateComponents(userId, false, true);
399 boolean changed = state.disabledComponents != null
400 ? state.disabledComponents.remove(componentClassName) : false;
401 changed |= state.enabledComponents.add(componentClassName);
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700402 return changed;
403 }
404
Amith Yamasani483f3b02012-03-13 16:08:00 -0700405 boolean disableComponentLPw(String componentClassName, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700406 PackageUserState state = modifyUserStateComponents(userId, true, false);
407 boolean changed = state.enabledComponents != null
408 ? state.enabledComponents.remove(componentClassName) : false;
409 changed |= state.disabledComponents.add(componentClassName);
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700410 return changed;
411 }
412
Amith Yamasani483f3b02012-03-13 16:08:00 -0700413 boolean restoreComponentLPw(String componentClassName, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700414 PackageUserState state = modifyUserStateComponents(userId, true, true);
415 boolean changed = state.disabledComponents != null
416 ? state.disabledComponents.remove(componentClassName) : false;
417 changed |= state.enabledComponents != null
418 ? state.enabledComponents.remove(componentClassName) : false;
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700419 return changed;
420 }
421
Amith Yamasani483f3b02012-03-13 16:08:00 -0700422 int getCurrentEnabledStateLPr(String componentName, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700423 PackageUserState state = readUserState(userId);
424 if (state.enabledComponents != null && state.enabledComponents.contains(componentName)) {
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700425 return COMPONENT_ENABLED_STATE_ENABLED;
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700426 } else if (state.disabledComponents != null
427 && state.disabledComponents.contains(componentName)) {
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700428 return COMPONENT_ENABLED_STATE_DISABLED;
429 } else {
430 return COMPONENT_ENABLED_STATE_DEFAULT;
431 }
432 }
Amith Yamasani13593602012-03-22 16:16:17 -0700433
434 void removeUser(int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700435 userState.delete(userId);
Amith Yamasani13593602012-03-22 16:16:17 -0700436 }
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800437
438 public IntentFilterVerificationInfo getIntentFilterVerificationInfo() {
439 return verificationInfo;
440 }
441
442 public void setIntentFilterVerificationInfo(IntentFilterVerificationInfo info) {
443 verificationInfo = info;
444 }
445
446 public int getDomainVerificationStatusForUser(int userId) {
447 return readUserState(userId).domainVerificationStatus;
448 }
449
450 public void setDomainVerificationStatusForUser(int status, int userId) {
451 modifyUserState(userId).domainVerificationStatus = status;
452 }
453
454 public void clearDomainVerificationStatusForUser(int userId) {
455 modifyUserState(userId).domainVerificationStatus =
456 PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
457 }
Amith Yamasani483f3b02012-03-13 16:08:00 -0700458}