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

Commit 5bd64609 authored by Samiul Islam's avatar Samiul Islam Committed by Android (Google) Code Review
Browse files

Merge "Create the service to be implemented by the holders of the Dependency...

Merge "Create the service to be implemented by the holders of the Dependency Installer role." into main
parents 9a568700 0da303b7
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -13806,6 +13806,7 @@ package android.content.pm {
  public final class SharedLibraryInfo implements android.os.Parcelable {
  public final class SharedLibraryInfo implements android.os.Parcelable {
    method public int describeContents();
    method public int describeContents();
    method @FlaggedApi("android.content.pm.sdk_dependency_installer") @NonNull public java.util.List<java.lang.String> getCertDigests();
    method @NonNull public android.content.pm.VersionedPackage getDeclaringPackage();
    method @NonNull public android.content.pm.VersionedPackage getDeclaringPackage();
    method @NonNull public java.util.List<android.content.pm.VersionedPackage> getDependentPackages();
    method @NonNull public java.util.List<android.content.pm.VersionedPackage> getDependentPackages();
    method @IntRange(from=0xffffffff) public long getLongVersion();
    method @IntRange(from=0xffffffff) public long getLongVersion();
+18 −0
Original line number Original line Diff line number Diff line
@@ -4594,6 +4594,24 @@ package android.content.pm {
}
}
package android.content.pm.dependencyinstaller {
  @FlaggedApi("android.content.pm.sdk_dependency_installer") public final class DependencyInstallerCallback implements android.os.Parcelable {
    method public int describeContents();
    method public void onAllDependenciesResolved(@NonNull int[]);
    method public void onFailureToResolveAllDependencies();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.dependencyinstaller.DependencyInstallerCallback> CREATOR;
  }
  @FlaggedApi("android.content.pm.sdk_dependency_installer") public abstract class DependencyInstallerService extends android.app.Service {
    ctor public DependencyInstallerService();
    method @NonNull public final android.os.IBinder onBind(@Nullable android.content.Intent);
    method public abstract void onDependenciesRequired(@NonNull java.util.List<android.content.pm.SharedLibraryInfo>, @NonNull android.content.pm.dependencyinstaller.DependencyInstallerCallback);
  }
}
package android.content.pm.dex {
package android.content.pm.dex {
  public class ArtManager {
  public class ArtManager {
+43 −0
Original line number Original line Diff line number Diff line
@@ -105,6 +105,8 @@ public final class SharedLibraryInfo implements Parcelable {
    private final List<VersionedPackage> mOptionalDependentPackages;
    private final List<VersionedPackage> mOptionalDependentPackages;
    private List<SharedLibraryInfo> mDependencies;
    private List<SharedLibraryInfo> mDependencies;


    private final List<String> mCertDigests;

    /**
    /**
     * Creates a new instance.
     * Creates a new instance.
     *
     *
@@ -134,6 +136,7 @@ public final class SharedLibraryInfo implements Parcelable {
        mDependencies = dependencies;
        mDependencies = dependencies;
        mIsNative = isNative;
        mIsNative = isNative;
        mOptionalDependentPackages = null;
        mOptionalDependentPackages = null;
        mCertDigests = null;
    }
    }


    /**
    /**
@@ -165,6 +168,7 @@ public final class SharedLibraryInfo implements Parcelable {
        mDeclaringPackage = declaringPackage;
        mDeclaringPackage = declaringPackage;
        mDependencies = dependencies;
        mDependencies = dependencies;
        mIsNative = isNative;
        mIsNative = isNative;
        mCertDigests = null;


        var allDependents = allDependentPackages.first;
        var allDependents = allDependentPackages.first;
        var usesLibOptional = allDependentPackages.second;
        var usesLibOptional = allDependentPackages.second;
@@ -206,6 +210,7 @@ public final class SharedLibraryInfo implements Parcelable {
        mIsNative = parcel.readBoolean();
        mIsNative = parcel.readBoolean();
        mOptionalDependentPackages = parcel.readParcelableList(new ArrayList<>(),
        mOptionalDependentPackages = parcel.readParcelableList(new ArrayList<>(),
                VersionedPackage.class.getClassLoader(), VersionedPackage.class);
                VersionedPackage.class.getClassLoader(), VersionedPackage.class);
        mCertDigests = parcel.createStringArrayList();
    }
    }


    /**
    /**
@@ -214,6 +219,29 @@ public final class SharedLibraryInfo implements Parcelable {
     * @param versionMajor
     * @param versionMajor
     */
     */
    public SharedLibraryInfo(String name, long versionMajor, int type) {
    public SharedLibraryInfo(String name, long versionMajor, int type) {
        //TODO: change to this(name, versionMajor, type, /* certDigest= */null); after flag removal
        mPath = null;
        mPackageName = null;
        mName = name;
        mVersion = versionMajor;
        mType = type;
        mDeclaringPackage = null;
        mDependentPackages = null;
        mDependencies = null;
        mIsNative = false;
        mOptionalDependentPackages = null;
        mCertDigests = null;
    }

    /**
     * @hide
     * @param name The lib name.
     * @param versionMajor The lib major version.
     * @param type The type of shared library.
     * @param certDigests The list of certificate digests for this shared library.
     */
    @FlaggedApi(Flags.FLAG_SDK_DEPENDENCY_INSTALLER)
    public SharedLibraryInfo(String name, long versionMajor, int type, List<String> certDigests) {
        mPath = null;
        mPath = null;
        mPackageName = null;
        mPackageName = null;
        mName = name;
        mName = name;
@@ -224,6 +252,7 @@ public final class SharedLibraryInfo implements Parcelable {
        mDependencies = null;
        mDependencies = null;
        mIsNative = false;
        mIsNative = false;
        mOptionalDependentPackages = null;
        mOptionalDependentPackages = null;
        mCertDigests = certDigests;
    }
    }


    /**
    /**
@@ -433,6 +462,19 @@ public final class SharedLibraryInfo implements Parcelable {
        return mOptionalDependentPackages;
        return mOptionalDependentPackages;
    }
    }


    /**
     * Gets the list of certificate digests for the shared library.
     *
     * @return The list of certificate digests
     */
    @FlaggedApi(Flags.FLAG_SDK_DEPENDENCY_INSTALLER)
    public @NonNull List<String> getCertDigests() {
        if (mCertDigests == null) {
            return Collections.emptyList();
        }
        return mCertDigests;
    }

    @Override
    @Override
    public int describeContents() {
    public int describeContents() {
        return 0;
        return 0;
@@ -463,6 +505,7 @@ public final class SharedLibraryInfo implements Parcelable {
        parcel.writeTypedList(mDependencies);
        parcel.writeTypedList(mDependencies);
        parcel.writeBoolean(mIsNative);
        parcel.writeBoolean(mIsNative);
        parcel.writeParcelableList(mOptionalDependentPackages, flags);
        parcel.writeParcelableList(mOptionalDependentPackages, flags);
        parcel.writeStringList(mCertDigests);
    }
    }


    private static String typeToString(int type) {
    private static String typeToString(int type) {
+19 −0
Original line number Original line Diff line number Diff line
/**
 * Copyright (C) 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.dependencyinstaller;

parcelable DependencyInstallerCallback;
 No newline at end of file
+100 −0
Original line number Original line Diff line number Diff line
/**
 * Copyright (C) 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.dependencyinstaller;

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.content.pm.Flags;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;

/**
 * Callbacks for {@link DependencyInstallerService}. The implementation of
 * DependencyInstallerService uses this interface to indicate completion of the session creation
 * request given by the system server.
 *
 * @hide
 */
@SystemApi
@FlaggedApi(Flags.FLAG_SDK_DEPENDENCY_INSTALLER)
public final class DependencyInstallerCallback implements Parcelable {
    private final IBinder mBinder;
    private final IDependencyInstallerCallback mCallback;

    /** @hide */
    public DependencyInstallerCallback(IBinder binder) {
        mBinder = binder;
        mCallback = IDependencyInstallerCallback.Stub.asInterface(binder);
    }

    private DependencyInstallerCallback(Parcel in) {
        mBinder = in.readStrongBinder();
        mCallback = IDependencyInstallerCallback.Stub.asInterface(mBinder);
    }

    /**
     * Callback to indicate that all the requested dependencies have been resolved and their
     * sessions created. See {@link  DependencyInstallerService#onDependenciesRequired}.
     *
     * @param sessionIds the install session IDs for all requested dependencies
     */
    public void onAllDependenciesResolved(@NonNull int[] sessionIds) {
        try {
            mCallback.onAllDependenciesResolved(sessionIds);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Callback to indicate that at least one of the required dependencies could not be resolved
     * and any associated sessions have been abandoned.
     */
    public void onFailureToResolveAllDependencies() {
        try {
            mCallback.onFailureToResolveAllDependencies();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(@NonNull Parcel out, int flags) {
        out.writeStrongBinder(mBinder);
    }

    public static final @NonNull Creator<DependencyInstallerCallback> CREATOR =
            new Creator<>() {
                @Override
                public DependencyInstallerCallback createFromParcel(Parcel in) {
                    return new DependencyInstallerCallback(in);
                }

                @Override
                public DependencyInstallerCallback[] newArray(int size) {
                    return new DependencyInstallerCallback[size];
                }
            };
}
Loading