Loading core/res/res/values/attrs_manifest.xml +8 −0 Original line number Diff line number Diff line Loading @@ -2839,6 +2839,14 @@ <attr name="path" /> <attr name="minSdkVersion" /> <attr name="maxSdkVersion" /> <!-- The order in which the apex system services are initiated. When there are dependencies among apex system services, setting this attribute for each of them ensures that they are created in the order required by those dependencies. The apex-system-services that are started manually within SystemServer ignore the initOrder and are not considered for automatic starting of the other services. The value is a simple integer, with higher number being initialized first. If not specified, the default order is 0. --> <attr name="initOrder" format="integer" /> </declare-styleable> <!-- The <code>receiver</code> tag declares an Loading services/core/java/com/android/server/pm/ApexManager.java +21 −14 Original line number Diff line number Diff line Loading @@ -32,9 +32,6 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageInstaller; import android.content.pm.PackageManager; import android.content.pm.SigningDetails; import com.android.server.pm.pkg.parsing.PackageInfoWithoutStateUtils; import com.android.server.pm.pkg.parsing.ParsingPackageUtils; import com.android.server.pm.pkg.component.ParsedApexSystemService; import android.content.pm.parsing.result.ParseResult; import android.content.pm.parsing.result.ParseTypeImpl; import android.os.Binder; Loading @@ -59,6 +56,9 @@ import com.android.modules.utils.build.UnboundedSdkLevel; import com.android.server.pm.parsing.PackageParser2; import com.android.server.pm.parsing.pkg.AndroidPackage; import com.android.server.pm.parsing.pkg.ParsedPackage; import com.android.server.pm.pkg.component.ParsedApexSystemService; import com.android.server.pm.pkg.parsing.PackageInfoWithoutStateUtils; import com.android.server.pm.pkg.parsing.ParsingPackageUtils; import com.android.server.utils.TimingsTraceAndSlog; import com.google.android.collect.Lists; Loading Loading @@ -414,9 +414,11 @@ public abstract class ApexManager { throws PackageManagerException; /** * Get a map of system services defined in an apex mapped to the jar files they reside in. * Get a list of apex system services implemented in an apex. * * <p>The list is sorted by initOrder for consistency. */ public abstract Map<String, String> getApexSystemServices(); public abstract List<ApexSystemServiceInfo> getApexSystemServices(); /** * Dumps various state information to the provided {@link PrintWriter} object. Loading Loading @@ -449,7 +451,7 @@ public abstract class ApexManager { * Map of all apex system services to the jar files they are contained in. */ @GuardedBy("mLock") private Map<String, String> mApexSystemServices = new ArrayMap<>(); private List<ApexSystemServiceInfo> mApexSystemServices = new ArrayList<>(); /** * Contains the list of {@code packageName}s of apks-in-apex for given Loading Loading @@ -605,14 +607,19 @@ public abstract class ApexManager { } String name = service.getName(); if (mApexSystemServices.containsKey(name)) { for (ApexSystemServiceInfo info : mApexSystemServices) { if (info.getName().equals(name)) { throw new IllegalStateException(String.format( "Duplicate apex-system-service %s from %s, %s", name, mApexSystemServices.get(name), service.getJarPath())); name, info.mJarPath, service.getJarPath())); } } mApexSystemServices.put(name, service.getJarPath()); ApexSystemServiceInfo info = new ApexSystemServiceInfo( service.getName(), service.getJarPath(), service.getInitOrder()); mApexSystemServices.add(info); } Collections.sort(mApexSystemServices); mPackageNameToApexModuleName.put(packageInfo.packageName, ai.moduleName); if (ai.isActive) { if (activePackagesSet.contains(packageInfo.packageName)) { Loading Loading @@ -1133,7 +1140,7 @@ public abstract class ApexManager { } @Override public Map<String, String> getApexSystemServices() { public List<ApexSystemServiceInfo> getApexSystemServices() { synchronized (mLock) { Preconditions.checkState(mApexSystemServices != null, "APEX packages have not been scanned"); Loading Loading @@ -1423,10 +1430,10 @@ public abstract class ApexManager { } @Override public Map<String, String> getApexSystemServices() { public List<ApexSystemServiceInfo> getApexSystemServices() { // TODO(satayev): we can't really support flattened apex use case, and need to migrate // the manifest entries into system's manifest asap. return Collections.emptyMap(); return Collections.emptyList(); } @Override Loading services/core/java/com/android/server/pm/ApexSystemServiceInfo.java 0 → 100644 +58 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.pm; import android.annotation.Nullable; /** * A helper class that contains information about apex-system-service to be used within system * server process. */ public final class ApexSystemServiceInfo implements Comparable<ApexSystemServiceInfo> { final String mName; @Nullable final String mJarPath; final int mInitOrder; public ApexSystemServiceInfo(String name, String jarPath, int initOrder) { this.mName = name; this.mJarPath = jarPath; this.mInitOrder = initOrder; } public String getName() { return mName; } public String getJarPath() { return mJarPath; } public int getInitOrder() { return mInitOrder; } @Override public int compareTo(ApexSystemServiceInfo other) { if (mInitOrder == other.mInitOrder) { return mName.compareTo(other.mName); } // higher initOrder values take precedence return -Integer.compare(mInitOrder, other.mInitOrder); } } services/core/java/com/android/server/pm/pkg/component/ParsedApexSystemService.java +3 −0 Original line number Diff line number Diff line Loading @@ -34,4 +34,7 @@ public interface ParsedApexSystemService { @Nullable String getMaxSdkVersion(); int getInitOrder(); } services/core/java/com/android/server/pm/pkg/component/ParsedApexSystemServiceImpl.java +23 −7 Original line number Diff line number Diff line Loading @@ -48,18 +48,18 @@ public class ParsedApexSystemServiceImpl implements ParsedApexSystemService, Par @Nullable private String maxSdkVersion; private int initOrder; public ParsedApexSystemServiceImpl() { } // Code below generated by codegen v1.0.23. // // DO NOT MODIFY! // CHECKSTYLE:OFF Generated code // // To regenerate run: // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/parsing/component/ParsedApexSystemServiceImpl.java // $ codegen $ANDROID_BUILD_TOP/frameworks/base/services/core/java/com/android/server/pm/pkg/component/ParsedApexSystemServiceImpl.java // // To exclude the generated code from IntelliJ auto-formatting enable (one-time): // Settings > Editor > Code Style > Formatter Control Loading @@ -71,13 +71,15 @@ public class ParsedApexSystemServiceImpl implements ParsedApexSystemService, Par @NonNull String name, @Nullable String jarPath, @Nullable String minSdkVersion, @Nullable String maxSdkVersion) { @Nullable String maxSdkVersion, int initOrder) { this.name = name; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, name); this.jarPath = jarPath; this.minSdkVersion = minSdkVersion; this.maxSdkVersion = maxSdkVersion; this.initOrder = initOrder; // onConstructed(); // You can define this method to get a callback } Loading @@ -102,6 +104,11 @@ public class ParsedApexSystemServiceImpl implements ParsedApexSystemService, Par return maxSdkVersion; } @DataClass.Generated.Member public int getInitOrder() { return initOrder; } @DataClass.Generated.Member public @NonNull ParsedApexSystemServiceImpl setName(@NonNull String value) { name = value; Loading @@ -128,6 +135,12 @@ public class ParsedApexSystemServiceImpl implements ParsedApexSystemService, Par return this; } @DataClass.Generated.Member public @NonNull ParsedApexSystemServiceImpl setInitOrder( int value) { initOrder = value; return this; } @DataClass.Generated.Member static Parcelling<String> sParcellingForName = Parcelling.Cache.get( Loading Loading @@ -187,6 +200,7 @@ public class ParsedApexSystemServiceImpl implements ParsedApexSystemService, Par sParcellingForJarPath.parcel(jarPath, dest, flags); sParcellingForMinSdkVersion.parcel(minSdkVersion, dest, flags); sParcellingForMaxSdkVersion.parcel(maxSdkVersion, dest, flags); dest.writeInt(initOrder); } @Override Loading @@ -205,6 +219,7 @@ public class ParsedApexSystemServiceImpl implements ParsedApexSystemService, Par String _jarPath = sParcellingForJarPath.unparcel(in); String _minSdkVersion = sParcellingForMinSdkVersion.unparcel(in); String _maxSdkVersion = sParcellingForMaxSdkVersion.unparcel(in); int _initOrder = in.readInt(); this.name = _name; com.android.internal.util.AnnotationValidations.validate( Loading @@ -212,6 +227,7 @@ public class ParsedApexSystemServiceImpl implements ParsedApexSystemService, Par this.jarPath = _jarPath; this.minSdkVersion = _minSdkVersion; this.maxSdkVersion = _maxSdkVersion; this.initOrder = _initOrder; // onConstructed(); // You can define this method to get a callback } Loading @@ -231,10 +247,10 @@ public class ParsedApexSystemServiceImpl implements ParsedApexSystemService, Par }; @DataClass.Generated( time = 1641431950080L, time = 1643723578605L, codegenVersion = "1.0.23", sourceFile = "frameworks/base/core/java/android/content/pm/parsing/component/ParsedApexSystemServiceImpl.java", inputSignatures = "private @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) @android.annotation.NonNull java.lang.String name\nprivate @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) @android.annotation.Nullable java.lang.String jarPath\nprivate @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) @android.annotation.Nullable java.lang.String minSdkVersion\nprivate @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) @android.annotation.Nullable java.lang.String maxSdkVersion\nclass ParsedApexSystemServiceImpl extends java.lang.Object implements [android.content.pm.parsing.component.ParsedApexSystemService, android.os.Parcelable]\n@com.android.internal.util.DataClass(genGetters=true, genAidl=false, genSetters=true, genParcelable=true)") sourceFile = "frameworks/base/services/core/java/com/android/server/pm/pkg/component/ParsedApexSystemServiceImpl.java", inputSignatures = "private @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) @android.annotation.NonNull java.lang.String name\nprivate @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) @android.annotation.Nullable java.lang.String jarPath\nprivate @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) @android.annotation.Nullable java.lang.String minSdkVersion\nprivate @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) @android.annotation.Nullable java.lang.String maxSdkVersion\nprivate int initOrder\nclass ParsedApexSystemServiceImpl extends java.lang.Object implements [com.android.server.pm.pkg.component.ParsedApexSystemService, android.os.Parcelable]\n@com.android.internal.util.DataClass(genGetters=true, genAidl=false, genSetters=true, genParcelable=true)") @Deprecated private void __metadata() {} Loading Loading
core/res/res/values/attrs_manifest.xml +8 −0 Original line number Diff line number Diff line Loading @@ -2839,6 +2839,14 @@ <attr name="path" /> <attr name="minSdkVersion" /> <attr name="maxSdkVersion" /> <!-- The order in which the apex system services are initiated. When there are dependencies among apex system services, setting this attribute for each of them ensures that they are created in the order required by those dependencies. The apex-system-services that are started manually within SystemServer ignore the initOrder and are not considered for automatic starting of the other services. The value is a simple integer, with higher number being initialized first. If not specified, the default order is 0. --> <attr name="initOrder" format="integer" /> </declare-styleable> <!-- The <code>receiver</code> tag declares an Loading
services/core/java/com/android/server/pm/ApexManager.java +21 −14 Original line number Diff line number Diff line Loading @@ -32,9 +32,6 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageInstaller; import android.content.pm.PackageManager; import android.content.pm.SigningDetails; import com.android.server.pm.pkg.parsing.PackageInfoWithoutStateUtils; import com.android.server.pm.pkg.parsing.ParsingPackageUtils; import com.android.server.pm.pkg.component.ParsedApexSystemService; import android.content.pm.parsing.result.ParseResult; import android.content.pm.parsing.result.ParseTypeImpl; import android.os.Binder; Loading @@ -59,6 +56,9 @@ import com.android.modules.utils.build.UnboundedSdkLevel; import com.android.server.pm.parsing.PackageParser2; import com.android.server.pm.parsing.pkg.AndroidPackage; import com.android.server.pm.parsing.pkg.ParsedPackage; import com.android.server.pm.pkg.component.ParsedApexSystemService; import com.android.server.pm.pkg.parsing.PackageInfoWithoutStateUtils; import com.android.server.pm.pkg.parsing.ParsingPackageUtils; import com.android.server.utils.TimingsTraceAndSlog; import com.google.android.collect.Lists; Loading Loading @@ -414,9 +414,11 @@ public abstract class ApexManager { throws PackageManagerException; /** * Get a map of system services defined in an apex mapped to the jar files they reside in. * Get a list of apex system services implemented in an apex. * * <p>The list is sorted by initOrder for consistency. */ public abstract Map<String, String> getApexSystemServices(); public abstract List<ApexSystemServiceInfo> getApexSystemServices(); /** * Dumps various state information to the provided {@link PrintWriter} object. Loading Loading @@ -449,7 +451,7 @@ public abstract class ApexManager { * Map of all apex system services to the jar files they are contained in. */ @GuardedBy("mLock") private Map<String, String> mApexSystemServices = new ArrayMap<>(); private List<ApexSystemServiceInfo> mApexSystemServices = new ArrayList<>(); /** * Contains the list of {@code packageName}s of apks-in-apex for given Loading Loading @@ -605,14 +607,19 @@ public abstract class ApexManager { } String name = service.getName(); if (mApexSystemServices.containsKey(name)) { for (ApexSystemServiceInfo info : mApexSystemServices) { if (info.getName().equals(name)) { throw new IllegalStateException(String.format( "Duplicate apex-system-service %s from %s, %s", name, mApexSystemServices.get(name), service.getJarPath())); name, info.mJarPath, service.getJarPath())); } } mApexSystemServices.put(name, service.getJarPath()); ApexSystemServiceInfo info = new ApexSystemServiceInfo( service.getName(), service.getJarPath(), service.getInitOrder()); mApexSystemServices.add(info); } Collections.sort(mApexSystemServices); mPackageNameToApexModuleName.put(packageInfo.packageName, ai.moduleName); if (ai.isActive) { if (activePackagesSet.contains(packageInfo.packageName)) { Loading Loading @@ -1133,7 +1140,7 @@ public abstract class ApexManager { } @Override public Map<String, String> getApexSystemServices() { public List<ApexSystemServiceInfo> getApexSystemServices() { synchronized (mLock) { Preconditions.checkState(mApexSystemServices != null, "APEX packages have not been scanned"); Loading Loading @@ -1423,10 +1430,10 @@ public abstract class ApexManager { } @Override public Map<String, String> getApexSystemServices() { public List<ApexSystemServiceInfo> getApexSystemServices() { // TODO(satayev): we can't really support flattened apex use case, and need to migrate // the manifest entries into system's manifest asap. return Collections.emptyMap(); return Collections.emptyList(); } @Override Loading
services/core/java/com/android/server/pm/ApexSystemServiceInfo.java 0 → 100644 +58 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.pm; import android.annotation.Nullable; /** * A helper class that contains information about apex-system-service to be used within system * server process. */ public final class ApexSystemServiceInfo implements Comparable<ApexSystemServiceInfo> { final String mName; @Nullable final String mJarPath; final int mInitOrder; public ApexSystemServiceInfo(String name, String jarPath, int initOrder) { this.mName = name; this.mJarPath = jarPath; this.mInitOrder = initOrder; } public String getName() { return mName; } public String getJarPath() { return mJarPath; } public int getInitOrder() { return mInitOrder; } @Override public int compareTo(ApexSystemServiceInfo other) { if (mInitOrder == other.mInitOrder) { return mName.compareTo(other.mName); } // higher initOrder values take precedence return -Integer.compare(mInitOrder, other.mInitOrder); } }
services/core/java/com/android/server/pm/pkg/component/ParsedApexSystemService.java +3 −0 Original line number Diff line number Diff line Loading @@ -34,4 +34,7 @@ public interface ParsedApexSystemService { @Nullable String getMaxSdkVersion(); int getInitOrder(); }
services/core/java/com/android/server/pm/pkg/component/ParsedApexSystemServiceImpl.java +23 −7 Original line number Diff line number Diff line Loading @@ -48,18 +48,18 @@ public class ParsedApexSystemServiceImpl implements ParsedApexSystemService, Par @Nullable private String maxSdkVersion; private int initOrder; public ParsedApexSystemServiceImpl() { } // Code below generated by codegen v1.0.23. // // DO NOT MODIFY! // CHECKSTYLE:OFF Generated code // // To regenerate run: // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/parsing/component/ParsedApexSystemServiceImpl.java // $ codegen $ANDROID_BUILD_TOP/frameworks/base/services/core/java/com/android/server/pm/pkg/component/ParsedApexSystemServiceImpl.java // // To exclude the generated code from IntelliJ auto-formatting enable (one-time): // Settings > Editor > Code Style > Formatter Control Loading @@ -71,13 +71,15 @@ public class ParsedApexSystemServiceImpl implements ParsedApexSystemService, Par @NonNull String name, @Nullable String jarPath, @Nullable String minSdkVersion, @Nullable String maxSdkVersion) { @Nullable String maxSdkVersion, int initOrder) { this.name = name; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, name); this.jarPath = jarPath; this.minSdkVersion = minSdkVersion; this.maxSdkVersion = maxSdkVersion; this.initOrder = initOrder; // onConstructed(); // You can define this method to get a callback } Loading @@ -102,6 +104,11 @@ public class ParsedApexSystemServiceImpl implements ParsedApexSystemService, Par return maxSdkVersion; } @DataClass.Generated.Member public int getInitOrder() { return initOrder; } @DataClass.Generated.Member public @NonNull ParsedApexSystemServiceImpl setName(@NonNull String value) { name = value; Loading @@ -128,6 +135,12 @@ public class ParsedApexSystemServiceImpl implements ParsedApexSystemService, Par return this; } @DataClass.Generated.Member public @NonNull ParsedApexSystemServiceImpl setInitOrder( int value) { initOrder = value; return this; } @DataClass.Generated.Member static Parcelling<String> sParcellingForName = Parcelling.Cache.get( Loading Loading @@ -187,6 +200,7 @@ public class ParsedApexSystemServiceImpl implements ParsedApexSystemService, Par sParcellingForJarPath.parcel(jarPath, dest, flags); sParcellingForMinSdkVersion.parcel(minSdkVersion, dest, flags); sParcellingForMaxSdkVersion.parcel(maxSdkVersion, dest, flags); dest.writeInt(initOrder); } @Override Loading @@ -205,6 +219,7 @@ public class ParsedApexSystemServiceImpl implements ParsedApexSystemService, Par String _jarPath = sParcellingForJarPath.unparcel(in); String _minSdkVersion = sParcellingForMinSdkVersion.unparcel(in); String _maxSdkVersion = sParcellingForMaxSdkVersion.unparcel(in); int _initOrder = in.readInt(); this.name = _name; com.android.internal.util.AnnotationValidations.validate( Loading @@ -212,6 +227,7 @@ public class ParsedApexSystemServiceImpl implements ParsedApexSystemService, Par this.jarPath = _jarPath; this.minSdkVersion = _minSdkVersion; this.maxSdkVersion = _maxSdkVersion; this.initOrder = _initOrder; // onConstructed(); // You can define this method to get a callback } Loading @@ -231,10 +247,10 @@ public class ParsedApexSystemServiceImpl implements ParsedApexSystemService, Par }; @DataClass.Generated( time = 1641431950080L, time = 1643723578605L, codegenVersion = "1.0.23", sourceFile = "frameworks/base/core/java/android/content/pm/parsing/component/ParsedApexSystemServiceImpl.java", inputSignatures = "private @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) @android.annotation.NonNull java.lang.String name\nprivate @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) @android.annotation.Nullable java.lang.String jarPath\nprivate @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) @android.annotation.Nullable java.lang.String minSdkVersion\nprivate @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) @android.annotation.Nullable java.lang.String maxSdkVersion\nclass ParsedApexSystemServiceImpl extends java.lang.Object implements [android.content.pm.parsing.component.ParsedApexSystemService, android.os.Parcelable]\n@com.android.internal.util.DataClass(genGetters=true, genAidl=false, genSetters=true, genParcelable=true)") sourceFile = "frameworks/base/services/core/java/com/android/server/pm/pkg/component/ParsedApexSystemServiceImpl.java", inputSignatures = "private @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) @android.annotation.NonNull java.lang.String name\nprivate @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) @android.annotation.Nullable java.lang.String jarPath\nprivate @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) @android.annotation.Nullable java.lang.String minSdkVersion\nprivate @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) @android.annotation.Nullable java.lang.String maxSdkVersion\nprivate int initOrder\nclass ParsedApexSystemServiceImpl extends java.lang.Object implements [com.android.server.pm.pkg.component.ParsedApexSystemService, android.os.Parcelable]\n@com.android.internal.util.DataClass(genGetters=true, genAidl=false, genSetters=true, genParcelable=true)") @Deprecated private void __metadata() {} Loading