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

Commit 2868507a authored by Shubang Lu's avatar Shubang Lu Committed by Android (Google) Code Review
Browse files

Merge "TIAF: Create TIAF components and session classes"

parents 039205d6 89049d43
Loading
Loading
Loading
Loading
+25 −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;

/**
 * Interface to the TV interactive app service.
 * @hide
 */
interface ITvIAppManager {
    void startIApp(in IBinder sessionToken, int userId);
}
 No newline at end of file
+25 −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;

/**
 * Sub-interface of ITvIAppService which is created per session and has its own context.
 * @hide
 */
oneway interface ITvIAppSession {
    void startIApp();
}
 No newline at end of file
+67 −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.SystemService;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

/**
 * Central system API to the overall TV interactive application framework (TIAF) architecture, which
 * arbitrates interaction between applications and interactive apps.
 * @hide
 */
@SystemService("tv_interactive_app")
public final class TvIAppManager {
    private static final String TAG = "TvIAppManager";

    private final ITvIAppManager mService;
    private final int mUserId;

    public TvIAppManager(ITvIAppManager service, int userId) {
        mService = service;
        mUserId = userId;
    }

    /**
     * The Session provides the per-session functionality of interactive app.
     */
    public static final class Session {
        private final IBinder mToken;
        private final ITvIAppManager mService;
        private final int mUserId;

        private Session(IBinder token, ITvIAppManager service, int userId) {
            mToken = token;
            mService = service;
            mUserId = userId;
        }

        void startIApp() {
            if (mToken == null) {
                Log.w(TAG, "The session has been already released");
                return;
            }
            try {
                mService.startIApp(mToken, mUserId);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
    }
}
+60 −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.app.Service;
import android.view.KeyEvent;

/**
 * The TvIAppService class represents a TV interactive applications RTE.
 * @hide
 */
public abstract class TvIAppService extends Service {
    private static final boolean DEBUG = false;
    private static final String TAG = "TvIAppService";

    /**
     * Base class for derived classes to implement to provide a TV interactive app session.
     */
    public abstract static class Session implements KeyEvent.Callback {
        /**
         * Starts TvIAppService session.
         */
        public void onStartIApp() {
        }

        void startIApp() {
            onStartIApp();
        }
    }

    /**
     * Implements the internal ITvIAppSession interface.
     */
    public static class ITvIAppSessionWrapper extends ITvIAppSession.Stub {
        private final Session mSessionImpl;

        public ITvIAppSessionWrapper(Session mSessionImpl) {
            this.mSessionImpl = mSessionImpl;
        }

        @Override
        public void startIApp() {
            mSessionImpl.startIApp();
        }
    }
}
+57 −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.content.Context;
import android.util.Log;
import android.view.ViewGroup;

/**
 * Displays contents of interactive TV applications.
 * @hide
 */
public class TvIAppView extends ViewGroup {
    private static final String TAG = "TvIAppView";
    private static final boolean DEBUG = false;

    // TODO: create session
    private TvIAppManager.Session mSession;

    public TvIAppView(Context context) {
        super(context, /* attrs = */null, /* defStyleAttr = */0);
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        if (DEBUG) {
            Log.d(TAG,
                    "onLayout (left=" + l + ", top=" + t + ", right=" + r + ", bottom=" + b + ",)");
        }
    }

    /**
     * Starts the interactive application.
     */
    public void startIApp() {
        if (DEBUG) {
            Log.d(TAG, "start");
        }
        if (mSession != null) {
            mSession.startIApp();
        }
    }
}
Loading