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.os.UserHandle;
22 
23 import com.android.internal.annotations.VisibleForTesting;
24 import com.android.internal.pm.parsing.pkg.ParsedPackage;
25 import com.android.internal.pm.pkg.parsing.ParsingPackageUtils;
26 import com.android.server.pm.pkg.AndroidPackage;
27 
28 /** A package to be scanned */
29 @VisibleForTesting
30 final class ScanRequest {
31     /** The parsed package */
32     @NonNull public final ParsedPackage mParsedPackage;
33     /** The package this package replaces */
34     @Nullable public final AndroidPackage mOldPkg;
35     /** Shared user settings, if the old package has a shared user */
36     @Nullable public final SharedUserSetting mOldSharedUserSetting;
37     /**
38      * Package settings of the currently installed version.
39      * <p><em>IMPORTANT:</em> The contents of this object may be modified
40      * during scan.
41      */
42     @Nullable public final PackageSetting mPkgSetting;
43     /** Shared user settings of the currently installed package */
44     @Nullable public final SharedUserSetting mSharedUserSetting;
45     /** A copy of the settings for the currently installed version */
46     @Nullable public final PackageSetting mOldPkgSetting;
47     /** Package settings for the disabled version on the /system partition */
48     @Nullable public final PackageSetting mDisabledPkgSetting;
49     /** Package settings for the installed version under its original package name */
50     @Nullable public final PackageSetting mOriginalPkgSetting;
51     /** The real package name of a renamed application */
52     @Nullable public final String mRealPkgName;
53     public final @ParsingPackageUtils.ParseFlags int mParseFlags;
54     public final @PackageManagerService.ScanFlags int mScanFlags;
55     /** The user for which the package is being scanned */
56     @Nullable public final UserHandle mUser;
57     /** Whether or not the platform package is being scanned */
58     public final boolean mIsPlatformPackage;
59     /** Override value for package ABI if set during install */
60     @Nullable public final String mCpuAbiOverride;
61 
ScanRequest( @onNull ParsedPackage parsedPackage, @Nullable SharedUserSetting oldSharedUserSetting, @Nullable AndroidPackage oldPkg, @Nullable PackageSetting pkgSetting, @Nullable SharedUserSetting sharedUserSetting, @Nullable PackageSetting disabledPkgSetting, @Nullable PackageSetting originalPkgSetting, @Nullable String realPkgName, @ParsingPackageUtils.ParseFlags int parseFlags, @PackageManagerService.ScanFlags int scanFlags, boolean isPlatformPackage, @Nullable UserHandle user, @Nullable String cpuAbiOverride)62     ScanRequest(
63             @NonNull ParsedPackage parsedPackage,
64             @Nullable SharedUserSetting oldSharedUserSetting,
65             @Nullable AndroidPackage oldPkg,
66             @Nullable PackageSetting pkgSetting,
67             @Nullable SharedUserSetting sharedUserSetting,
68             @Nullable PackageSetting disabledPkgSetting,
69             @Nullable PackageSetting originalPkgSetting,
70             @Nullable String realPkgName,
71             @ParsingPackageUtils.ParseFlags int parseFlags,
72             @PackageManagerService.ScanFlags int scanFlags,
73             boolean isPlatformPackage,
74             @Nullable UserHandle user,
75             @Nullable String cpuAbiOverride) {
76         mParsedPackage = parsedPackage;
77         mOldPkg = oldPkg;
78         mPkgSetting = pkgSetting;
79         mOldSharedUserSetting = oldSharedUserSetting;
80         mSharedUserSetting = sharedUserSetting;
81         mOldPkgSetting = pkgSetting == null ? null : new PackageSetting(pkgSetting);
82         mDisabledPkgSetting = disabledPkgSetting;
83         mOriginalPkgSetting = originalPkgSetting;
84         mRealPkgName = realPkgName;
85         mParseFlags = parseFlags;
86         mScanFlags = scanFlags;
87         mIsPlatformPackage = isPlatformPackage;
88         mUser = user;
89         mCpuAbiOverride = cpuAbiOverride;
90     }
91 }
92