1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.media.tv.cts; 18 19 import android.content.Context; 20 import android.net.Uri; 21 import android.os.Process; 22 import android.view.Surface; 23 24 /** 25 * A TvInputService for testing crash on TV input application. 26 */ 27 public class FaultyTvInputService extends StubTvInputService { 28 @Override onCreateSession(String inputId)29 public Session onCreateSession(String inputId) { 30 return new FaultySession(this); 31 } 32 33 @Override onCreateRecordingSession(String inputId)34 public RecordingSession onCreateRecordingSession(String inputId) { 35 return new FaultyRecordingSession(this); 36 } 37 38 public static class FaultySession extends Session { FaultySession(Context context)39 FaultySession(Context context) { 40 super(context); 41 } 42 43 @Override onRelease()44 public void onRelease() { } 45 46 @Override onTune(Uri ChannelUri)47 public boolean onTune(Uri ChannelUri) { 48 Process.killProcess(Process.myPid()); 49 return false; 50 } 51 52 @Override onSetSurface(Surface surface)53 public boolean onSetSurface(Surface surface) { 54 return false; 55 } 56 57 @Override onSetCaptionEnabled(boolean enabled)58 public void onSetCaptionEnabled(boolean enabled) { } 59 60 @Override onSetStreamVolume(float volume)61 public void onSetStreamVolume(float volume) { } 62 } 63 64 public static class FaultyRecordingSession extends RecordingSession { FaultyRecordingSession(Context context)65 FaultyRecordingSession(Context context) { 66 super(context); 67 } 68 69 @Override onTune(Uri channelUri)70 public void onTune(Uri channelUri) { 71 Process.killProcess(Process.myPid()); 72 } 73 74 @Override onStartRecording(Uri programHint)75 public void onStartRecording(Uri programHint) { } 76 77 @Override onStopRecording()78 public void onStopRecording() { } 79 80 @Override onRelease()81 public void onRelease() { } 82 } 83 } 84