Loading media/java/android/media/tv/ad/ITvAdManager.aidl 0 → 100644 +25 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2023 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.ad; /** * Interface to the TV AD service. * @hide */ interface ITvAdManager { void startAdService(in IBinder sessionToken, int userId); } media/java/android/media/tv/ad/ITvAdSession.aidl 0 → 100644 +25 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2023 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.ad; /** * Sub-interface of ITvAdService which is created per session and has its own context. * @hide */ oneway interface ITvAdSession { void startAdService(); } media/java/android/media/tv/ad/TvAdManager.java 0 → 100644 +65 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2023 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.ad; import android.os.IBinder; import android.os.RemoteException; import android.util.Log; /** * Central system API to the overall client-side TV AD architecture, which arbitrates interaction * between applications and AD services. * @hide */ public class TvAdManager { private static final String TAG = "TvAdManager"; private final ITvAdManager mService; private final int mUserId; public TvAdManager(ITvAdManager service, int userId) { mService = service; mUserId = userId; } /** * The Session provides the per-session functionality of AD service. */ public static final class Session { private final IBinder mToken; private final ITvAdManager mService; private final int mUserId; private Session(IBinder token, ITvAdManager service, int userId) { mToken = token; mService = service; mUserId = userId; } void startAdService() { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.startAdService(mToken, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } } media/java/android/media/tv/ad/TvAdService.java 0 → 100644 +60 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2023 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.ad; import android.app.Service; import android.view.KeyEvent; /** * The TvAdService class represents a TV client-side advertisement service. * @hide */ public abstract class TvAdService extends Service { private static final boolean DEBUG = false; private static final String TAG = "TvAdService"; /** * Base class for derived classes to implement to provide a TV AD session. */ public abstract static class Session implements KeyEvent.Callback { /** * Starts TvAdService session. */ public void onStartAdService() { } void startAdService() { onStartAdService(); } } /** * Implements the internal ITvAdService interface. */ public static class ITvAdSessionWrapper extends ITvAdSession.Stub { private final Session mSessionImpl; public ITvAdSessionWrapper(Session mSessionImpl) { this.mSessionImpl = mSessionImpl; } @Override public void startAdService() { mSessionImpl.startAdService(); } } } media/java/android/media/tv/ad/TvAdView.java 0 → 100644 +57 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2023 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.ad; import android.content.Context; import android.util.Log; import android.view.ViewGroup; /** * Displays contents of TV AD services. * @hide */ public class TvAdView extends ViewGroup { private static final String TAG = "TvAdView"; private static final boolean DEBUG = false; // TODO: create session private TvAdManager.Session mSession; public TvAdView(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 AD service. */ public void startAdService() { if (DEBUG) { Log.d(TAG, "start"); } if (mSession != null) { mSession.startAdService(); } } } Loading
media/java/android/media/tv/ad/ITvAdManager.aidl 0 → 100644 +25 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2023 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.ad; /** * Interface to the TV AD service. * @hide */ interface ITvAdManager { void startAdService(in IBinder sessionToken, int userId); }
media/java/android/media/tv/ad/ITvAdSession.aidl 0 → 100644 +25 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2023 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.ad; /** * Sub-interface of ITvAdService which is created per session and has its own context. * @hide */ oneway interface ITvAdSession { void startAdService(); }
media/java/android/media/tv/ad/TvAdManager.java 0 → 100644 +65 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2023 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.ad; import android.os.IBinder; import android.os.RemoteException; import android.util.Log; /** * Central system API to the overall client-side TV AD architecture, which arbitrates interaction * between applications and AD services. * @hide */ public class TvAdManager { private static final String TAG = "TvAdManager"; private final ITvAdManager mService; private final int mUserId; public TvAdManager(ITvAdManager service, int userId) { mService = service; mUserId = userId; } /** * The Session provides the per-session functionality of AD service. */ public static final class Session { private final IBinder mToken; private final ITvAdManager mService; private final int mUserId; private Session(IBinder token, ITvAdManager service, int userId) { mToken = token; mService = service; mUserId = userId; } void startAdService() { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.startAdService(mToken, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } }
media/java/android/media/tv/ad/TvAdService.java 0 → 100644 +60 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2023 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.ad; import android.app.Service; import android.view.KeyEvent; /** * The TvAdService class represents a TV client-side advertisement service. * @hide */ public abstract class TvAdService extends Service { private static final boolean DEBUG = false; private static final String TAG = "TvAdService"; /** * Base class for derived classes to implement to provide a TV AD session. */ public abstract static class Session implements KeyEvent.Callback { /** * Starts TvAdService session. */ public void onStartAdService() { } void startAdService() { onStartAdService(); } } /** * Implements the internal ITvAdService interface. */ public static class ITvAdSessionWrapper extends ITvAdSession.Stub { private final Session mSessionImpl; public ITvAdSessionWrapper(Session mSessionImpl) { this.mSessionImpl = mSessionImpl; } @Override public void startAdService() { mSessionImpl.startAdService(); } } }
media/java/android/media/tv/ad/TvAdView.java 0 → 100644 +57 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2023 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.ad; import android.content.Context; import android.util.Log; import android.view.ViewGroup; /** * Displays contents of TV AD services. * @hide */ public class TvAdView extends ViewGroup { private static final String TAG = "TvAdView"; private static final boolean DEBUG = false; // TODO: create session private TvAdManager.Session mSession; public TvAdView(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 AD service. */ public void startAdService() { if (DEBUG) { Log.d(TAG, "start"); } if (mSession != null) { mSession.startAdService(); } } }