1 /*
2  * Copyright (C) 2021 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 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.content.pm.IPackageInstallObserver2;
22 import android.content.pm.SigningDetails;
23 import android.os.UserHandle;
24 import android.util.ArrayMap;
25 
26 import com.android.internal.util.Preconditions;
27 
28 import java.io.File;
29 import java.util.List;
30 
31 final class InstallArgs {
32     File mCodeFile;
33     /** @see InstallingSession#mOriginInfo */
34     final OriginInfo mOriginInfo;
35     /** @see InstallingSession#mMoveInfo */
36     final MoveInfo mMoveInfo;
37 
38     final IPackageInstallObserver2 mObserver;
39     // Always refers to PackageManager flags only
40     final int mInstallFlags;
41     final int mDevelopmentInstallFlags;
42     @NonNull
43     final InstallSource mInstallSource;
44     final String mVolumeUuid;
45     final UserHandle mUser;
46     final String mAbiOverride;
47     @NonNull
48     final ArrayMap<String, Integer> mPermissionStates;
49     final List<String> mAllowlistedRestrictedPermissions;
50     final int mAutoRevokePermissionsMode;
51     /** If non-null, drop an async trace when the install completes */
52     final String mTraceMethod;
53     final int mTraceCookie;
54     final SigningDetails mSigningDetails;
55     final int mInstallReason;
56     final int mInstallScenario;
57     final boolean mForceQueryableOverride;
58     final int mDataLoaderType;
59     final int mPackageSource;
60     final boolean mApplicationEnabledSettingPersistent;
61     @Nullable
62     final String mDexoptCompilerFilter;
63 
64     // The list of instruction sets supported by this app. This is currently
65     // only used during the rmdex() phase to clean up resources. We can get rid of this
66     // if we move dex files under the common app path.
67     @Nullable
68     final String[] mInstructionSets;
69 
InstallArgs(OriginInfo originInfo, MoveInfo moveInfo, IPackageInstallObserver2 observer, int installFlags, int developmentInstallFlags, InstallSource installSource, String volumeUuid, UserHandle user, String[] instructionSets, String abiOverride, @NonNull ArrayMap<String, Integer> permissionStates, List<String> allowlistedRestrictedPermissions, int autoRevokePermissionsMode, String traceMethod, int traceCookie, SigningDetails signingDetails, int installReason, int installScenario, boolean forceQueryableOverride, int dataLoaderType, int packageSource, boolean applicationEnabledSettingPersistent, String dexoptCompilerFilter)70     InstallArgs(OriginInfo originInfo, MoveInfo moveInfo, IPackageInstallObserver2 observer,
71             int installFlags, int developmentInstallFlags, InstallSource installSource,
72             String volumeUuid,  UserHandle user, String[] instructionSets, String abiOverride,
73             @NonNull ArrayMap<String, Integer> permissionStates,
74             List<String> allowlistedRestrictedPermissions,
75             int autoRevokePermissionsMode, String traceMethod, int traceCookie,
76             SigningDetails signingDetails, int installReason, int installScenario,
77             boolean forceQueryableOverride, int dataLoaderType, int packageSource,
78             boolean applicationEnabledSettingPersistent, String dexoptCompilerFilter) {
79         mOriginInfo = originInfo;
80         mMoveInfo = moveInfo;
81         mInstallFlags = installFlags;
82         mDevelopmentInstallFlags = developmentInstallFlags;
83         mObserver = observer;
84         mInstallSource = Preconditions.checkNotNull(installSource);
85         mVolumeUuid = volumeUuid;
86         mUser = user;
87         mInstructionSets = instructionSets;
88         mAbiOverride = abiOverride;
89         mPermissionStates = permissionStates;
90         mAllowlistedRestrictedPermissions = allowlistedRestrictedPermissions;
91         mAutoRevokePermissionsMode = autoRevokePermissionsMode;
92         mTraceMethod = traceMethod;
93         mTraceCookie = traceCookie;
94         mSigningDetails = signingDetails;
95         mInstallReason = installReason;
96         mInstallScenario = installScenario;
97         mForceQueryableOverride = forceQueryableOverride;
98         mDataLoaderType = dataLoaderType;
99         mPackageSource = packageSource;
100         mApplicationEnabledSettingPersistent = applicationEnabledSettingPersistent;
101         mDexoptCompilerFilter = dexoptCompilerFilter;
102     }
103 }
104