Kenny Root | cf0b38c | 2011-03-22 14:17:59 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.server.pm; |
| 18 | |
Winson | e075629 | 2020-01-31 12:21:54 -0800 | [diff] [blame] | 19 | import android.annotation.NonNull; |
Taras Antoshchuk | a7d9c73 | 2019-10-29 13:46:19 +0100 | [diff] [blame] | 20 | import android.annotation.Nullable; |
Christopher Tate | 628946a | 2013-10-18 18:11:05 -0700 | [diff] [blame] | 21 | import android.content.pm.ApplicationInfo; |
Jeff Sharkey | c5967e9 | 2016-01-07 18:50:29 -0700 | [diff] [blame] | 22 | import android.content.pm.PackageManager; |
Netta P | 426cbef | 2017-02-10 14:38:39 -0800 | [diff] [blame] | 23 | import android.content.pm.UserInfo; |
| 24 | import android.service.pm.PackageProto; |
Taras Antoshchuk | a7d9c73 | 2019-10-29 13:46:19 +0100 | [diff] [blame] | 25 | import android.util.ArrayMap; |
| 26 | import android.util.ArraySet; |
Netta P | 426cbef | 2017-02-10 14:38:39 -0800 | [diff] [blame] | 27 | import android.util.proto.ProtoOutputStream; |
Kenny Root | cf0b38c | 2011-03-22 14:17:59 -0700 | [diff] [blame] | 28 | |
Winson Chiu | 8e865ec | 2020-04-01 18:20:51 +0000 | [diff] [blame] | 29 | import com.android.internal.annotations.VisibleForTesting; |
Winson | e23ae20 | 2020-01-24 11:56:44 -0800 | [diff] [blame] | 30 | import com.android.server.pm.parsing.pkg.AndroidPackage; |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 31 | import com.android.server.pm.permission.PermissionsState; |
Winson | e075629 | 2020-01-31 12:21:54 -0800 | [diff] [blame] | 32 | import com.android.server.pm.pkg.PackageStateUnserialized; |
Todd Kennedy | 82b0842 | 2017-09-28 13:32:05 -0700 | [diff] [blame] | 33 | |
Kenny Root | cf0b38c | 2011-03-22 14:17:59 -0700 | [diff] [blame] | 34 | import java.io.File; |
Taras Antoshchuk | a7d9c73 | 2019-10-29 13:46:19 +0100 | [diff] [blame] | 35 | import java.util.ArrayList; |
| 36 | import java.util.Collections; |
Svet Ganov | 354cd3c | 2015-12-17 11:35:04 -0800 | [diff] [blame] | 37 | import java.util.List; |
Taras Antoshchuk | a7d9c73 | 2019-10-29 13:46:19 +0100 | [diff] [blame] | 38 | import java.util.Map; |
| 39 | import java.util.Set; |
Kenny Root | cf0b38c | 2011-03-22 14:17:59 -0700 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * Settings data for a particular package we know about. |
| 43 | */ |
Winson | e075629 | 2020-01-31 12:21:54 -0800 | [diff] [blame] | 44 | public class PackageSetting extends PackageSettingBase { |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 45 | int appId; |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 46 | |
Patrick Baumann | 7486092 | 2020-04-01 14:10:04 -0700 | [diff] [blame] | 47 | @Nullable |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 48 | public AndroidPackage pkg; |
Todd Kennedy | 3cd658e | 2016-08-16 15:00:31 -0700 | [diff] [blame] | 49 | /** |
| 50 | * WARNING. The object reference is important. We perform integer equality and NOT |
| 51 | * object equality to check whether shared user settings are the same. |
| 52 | */ |
Kenny Root | cf0b38c | 2011-03-22 14:17:59 -0700 | [diff] [blame] | 53 | SharedUserSetting sharedUser; |
Todd Kennedy | 788c842 | 2016-08-10 10:52:34 -0700 | [diff] [blame] | 54 | /** |
| 55 | * Temporary holding space for the shared user ID. While parsing package settings, the |
Todd Kennedy | 3cd658e | 2016-08-16 15:00:31 -0700 | [diff] [blame] | 56 | * shared users tag may come after the packages. In this case, we must delay linking the |
Todd Kennedy | 788c842 | 2016-08-10 10:52:34 -0700 | [diff] [blame] | 57 | * shared user setting with the package setting. The shared user ID lets us link the |
| 58 | * two objects. |
| 59 | */ |
| 60 | private int sharedUserId; |
Kenny Root | cf0b38c | 2011-03-22 14:17:59 -0700 | [diff] [blame] | 61 | |
Taras Antoshchuk | a7d9c73 | 2019-10-29 13:46:19 +0100 | [diff] [blame] | 62 | /** |
| 63 | * Maps mime group name to the set of Mime types in a group. Mime groups declared |
| 64 | * by app are populated with empty sets at construction. |
| 65 | * Mime groups can not be created/removed at runtime, thus keys in this map should not change |
| 66 | */ |
| 67 | @Nullable |
| 68 | Map<String, ArraySet<String>> mimeGroups; |
| 69 | |
Winson | e075629 | 2020-01-31 12:21:54 -0800 | [diff] [blame] | 70 | @NonNull |
| 71 | private PackageStateUnserialized pkgState = new PackageStateUnserialized(); |
| 72 | |
Winson Chiu | 8e865ec | 2020-04-01 18:20:51 +0000 | [diff] [blame] | 73 | @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) |
| 74 | public PackageSetting(String name, String realName, File codePath, File resourcePath, |
Narayan Kamath | ff110bd | 2014-07-04 18:30:45 +0100 | [diff] [blame] | 75 | String legacyNativeLibraryPathString, String primaryCpuAbiString, |
Narayan Kamath | 4903f64 | 2014-08-11 13:33:45 +0100 | [diff] [blame] | 76 | String secondaryCpuAbiString, String cpuAbiOverrideString, |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 77 | long pVersionCode, int pkgFlags, int privateFlags, |
| 78 | int sharedUserId, String[] usesStaticLibraries, |
Taras Antoshchuk | a7d9c73 | 2019-10-29 13:46:19 +0100 | [diff] [blame] | 79 | long[] usesStaticLibrariesVersions, Map<String, ArraySet<String>> mimeGroups) { |
Narayan Kamath | ff110bd | 2014-07-04 18:30:45 +0100 | [diff] [blame] | 80 | super(name, realName, codePath, resourcePath, legacyNativeLibraryPathString, |
Narayan Kamath | 4903f64 | 2014-08-11 13:33:45 +0100 | [diff] [blame] | 81 | primaryCpuAbiString, secondaryCpuAbiString, cpuAbiOverrideString, |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 82 | pVersionCode, pkgFlags, privateFlags, |
Svet Ganov | 6788212 | 2016-12-11 16:36:34 -0800 | [diff] [blame] | 83 | usesStaticLibraries, usesStaticLibrariesVersions); |
Todd Kennedy | 788c842 | 2016-08-10 10:52:34 -0700 | [diff] [blame] | 84 | this.sharedUserId = sharedUserId; |
Taras Antoshchuk | a7d9c73 | 2019-10-29 13:46:19 +0100 | [diff] [blame] | 85 | copyMimeGroups(mimeGroups); |
Kenny Root | cf0b38c | 2011-03-22 14:17:59 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | /** |
| 89 | * New instance of PackageSetting replicating the original settings. |
| 90 | * Note that it keeps the same PackageParser.Package instance. |
| 91 | */ |
| 92 | PackageSetting(PackageSetting orig) { |
Todd Kennedy | 3cd658e | 2016-08-16 15:00:31 -0700 | [diff] [blame] | 93 | super(orig, orig.realName); |
| 94 | doCopy(orig); |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * New instance of PackageSetting replicating the original settings, but, allows specifying |
| 99 | * a real package name. |
| 100 | * Note that it keeps the same PackageParser.Package instance. |
| 101 | */ |
| 102 | PackageSetting(PackageSetting orig, String realPkgName) { |
| 103 | super(orig, realPkgName); |
Todd Kennedy | 788c842 | 2016-08-10 10:52:34 -0700 | [diff] [blame] | 104 | doCopy(orig); |
| 105 | } |
Kenny Root | cf0b38c | 2011-03-22 14:17:59 -0700 | [diff] [blame] | 106 | |
Todd Kennedy | 788c842 | 2016-08-10 10:52:34 -0700 | [diff] [blame] | 107 | public int getSharedUserId() { |
| 108 | if (sharedUser != null) { |
| 109 | return sharedUser.userId; |
| 110 | } |
| 111 | return sharedUserId; |
Kenny Root | cf0b38c | 2011-03-22 14:17:59 -0700 | [diff] [blame] | 112 | } |
| 113 | |
Todd Kennedy | c29b11a | 2017-10-23 15:55:59 -0700 | [diff] [blame] | 114 | public SharedUserSetting getSharedUser() { |
| 115 | return sharedUser; |
| 116 | } |
| 117 | |
Kenny Root | cf0b38c | 2011-03-22 14:17:59 -0700 | [diff] [blame] | 118 | @Override |
| 119 | public String toString() { |
| 120 | return "PackageSetting{" |
| 121 | + Integer.toHexString(System.identityHashCode(this)) |
Amith Yamasani | 1359360 | 2012-03-22 16:16:17 -0700 | [diff] [blame] | 122 | + " " + name + "/" + appId + "}"; |
Kenny Root | cf0b38c | 2011-03-22 14:17:59 -0700 | [diff] [blame] | 123 | } |
Jeff Sharkey | 02e4d16e | 2013-08-12 20:31:36 -0700 | [diff] [blame] | 124 | |
Todd Kennedy | 788c842 | 2016-08-10 10:52:34 -0700 | [diff] [blame] | 125 | public void copyFrom(PackageSetting orig) { |
| 126 | super.copyFrom(orig); |
| 127 | doCopy(orig); |
| 128 | } |
| 129 | |
| 130 | private void doCopy(PackageSetting orig) { |
| 131 | appId = orig.appId; |
| 132 | pkg = orig.pkg; |
| 133 | sharedUser = orig.sharedUser; |
| 134 | sharedUserId = orig.sharedUserId; |
Taras Antoshchuk | a7d9c73 | 2019-10-29 13:46:19 +0100 | [diff] [blame] | 135 | copyMimeGroups(orig.mimeGroups); |
| 136 | } |
| 137 | |
| 138 | private void copyMimeGroups(@Nullable Map<String, ArraySet<String>> newMimeGroups) { |
| 139 | if (newMimeGroups == null) { |
| 140 | mimeGroups = null; |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | mimeGroups = new ArrayMap<>(newMimeGroups.size()); |
| 145 | for (String mimeGroup : newMimeGroups.keySet()) { |
| 146 | ArraySet<String> mimeTypes = newMimeGroups.get(mimeGroup); |
| 147 | |
| 148 | if (mimeTypes != null) { |
| 149 | mimeGroups.put(mimeGroup, new ArraySet<>(mimeTypes)); |
| 150 | } else { |
| 151 | mimeGroups.put(mimeGroup, new ArraySet<>()); |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Updates declared MIME groups, removing no longer declared groups |
| 158 | * and keeping previous state of MIME groups |
| 159 | */ |
| 160 | void updateMimeGroups(@Nullable Set<String> newMimeGroupNames) { |
| 161 | if (newMimeGroupNames == null) { |
| 162 | mimeGroups = null; |
| 163 | return; |
| 164 | } |
| 165 | |
| 166 | if (mimeGroups == null) { |
| 167 | // set mimeGroups to empty map to avoid repeated null-checks in the next loop |
| 168 | mimeGroups = Collections.emptyMap(); |
| 169 | } |
| 170 | |
| 171 | ArrayMap<String, ArraySet<String>> updatedMimeGroups = |
| 172 | new ArrayMap<>(newMimeGroupNames.size()); |
| 173 | |
| 174 | for (String mimeGroup : newMimeGroupNames) { |
| 175 | if (mimeGroups.containsKey(mimeGroup)) { |
| 176 | updatedMimeGroups.put(mimeGroup, mimeGroups.get(mimeGroup)); |
| 177 | } else { |
| 178 | updatedMimeGroups.put(mimeGroup, new ArraySet<>()); |
| 179 | } |
| 180 | } |
| 181 | mimeGroups = updatedMimeGroups; |
Todd Kennedy | 788c842 | 2016-08-10 10:52:34 -0700 | [diff] [blame] | 182 | } |
| 183 | |
Todd Kennedy | 91a39d1 | 2017-09-27 12:37:04 -0700 | [diff] [blame] | 184 | @Override |
Svetoslav | c6d1c34 | 2015-02-26 14:44:43 -0800 | [diff] [blame] | 185 | public PermissionsState getPermissionsState() { |
| 186 | return (sharedUser != null) |
| 187 | ? sharedUser.getPermissionsState() |
| 188 | : super.getPermissionsState(); |
Jeff Sharkey | 02e4d16e | 2013-08-12 20:31:36 -0700 | [diff] [blame] | 189 | } |
Christopher Tate | 628946a | 2013-10-18 18:11:05 -0700 | [diff] [blame] | 190 | |
Todd Kennedy | 0eb9738 | 2017-10-03 16:57:22 -0700 | [diff] [blame] | 191 | public int getAppId() { |
| 192 | return appId; |
| 193 | } |
| 194 | |
Todd Kennedy | c29b11a | 2017-10-23 15:55:59 -0700 | [diff] [blame] | 195 | public void setInstallPermissionsFixed(boolean fixed) { |
| 196 | installPermissionsFixed = fixed; |
| 197 | } |
| 198 | |
| 199 | public boolean areInstallPermissionsFixed() { |
| 200 | return installPermissionsFixed; |
| 201 | } |
| 202 | |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 203 | // TODO(b/135203078): Remove these in favor of reading from the package directly |
Christopher Tate | 628946a | 2013-10-18 18:11:05 -0700 | [diff] [blame] | 204 | public boolean isPrivileged() { |
Alex Klyubin | b9f8a52 | 2015-02-03 11:12:59 -0800 | [diff] [blame] | 205 | return (pkgPrivateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0; |
Christopher Tate | 628946a | 2013-10-18 18:11:05 -0700 | [diff] [blame] | 206 | } |
Fyodor Kupolov | eeea67b | 2015-02-23 17:14:45 -0800 | [diff] [blame] | 207 | |
Svet Ganov | 087dce2 | 2017-09-07 15:42:16 -0700 | [diff] [blame] | 208 | public boolean isOem() { |
| 209 | return (pkgPrivateFlags & ApplicationInfo.PRIVATE_FLAG_OEM) != 0; |
| 210 | } |
| 211 | |
Jiyong Park | 002fdbd | 2017-02-13 20:50:31 +0900 | [diff] [blame] | 212 | public boolean isVendor() { |
| 213 | return (pkgPrivateFlags & ApplicationInfo.PRIVATE_FLAG_VENDOR) != 0; |
| 214 | } |
| 215 | |
Jaekyun Seok | 1713d9e | 2018-01-12 21:47:26 +0900 | [diff] [blame] | 216 | public boolean isProduct() { |
| 217 | return (pkgPrivateFlags & ApplicationInfo.PRIVATE_FLAG_PRODUCT) != 0; |
| 218 | } |
| 219 | |
Jeongik Cha | 9ec059a | 2019-07-04 21:12:06 +0900 | [diff] [blame] | 220 | public boolean isSystemExt() { |
| 221 | return (pkgPrivateFlags & ApplicationInfo.PRIVATE_FLAG_SYSTEM_EXT) != 0; |
Dario Freni | 2bef176 | 2018-06-01 14:02:08 +0100 | [diff] [blame] | 222 | } |
| 223 | |
MÃ¥rten Kongstad | 48c24cf | 2019-02-25 10:54:09 +0100 | [diff] [blame] | 224 | public boolean isOdm() { |
| 225 | return (pkgPrivateFlags & ApplicationInfo.PRIVATE_FLAG_ODM) != 0; |
| 226 | } |
| 227 | |
Svet Ganov | 12a692a | 2015-03-28 19:34:15 -0700 | [diff] [blame] | 228 | public boolean isSystem() { |
| 229 | return (pkgFlags & ApplicationInfo.FLAG_SYSTEM) != 0; |
| 230 | } |
Svetoslav | d2cf3ae | 2015-04-02 16:51:55 -0700 | [diff] [blame] | 231 | |
Todd Kennedy | 91a39d1 | 2017-09-27 12:37:04 -0700 | [diff] [blame] | 232 | @Override |
Svetoslav | d2cf3ae | 2015-04-02 16:51:55 -0700 | [diff] [blame] | 233 | public boolean isSharedUser() { |
| 234 | return sharedUser != null; |
| 235 | } |
Jeff Sharkey | c5967e9 | 2016-01-07 18:50:29 -0700 | [diff] [blame] | 236 | |
| 237 | public boolean isMatch(int flags) { |
| 238 | if ((flags & PackageManager.MATCH_SYSTEM_ONLY) != 0) { |
| 239 | return isSystem(); |
| 240 | } |
| 241 | return true; |
| 242 | } |
Netta P | 426cbef | 2017-02-10 14:38:39 -0800 | [diff] [blame] | 243 | |
Taras Antoshchuk | a7d9c73 | 2019-10-29 13:46:19 +0100 | [diff] [blame] | 244 | public boolean setMimeGroup(String mimeGroup, List<String> mimeTypes) { |
| 245 | ArraySet<String> oldMimeTypes = getMimeGroupInternal(mimeGroup); |
| 246 | if (oldMimeTypes == null) { |
Taras Antoshchuk | 8a60024 | 2020-03-17 22:56:54 +0100 | [diff] [blame] | 247 | throw new IllegalArgumentException("Unknown MIME group " + mimeGroup |
| 248 | + " for package " + name); |
Taras Antoshchuk | a7d9c73 | 2019-10-29 13:46:19 +0100 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | ArraySet<String> newMimeTypes = new ArraySet<>(mimeTypes); |
| 252 | boolean hasChanges = !newMimeTypes.equals(oldMimeTypes); |
| 253 | mimeGroups.put(mimeGroup, newMimeTypes); |
| 254 | return hasChanges; |
| 255 | } |
| 256 | |
Taras Antoshchuk | a7d9c73 | 2019-10-29 13:46:19 +0100 | [diff] [blame] | 257 | public List<String> getMimeGroup(String mimeGroup) { |
| 258 | ArraySet<String> mimeTypes = getMimeGroupInternal(mimeGroup); |
| 259 | if (mimeTypes == null) { |
Taras Antoshchuk | 8a60024 | 2020-03-17 22:56:54 +0100 | [diff] [blame] | 260 | throw new IllegalArgumentException("Unknown MIME group " + mimeGroup |
| 261 | + " for package " + name); |
Taras Antoshchuk | a7d9c73 | 2019-10-29 13:46:19 +0100 | [diff] [blame] | 262 | } |
| 263 | return new ArrayList<>(mimeTypes); |
| 264 | } |
| 265 | |
| 266 | private ArraySet<String> getMimeGroupInternal(String mimeGroup) { |
| 267 | return mimeGroups != null ? mimeGroups.get(mimeGroup) : null; |
| 268 | } |
| 269 | |
Jeffrey Huang | cb78285 | 2019-12-05 11:28:11 -0800 | [diff] [blame] | 270 | public void dumpDebug(ProtoOutputStream proto, long fieldId, List<UserInfo> users) { |
Netta P | 426cbef | 2017-02-10 14:38:39 -0800 | [diff] [blame] | 271 | final long packageToken = proto.start(fieldId); |
| 272 | proto.write(PackageProto.NAME, (realName != null ? realName : name)); |
| 273 | proto.write(PackageProto.UID, appId); |
| 274 | proto.write(PackageProto.VERSION_CODE, versionCode); |
Netta P | 426cbef | 2017-02-10 14:38:39 -0800 | [diff] [blame] | 275 | proto.write(PackageProto.INSTALL_TIME_MS, firstInstallTime); |
| 276 | proto.write(PackageProto.UPDATE_TIME_MS, lastUpdateTime); |
Alan Stokes | 819fea2 | 2019-10-16 16:54:09 +0100 | [diff] [blame] | 277 | proto.write(PackageProto.INSTALLER_NAME, installSource.installerPackageName); |
Netta P | 426cbef | 2017-02-10 14:38:39 -0800 | [diff] [blame] | 278 | |
| 279 | if (pkg != null) { |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 280 | proto.write(PackageProto.VERSION_STRING, pkg.getVersionName()); |
Joe Onorato | 01fdbc1 | 2019-04-29 16:07:01 -0700 | [diff] [blame] | 281 | |
Netta P | 426cbef | 2017-02-10 14:38:39 -0800 | [diff] [blame] | 282 | long splitToken = proto.start(PackageProto.SPLITS); |
| 283 | proto.write(PackageProto.SplitProto.NAME, "base"); |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 284 | proto.write(PackageProto.SplitProto.REVISION_CODE, pkg.getBaseRevisionCode()); |
Netta P | 426cbef | 2017-02-10 14:38:39 -0800 | [diff] [blame] | 285 | proto.end(splitToken); |
Joe Onorato | 01fdbc1 | 2019-04-29 16:07:01 -0700 | [diff] [blame] | 286 | |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 287 | if (pkg.getSplitNames() != null) { |
| 288 | for (int i = 0; i < pkg.getSplitNames().length; i++) { |
Netta P | 426cbef | 2017-02-10 14:38:39 -0800 | [diff] [blame] | 289 | splitToken = proto.start(PackageProto.SPLITS); |
Winson | 14ff717 | 2019-10-23 10:42:27 -0700 | [diff] [blame] | 290 | proto.write(PackageProto.SplitProto.NAME, pkg.getSplitNames()[i]); |
| 291 | proto.write(PackageProto.SplitProto.REVISION_CODE, |
| 292 | pkg.getSplitRevisionCodes()[i]); |
Netta P | 426cbef | 2017-02-10 14:38:39 -0800 | [diff] [blame] | 293 | proto.end(splitToken); |
| 294 | } |
| 295 | } |
Alan Stokes | 69d2abf | 2019-10-10 11:02:38 +0100 | [diff] [blame] | 296 | |
| 297 | long sourceToken = proto.start(PackageProto.INSTALL_SOURCE); |
| 298 | proto.write(PackageProto.InstallSourceProto.INITIATING_PACKAGE_NAME, |
| 299 | installSource.initiatingPackageName); |
Alan Stokes | 5ed8537 | 2019-11-06 09:32:49 +0000 | [diff] [blame] | 300 | proto.write(PackageProto.InstallSourceProto.ORIGINATING_PACKAGE_NAME, |
| 301 | installSource.originatingPackageName); |
Alan Stokes | 69d2abf | 2019-10-10 11:02:38 +0100 | [diff] [blame] | 302 | proto.end(sourceToken); |
Netta P | 426cbef | 2017-02-10 14:38:39 -0800 | [diff] [blame] | 303 | } |
| 304 | writeUsersInfoToProto(proto, PackageProto.USERS); |
| 305 | proto.end(packageToken); |
| 306 | } |
Patrick | 4ccae94 | 2018-07-17 09:15:55 -0700 | [diff] [blame] | 307 | |
| 308 | /** Updates all fields in the current setting from another. */ |
| 309 | public void updateFrom(PackageSetting other) { |
| 310 | super.updateFrom(other); |
| 311 | appId = other.appId; |
| 312 | pkg = other.pkg; |
| 313 | sharedUserId = other.sharedUserId; |
| 314 | sharedUser = other.sharedUser; |
Taras Antoshchuk | a7d9c73 | 2019-10-29 13:46:19 +0100 | [diff] [blame] | 315 | |
| 316 | Set<String> mimeGroupNames = other.mimeGroups != null ? other.mimeGroups.keySet() : null; |
| 317 | updateMimeGroups(mimeGroupNames); |
Winson | 10bb870 | 2020-03-05 18:58:09 -0800 | [diff] [blame] | 318 | |
| 319 | getPkgState().updateFrom(other.getPkgState()); |
Patrick | 4ccae94 | 2018-07-17 09:15:55 -0700 | [diff] [blame] | 320 | } |
Winson | e075629 | 2020-01-31 12:21:54 -0800 | [diff] [blame] | 321 | |
| 322 | @NonNull |
| 323 | public PackageStateUnserialized getPkgState() { |
| 324 | return pkgState; |
| 325 | } |
Jeff Sharkey | 02e4d16e | 2013-08-12 20:31:36 -0700 | [diff] [blame] | 326 | } |