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.text.format.Time;
import android.util.Log;
import com.mstar.android.tv.IEventClient;
import com.mstar.android.tv.ITvService;
import com.mstar.android.tvapi.common.TimerManager;
import com.mstar.android.tvapi.common.exception.TvCommonException;
import com.mstar.android.tvapi.common.vo.EnumSleepTimeState;
import com.mstar.android.tvapi.common.vo.EpgEventTimerInfo;
import com.mstar.android.tvapi.common.vo.OnTimeTvDescriptor;
import com.mstar.android.tvapi.common.vo.StandardTime;
import com.mstar.android.tvapi.common.vo.TvOsType;
import com.mstar.android.tvapi.dtv.vo.EnumEpgTimerCheck;
import java.util.ArrayList;
import java.util.Iterator;

/* JADX INFO: loaded from: classes.dex */
public class TvTimerManager extends IEventClient.Stub {
    public static final int DAYLIGHT_SAVING_AUTO = 0;
    public static final int DAYLIGHT_SAVING_USER_OFF = 1;
    public static final int DAYLIGHT_SAVING_USER_ON = 2;
    public static final int EPG_TIMECHECK_ENDTIME_BEFORE_START = 4;
    public static final int EPG_TIMECHECK_ENDTIME_EXCEED_PERIOD = 5;
    public static final int EPG_TIMECHECK_NONE = 0;
    public static final int EPG_TIMECHECK_OVERLAY = 3;
    public static final int EPG_TIMECHECK_PAST = 2;
    public static final int EPG_TIMECHECK_SUCCESS = 1;
    public static final int EPG_TIMER_ACTION_CI_OP_REFRESH = 4;
    public static final int EPG_TIMER_ACTION_NONE = 0;
    public static final int EPG_TIMER_ACTION_RECORDER_START = 2;
    public static final int EPG_TIMER_ACTION_RECORDER_STOP = 3;
    public static final int EPG_TIMER_ACTION_REMINDER = 1;
    public static final int SLEEP_TIME_10MIN = 1;
    public static final int SLEEP_TIME_120MIN = 6;
    public static final int SLEEP_TIME_180MIN = 7;
    public static final int SLEEP_TIME_20MIN = 2;
    public static final int SLEEP_TIME_240MIN = 8;
    public static final int SLEEP_TIME_30MIN = 3;
    public static final int SLEEP_TIME_60MIN = 4;
    public static final int SLEEP_TIME_90MIN = 5;
    public static final int SLEEP_TIME_OFF = 0;
    private static final String TAG = "TvTimerManager";
    public static final int TVTIMER_BEAT_ONE_SECOND = 4;
    public static final int TVTIMER_DESTROY_COUNTDOWN = 0;
    public static final int TVTIMER_EPG_TIMER_COUNTDOWN = 8;
    public static final int TVTIMER_EPG_TIMER_RECORD_START = 9;
    public static final int TVTIMER_EPG_TIME_UP = 7;
    public static final int TVTIMER_KILL_LASTMINUTE = 13;
    public static final int TVTIMER_LAST_MINUTE_UPDATE = 2;
    public static final int TVTIMER_LAST_MINUTE_WARN = 1;
    public static final int TVTIMER_OAD_TIME_SCAN = 11;
    public static final int TVTIMER_POWER_DOWNTIME = 3;
    public static final int TVTIMER_PVR_NOTIFY_RECORD_STOP = 10;
    public static final int TVTIMER_SIGNAL_LOCK = 6;
    public static final int TVTIMER_SYSTEM_CLOCK_CHANGE = 5;
    public static final int TVTIMER_TIME_ZONE_CHG = 12;
    private static TvTimerManager mInstance;
    private static ITvTimer mService;
    private EventHandler mHandler;

