package com.mstar.android.tv;

import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;
import com.mstar.android.tv.IEventClient;
import com.mstar.android.tv.ITvService;
import com.mstar.android.tvapi.common.PvrManager;
import com.mstar.android.tvapi.common.exception.TvCommonException;
import com.mstar.android.tvapi.common.vo.CaptureThumbnailResult;
import com.mstar.android.tvapi.common.vo.EnumPvrStatus;
import com.mstar.android.tvapi.common.vo.PvrFileInfo;
import com.mstar.android.tvapi.common.vo.PvrPlaybackSpeed;
import com.mstar.android.tvapi.common.vo.VideoWindowType;
import java.util.ArrayList;
import java.util.Iterator;

/* JADX INFO: loaded from: classes.dex */
public class TvPvrManager extends IEventClient.Stub {
    public static final int PVR_FILE_SYSTEM_TYPE_EXFAT = 7;
    public static final int PVR_FILE_SYSTEM_TYPE_EXT2 = 3;
    public static final int PVR_FILE_SYSTEM_TYPE_EXT3 = 4;
    public static final int PVR_FILE_SYSTEM_TYPE_EXT4 = 8;
    public static final int PVR_FILE_SYSTEM_TYPE_INVALID = 9;
    public static final int PVR_FILE_SYSTEM_TYPE_JFFS2 = 1;
    public static final int PVR_FILE_SYSTEM_TYPE_MSDOS = 5;
    public static final int PVR_FILE_SYSTEM_TYPE_NTFS = 6;
    public static final int PVR_FILE_SYSTEM_TYPE_UNKNOWN = 0;
    public static final int PVR_FILE_SYSTEM_TYPE_VFAT = 2;
    public static final int PVR_PLAYBACK_SPEED_0X = 0;
    public static final int PVR_PLAYBACK_SPEED_1X = 1000;
    public static final int PVR_PLAYBACK_SPEED_FB_16X = -16000;
    public static final int PVR_PLAYBACK_SPEED_FB_1X = -1000;
    public static final int PVR_PLAYBACK_SPEED_FB_2X = -2000;
    public static final int PVR_PLAYBACK_SPEED_FB_32X = -32000;
    public static final int PVR_PLAYBACK_SPEED_FB_4X = -4000;
    public static final int PVR_PLAYBACK_SPEED_FB_8X = -8000;
    public static final int PVR_PLAYBACK_SPEED_FF_16X = 16000;
    public static final int PVR_PLAYBACK_SPEED_FF_2X = 2000;
    public static final int PVR_PLAYBACK_SPEED_FF_32X = 32000;
    public static final int PVR_PLAYBACK_SPEED_FF_4X = 4000;
    public static final int PVR_PLAYBACK_SPEED_FF_8X = 8000;
    public static final int PVR_PLAYBACK_SPEED_INVALID = 65535;
    public static final int PVR_PLAYBACK_SPEED_SF_16X = 64;
    public static final int PVR_PLAYBACK_SPEED_SF_2X = 500;
    public static final int PVR_PLAYBACK_SPEED_SF_32X = 32;
    public static final int PVR_PLAYBACK_SPEED_SF_4X = 250;
    public static final int PVR_PLAYBACK_SPEED_SF_8X = 125;
    public static final int PVR_PLAYBACK_SPEED_STEP_IN = 1;
    public static final int PVR_STATUS_ERROR = 20;
    public static final int PVR_STATUS_ERROR_BAD_VIDEO_AUDIO = 13;
    public static final int PVR_STATUS_ERROR_CANT_RECORD_DATA_ONLY_PROGRAM = 9;
    public static final int PVR_STATUS_ERROR_CANT_RECORD_VOD_CONTENT = 19;
    public static final int PVR_STATUS_ERROR_CI_PLUS_COPY_PROTECTION = 6;
    public static final int PVR_STATUS_ERROR_CI_PLUS_UNPLUGIN = 7;
    public static final int PVR_STATUS_ERROR_CI_PLUS_UNSUPPORT = 8;
    public static final int PVR_STATUS_ERROR_GINGA_RUNNING = 12;
    public static final int PVR_STATUS_ERROR_MAX_RECORDING_REACHED = 17;
    public static final int PVR_STATUS_ERROR_MEHG5_DATA_ONLY_PROGRAM = 18;
    public static final int PVR_STATUS_ERROR_MUTE_CH_BLOCKED = 15;
    public static final int PVR_STATUS_ERROR_MUTE_RATING_BLOCKED = 16;
    public static final int PVR_STATUS_ERROR_NO_DISK_DETECTED = 1;
    public static final int PVR_STATUS_ERROR_NO_SIGNAL = 10;
    public static final int PVR_STATUS_ERROR_READ_ONLY_FILE_SYSTEM = 3;
    public static final int PVR_STATUS_ERROR_RECORD_OUT_OF_DISK_SPACE = 11;
    public static final int PVR_STATUS_ERROR_RETENTION_LIMIT_EXPIRED = 14;
    public static final int PVR_STATUS_ERROR_STILL_CHECK_DISK = 21;
    public static final int PVR_STATUS_ERROR_TIMESHIFT_OUT_OF_DISK_SPACE = 4;
    public static final int PVR_STATUS_ERROR_UNSUPPORTED_FILE_SYSTEM = 2;
    public static final int PVR_STATUS_SUCCESS = 0;
    public static final int PVR_STATUS_SUCCESS_CI_PLUS_COPY_PROTECTION = 5;
    private static final String TAG = "TvPvrManager";
    private static final int TVPVR_FORMAT_EVENT_END = 1999;
    private static final int TVPVR_FORMAT_EVENT_START = 1000;
    public static final int TVPVR_NOTIFY_FORMAT_FINISHED = 1001;
    public static final int TVPVR_NOTIFY_PLAYBACK_BEGIN = 2002;
    public static final int TVPVR_NOTIFY_PLAYBACK_STOP = 2001;
    public static final int TVPVR_NOTIFY_USB_INSERTED = 1;
    public static final int TVPVR_NOTIFY_USB_REMOVED = 2;
    private static final int TVPVR_PLAYBACK_EVENT_END = 2999;
    private static final int TVPVR_PLAYBACK_EVENT_START = 2000;
    private static final int TVPVR_USB_EVENT_END = 999;
    private static final int TVPVR_USB_EVENT_START = 0;
    private static TvPvrManager mInstance;
    private static ITvPvr mService;
    private EventHandler mHandler;

