Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5d6dd6f authored by Shawn Willden's avatar Shawn Willden
Browse files

Add getPackageInfo to IPackageManagerNative

The new native OMAPI service (replacing the existing Java APK-based
implementation of OMAPI, mostly because OMAPI is needed during early
boot and the Java OMAPI cannot start early) needs to retrieve package
information from PackageManager.  It doesn't need to get the package
info during early boot, only later when Android apps begin using it.

Bug: 380331467
Test: atest CtsPackageManagerTestCases
Flag: EXEMPT AIDL interface change
Change-Id: Ib351118d30bed9e9c387a9e811332db3bb3ec945
parent 6db41fd6
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -910,9 +910,12 @@ aidl_interface {
    local_include_dir: "aidl",
    host_supported: true,
    srcs: [
        "aidl/android/content/pm/ApexStagedEvent.aidl",
        "aidl/android/content/pm/IPackageManagerNative.aidl",
        "aidl/android/content/pm/IStagedApexObserver.aidl",
        "aidl/android/content/pm/ApexStagedEvent.aidl",
        "aidl/android/content/pm/PackageInfoNative.aidl",
        "aidl/android/content/pm/SignatureNative.aidl",
        "aidl/android/content/pm/SigningInfoNative.aidl",
        "aidl/android/content/pm/StagedApexInfo.aidl",
    ],
    backend: {
@@ -922,6 +925,10 @@ aidl_interface {
                "com.android.virt",
            ],
            enabled: true,
            gen_mockall: true,
            additional_rustlibs: [
                "libmockall",
            ],
        },
    },
}
+27 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
package android.content.pm;

import android.content.pm.IStagedApexObserver;
import android.content.pm.PackageInfoNative;
import android.content.pm.StagedApexInfo;

/**
@@ -42,6 +43,32 @@ interface IPackageManagerNative {
     */
    @utf8InCpp String[] getNamesForUids(in int[] uids);

    /**
     * Retrieve package signing information for an application package that is installed on the
     * system.
     *
     * Note that the PackageInfoNative returned may contain unset @nullable fields.  This method
     * only populates the signingInfo field, as well as the (non-@nullable) packageName.
     *
     * @param packageName The full name (i.e. com.google.apps.contacts) of the desired package.
     * @param userId of the user that has the installed package.
     *
     * @return A PackageInfoNative object containing the package name and signing info.
     */
    @nullable PackageInfoNative getPackageInfoWithSigningInfo(String packageName, int userId);

    /**
     * Retrieve signing information for application packages associated with the specified uid.
     *
     * Note that the PackageInfoNative returned may contain unset @nullable fields.  This method
     * only populates the signingInfo field, as well as the (non-@nullable) packageName.
     *
     * @param uid The uid for which associated package information should be returned.
     *
     * @return An array of PackageInfoNative objects containing package names and signing info.
     */
    @nullable PackageInfoNative[] getPackageInfoWithSigningInfoForUid(int uid);

    /**
     * Return the UID associated with the given package name.
     * Note that the same package will have different UIDs under different UserHandle on
+40 −0
Original line number Diff line number Diff line
/*
**
** Copyright 2024, 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 android.content.pm;

import android.content.pm.SigningInfoNative;

/**
 * Overall information about the contents of a package.  This corresponds to a subset of the
 * information collected from AndroidManifest.xml
 *
 * At present it's a very small subset, because it includes only items that have been required
 * by native code, but it uses the same structure and naming as the full PackageInfo in order
 * to ensure other elements can be cleanly added as necessary.
 *
 * See frameworks/base/core/java/android/content/pm/PackageInfo.java.
 */
parcelable PackageInfoNative {
    String packageName;

    /**
     * Signing information read from the package file, potentially including past signing
     * certificates no longer used after signing certificate rotation.
     */
    @nullable SigningInfoNative signingInfo;
}
 No newline at end of file
+21 −0
Original line number Diff line number Diff line
/*
** Copyright 2024, 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 android.content.pm;

parcelable SignatureNative {
    byte[] signature;
}
 No newline at end of file
+38 −0
Original line number Diff line number Diff line
/*
** Copyright 2024, 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 android.content.pm;

import android.content.pm.SignatureNative;

/**
 * Information pertaining to the signing certificates used to sign a package.
 *
 * At present it's a small subset because it includes only items that have been required by
 * native code, but it uses the same structure and naming as the full SigningInfo in order to
 * ensure other elements can be cleanly added as necessary.
 *
 * See frameworks/base/core/java/android/content/pm/SigningInfo.java.
 */
parcelable SigningInfoNative {
    /**
     * APK content signers.  Includes the content of `SigningInfo#apkContentSigners()` if
     * `SigningInfo#hasMultipleSigners()` returns true, or the content of
     * `SigningInfo#getSigningCertificateHistory` otherwise.  Empty array if not set (i.e. not
     * nullable).
     */
    SignatureNative[] apkContentSigners;
}
 No newline at end of file