blob: bbdfe31828dd881d1163a035aa96ffbd745fc6a9 [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
Jeff Sharkeye31b8202015-04-29 21:44:57 -0700110 /**
111 * Non-persisted value indicating this package has been temporarily frozen,
112 * usually during a critical section of the package update pipeline. The
113 * platform will refuse to launch packages in a frozen state.
114 */
115 boolean frozen = false;
116
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700117 PackageSettingBase origPackage;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700118
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700119 /** Package name of the app that installed this package */
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700120 String installerPackageName;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700121 /** UUID of {@link VolumeInfo} hosting this app */
122 String volumeUuid;
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800123
124 IntentFilterVerificationInfo verificationInfo;
125
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700126 PackageSettingBase(String name, String realName, File codePath, File resourcePath,
Narayan Kamathff110bd2014-07-04 18:30:45 +0100127 String legacyNativeLibraryPathString, String primaryCpuAbiString,
Narayan Kamath4903f642014-08-11 13:33:45 +0100128 String secondaryCpuAbiString, String cpuAbiOverrideString,
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800129 int pVersionCode, int pkgFlags, int pkgPrivateFlags) {
130 super(pkgFlags, pkgPrivateFlags);
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700131 this.name = name;
132 this.realName = realName;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100133 init(codePath, resourcePath, legacyNativeLibraryPathString, primaryCpuAbiString,
Narayan Kamath4903f642014-08-11 13:33:45 +0100134 secondaryCpuAbiString, cpuAbiOverrideString, pVersionCode);
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700135 }
136
137 /**
138 * New instance of PackageSetting with one-level-deep cloning.
139 */
140 @SuppressWarnings("unchecked")
141 PackageSettingBase(PackageSettingBase base) {
142 super(base);
143
144 name = base.name;
145 realName = base.realName;
146 codePath = base.codePath;
147 codePathString = base.codePathString;
148 resourcePath = base.resourcePath;
149 resourcePathString = base.resourcePathString;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100150 legacyNativeLibraryPathString = base.legacyNativeLibraryPathString;
151 primaryCpuAbiString = base.primaryCpuAbiString;
152 secondaryCpuAbiString = base.secondaryCpuAbiString;
Narayan Kamath4903f642014-08-11 13:33:45 +0100153 cpuAbiOverrideString = base.cpuAbiOverrideString;
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700154 timeStamp = base.timeStamp;
155 firstInstallTime = base.firstInstallTime;
156 lastUpdateTime = base.lastUpdateTime;
157 versionCode = base.versionCode;
158
159 uidError = base.uidError;
160
161 signatures = new PackageSignatures(base.signatures);
162
Svetoslavcf959f62015-03-26 20:53:34 -0700163 installPermissionsFixed = base.installPermissionsFixed;
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700164 userState.clear();
165 for (int i=0; i<base.userState.size(); i++) {
166 userState.put(base.userState.keyAt(i),
167 new PackageUserState(base.userState.valueAt(i)));
168 }
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700169 installStatus = base.installStatus;
170
171 origPackage = base.origPackage;
172
173 installerPackageName = base.installerPackageName;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700174 volumeUuid = base.volumeUuid;
Geremy Condraf1bcca82013-01-07 22:35:24 -0800175
176 keySetData = new PackageKeySetData(base.keySetData);
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700177 }
178
Narayan Kamathff110bd2014-07-04 18:30:45 +0100179 void init(File codePath, File resourcePath, String legacyNativeLibraryPathString,
Narayan Kamath4903f642014-08-11 13:33:45 +0100180 String primaryCpuAbiString, String secondaryCpuAbiString,
181 String cpuAbiOverrideString, int pVersionCode) {
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700182 this.codePath = codePath;
183 this.codePathString = codePath.toString();
184 this.resourcePath = resourcePath;
185 this.resourcePathString = resourcePath.toString();
Narayan Kamathff110bd2014-07-04 18:30:45 +0100186 this.legacyNativeLibraryPathString = legacyNativeLibraryPathString;
187 this.primaryCpuAbiString = primaryCpuAbiString;
188 this.secondaryCpuAbiString = secondaryCpuAbiString;
Narayan Kamath4903f642014-08-11 13:33:45 +0100189 this.cpuAbiOverrideString = cpuAbiOverrideString;
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700190 this.versionCode = pVersionCode;
191 }
192
193 public void setInstallerPackageName(String packageName) {
194 installerPackageName = packageName;
195 }
196
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700197 public String getInstallerPackageName() {
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700198 return installerPackageName;
199 }
200
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700201 public void setVolumeUuid(String volumeUuid) {
202 this.volumeUuid = volumeUuid;
203 }
204
205 public String getVolumeUuid() {
206 return volumeUuid;
207 }
208
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700209 public void setInstallStatus(int newStatus) {
210 installStatus = newStatus;
211 }
212
213 public int getInstallStatus() {
214 return installStatus;
215 }
216
217 public void setTimeStamp(long newStamp) {
218 timeStamp = newStamp;
219 }
220
221 /**
222 * Make a shallow copy of this package settings.
223 */
224 public void copyFrom(PackageSettingBase base) {
Svet Ganov37f05182015-03-31 16:52:11 -0700225 mPermissionsState.copyFrom(base.mPermissionsState);
Narayan Kamathff110bd2014-07-04 18:30:45 +0100226 primaryCpuAbiString = base.primaryCpuAbiString;
227 secondaryCpuAbiString = base.secondaryCpuAbiString;
Narayan Kamath4903f642014-08-11 13:33:45 +0100228 cpuAbiOverrideString = base.cpuAbiOverrideString;
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700229 timeStamp = base.timeStamp;
230 firstInstallTime = base.firstInstallTime;
231 lastUpdateTime = base.lastUpdateTime;
232 signatures = base.signatures;
Svetoslavcf959f62015-03-26 20:53:34 -0700233 installPermissionsFixed = base.installPermissionsFixed;
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700234 userState.clear();
235 for (int i=0; i<base.userState.size(); i++) {
236 userState.put(base.userState.keyAt(i), base.userState.valueAt(i));
237 }
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700238 installStatus = base.installStatus;
Geremy Condraf1bcca82013-01-07 22:35:24 -0800239 keySetData = base.keySetData;
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800240 verificationInfo = base.verificationInfo;
hyemin.hwangb4faf982015-07-09 09:16:12 +0900241 installerPackageName = base.installerPackageName;
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700242 }
243
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700244 private PackageUserState modifyUserState(int userId) {
245 PackageUserState state = userState.get(userId);
246 if (state == null) {
Dianne Hackborn4a9f0712012-10-02 15:29:06 -0700247 state = new PackageUserState();
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700248 userState.put(userId, state);
249 }
250 return state;
251 }
252
253 public PackageUserState readUserState(int userId) {
254 PackageUserState state = userState.get(userId);
Dianne Hackbornd4ac8d72012-09-27 23:20:10 -0700255 if (state != null) {
256 return state;
257 }
Dianne Hackborn4a9f0712012-10-02 15:29:06 -0700258 return DEFAULT_USER_STATE;
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700259 }
260
Dianne Hackborn3fa3c28a2013-03-26 16:15:41 -0700261 void setEnabled(int state, int userId, String callingPackage) {
262 PackageUserState st = modifyUserState(userId);
263 st.enabled = state;
264 st.lastDisableAppCaller = callingPackage;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700265 }
266
267 int getEnabled(int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700268 return readUserState(userId).enabled;
269 }
270
Dianne Hackborn3fa3c28a2013-03-26 16:15:41 -0700271 String getLastDisabledAppCaller(int userId) {
272 return readUserState(userId).lastDisableAppCaller;
273 }
274
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700275 void setInstalled(boolean inst, int userId) {
276 modifyUserState(userId).installed = inst;
277 }
278
279 boolean getInstalled(int userId) {
280 return readUserState(userId).installed;
281 }
282
283 boolean isAnyInstalled(int[] users) {
284 for (int user: users) {
285 if (readUserState(user).installed) {
286 return true;
287 }
288 }
289 return false;
290 }
291
Dianne Hackborn786b4402012-08-27 15:14:02 -0700292 int[] queryInstalledUsers(int[] users, boolean installed) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700293 int 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 num++;
297 }
298 }
299 int[] res = new int[num];
300 num = 0;
301 for (int user : users) {
Dianne Hackborn786b4402012-08-27 15:14:02 -0700302 if (getInstalled(user) == installed) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700303 res[num] = user;
304 num++;
305 }
306 }
307 return res;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700308 }
309
310 boolean getStopped(int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700311 return readUserState(userId).stopped;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700312 }
313
314 void setStopped(boolean stop, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700315 modifyUserState(userId).stopped = stop;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700316 }
317
318 boolean getNotLaunched(int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700319 return readUserState(userId).notLaunched;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700320 }
321
322 void setNotLaunched(boolean stop, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700323 modifyUserState(userId).notLaunched = stop;
324 }
325
Amith Yamasanie5bcff62014-07-19 15:44:09 -0700326 boolean getHidden(int userId) {
327 return readUserState(userId).hidden;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700328 }
329
Amith Yamasanie5bcff62014-07-19 15:44:09 -0700330 void setHidden(boolean hidden, int userId) {
331 modifyUserState(userId).hidden = hidden;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700332 }
333
Kenny Guyc13053b2014-05-29 14:17:17 +0100334 boolean getBlockUninstall(int userId) {
335 return readUserState(userId).blockUninstall;
336 }
337
338 void setBlockUninstall(boolean blockUninstall, int userId) {
339 modifyUserState(userId).blockUninstall = blockUninstall;
340 }
341
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700342 void setUserState(int userId, int enabled, boolean installed, boolean stopped,
Amith Yamasanie5bcff62014-07-19 15:44:09 -0700343 boolean notLaunched, boolean hidden,
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700344 String lastDisableAppCaller, ArraySet<String> enabledComponents,
Christopher Tatef0d6cb32015-07-10 17:44:53 -0700345 ArraySet<String> disabledComponents, boolean blockUninstall, int domainVerifState,
346 int linkGeneration) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700347 PackageUserState state = modifyUserState(userId);
348 state.enabled = enabled;
349 state.installed = installed;
350 state.stopped = stopped;
351 state.notLaunched = notLaunched;
Amith Yamasanie5bcff62014-07-19 15:44:09 -0700352 state.hidden = hidden;
Dianne Hackborn3fa3c28a2013-03-26 16:15:41 -0700353 state.lastDisableAppCaller = lastDisableAppCaller;
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700354 state.enabledComponents = enabledComponents;
355 state.disabledComponents = disabledComponents;
Kenny Guyc13053b2014-05-29 14:17:17 +0100356 state.blockUninstall = blockUninstall;
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800357 state.domainVerificationStatus = domainVerifState;
Christopher Tatef0d6cb32015-07-10 17:44:53 -0700358 state.appLinkGeneration = linkGeneration;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700359 }
360
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700361 ArraySet<String> getEnabledComponents(int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700362 return readUserState(userId).enabledComponents;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700363 }
364
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700365 ArraySet<String> getDisabledComponents(int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700366 return readUserState(userId).disabledComponents;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700367 }
368
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700369 void setEnabledComponents(ArraySet<String> components, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700370 modifyUserState(userId).enabledComponents = components;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700371 }
372
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700373 void setDisabledComponents(ArraySet<String> components, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700374 modifyUserState(userId).disabledComponents = components;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700375 }
376
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700377 void setEnabledComponentsCopy(ArraySet<String> components, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700378 modifyUserState(userId).enabledComponents = components != null
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700379 ? new ArraySet<String>(components) : null;
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700380 }
381
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700382 void setDisabledComponentsCopy(ArraySet<String> components, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700383 modifyUserState(userId).disabledComponents = components != null
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700384 ? new ArraySet<String>(components) : null;
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700385 }
386
387 PackageUserState modifyUserStateComponents(int userId, boolean disabled, boolean enabled) {
388 PackageUserState state = modifyUserState(userId);
389 if (disabled && state.disabledComponents == null) {
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700390 state.disabledComponents = new ArraySet<String>(1);
Amith Yamasani483f3b02012-03-13 16:08:00 -0700391 }
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700392 if (enabled && state.enabledComponents == null) {
Jeff Sharkey9f837a92014-10-24 12:07:24 -0700393 state.enabledComponents = new ArraySet<String>(1);
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700394 }
395 return state;
Amith Yamasani483f3b02012-03-13 16:08:00 -0700396 }
397
398 void addDisabledComponent(String componentClassName, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700399 modifyUserStateComponents(userId, true, false).disabledComponents.add(componentClassName);
Amith Yamasani483f3b02012-03-13 16:08:00 -0700400 }
401
402 void addEnabledComponent(String componentClassName, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700403 modifyUserStateComponents(userId, false, true).enabledComponents.add(componentClassName);
Amith Yamasani483f3b02012-03-13 16:08:00 -0700404 }
405
406 boolean enableComponentLPw(String componentClassName, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700407 PackageUserState state = modifyUserStateComponents(userId, false, true);
408 boolean changed = state.disabledComponents != null
409 ? state.disabledComponents.remove(componentClassName) : false;
410 changed |= state.enabledComponents.add(componentClassName);
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700411 return changed;
412 }
413
Amith Yamasani483f3b02012-03-13 16:08:00 -0700414 boolean disableComponentLPw(String componentClassName, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700415 PackageUserState state = modifyUserStateComponents(userId, true, false);
416 boolean changed = state.enabledComponents != null
417 ? state.enabledComponents.remove(componentClassName) : false;
418 changed |= state.disabledComponents.add(componentClassName);
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700419 return changed;
420 }
421
Amith Yamasani483f3b02012-03-13 16:08:00 -0700422 boolean restoreComponentLPw(String componentClassName, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700423 PackageUserState state = modifyUserStateComponents(userId, true, true);
424 boolean changed = state.disabledComponents != null
425 ? state.disabledComponents.remove(componentClassName) : false;
426 changed |= state.enabledComponents != null
427 ? state.enabledComponents.remove(componentClassName) : false;
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700428 return changed;
429 }
430
Amith Yamasani483f3b02012-03-13 16:08:00 -0700431 int getCurrentEnabledStateLPr(String componentName, int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700432 PackageUserState state = readUserState(userId);
433 if (state.enabledComponents != null && state.enabledComponents.contains(componentName)) {
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700434 return COMPONENT_ENABLED_STATE_ENABLED;
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700435 } else if (state.disabledComponents != null
436 && state.disabledComponents.contains(componentName)) {
Kenny Rootcf0b38c2011-03-22 14:17:59 -0700437 return COMPONENT_ENABLED_STATE_DISABLED;
438 } else {
439 return COMPONENT_ENABLED_STATE_DEFAULT;
440 }
441 }
Amith Yamasani13593602012-03-22 16:16:17 -0700442
443 void removeUser(int userId) {
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700444 userState.delete(userId);
Amith Yamasani13593602012-03-22 16:16:17 -0700445 }
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800446
Fabrice Di Meglio62271722015-04-10 17:24:02 -0700447 IntentFilterVerificationInfo getIntentFilterVerificationInfo() {
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800448 return verificationInfo;
449 }
450
Fabrice Di Meglio62271722015-04-10 17:24:02 -0700451 void setIntentFilterVerificationInfo(IntentFilterVerificationInfo info) {
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800452 verificationInfo = info;
453 }
454
Christopher Tatef0d6cb32015-07-10 17:44:53 -0700455 // Returns a packed value as a long:
456 //
457 // high 'int'-sized word: link status: undefined/ask/never/always.
458 // low 'int'-sized word: relative priority among 'always' results.
459 long getDomainVerificationStatusForUser(int userId) {
460 PackageUserState state = readUserState(userId);
461 long result = (long) state.appLinkGeneration;
462 result |= ((long) state.domainVerificationStatus) << 32;
463 return result;
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800464 }
465
Christopher Tatef0d6cb32015-07-10 17:44:53 -0700466 void setDomainVerificationStatusForUser(final int status, int generation, int userId) {
467 PackageUserState state = modifyUserState(userId);
468 state.domainVerificationStatus = status;
469 if (status == PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS) {
470 state.appLinkGeneration = generation;
471 }
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800472 }
473
Fabrice Di Meglio62271722015-04-10 17:24:02 -0700474 void clearDomainVerificationStatusForUser(int userId) {
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -0800475 modifyUserState(userId).domainVerificationStatus =
476 PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
477 }
Amith Yamasani483f3b02012-03-13 16:08:00 -0700478}