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