    @Deprecated
    private final ArrayList<TimerManager.OnTimerEventListener> mTimerEventListeners = new ArrayList<>();
    private final ArrayList<OnCountdownEventListener> mCountdownEventListeners = new ArrayList<>();
    private final ArrayList<OnSystemClockEventListener> mSystemClockEventListeners = new ArrayList<>();
    private final ArrayList<OnSignalEventListener> mSignalEventListeners = new ArrayList<>();
    private final ArrayList<OnEpgTimerEventListener> mEpgTimerEventListeners = new ArrayList<>();
    private final ArrayList<OnPvrTimerEventListener> mPvrTimerEventListeners = new ArrayList<>();
    private final ArrayList<OnOadTimerEventListener> mOadTimerEventListeners = 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 <= 3 || 13 == i2) {
                synchronized (TvTimerManager.this.mCountdownEventListeners) {
                    try {
                        Iterator it = TvTimerManager.this.mCountdownEventListeners.iterator();
                        while (it.hasNext()) {
                            ((OnCountdownEventListener) it.next()).onCountdownEvent(message.what, message.arg1, message.arg2);
                        }
                    } finally {
                    }
                }
            } else if (i2 <= 5) {
                synchronized (TvTimerManager.this.mSystemClockEventListeners) {
                    try {
                        Iterator it2 = TvTimerManager.this.mSystemClockEventListeners.iterator();
                        while (it2.hasNext()) {
                            ((OnSystemClockEventListener) it2.next()).onSystemClockEvent(message.what);
                        }
                    } finally {
                    }
                }
            } else if (i2 <= 6) {
                synchronized (TvTimerManager.this.mSignalEventListeners) {
                    try {
                        Iterator it3 = TvTimerManager.this.mSignalEventListeners.iterator();
                        while (it3.hasNext()) {
                            ((OnSignalEventListener) it3.next()).onSignalEvent(message.what);
                        }
                    } finally {
                    }
                }
            } else if (i2 <= 9) {
                synchronized (TvTimerManager.this.mEpgTimerEventListeners) {
                    try {
                        Iterator it4 = TvTimerManager.this.mEpgTimerEventListeners.iterator();
                        while (it4.hasNext()) {
                            ((OnEpgTimerEventListener) it4.next()).onEpgTimerEvent(message.what, message.arg1, message.arg2);
                        }
                    } finally {
                    }
                }
            } else if (i2 <= 10) {
                synchronized (TvTimerManager.this.mPvrTimerEventListeners) {
                    try {
                        Iterator it5 = TvTimerManager.this.mPvrTimerEventListeners.iterator();
                        while (it5.hasNext()) {
                            ((OnPvrTimerEventListener) it5.next()).onPvrTimerEvent(message.what, message.arg1, message.arg2);
                        }
                    } finally {
                    }
                }
            } else if (i2 <= 11) {
                synchronized (TvTimerManager.this.mOadTimerEventListeners) {
                    try {
                        Iterator it6 = TvTimerManager.this.mOadTimerEventListeners.iterator();
                        while (it6.hasNext()) {
                            ((OnOadTimerEventListener) it6.next()).onOadTimerEvent(message.what);
                        }
                    } finally {
                    }
                }
            }
            switch (message.what) {
                case 0:
                    synchronized (TvTimerManager.this.mTimerEventListeners) {
                        try {
                            Iterator it7 = TvTimerManager.this.mTimerEventListeners.iterator();
                            while (it7.hasNext()) {
                                ((TimerManager.OnTimerEventListener) it7.next()).onDestroyCountDown(null, message.what, message.arg1, message.arg2);
                            }
                        } finally {
                        }
                        break;
                    }
                    return;
                case 1:
                    synchronized (TvTimerManager.this.mTimerEventListeners) {
                        try {
                            Iterator it8 = TvTimerManager.this.mTimerEventListeners.iterator();
                            while (it8.hasNext()) {
                                ((TimerManager.OnTimerEventListener) it8.next()).onLastMinuteWarn(null, message.what, message.arg1, message.arg2);
                            }
                        } finally {
                        }
                        break;
                    }
                    return;
                case 2:
                    synchronized (TvTimerManager.this.mTimerEventListeners) {
                        try {
                            Iterator it9 = TvTimerManager.this.mTimerEventListeners.iterator();
                            while (it9.hasNext()) {
                                ((TimerManager.OnTimerEventListener) it9.next()).onUpdateLastMinute(null, message.what, message.arg1, message.arg2);
                            }
                        } finally {
                        }
                        break;
                    }
                    return;
                case 3:
                    synchronized (TvTimerManager.this.mTimerEventListeners) {
                        try {
                            Iterator it10 = TvTimerManager.this.mTimerEventListeners.iterator();
                            while (it10.hasNext()) {
                                ((TimerManager.OnTimerEventListener) it10.next()).onPowerDownTime(null, message.what, message.arg1, message.arg2);
                            }
                        } finally {
                        }
                        break;
                    }
                    return;
                case 4:
                    synchronized (TvTimerManager.this.mTimerEventListeners) {
                        try {
                            Iterator it11 = TvTimerManager.this.mTimerEventListeners.iterator();
                            while (it11.hasNext()) {
                                ((TimerManager.OnTimerEventListener) it11.next()).onOneSecondBeat(null, message.what, message.arg1, message.arg2);
                            }
                        } finally {
                        }
                        break;
                    }
                    return;
                case 5:
                    synchronized (TvTimerManager.this.mTimerEventListeners) {
                        try {
                            Iterator it12 = TvTimerManager.this.mTimerEventListeners.iterator();
                            while (it12.hasNext()) {
                                ((TimerManager.OnTimerEventListener) it12.next()).onSystemClkChg(null, message.what, message.arg1, message.arg2);
                            }
                        } finally {
                        }
                        break;
                    }
                    return;
                case 6:
                    synchronized (TvTimerManager.this.mTimerEventListeners) {
                        try {
                            Iterator it13 = TvTimerManager.this.mTimerEventListeners.iterator();
                            while (it13.hasNext()) {
                                ((TimerManager.OnTimerEventListener) it13.next()).onSignalLock(null, message.what, message.arg1, message.arg2);
                            }
                        } finally {
                        }
                        break;
                    }
                    return;
                case 7:
                    synchronized (TvTimerManager.this.mTimerEventListeners) {
                        try {
                            Iterator it14 = TvTimerManager.this.mTimerEventListeners.iterator();
                            while (it14.hasNext()) {
                                ((TimerManager.OnTimerEventListener) it14.next()).onEpgTimeUp(null, message.what, message.arg1, message.arg2);
                            }
                        } finally {
                        }
                        break;
                    }
                    return;
                case 8:
                    synchronized (TvTimerManager.this.mTimerEventListeners) {
                        try {
                            Iterator it15 = TvTimerManager.this.mTimerEventListeners.iterator();
                            while (it15.hasNext()) {
                                ((TimerManager.OnTimerEventListener) it15.next()).onEpgTimerCountDown(null, message.what, message.arg1, message.arg2);
                            }
                        } finally {
                        }
                        break;
                    }
                    return;
                case 9:
                    synchronized (TvTimerManager.this.mTimerEventListeners) {
                        try {
                            Iterator it16 = TvTimerManager.this.mTimerEventListeners.iterator();
                            while (it16.hasNext()) {
                                ((TimerManager.OnTimerEventListener) it16.next()).onEpgTimerRecordStart(null, message.what, message.arg1, message.arg2);
                            }
                        } finally {
                        }
                        break;
                    }
                    return;
                case 10:
                    synchronized (TvTimerManager.this.mTimerEventListeners) {
                        try {
                            Iterator it17 = TvTimerManager.this.mTimerEventListeners.iterator();
                            while (it17.hasNext()) {
                                ((TimerManager.OnTimerEventListener) it17.next()).onPvrNotifyRecordStop(null, message.what, message.arg1, message.arg2);
                            }
                        } finally {
                        }
                        break;
                    }
                    return;
                case 11:
                    synchronized (TvTimerManager.this.mTimerEventListeners) {
                        try {
                            Iterator it18 = TvTimerManager.this.mTimerEventListeners.iterator();
                            while (it18.hasNext()) {
                                ((TimerManager.OnTimerEventListener) it18.next()).onOadTimeScan(null, message.what, message.arg1, message.arg2);
                            }
                        } finally {
                        }
                        break;
                    }
                    return;
                default:
                    return;
            }
        }
    }

    public interface OnCountdownEventListener {
        boolean onCountdownEvent(int i2, int i3, int i4);
    }

    public interface OnEpgTimerEventListener {
        boolean onEpgTimerEvent(int i2, int i3, int i4);
    }

    public interface OnOadTimerEventListener {
        boolean onOadTimerEvent(int i2);
    }

    public interface OnPvrTimerEventListener {
        boolean onPvrTimerEvent(int i2, int i3, int i4);
    }

    public interface OnSignalEventListener {
        boolean onSignalEvent(int i2);
    }

    public interface OnSystemClockEventListener {
        boolean onSystemClockEvent(int i2);
    }

    private TvTimerManager() 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.getTvTimer();
            } 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).getTvTimer();
            } 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 TvTimerManager getInstance() {
        if (mInstance == null) {
            synchronized (TvTimerManager.class) {
                if (mInstance == null) {
                    try {
                        mInstance = new TvTimerManager();
                    } catch (TvCommonException e2) {
                        e2.printStackTrace();
                        return null;
                    }
                }
            }
        }
        return mInstance;
    }

    @Deprecated
    public EnumEpgTimerCheck addEpgEvent(EpgEventTimerInfo epgEventTimerInfo) {
        return EnumEpgTimerCheck.values()[addEpgNewEvent(epgEventTimerInfo)];
    }

    public int addEpgNewEvent(EpgEventTimerInfo epgEventTimerInfo) {
        try {
            return mService.addEpgEvent(epgEventTimerInfo);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 0;
        }
    }

    public void cancelEpgTimerEvent(int i2, boolean z2) {
        try {
            mService.cancelEpgTimerEvent(i2, z2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public int convertGPSTime2UTC(int i2) {
        try {
            return mService.convertGPSTime2UTC(i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 0;
        }
    }

    public Time convertSeconds2StTime(int i2) {
        Time time = new Time();
        try {
            time.set(mService.convertSeconds2StTime(i2));
            Log.d(TAG, "convertSeconds2StTime: " + time.year + "." + time.month + "." + time.monthDay + "." + time.hour + "." + time.minute + "." + time.second);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
        return time;
    }

    public int convertUTCTime2GPS(int i2) {
        try {
            return mService.convertUTCTime2GPS(i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 0;
        }
    }

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

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

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

    protected void finalize() throws Throwable {
        try {
            mService.removeClient(this);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public int getClockOffset() {
        int clockOffset = 0;
        try {
            clockOffset = mService.getClockOffset();
            Log.d(TAG, "getClockOffset(), return int " + clockOffset);
            return clockOffset;
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return clockOffset;
        }
    }

    @Deprecated
    public StandardTime getCurTimer() {
        StandardTime curTimer = null;
        try {
            curTimer = mService.getCurTimer();
            Log.d(TAG, "getCurTimer:" + ((Time) curTimer).year + "." + ((Time) curTimer).month + "." + ((Time) curTimer).monthDay + "." + ((Time) curTimer).hour + "." + ((Time) curTimer).minute + "." + ((Time) curTimer).second);
            return curTimer;
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return curTimer;
        }
    }

    public Time getCurrentTvTime() {
        Time time;
        RemoteException e2;
        try {
            time = new Time(mService.getCurrentTvTime());
            try {
                Log.d(TAG, "getCurrentTvTime(), time:" + time);
            } catch (RemoteException e3) {
                e2 = e3;
                e2.printStackTrace();
            }
        } catch (RemoteException e4) {
            time = null;
            e2 = e4;
        }
        return time;
    }

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

    @Deprecated
    public boolean getDaylightSavingState() {
        boolean daylightSavingState = false;
        try {
            daylightSavingState = mService.getDaylightSavingState();
            Log.d(TAG, "getDaylightSavingState(), result = " + daylightSavingState);
            return daylightSavingState;
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return daylightSavingState;
        }
    }

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

    public int getEpgTimerEventCount() {
        try {
            return mService.getEpgTimerEventCount();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 0;
        }
    }

    public EpgEventTimerInfo getEpgTimerRecordingProgram() {
        try {
            return mService.getEpgTimerRecordingProgram();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    @Deprecated
    public StandardTime getOffTimer() {
        StandardTime offTimer = null;
        try {
            offTimer = mService.getOffTimer();
            Log.d(TAG, "getOffTimer:" + ((Time) offTimer).year + "." + ((Time) offTimer).month + "." + ((Time) offTimer).monthDay + "." + ((Time) offTimer).hour + "." + ((Time) offTimer).minute + "." + ((Time) offTimer).second);
            return offTimer;
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return offTimer;
        }
    }

    public OnTimeTvDescriptor getOnTimeEvent() {
        OnTimeTvDescriptor onTimeEvent = null;
        try {
            onTimeEvent = mService.getOnTimeEvent();
            Log.d(TAG, "setOnTimeEvent, return OnTimeTvDescriptor mChNo = " + onTimeEvent.mChNo + ", mVol = " + ((int) onTimeEvent.mVol) + ", enTVSrc = " + onTimeEvent.enTVSrc);
            return onTimeEvent;
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return onTimeEvent;
        }
    }

    @Deprecated
    public StandardTime getOnTimer() {
        StandardTime onTimer = null;
        try {
            onTimer = mService.getOnTimer();
            Log.d(TAG, "getOnTimer, return StandardTime year = " + ((Time) onTimer).year + ", month = " + ((Time) onTimer).month + ", day = " + ((Time) onTimer).monthDay + ", hour = " + ((Time) onTimer).hour + ", minute = " + ((Time) onTimer).minute + ", second = " + ((Time) onTimer).second);
            return onTimer;
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return onTimer;
        }
    }

    public int getRtcClock() {
        int rtcClock = 0;
        try {
            rtcClock = mService.getRtcClock();
            Log.d(TAG, "getRtcClock(), return int " + rtcClock);
            return rtcClock;
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return rtcClock;
        }
    }

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

    @Deprecated
    public EnumSleepTimeState getSleepMode() {
        return EnumSleepTimeState.values()[getSleepTimeMode()];
    }

    public int getSleepTimeMode() {
        int sleepMode;
        try {
            sleepMode = mService.getSleepMode();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            sleepMode = 0;
        }
        Log.d(TAG, "getSleepTimeMode(), return int " + sleepMode);
        return sleepMode;
    }

    public int getSleepTimeRemainMins() {
        Log.d(TAG, "GetSleepTimeRemainMins ");
        try {
            return mService.getSleepTimeRemainMins();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return -1;
        }
    }

    public TvOsType.EnumTimeZone getTimeZone() {
        try {
            int timeZone = mService.getTimeZone();
            int ordinalThroughValue = TvOsType.EnumTimeZone.getOrdinalThroughValue(timeZone);
            enumTimeZone = ordinalThroughValue != -1 ? TvOsType.EnumTimeZone.values()[ordinalThroughValue] : null;
            Log.d(TAG, "getTimeZone(), return int " + timeZone);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
        return enumTimeZone;
    }

    public Time getTvOffTimer() {
        Time time;
        Time time2 = null;
        try {
            time = new Time(mService.getOffTimer());
        } catch (RemoteException e2) {
            e = e2;
        }
        try {
            Log.d(TAG, "getTvOffTimer:" + time.year + "." + time.month + "." + time.monthDay + "." + time.hour + "." + time.minute + "." + time.second);
            return time;
        } catch (RemoteException e3) {
            e = e3;
            time2 = time;
            e.printStackTrace();
            return time2;
        }
    }

    public Time getTvOnTimer() {
        Time time;
        RemoteException e2;
        try {
            time = new Time(mService.getOnTimer());
        } catch (RemoteException e3) {
            time = null;
            e2 = e3;
        }
        try {
            Log.d(TAG, "getTvOnTimer, return Time year = " + time.year + ", month = " + time.month + ", day = " + time.monthDay + ", hour = " + time.hour + ", minute = " + time.minute + ", second = " + time.second);
        } catch (RemoteException e4) {
            e2 = e4;
            e2.printStackTrace();
        }
        return time;
    }

    public int getTvSystemTime() {
        try {
            return mService.getTvSystemTime();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 0;
        }
    }

    public int isEpgEventValid(EpgEventTimerInfo epgEventTimerInfo) {
        try {
            return mService.isEpgTimerSettingValid(epgEventTimerInfo);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 0;
        }
    }

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

    @Deprecated
    public EnumEpgTimerCheck isEpgTimerSettingValid(EpgEventTimerInfo epgEventTimerInfo) {
        return EnumEpgTimerCheck.values()[isEpgEventValid(epgEventTimerInfo)];
    }

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

    public boolean isOnTimerEnable() {
        try {
            return mService.isOnTimerEnable();
        } 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;
    }

    public boolean registerOnCountdownEventListener(OnCountdownEventListener onCountdownEventListener) {
        synchronized (this.mCountdownEventListeners) {
            this.mCountdownEventListeners.add(onCountdownEventListener);
        }
        return true;
    }

    public boolean registerOnEpgTimerEventListener(OnEpgTimerEventListener onEpgTimerEventListener) {
        synchronized (this.mEpgTimerEventListeners) {
            this.mEpgTimerEventListeners.add(onEpgTimerEventListener);
        }
        return true;
    }

    public boolean registerOnOadTimerEventListener(OnOadTimerEventListener onOadTimerEventListener) {
        synchronized (this.mOadTimerEventListeners) {
            this.mOadTimerEventListeners.add(onOadTimerEventListener);
        }
        return true;
    }

    public boolean registerOnPvrTimerEventListener(OnPvrTimerEventListener onPvrTimerEventListener) {
        synchronized (this.mPvrTimerEventListeners) {
            this.mPvrTimerEventListeners.add(onPvrTimerEventListener);
        }
        return true;
    }

    public boolean registerOnSignalEventListener(OnSignalEventListener onSignalEventListener) {
        synchronized (this.mSignalEventListeners) {
            this.mSignalEventListeners.add(onSignalEventListener);
        }
        return true;
    }

    public boolean registerOnSystemClockEventListener(OnSystemClockEventListener onSystemClockEventListener) {
        synchronized (this.mSystemClockEventListeners) {
            this.mSystemClockEventListeners.add(onSystemClockEventListener);
        }
        return true;
    }

    @Deprecated
    public boolean registerOnTimerEventListener(TimerManager.OnTimerEventListener onTimerEventListener) {
        synchronized (this.mTimerEventListeners) {
            this.mTimerEventListeners.add(onTimerEventListener);
        }
        return true;
    }

    public boolean setAutoSync(boolean z2) {
        boolean autoSync = false;
        try {
            autoSync = mService.setAutoSync(z2);
            Log.d(TAG, "set Auto Sync");
            return autoSync;
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return autoSync;
        }
    }

    public void setClkTime(long j2, boolean z2) {
        try {
            mService.setClkTime(j2, z2);
            Log.d(TAG, "set CLK Time");
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

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

    @Deprecated
    public void setDaylightSavingState(boolean z2) {
        try {
            mService.setDaylightSavingState(z2);
            Log.d(TAG, "set daylightsavingstate");
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

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

    @Deprecated
    public boolean setOffTimer(StandardTime standardTime) {
        Log.d(TAG, "setOffTimer:" + ((Time) standardTime).year + "." + ((Time) standardTime).month + "." + ((Time) standardTime).monthDay + "." + ((Time) standardTime).hour + "." + ((Time) standardTime).minute + "." + ((Time) standardTime).second);
        try {
            return mService.setOffTimer(standardTime);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean setOffTimerEnable(boolean z2) {
        Log.d(TAG, "setAtvChannel(), paras bEnable = " + z2);
        try {
            return mService.setOffTimerEnable(z2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean setOnTimeEvent(OnTimeTvDescriptor onTimeTvDescriptor) {
        Log.d(TAG, "setOnTimeEvent, paras OnTimeTvDescriptor stEvent.mChNo = " + onTimeTvDescriptor.mChNo + ", stEvent.mVol = " + ((int) onTimeTvDescriptor.mVol) + ", stEvent.enTVSrc = " + onTimeTvDescriptor.enTVSrc);
        try {
            return mService.setOnTimeEvent(onTimeTvDescriptor);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    @Deprecated
    public boolean setOnTimer(StandardTime standardTime) {
        Log.d(TAG, "setOnTimer:" + ((Time) standardTime).year + "." + ((Time) standardTime).month + "." + ((Time) standardTime).monthDay + "." + ((Time) standardTime).hour + "." + ((Time) standardTime).minute + "." + ((Time) standardTime).second);
        try {
            return mService.setOnTimer(standardTime);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean setOnTimerEnable(boolean z2) {
        Log.d(TAG, "setAtvChannel(), paras bEnable = " + z2);
        try {
            return mService.setOnTimerEnable(z2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

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

    @Deprecated
    public boolean setSleepMode(EnumSleepTimeState enumSleepTimeState) {
        return setSleepTimeMode(enumSleepTimeState.ordinal());
    }

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

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

    public void setTimeZone(TvOsType.EnumTimeZone enumTimeZone, boolean z2) {
        try {
            mService.setTimeZone(enumTimeZone.ordinal(), z2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public boolean setTvOffTimer(Time time) {
        Log.d(TAG, "setTvOffTimer:" + time.year + "." + time.month + "." + time.monthDay + "." + time.hour + "." + time.minute + "." + time.second);
        StandardTime standardTime = new StandardTime();
        standardTime.set(time);
        try {
            return mService.setOffTimer(standardTime);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean setTvOnTimer(Time time) {
        Log.d(TAG, "setTvOnTimer:" + time.year + "." + time.month + "." + time.monthDay + "." + time.hour + "." + time.minute + "." + time.second);
        StandardTime standardTime = new StandardTime();
        standardTime.set(time);
        try {
            return mService.setOnTimer(standardTime);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean unregisterOnCountdownEventListener(OnCountdownEventListener onCountdownEventListener) {
        synchronized (this.mCountdownEventListeners) {
            this.mCountdownEventListeners.remove(onCountdownEventListener);
        }
        return true;
    }

    public boolean unregisterOnEpgTimerEventListener(OnEpgTimerEventListener onEpgTimerEventListener) {
        synchronized (this.mEpgTimerEventListeners) {
            this.mEpgTimerEventListeners.remove(onEpgTimerEventListener);
        }
        return true;
    }

    public boolean unregisterOnOadTimerEventListener(OnOadTimerEventListener onOadTimerEventListener) {
        synchronized (this.mOadTimerEventListeners) {
            this.mOadTimerEventListeners.remove(onOadTimerEventListener);
        }
        return true;
    }

    public boolean unregisterOnPvrTimerEventListener(OnPvrTimerEventListener onPvrTimerEventListener) {
        synchronized (this.mPvrTimerEventListeners) {
            this.mPvrTimerEventListeners.remove(onPvrTimerEventListener);
        }
        return true;
    }

    public boolean unregisterOnSignalEventListener(OnSignalEventListener onSignalEventListener) {
        synchronized (this.mSignalEventListeners) {
            this.mSignalEventListeners.remove(onSignalEventListener);
        }
        return true;
    }

    public boolean unregisterOnSystemClockEventListener(OnSystemClockEventListener onSystemClockEventListener) {
        synchronized (this.mSystemClockEventListeners) {
            this.mSystemClockEventListeners.remove(onSystemClockEventListener);
        }
        return true;
    }

    @Deprecated
    public boolean unregisterOnTimerEventListener(TimerManager.OnTimerEventListener onTimerEventListener) {
        synchronized (this.mTimerEventListeners) {
            this.mTimerEventListeners.remove(onTimerEventListener);
        }
        return true;
    }

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