    @Deprecated
    private ArrayList<PvrManager.OnPvrEventListener> mPvrListeners = new ArrayList<>();
    private ArrayList<OnUsbEventListener> mUsbEventListeners = new ArrayList<>();
    private ArrayList<OnFormatEventListener> mFormatEventListeners = new ArrayList<>();
    private ArrayList<OnPlaybackEventListener> mPlaybackEventListeners = new ArrayList<>();

    private class EventHandler extends Handler {
        EventHandler(Looper looper) {
            super(looper);
        }

        @Override // android.os.Handler
        public void handleMessage(Message message) {
            int i2 = message.what;
            if (i2 > 0 && i2 < 999) {
                synchronized (TvPvrManager.this.mUsbEventListeners) {
                    try {
                        Iterator it = TvPvrManager.this.mUsbEventListeners.iterator();
                        while (it.hasNext()) {
                            ((OnUsbEventListener) it.next()).onUsbEvent(message.what, message.arg1, message.arg2, message.obj);
                        }
                    } finally {
                    }
                }
            } else if (i2 > 1000 && i2 < 1999) {
                synchronized (TvPvrManager.this.mFormatEventListeners) {
                    try {
                        Iterator it2 = TvPvrManager.this.mFormatEventListeners.iterator();
                        while (it2.hasNext()) {
                            ((OnFormatEventListener) it2.next()).onFormatEvent(message.what, message.arg1, message.arg2, message.obj);
                        }
                    } finally {
                    }
                }
            } else if (i2 > 2000 && i2 < 2999) {
                synchronized (TvPvrManager.this.mPlaybackEventListeners) {
                    try {
                        Iterator it3 = TvPvrManager.this.mPlaybackEventListeners.iterator();
                        while (it3.hasNext()) {
                            ((OnPlaybackEventListener) it3.next()).onPlaybackEvent(message.what, message.arg1, message.arg2, message.obj);
                        }
                    } finally {
                    }
                }
            }
            int i3 = message.what;
            if (i3 == 1) {
                synchronized (TvPvrManager.this.mPvrListeners) {
                    try {
                        Iterator it4 = TvPvrManager.this.mPvrListeners.iterator();
                        while (it4.hasNext()) {
                            ((PvrManager.OnPvrEventListener) it4.next()).onPvrNotifyUsbInserted(com.mstar.android.tvapi.common.TvManager.getInstance().getPvrManager(), message.what, message.arg1, message.arg2);
                        }
                    } finally {
                    }
                }
                return;
            }
            if (i3 == 2) {
                synchronized (TvPvrManager.this.mPvrListeners) {
                    try {
                        Iterator it5 = TvPvrManager.this.mPvrListeners.iterator();
                        while (it5.hasNext()) {
                            ((PvrManager.OnPvrEventListener) it5.next()).onPvrNotifyUsbInserted(com.mstar.android.tvapi.common.TvManager.getInstance().getPvrManager(), message.what, message.arg1, message.arg2);
                        }
                    } finally {
                    }
                }
                return;
            }
            if (i3 == 1001) {
                synchronized (TvPvrManager.this.mPvrListeners) {
                    try {
                        Iterator it6 = TvPvrManager.this.mPvrListeners.iterator();
                        while (it6.hasNext()) {
                            ((PvrManager.OnPvrEventListener) it6.next()).onPvrNotifyFormatFinished(com.mstar.android.tvapi.common.TvManager.getInstance().getPvrManager(), message.what, message.arg1, message.arg2);
                        }
                    } finally {
                    }
                }
                return;
            }
            if (i3 == 2001) {
                synchronized (TvPvrManager.this.mPvrListeners) {
                    try {
                        Iterator it7 = TvPvrManager.this.mPvrListeners.iterator();
                        while (it7.hasNext()) {
                            ((PvrManager.OnPvrEventListener) it7.next()).onPvrNotifyPlaybackStop(com.mstar.android.tvapi.common.TvManager.getInstance().getPvrManager(), message.what, message.arg1, message.arg2);
                        }
                    } finally {
                    }
                }
                return;
            }
            if (i3 != 2002) {
                Log.e(TvPvrManager.TAG, "Unknown message type " + message.what);
                return;
            }
            synchronized (TvPvrManager.this.mPvrListeners) {
                try {
                    Iterator it8 = TvPvrManager.this.mPvrListeners.iterator();
                    while (it8.hasNext()) {
                        ((PvrManager.OnPvrEventListener) it8.next()).onPvrNotifyPlaybackBegin(com.mstar.android.tvapi.common.TvManager.getInstance().getPvrManager(), message.what, message.arg1, message.arg2);
                    }
                } finally {
                }
            }
        }
    }

