• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.Nullable;
20 import android.content.pm.SharedLibraryInfo;
21 import android.content.pm.SigningDetails;
22 import android.util.ArrayMap;
23 
24 import com.android.server.pm.parsing.pkg.AndroidPackage;
25 
26 import java.util.ArrayList;
27 import java.util.List;
28 import java.util.Map;
29 
30 /**
31  * A container of all data needed to commit a package to in-memory data structures and to disk.
32  * TODO: move most of the data contained here into a PackageSetting for commit.
33  */
34 final class ReconciledPackage {
35     public final ReconcileRequest mRequest;
36     public final PackageSetting mPkgSetting;
37     public final ScanResult mScanResult;
38     // TODO: Remove install-specific details from the reconcile result
39     public final PackageInstalledInfo mInstallResult;
40     @Nullable public final PrepareResult mPrepareResult;
41     @Nullable public final InstallArgs mInstallArgs;
42     public final DeletePackageAction mDeletePackageAction;
43     public final List<SharedLibraryInfo> mAllowedSharedLibraryInfos;
44     public final SigningDetails mSigningDetails;
45     public final boolean mSharedUserSignaturesChanged;
46     public ArrayList<SharedLibraryInfo> mCollectedSharedLibraryInfos;
47     public final boolean mRemoveAppKeySetData;
48 
ReconciledPackage(ReconcileRequest request, InstallArgs installArgs, PackageSetting pkgSetting, PackageInstalledInfo installResult, PrepareResult prepareResult, ScanResult scanResult, DeletePackageAction deletePackageAction, List<SharedLibraryInfo> allowedSharedLibraryInfos, SigningDetails signingDetails, boolean sharedUserSignaturesChanged, boolean removeAppKeySetData)49     ReconciledPackage(ReconcileRequest request,
50             InstallArgs installArgs,
51             PackageSetting pkgSetting,
52             PackageInstalledInfo installResult,
53             PrepareResult prepareResult,
54             ScanResult scanResult,
55             DeletePackageAction deletePackageAction,
56             List<SharedLibraryInfo> allowedSharedLibraryInfos,
57             SigningDetails signingDetails,
58             boolean sharedUserSignaturesChanged,
59             boolean removeAppKeySetData) {
60         mRequest = request;
61         mInstallArgs = installArgs;
62         mPkgSetting = pkgSetting;
63         mInstallResult = installResult;
64         mPrepareResult = prepareResult;
65         mScanResult = scanResult;
66         mDeletePackageAction = deletePackageAction;
67         mAllowedSharedLibraryInfos = allowedSharedLibraryInfos;
68         mSigningDetails = signingDetails;
69         mSharedUserSignaturesChanged = sharedUserSignaturesChanged;
70         mRemoveAppKeySetData = removeAppKeySetData;
71     }
72 
73     /**
74      * Returns a combined set of packages containing the packages already installed combined
75      * with the package(s) currently being installed. The to-be installed packages take
76      * precedence and may shadow already installed packages.
77      */
getCombinedAvailablePackages()78     Map<String, AndroidPackage> getCombinedAvailablePackages() {
79         final ArrayMap<String, AndroidPackage> combined =
80                 new ArrayMap<>(mRequest.mAllPackages.size() + mRequest.mScannedPackages.size());
81 
82         combined.putAll(mRequest.mAllPackages);
83 
84         for (ScanResult scanResult : mRequest.mScannedPackages.values()) {
85             combined.put(scanResult.mPkgSetting.getPackageName(),
86                     scanResult.mRequest.mParsedPackage);
87         }
88 
89         return combined;
90     }
91 }
92