PMS 里的 mPackages 保存了所有 应用包的信息
frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java
public class PackageManagerService implements PackageSender, TestUtilityService {
// Keys are String (package name), values are Package.
@Watched
@GuardedBy("mLock")
final WatchedArrayMap<String, AndroidPackage> mPackages = new WatchedArrayMap<>();
AndroidPackage 封装了应用包的信息
frameworks/base/services/core/java/com/android/server/pm/parsing/pkg/AndroidPackage.java
/**
* The last state of a package during parsing/install before it is available in {@link
* com.android.server.pm.PackageManagerService#mPackages}.
* <p>
* It is the responsibility of the caller to understand what data is available at what step of the
* parsing or install process.
* <p>
*
* @hide
*/
public interface AndroidPackage extends ParsingPackageRead, AndroidPackageApi,
OverlayConfig.PackageProvider.Package {
/**
* The package name as declared in the manifest, since the package can be renamed. For example,
* static shared libs use synthetic package names.
*/
@NonNull
String getManifestPackageName();
}
它取代了旧OS 的 PackageParser.Package, 参考:
frameworks/base/core/java/android/content/pm/PackageParser.java
* @deprecated This class is mostly unused and no new changes should be added to it. Use
* ParsingPackageUtils and related parsing v2 infrastructure in
* the core/services parsing subpackages. Or for a quick parse of a provided APK, use
* {@link PackageManager#getPackageArchiveInfo(String, int)}.
*
* @hide
*/
@Deprecated
public class PackageParser {
/**
* Representation of a full package parsed from APK files on disk. A package
* consists of a single base APK, and zero or more split APKs.
*
* Deprecated internally. Use AndroidPackage instead.
*/
public final static class Package implements Parcelable {
AndroidPackageApi 里定义了获取四大组件等的方法
frameworks/base/services/core/java/com/android/server/pm/pkg/AndroidPackageApi.java
/**
* Explicit interface used for consumers like mainline who need a {@link SystemApi @SystemApi} form
* of {@link AndroidPackage}. *
* @hide
*/
//@SystemApi(client = SystemApi.Client.SYSTEM_SERVER)
public interface AndroidPackageApi {
@NonNull
List<ParsedActivity> getActivities();
@NonNull
List<ParsedProvider> getProviders();
@NonNull
List<ParsedActivity> getReceivers();
@NonNull
List<ParsedService> getServices();
}
而 AndroidPackage 的又被接口 ParsedPackage 继承 (具体实现类在哪里??)
frameworks/base/services/core/java/com/android/server/pm/parsing/pkg/ParsedPackage.java
/**
* Methods used for mutation after direct package parsing, mostly done inside
* {@link com.android.server.pm.PackageManagerService}.
*
* Java disallows defining this as an inner interface, so this must be a separate file.
*
* @hide
*/
public interface ParsedPackage extends AndroidPackage {
AndroidPackage hideAsFinal();
ParsedPackage addUsesLibrary(int index, String libraryName);
后续, PMS 是在什么时机保存 各个 apk 的 信息的?
网友评论