    public interface OnFormatEventListener {
        boolean onFormatEvent(int i2, int i3, int i4, Object obj);
    }

    public interface OnPlaybackEventListener {
        boolean onPlaybackEvent(int i2, int i3, int i4, Object obj);
    }

    public interface OnUsbEventListener {
        boolean onUsbEvent(int i2, int i3, int i4, Object obj);
    }

    private TvPvrManager() throws TvCommonException {
        this.mHandler = null;
        if (true == TvServiceBinder.isNeedBindService()) {
            ITvService tvService = TvServiceBinder.getTvService();
            if (tvService == null) {
                Log.e(TAG, "TvService doesn't exist!!");
                throw new TvCommonException("TvService doesn't exist.");
            }
            try {
                mService = tvService.getTvPvr();
            } catch (RemoteException e2) {
                e2.printStackTrace();
            }
        } else {
            IBinder service = ServiceManager.getService("tv");
            if (service == null) {
                Log.e(TAG, "TvService doesn't exist!!");
                throw new TvCommonException("TvService doesn't exist.");
            }
            try {
                mService = ITvService.Stub.asInterface(service).getTvPvr();
            } catch (RemoteException e3) {
                e3.printStackTrace();
            }
        }
        Looper looperMyLooper = Looper.myLooper();
        if (looperMyLooper != null) {
            this.mHandler = new EventHandler(looperMyLooper);
        } else {
            Looper mainLooper = Looper.getMainLooper();
            if (mainLooper != null) {
                this.mHandler = new EventHandler(mainLooper);
            } else {
                this.mHandler = null;
            }
        }
        try {
            mService.addClient(this);
        } catch (RemoteException e4) {
            e4.printStackTrace();
        }
    }

