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

Commit 5a7cfb25 authored by shubang's avatar shubang
Browse files

TIAF: make AppLinkInfo a class

Bug: 16677688
Test: mmm
Change-Id: Ifb9cd66fea292f76af3551d9642dc1edc9e4d1c3
parent 928116e4
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.media.tv.interactive;

parcelable AppLinkInfo;
 No newline at end of file
+234 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.media.tv.interactive;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * App link information used by TV interactive app to launch Android apps.
 * @hide
 */
public final class AppLinkInfo implements Parcelable {
    private @NonNull String mPackageName;
    private @NonNull String mClassName;
    private @Nullable String mUriScheme;
    private @Nullable String mUriHost;
    private @Nullable String mUriPrefix;


    /**
     * Creates a new AppLinkInfo.
     */
    private AppLinkInfo(
            @NonNull String packageName,
            @NonNull String className,
            @Nullable String uriScheme,
            @Nullable String uriHost,
            @Nullable String uriPrefix) {
        this.mPackageName = packageName;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mPackageName);
        this.mClassName = className;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mClassName);
        this.mUriScheme = uriScheme;
        this.mUriHost = uriHost;
        this.mUriPrefix = uriPrefix;
    }

    /**
     * Gets package name of the App link.
     */
    @NonNull
    public String getPackageName() {
        return mPackageName;
    }

    /**
     * Gets package class of the App link.
     */
    @NonNull
    public String getClassName() {
        return mClassName;
    }

    /**
     * Gets URI scheme of the App link.
     */
    @Nullable
    public String getUriScheme() {
        return mUriScheme;
    }

    /**
     * Gets URI host of the App link.
     */
    @Nullable
    public String getUriHost() {
        return mUriHost;
    }

    /**
     * Gets URI prefix of the App link.
     */
    @Nullable
    public String getUriPrefix() {
        return mUriPrefix;
    }

    @Override
    public String toString() {
        return "AppLinkInfo { "
                + "packageName = " + mPackageName + ", "
                + "className = " + mClassName + ", "
                + "uriScheme = " + mUriScheme + ", "
                + "uriHost = " + mUriHost + ", "
                + "uriPrefix = " + mUriPrefix
                + " }";
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeString(mPackageName);
        dest.writeString(mClassName);
        dest.writeString(mUriScheme);
        dest.writeString(mUriHost);
        dest.writeString(mUriPrefix);
    }

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

    /* package-private */ AppLinkInfo(@NonNull Parcel in) {
        String packageName = in.readString();
        String className = in.readString();
        String uriScheme = in.readString();
        String uriHost = in.readString();
        String uriPrefix = in.readString();

        this.mPackageName = packageName;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mPackageName);
        this.mClassName = className;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mClassName);
        this.mUriScheme = uriScheme;
        this.mUriHost = uriHost;
        this.mUriPrefix = uriPrefix;
    }

    @NonNull
    public static final Parcelable.Creator<AppLinkInfo> CREATOR =
            new Parcelable.Creator<AppLinkInfo>() {
                @Override
                public AppLinkInfo[] newArray(int size) {
                    return new AppLinkInfo[size];
                }

                @Override
                public AppLinkInfo createFromParcel(@NonNull Parcel in) {
                    return new AppLinkInfo(in);
                }
            };

    /**
     * A builder for {@link AppLinkInfo}
     */
    public static final class Builder {
        private @NonNull String mPackageName;
        private @NonNull String mClassName;
        private @Nullable String mUriScheme;
        private @Nullable String mUriHost;
        private @Nullable String mUriPrefix;

        /**
         * Creates a new Builder.
         */
        public Builder(
                @NonNull String packageName,
                @NonNull String className) {
            mPackageName = packageName;
            com.android.internal.util.AnnotationValidations.validate(
                    NonNull.class, null, mPackageName);
            mClassName = className;
            com.android.internal.util.AnnotationValidations.validate(
                    NonNull.class, null, mClassName);
        }

        /**
         * Sets package name of the App link.
         */
        @NonNull
        public Builder setPackageName(@NonNull String value) {
            mPackageName = value;
            return this;
        }

        /**
         * Sets app name of the App link.
         */
        @NonNull
        public Builder setClassName(@NonNull String value) {
            mClassName = value;
            return this;
        }

        /**
         * Sets URI scheme of the App link.
         */
        @NonNull
        public Builder setUriScheme(@Nullable String value) {
            mUriScheme = value;
            return this;
        }

        /**
         * Sets URI host of the App link.
         */
        @NonNull
        public Builder setUriHost(@Nullable String value) {
            mUriHost = value;
            return this;
        }

        /**
         * Sets URI prefix of the App link.
         */
        @NonNull
        public Builder setUriPrefix(@Nullable String value) {
            mUriPrefix = value;
            return this;
        }

        /** Builds the instance. This builder should not be touched after calling this! */
        @NonNull
        public AppLinkInfo build() {
            AppLinkInfo o = new AppLinkInfo(
                    mPackageName,
                    mClassName,
                    mUriScheme,
                    mUriHost,
                    mUriPrefix);
            return o;
        }
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.graphics.Rect;
import android.media.tv.AdResponse;
import android.media.tv.BroadcastInfoResponse;
import android.media.tv.TvTrackInfo;
import android.media.tv.interactive.AppLinkInfo;
import android.media.tv.interactive.ITvInteractiveAppClient;
import android.media.tv.interactive.ITvInteractiveAppManagerCallback;
import android.media.tv.interactive.TvInteractiveAppInfo;
@@ -34,8 +35,8 @@ import android.view.Surface;
interface ITvInteractiveAppManager {
    List<TvInteractiveAppInfo> getTvInteractiveAppServiceList(int userId);
    void prepare(String tiasId, int type, int userId);
    void registerAppLinkInfo(String tiasId, in Bundle info, int userId);
    void unregisterAppLinkInfo(String tiasId, in Bundle info, int userId);
    void registerAppLinkInfo(String tiasId, in AppLinkInfo info, int userId);
    void unregisterAppLinkInfo(String tiasId, in AppLinkInfo info, int userId);
    void sendAppLinkCommand(String tiasId, in Bundle command, int userId);
    void startInteractiveApp(in IBinder sessionToken, int userId);
    void stopInteractiveApp(in IBinder sessionToken, int userId);
+3 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.media.tv.interactive;

import android.media.tv.interactive.AppLinkInfo;
import android.media.tv.interactive.ITvInteractiveAppServiceCallback;
import android.media.tv.interactive.ITvInteractiveAppSessionCallback;
import android.os.Bundle;
@@ -32,7 +33,7 @@ oneway interface ITvInteractiveAppService {
    void createSession(in InputChannel channel, in ITvInteractiveAppSessionCallback callback,
            in String iAppServiceId, int type);
    void prepare(int type);
    void registerAppLinkInfo(in Bundle info);
    void unregisterAppLinkInfo(in Bundle info);
    void registerAppLinkInfo(in AppLinkInfo info);
    void unregisterAppLinkInfo(in AppLinkInfo info);
    void sendAppLinkCommand(in Bundle command);
}
 No newline at end of file
+3 −2
Original line number Diff line number Diff line
@@ -757,7 +757,8 @@ public final class TvInteractiveAppManager {
     * Registers app link info.
     * @hide
     */
    public void registerAppLinkInfo(@NonNull String tvIAppServiceId, @NonNull Bundle appLinkInfo) {
    public void registerAppLinkInfo(
            @NonNull String tvIAppServiceId, @NonNull AppLinkInfo appLinkInfo) {
        try {
            mService.registerAppLinkInfo(tvIAppServiceId, appLinkInfo, mUserId);
        } catch (RemoteException e) {
@@ -770,7 +771,7 @@ public final class TvInteractiveAppManager {
     * @hide
     */
    public void unregisterAppLinkInfo(
            @NonNull String tvIAppServiceId, @NonNull Bundle appLinkInfo) {
            @NonNull String tvIAppServiceId, @NonNull AppLinkInfo appLinkInfo) {
        try {
            mService.unregisterAppLinkInfo(tvIAppServiceId, appLinkInfo, mUserId);
        } catch (RemoteException e) {
Loading