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

Commit b4fdb933 authored by Todd Kennedy's avatar Todd Kennedy Committed by Android (Google) Code Review
Browse files

Merge "Allow ephemeral provider/installer"

parents 368c31d1 b8a279ee
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -281,6 +281,7 @@ LOCAL_SRC_FILES += \
	core/java/com/android/internal/app/IAppOpsService.aidl \
	core/java/com/android/internal/app/IAssistScreenshotReceiver.aidl \
	core/java/com/android/internal/app/IBatteryStats.aidl \
	core/java/com/android/internal/app/IEphemeralResolver.aidl \
	core/java/com/android/internal/app/IProcessStats.aidl \
	core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl \
	core/java/com/android/internal/app/IVoiceInteractionSessionShowCallback.aidl \
+2 −0
Original line number Diff line number Diff line
@@ -8522,6 +8522,7 @@ package android.content {
    field public static final java.lang.String ACTION_INPUT_METHOD_CHANGED = "android.intent.action.INPUT_METHOD_CHANGED";
    field public static final java.lang.String ACTION_INSERT = "android.intent.action.INSERT";
    field public static final java.lang.String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
    field public static final java.lang.String ACTION_INSTALL_EPHEMERAL_PACKAGE = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
    field public static final java.lang.String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
    field public static final java.lang.String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
    field public static final java.lang.String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
@@ -8569,6 +8570,7 @@ package android.content {
    field public static final java.lang.String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
    field public static final java.lang.String ACTION_QUICK_CLOCK = "android.intent.action.QUICK_CLOCK";
    field public static final java.lang.String ACTION_REBOOT = "android.intent.action.REBOOT";
    field public static final java.lang.String ACTION_RESOLVE_EPHEMERAL_PACKAGE = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
    field public static final java.lang.String ACTION_RUN = "android.intent.action.RUN";
    field public static final java.lang.String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
    field public static final java.lang.String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
+30 −0
Original line number Diff line number Diff line
@@ -1425,6 +1425,36 @@ public class Intent implements Parcelable, Cloneable {
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";

    /**
     * Activity Action: Launch ephemeral installer.
     * <p>
     * Input: The data must be a http: URI that the ephemeral application is registered
     * to handle.
     * <p class="note">
     * This is a protected intent that can only be sent by the system.
     * </p>
     *
     * @hide
     */
    @SystemApi
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
            = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";

    /**
     * Service Action: Resolve ephemeral application.
     * <p>
     * The system will have a persistent connection to this service.
     * This is a protected intent that can only be sent by the system.
     * </p>
     *
     * @hide
     */
    @SystemApi
    @SdkConstant(SdkConstantType.SERVICE_ACTION)
    public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
            = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";

    /**
     * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
     * package.  Specifies the installer package name; this package will receive the
+19 −0
Original line number Diff line number Diff line
/*
** Copyright 2015, 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.internal.app;

parcelable EphemeralResolveInfo;
+113 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 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.internal.app;

import android.content.IntentFilter;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;

/**
 * Information that is returned when resolving ephemeral
 * applications.
 */
public final class EphemeralResolveInfo implements Parcelable {
    public static final String SHA_ALGORITHM = "SHA-256";
    private byte[] mDigestBytes;
    private int mDigestPrefix;
    private final List<IntentFilter> mFilters = new ArrayList<IntentFilter>();

    public EphemeralResolveInfo(Uri uri, List<IntentFilter> filters) {
        generateDigest(uri);
        mFilters.addAll(filters);
    }

    private EphemeralResolveInfo(Parcel in) {
        readFromParcel(in);
    }

    public byte[] getDigestBytes() {
        return mDigestBytes;
    }

    public int getDigestPrefix() {
        return mDigestPrefix;
    }

    public List<IntentFilter> getFilters() {
        return mFilters;
    }

    private void generateDigest(Uri uri) {
        try {
            final MessageDigest digest = MessageDigest.getInstance(SHA_ALGORITHM);
            final byte[] hostBytes = uri.getHost().getBytes();
            final byte[] digestBytes = digest.digest(hostBytes);
            mDigestBytes = digestBytes;
            mDigestPrefix =
                    digestBytes[0] << 24
                    | digestBytes[1] << 16
                    | digestBytes[2] << 8
                    | digestBytes[3] << 0;
        } catch (NoSuchAlgorithmException e) {
            throw new IllegalStateException("could not find digest algorithm");
        }
    }

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

    @Override
    public void writeToParcel(Parcel out, int flags) {
        if (mDigestBytes == null) {
            out.writeInt(0);
        } else {
            out.writeInt(mDigestBytes.length);
            out.writeByteArray(mDigestBytes);
        }
        out.writeInt(mDigestPrefix);
        out.writeList(mFilters);
    }

    private void readFromParcel(Parcel in) {
        int digestBytesSize = in.readInt();
        if (digestBytesSize > 0) {
            mDigestBytes = new byte[digestBytesSize];
            in.readByteArray(mDigestBytes);
        }
        mDigestPrefix = in.readInt();
        in.readList(mFilters, null /*loader*/);
    }

    public static final Parcelable.Creator<EphemeralResolveInfo> CREATOR
            = new Parcelable.Creator<EphemeralResolveInfo>() {
        public EphemeralResolveInfo createFromParcel(Parcel in) {
            return new EphemeralResolveInfo(in);
        }

        public EphemeralResolveInfo[] newArray(int size) {
            return new EphemeralResolveInfo[size];
        }
    };
}
Loading