• 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.os.Process;
22 
23 import com.android.internal.annotations.VisibleForTesting;
24 
25 import java.util.List;
26 
27 /** The result of a package scan. */
28 @VisibleForTesting
29 final class ScanResult {
30     /** The request that initiated the scan that produced this result. */
31     public final ScanRequest mRequest;
32     /** Whether or not the package scan was successful */
33     public final boolean mSuccess;
34     /**
35      * Whether or not the original PackageSetting needs to be updated with this result on
36      * commit.
37      */
38     public final boolean mExistingSettingCopied;
39     /**
40      * The previous app ID if the app decided to leave a shared user ID.
41      * The value is set *only* if the app is leaving a shared user ID.
42      * Default value is Process.INVALID_UID.
43      */
44     public final int mPreviousAppId;
45     /**
46      * The final package settings. This may be the same object passed in
47      * the {@link ScanRequest}, but, with modified values.
48      */
49     @Nullable
50     public final PackageSetting mPkgSetting;
51     /** ABI code paths that have changed in the package scan */
52     @Nullable public final List<String> mChangedAbiCodePath;
53 
54     public final SharedLibraryInfo mSdkSharedLibraryInfo;
55 
56     public final SharedLibraryInfo mStaticSharedLibraryInfo;
57 
58     public final List<SharedLibraryInfo> mDynamicSharedLibraryInfos;
59 
ScanResult( ScanRequest request, boolean success, @Nullable PackageSetting pkgSetting, @Nullable List<String> changedAbiCodePath, boolean existingSettingCopied, int previousAppId, SharedLibraryInfo sdkSharedLibraryInfo, SharedLibraryInfo staticSharedLibraryInfo, List<SharedLibraryInfo> dynamicSharedLibraryInfos)60     ScanResult(
61             ScanRequest request, boolean success,
62             @Nullable PackageSetting pkgSetting,
63             @Nullable List<String> changedAbiCodePath, boolean existingSettingCopied,
64             int previousAppId,
65             SharedLibraryInfo sdkSharedLibraryInfo,
66             SharedLibraryInfo staticSharedLibraryInfo,
67             List<SharedLibraryInfo> dynamicSharedLibraryInfos) {
68         mRequest = request;
69         mSuccess = success;
70         mPkgSetting = pkgSetting;
71         mChangedAbiCodePath = changedAbiCodePath;
72         mExistingSettingCopied = existingSettingCopied;
73         // Hardcode mPreviousAppId to INVALID_UID (http://b/221088088)
74         // This will disable all migration code paths in PMS and PermMS
75         mPreviousAppId = Process.INVALID_UID;
76         mSdkSharedLibraryInfo = sdkSharedLibraryInfo;
77         mStaticSharedLibraryInfo = staticSharedLibraryInfo;
78         mDynamicSharedLibraryInfos = dynamicSharedLibraryInfos;
79     }
80 
81     /**
82      * Whether the original PackageSetting needs to be updated with
83      * a new app ID. Useful when leaving a sharedUserId.
84      */
needsNewAppId()85     public boolean needsNewAppId() {
86         return mPreviousAppId != Process.INVALID_UID;
87     }
88 }
89