1 /* 2 * Copyright (C) 2020 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.pkg; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.annotation.UserIdInt; 22 import android.content.pm.SigningDetails; 23 import android.util.SparseArray; 24 25 import com.android.internal.pm.parsing.pkg.AndroidPackageInternal; 26 import com.android.server.pm.InstallSource; 27 import com.android.server.pm.PackageKeySetData; 28 import com.android.server.pm.permission.LegacyPermissionState; 29 30 import java.io.File; 31 import java.util.Set; 32 import java.util.UUID; 33 34 /** 35 * Exposes internal types for internal usage of {@link PackageState}. 36 * @hide 37 */ 38 public interface PackageStateInternal extends PackageState { 39 40 @Nullable getPkg()41 AndroidPackageInternal getPkg(); 42 43 // TODO: Remove in favor of exposing APIs directly? 44 @NonNull getTransientState()45 PackageStateUnserialized getTransientState(); 46 47 @NonNull getDomainSetId()48 UUID getDomainSetId(); 49 50 @NonNull getSigningDetails()51 SigningDetails getSigningDetails(); 52 53 @NonNull getInstallSource()54 InstallSource getInstallSource(); 55 56 // TODO: Remove this in favor of boolean APIs getFlags()57 int getFlags(); getPrivateFlags()58 int getPrivateFlags(); 59 60 @NonNull getUserStates()61 SparseArray<? extends PackageUserStateInternal> getUserStates(); 62 63 /** 64 * @return the result of {@link #getUserStates()}.get(userId) or 65 * {@link PackageUserState#DEFAULT} if the state doesn't exist. 66 */ 67 @NonNull getUserStateOrDefault(@serIdInt int userId)68 default PackageUserStateInternal getUserStateOrDefault(@UserIdInt int userId) { 69 PackageUserStateInternal userState = getUserStates().get(userId); 70 return userState == null ? PackageUserStateInternal.DEFAULT : userState; 71 } 72 73 @NonNull getLegacyPermissionState()74 LegacyPermissionState getLegacyPermissionState(); 75 76 @Nullable getRealName()77 String getRealName(); 78 isLoading()79 boolean isLoading(); 80 81 @NonNull getPathString()82 String getPathString(); 83 getLoadingProgress()84 float getLoadingProgress(); 85 getLoadingCompletedTime()86 long getLoadingCompletedTime(); 87 88 @NonNull getKeySetData()89 PackageKeySetData getKeySetData(); 90 91 /** 92 * Return the exact value stored inside this object for the primary CPU ABI type. This does 93 * not fallback to the inner {@link #getAndroidPackage()}, unlike {@link #getPrimaryCpuAbi()}. 94 * 95 * @deprecated Use {@link #getPrimaryCpuAbi()} if at all possible. 96 * 97 * TODO(b/249779400): Remove and see if the fallback-only API is a usable replacement 98 */ 99 @Deprecated 100 @Nullable getPrimaryCpuAbiLegacy()101 String getPrimaryCpuAbiLegacy(); 102 103 /** 104 * Same behavior as {@link #getPrimaryCpuAbiLegacy()}, but with the secondary ABI. 105 * 106 * @deprecated Use {@link #getSecondaryCpuAbi()} if at all possible. 107 */ 108 @Nullable getSecondaryCpuAbiLegacy()109 String getSecondaryCpuAbiLegacy(); 110 111 /** 112 * @return the app metadata file path. 113 */ 114 @Nullable getAppMetadataFilePath()115 String getAppMetadataFilePath(); 116 117 @Nullable getOldPaths()118 Set<File> getOldPaths(); 119 120 /** 121 * @return the source of the app metadata that is currently associated with the given package. 122 */ getAppMetadataSource()123 int getAppMetadataSource(); 124 } 125