    public static TvPvrManager getInstance() {
        if (mInstance == null) {
            synchronized (TvPvrManager.class) {
                if (mInstance == null) {
                    try {
                        mInstance = new TvPvrManager();
                    } catch (TvCommonException e2) {
                        e2.printStackTrace();
                        return null;
                    }
                }
            }
        }
        return mInstance;
    }

    public boolean assignThumbnailFileInfoHandler(String str) {
        try {
            return mService.assignThumbnailFileInfoHandler(str);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public CaptureThumbnailResult captureThumbnail() {
        try {
            return mService.captureThumbnail();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public boolean changeDevice(short s2) {
        try {
            return mService.changeDevice(s2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public int checkUsbSpeed() {
        try {
            return mService.checkUsbSpeed();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return -1;
        }
    }

    public void clearMetadata() {
        try {
            mService.clearMetadata();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public boolean createMetadata(String str) {
        try {
            return mService.createMetadata(str);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public void deletefile(int i2, String str) {
        try {
            mService.deletefile(i2, str);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void doPlaybackFastBackward() {
        try {
            mService.doPlaybackFastBackward();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void doPlaybackFastForward() {
        try {
            mService.doPlaybackFastForward();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void doPlaybackJumpBackward() {
        try {
            mService.doPlaybackJumpBackward();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void doPlaybackJumpForward() {
        try {
            mService.doPlaybackJumpForward();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    protected void finalize() throws Throwable {
        Log.d(TAG, "finalize TvPvrManager ");
        try {
            mService.removeClient(this);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public int getCurPlaybackTimeInSecond() {
        try {
            return mService.getCurPlaybackTimeInSecond();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return -1;
        }
    }

    public String getCurPlaybackingFileName() {
        try {
            return mService.getCurPlaybackingFileName();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public int getCurRecordTimeInSecond() {
        try {
            return mService.getCurRecordTimeInSecond();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return -1;
        }
    }

    public String getCurRecordingFileName() {
        try {
            return mService.getCurRecordingFileName();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public long getCurTimeshiftTimeInMiliSecSinceEpoch() {
        long curTimeshiftTimeInMiliSecSinceEpoch;
        try {
            curTimeshiftTimeInMiliSecSinceEpoch = mService.getCurTimeshiftTimeInMiliSecSinceEpoch();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            curTimeshiftTimeInMiliSecSinceEpoch = 0;
        }
        Log.d(TAG, "getCurTimeshiftTimeInMiliSecSinceEpoch() return = " + curTimeshiftTimeInMiliSecSinceEpoch);
        return curTimeshiftTimeInMiliSecSinceEpoch;
    }

    public String getFileEventName(String str) {
        try {
            return mService.getFileEventName(str);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public int getFileLcn(int i2) {
        try {
            return mService.getFileLcn(i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return -1;
        }
    }

    public String getFileServiceName(String str) {
        try {
            return mService.getFileServiceName(str);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public boolean getIsBootByRecord() {
        Log.d(TAG, "getIsBootByRecord");
        try {
            return mService.getIsBootByRecord();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public int getMetadataSortKey() {
        try {
            return mService.getMetadataSortKey();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return -1;
        }
    }

    @Deprecated
    public PvrPlaybackSpeed.EnumPvrPlaybackSpeed getPlaybackSpeed() {
        try {
            return PvrPlaybackSpeed.EnumPvrPlaybackSpeed.values()[PvrPlaybackSpeed.EnumPvrPlaybackSpeed.getOrdinalThroughValue(getPvrPlaybackSpeed())];
        } catch (ArrayIndexOutOfBoundsException e2) {
            e2.printStackTrace();
            return PvrPlaybackSpeed.EnumPvrPlaybackSpeed.E_PVR_PLAYBACK_SPEED_INVALID;
        }
    }

    public PvrFileInfo getPvrFileInfo(int i2, int i3) {
        try {
            return mService.getPvrFileInfo(i2, i3);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public int getPvrFileNumber() {
        try {
            return mService.getPvrFileNumber();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return -1;
        }
    }

    public int getPvrFileResumePointInSec(String str, int i2) {
        try {
            return mService.getPvrFileResumePointInSec(str, i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 0;
        }
    }

    public String getPvrMountPath() {
        try {
            return mService.getPvrMountPath();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public int getPvrPlaybackSpeed() {
        try {
            return PvrPlaybackSpeed.EnumPvrPlaybackSpeed.values()[mService.getPlaybackSpeed()].getValue();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 65535;
        } catch (ArrayIndexOutOfBoundsException e3) {
            e3.printStackTrace();
            return 65535;
        }
    }

    public int getRecordedFileDurationTime(String str) {
        try {
            return mService.getRecordedFileDurationTime(str);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return -1;
        }
    }

    public String getThumbnailDisplay(int i2) {
        try {
            return mService.getThumbnailDisplay(i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public int getThumbnailNumber() {
        try {
            return mService.getThumbnailNumber();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return -1;
        }
    }

    public String getThumbnailPath(int i2) {
        try {
            return mService.getThumbnailPath(i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public long getTimeshiftStartTimeInMiliSecSinceEpoch() {
        long timeshiftStartTimeInMiliSecSinceEpoch;
        try {
            timeshiftStartTimeInMiliSecSinceEpoch = mService.getTimeshiftStartTimeInMiliSecSinceEpoch();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            timeshiftStartTimeInMiliSecSinceEpoch = 0;
        }
        Log.d(TAG, "getTimeshiftStartTimeInMiliSecSinceEpoch() return = " + timeshiftStartTimeInMiliSecSinceEpoch);
        return timeshiftStartTimeInMiliSecSinceEpoch;
    }

    public short getUsbDeviceIndex() {
        try {
            return (short) mService.getUsbDeviceIndex();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return (short) -1;
        }
    }

    public int getUsbDeviceNumber() {
        try {
            return mService.getUsbDeviceNumber();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return -1;
        }
    }

    public int getUsbPartitionNumber() {
        try {
            return mService.getUsbPartitionNumber();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return -1;
        }
    }

    public boolean isAlwaysTimeShift() {
        try {
            return mService.isAlwaysTimeShift();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean isAlwaysTimeShiftPlaybackPaused() {
        try {
            return mService.isAlwaysTimeShiftPlaybackPaused();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean isAlwaysTimeShiftRecording() {
        try {
            return mService.isAlwaysTimeShiftRecording();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean isMetadataSortAscending() {
        try {
            return mService.isMetadataSortAscending();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean isPlaybackParentalLock() {
        try {
            return mService.isPlaybackParentalLock();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean isPlaybackPaused() {
        try {
            return mService.isPlaybackPaused();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean isPlaybacking() {
        try {
            return mService.isPlaybacking();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean isRecordPaused() {
        try {
            return mService.isRecordPaused();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean isRecording() {
        try {
            return mService.isRecording();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean isTimeShiftRecording() {
        try {
            return mService.isTimeShiftRecording();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean jumpPlaybackTime(int i2) {
        try {
            return mService.jumpPlaybackTime(i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean jumpPlaybackTimeInMS(int i2) {
        boolean zJumpPlaybackTimeInMS;
        try {
            zJumpPlaybackTimeInMS = mService.jumpPlaybackTimeInMS(i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            zJumpPlaybackTimeInMS = false;
        }
        Log.d(TAG, "jumpPlaybackTimeInMS() return" + zJumpPlaybackTimeInMS);
        return zJumpPlaybackTimeInMS;
    }

    public boolean jumpPlaybackTimeInMiliSecSinceEpoch(long j2) {
        boolean zJumpPlaybackTimeInMiliSecSinceEpoch;
        try {
            Log.d(TAG, "jumpPlaybackTimeInMiliSecSinceEpoch(), timeInMiliSecSinceEpoch = " + j2);
            zJumpPlaybackTimeInMiliSecSinceEpoch = mService.jumpPlaybackTimeInMiliSecSinceEpoch(j2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            zJumpPlaybackTimeInMiliSecSinceEpoch = false;
        }
        Log.d(TAG, "jumpPlaybackTimeInMiliSecSinceEpoch(), ret = " + zJumpPlaybackTimeInMiliSecSinceEpoch);
        return zJumpPlaybackTimeInMiliSecSinceEpoch;
    }

    public boolean jumpToThumbnail(int i2) {
        try {
            return mService.jumpToThumbnail(i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    @Override // com.mstar.android.tv.IEventClient
    public boolean onEvent(Message message) throws RemoteException {
        EventHandler eventHandler = this.mHandler;
        if (eventHandler == null) {
            return true;
        }
        Message messageObtainMessage = eventHandler.obtainMessage();
        messageObtainMessage.copyFrom(message);
        this.mHandler.sendMessage(messageObtainMessage);
        return true;
    }

    @Deprecated
    public EnumPvrStatus pauseAlwaysTimeShiftPlayback(boolean z2) {
        return EnumPvrStatus.values()[pausePvrAlwaysTimeShiftPlayback(z2)];
    }

    public short pauseAlwaysTimeShiftRecord() {
        short sPauseAlwaysTimeShiftRecord = -1;
        try {
            sPauseAlwaysTimeShiftRecord = (short) mService.pauseAlwaysTimeShiftRecord();
            Log.d(TAG, "pauseAlwaysTimeShiftRecord(), recordStatus = " + ((int) sPauseAlwaysTimeShiftRecord));
            return sPauseAlwaysTimeShiftRecord;
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return sPauseAlwaysTimeShiftRecord;
        }
    }

    public void pausePlayback() {
        try {
            mService.pausePlayback();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public int pausePvrAlwaysTimeShiftPlayback(boolean z2) {
        Log.d(TAG, "pausePvrAlwaysTimeShiftPlayback(), ready = " + z2);
        try {
            int iPauseAlwaysTimeShiftPlayback = mService.pauseAlwaysTimeShiftPlayback(z2);
            Log.d(TAG, "pausePvrAlwaysTimeShiftPlayback(), ret = " + iPauseAlwaysTimeShiftPlayback);
            return iPauseAlwaysTimeShiftPlayback;
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 20;
        }
    }

    public void pauseRecord() {
        try {
            mService.pauseRecord();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public boolean registerOnFormatEventListener(OnFormatEventListener onFormatEventListener) {
        Log.d(TAG, "registerOnFormatEventListener ");
        synchronized (this.mFormatEventListeners) {
            this.mFormatEventListeners.add(onFormatEventListener);
        }
        return true;
    }

    public boolean registerOnPlaybackEventListener(OnPlaybackEventListener onPlaybackEventListener) {
        Log.d(TAG, "registerOnPlaybackEventListener ");
        synchronized (this.mPlaybackEventListeners) {
            this.mPlaybackEventListeners.add(onPlaybackEventListener);
        }
        return true;
    }

    @Deprecated
    public boolean registerOnPvrEventListener(PvrManager.OnPvrEventListener onPvrEventListener) {
        Log.d(TAG, "registerOnPvrEventListener ");
        synchronized (this.mPvrListeners) {
            this.mPvrListeners.add(onPvrEventListener);
        }
        return true;
    }

    public boolean registerOnUsbEventListener(OnUsbEventListener onUsbEventListener) {
        Log.d(TAG, "registerOnUsbEventListener ");
        synchronized (this.mUsbEventListeners) {
            this.mUsbEventListeners.add(onUsbEventListener);
        }
        return true;
    }

    public void resumePlayback() {
        try {
            mService.resumePlayback();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void resumeRecord() {
        try {
            mService.resumeRecord();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void setAlwaysTimeShift(boolean z2) {
        try {
            mService.setAlwaysTimeShift(z2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void setIsBootByRecord(boolean z2) {
        Log.d(TAG, "setIsBootByRecord");
        try {
            mService.setIsBootByRecord(z2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void setMetadataSortAscending(boolean z2) {
        try {
            mService.setMetadataSortAscending(z2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void setMetadataSortKey(int i2) {
        try {
            mService.setMetadataSortKey(i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    @Deprecated
    public void setPlaybackSpeed(PvrPlaybackSpeed.EnumPvrPlaybackSpeed enumPvrPlaybackSpeed) {
        setPvrPlaybackSpeed(enumPvrPlaybackSpeed.getValue());
    }

    public void setPlaybackSpeedInFloat(float f2) {
        try {
            Log.d(TAG, "setPlaybackSpeedInFloat(), playbackSpeed = " + f2);
            mService.setPlaybackSpeedInFloat(f2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void setPlaybackWindow(VideoWindowType videoWindowType, int i2, int i3) {
        try {
            mService.setPlaybackWindow(videoWindowType, i2, i3);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public boolean setPvrFileResumePoint(String str, int i2) {
        try {
            return mService.setPvrFileResumePoint(str, i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean setPvrParams(String str, short s2) {
        try {
            return mService.setPvrParams(str, s2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public void setPvrPlaybackSpeed(int i2) {
        try {
            int ordinalThroughValue = PvrPlaybackSpeed.EnumPvrPlaybackSpeed.getOrdinalThroughValue(i2);
            if (ordinalThroughValue == -1) {
                return;
            }
            mService.setPlaybackSpeed(ordinalThroughValue);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void setTimeShiftFileSize(long j2) {
        try {
            mService.setTimeShiftFileSize(j2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public short startAlwaysTimeShiftPlayback() {
        short sStartAlwaysTimeShiftPlayback = -1;
        try {
            sStartAlwaysTimeShiftPlayback = (short) mService.startAlwaysTimeShiftPlayback();
            Log.d(TAG, "startAlwaysTimeShiftPlayback(), recordStatus = " + ((int) sStartAlwaysTimeShiftPlayback));
            return sStartAlwaysTimeShiftPlayback;
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return sStartAlwaysTimeShiftPlayback;
        }
    }

    public short startAlwaysTimeShiftRecord() {
        short sStartAlwaysTimeShiftRecord = -1;
        try {
            sStartAlwaysTimeShiftRecord = (short) mService.startAlwaysTimeShiftRecord();
            Log.d(TAG, "startAlwaysTimeShiftRecord(), recordStatus = " + ((int) sStartAlwaysTimeShiftRecord));
            return sStartAlwaysTimeShiftRecord;
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return sStartAlwaysTimeShiftRecord;
        }
    }

    @Deprecated
    public EnumPvrStatus startPlayback(String str) {
        return EnumPvrStatus.values()[startPvrPlayback(str)];
    }

    public void startPlaybackLoop(int i2, int i3) {
        try {
            mService.startPlaybackLoop(i2, i3);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public int startPvrPlayback(String str) {
        try {
            return mService.startPlayback(str);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 20;
        }
    }

    public int startPvrPlaybackInSec(String str, int i2) {
        try {
            return mService.startPlaybackInSec(str, i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 20;
        }
    }

    public int startPvrRecord() {
        try {
            return mService.startRecord();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 20;
        }
    }

    public int startPvrTimeShiftPlayback() {
        try {
            return mService.startTimeShiftPlayback();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 20;
        }
    }

    public int startPvrTimeShiftRecord() {
        try {
            return mService.startTimeShiftRecord();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 20;
        }
    }

    @Deprecated
    public EnumPvrStatus startRecord() {
        return EnumPvrStatus.values()[startPvrRecord()];
    }

    @Deprecated
    public EnumPvrStatus startTimeShiftPlayback() {
        return EnumPvrStatus.values()[startPvrTimeShiftPlayback()];
    }

    @Deprecated
    public EnumPvrStatus startTimeShiftRecord() {
        return EnumPvrStatus.values()[startPvrTimeShiftRecord()];
    }

    public void stepInPlayback() {
        try {
            mService.stepInPlayback();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void stopAlwaysTimeShiftPlayback() {
        try {
            mService.stopAlwaysTimeShiftPlayback();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public short stopAlwaysTimeShiftRecord() {
        short sStopAlwaysTimeShiftRecord = -1;
        try {
            sStopAlwaysTimeShiftRecord = (short) mService.stopAlwaysTimeShiftRecord();
            Log.d(TAG, "stopAlwaysTimeShiftRecord(), recordStatus = " + ((int) sStopAlwaysTimeShiftRecord));
            return sStopAlwaysTimeShiftRecord;
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return sStopAlwaysTimeShiftRecord;
        }
    }

    public void stopPlayback() {
        try {
            mService.stopPlayback();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void stopPlaybackLoop() {
        try {
            mService.stopPlaybackLoop();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public boolean stopPvr() {
        try {
            return mService.stopPvr();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public void stopRecord() {
        try {
            mService.stopRecord();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void stopTimeShift() {
        try {
            mService.stopTimeShift();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void stopTimeShiftPlayback() {
        try {
            mService.stopTimeShiftPlayback();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void stopTimeShiftRecord() {
        try {
            mService.stopTimeShiftRecord();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public boolean unlockPlayback() {
        try {
            return mService.unlockPlayback();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean unregisterOnFormatEventListener(OnFormatEventListener onFormatEventListener) {
        synchronized (this.mFormatEventListeners) {
            this.mFormatEventListeners.remove(onFormatEventListener);
            Log.d(TAG, "unregisterOnFormatEventListener  size: " + this.mFormatEventListeners.size());
        }
        return true;
    }

    public boolean unregisterOnPlaybackEventListener(OnPlaybackEventListener onPlaybackEventListener) {
        synchronized (this.mPlaybackEventListeners) {
            this.mPlaybackEventListeners.remove(onPlaybackEventListener);
            Log.d(TAG, "unregisterOnPlaybackEventListener  size: " + this.mPlaybackEventListeners.size());
        }
        return true;
    }

    @Deprecated
    public synchronized boolean unregisterOnPvrEventListener(PvrManager.OnPvrEventListener onPvrEventListener) {
        synchronized (this.mPvrListeners) {
            this.mPvrListeners.remove(onPvrEventListener);
            Log.d(TAG, "unregisterOnPvrEventListener  size: " + this.mPvrListeners.size());
        }
        return true;
    }

    public boolean unregisterOnUsbEventListener(OnUsbEventListener onUsbEventListener) {
        synchronized (this.mUsbEventListeners) {
            this.mUsbEventListeners.remove(onUsbEventListener);
            Log.d(TAG, "unregisterOnUsbEventListener  size: " + this.mUsbEventListeners.size());
        }
        return true;
    }
}
