package com.mstar.android.tv;

import android.os.RemoteException;
import android.util.Log;
import com.mstar.android.tvapi.common.vo.CCSetting;
import com.mstar.android.tvapi.common.vo.CaptionOptionSetting;

/* JADX INFO: loaded from: classes.dex */
public class TvCcManager {
    public static final int ATSC_CC_MODE_NUM = 3;
    public static final int ATSC_CC_MODE_OFF = 1;
    public static final int ATSC_CC_MODE_ON = 0;
    public static final int ATSC_CC_MODE_ONMUTE = 2;
    public static final int CAPTION_CC1 = 2;
    public static final int CAPTION_CC2 = 3;
    public static final int CAPTION_CC3 = 4;
    public static final int CAPTION_CC4 = 5;
    public static final int CAPTION_OFF = 0;
    public static final int CAPTION_ON = 1;
    public static final int CAPTION_TEXT1 = 6;
    public static final int CAPTION_TEXT2 = 7;
    public static final int CAPTION_TEXT3 = 8;
    public static final int CAPTION_TEXT4 = 9;
    public static final short CC_COLOR_BLACK = 0;
    public static final short CC_COLOR_BLUE = 4;
    public static final short CC_COLOR_CYAN = 6;
    public static final short CC_COLOR_DEFAULT = 8;
    public static final short CC_COLOR_GREEN = 2;
    public static final short CC_COLOR_MAGENTA = 5;
    public static final short CC_COLOR_RED = 1;
    public static final short CC_COLOR_WHITE = 7;
    public static final short CC_COLOR_YELLOW = 3;
    public static final short CC_EDGE_STYLE_DEFAULT = 6;
    public static final short CC_EDGE_STYLE_DEPRESSED = 2;
    public static final short CC_EDGE_STYLE_LEFT_SHADOW = 4;
    public static final short CC_EDGE_STYLE_NONE = 0;
    public static final short CC_EDGE_STYLE_RAISED = 1;
    public static final short CC_EDGE_STYLE_RIGHT_SHADOW = 5;
    public static final short CC_EDGE_STYLE_UNIFORM = 3;
    public static final short CC_FONT_SIZE_DEFAULT = 3;
    public static final short CC_FONT_SIZE_LARGE = 2;
    public static final short CC_FONT_SIZE_NORMAL = 0;
    public static final short CC_FONT_SIZE_SMALL = 1;
    public static final short CC_FONT_STYLE_DEFAULT = 0;
    public static final short CC_FONT_STYLE_STYLE1 = 1;
    public static final short CC_FONT_STYLE_STYLE2 = 2;
    public static final short CC_FONT_STYLE_STYLE3 = 3;
    public static final short CC_FONT_STYLE_STYLE4 = 4;
    public static final short CC_FONT_STYLE_STYLE5 = 5;
    public static final short CC_FONT_STYLE_STYLE6 = 6;
    public static final short CC_FONT_STYLE_STYLE7 = 7;
    public static final short CC_ITALIC_OFF = 0;
    public static final short CC_ITALIC_ON = 1;
    public static final short CC_MODE_CUSTOM = 0;
    public static final short CC_MODE_DEFAULT = 1;
    public static final short CC_OPACITY_DEFAULT = 4;
    public static final short CC_OPACITY_FLASHING = 1;
    public static final short CC_OPACITY_SOLID = 0;
    public static final short CC_OPACITY_TRANSLUCENT = 2;
    public static final short CC_OPACITY_TRANSPARENT = 3;
    public static final short CC_UNDERLINE_OFF = 0;
    public static final short CC_UNDERLINE_ON = 1;
    public static final int CLOSED_CAPTION_CC1 = 3;
    public static final int CLOSED_CAPTION_CC2 = 4;
    public static final int CLOSED_CAPTION_CC3 = 5;
    public static final int CLOSED_CAPTION_CC4 = 6;
    public static final int CLOSED_CAPTION_OFF = 0;
    public static final int CLOSED_CAPTION_ON = 1;
    public static final int CLOSED_CAPTION_ON_WHEN_MUTE = 2;
    public static final int CLOSED_CAPTION_TEXT1 = 7;
    public static final int CLOSED_CAPTION_TEXT2 = 8;
    public static final int CLOSED_CAPTION_TEXT3 = 9;
    public static final int CLOSED_CAPTION_TEXT4 = 10;
    private static final String TAG = "TvCcManager";
    static TvCcManager mInstance;
    private static ITvCc mService;

    private TvCcManager() {
    }

    public static TvCcManager getInstance() {
        if (mInstance == null) {
            synchronized (TvCcManager.class) {
                try {
                    if (mInstance == null) {
                        mInstance = new TvCcManager();
                    }
                } finally {
                }
            }
        }
        return mInstance;
    }

    private static ITvCc getService() {
        ITvCc iTvCc = mService;
        if (iTvCc != null) {
            return iTvCc;
        }
        if (true == TvServiceBinder.isNeedBindService()) {
            ITvService tvService = TvServiceBinder.getTvService();
            if (tvService == null) {
                Log.e(TAG, "TvService doesn't exist!!");
                throw new NullPointerException("TvService doesn't exist.");
            }
            try {
                mService = tvService.getTvCc();
            } catch (RemoteException e2) {
                e2.printStackTrace();
            }
        } else {
            mService = TvManager.getInstance().getTvCc();
        }
        return mService;
    }

    public boolean creatPreviewCcWindow() {
        try {
            return getService().creatPreviewCcWindow();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean doesCcExist() throws RemoteException {
        try {
            return getService().doesCcExist();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean drawPreviewCc(CaptionOptionSetting captionOptionSetting) {
        Log.d(TAG, "drawPreviewCc paras CaptionOptionSetting setting.currProgInfoBGColor = " + ((int) captionOptionSetting.currProgInfoBGColor) + ", setting.currProgInfoBGOpacity = " + ((int) captionOptionSetting.currProgInfoBGOpacity) + ", setting.currProgInfoEdgeColor = " + ((int) captionOptionSetting.currProgInfoEdgeColor) + ", setting.currProgInfoEdgeStyle = " + ((int) captionOptionSetting.currProgInfoEdgeStyle) + ", setting.currProgInfoFGColor = " + ((int) captionOptionSetting.currProgInfoFGColor) + ", setting.currProgInfoFGOpacity = " + ((int) captionOptionSetting.currProgInfoFGOpacity) + ", setting.currProgInfoFontSize = " + ((int) captionOptionSetting.currProgInfoFontSize) + ", setting.currProgInfoFontStyle = " + ((int) captionOptionSetting.currProgInfoFontStyle));
        try {
            return getService().drawPreviewCc(captionOptionSetting);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean exitPreviewCc() {
        try {
            return getService().exitPreviewCc();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public CaptionOptionSetting getAdvancedSetting(int i2) {
        try {
            return getService().getAdvancedSetting(i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public int getAtscCcMode() {
        if (TvCommonManager.getInstance().isSupportModule(8)) {
            return getCCSetting().ccMode;
        }
        throw new IllegalAccessError("Available only if Supernova Support CC");
    }

    public CCSetting getCCSetting() {
        try {
            return getService().getCCSetting();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    @Deprecated
    public int getCcMode() {
        return getIsdbCcMode();
    }

    public int getClosedCaptionMode() {
        try {
            return getService().getClosedCaptionMode();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 0;
        }
    }

    @Deprecated
    public int getIsdbCcMode() {
        if (!TvCommonManager.getInstance().isSupportModule(9)) {
            throw new IllegalAccessError("Available only if Supernova Support BRAZIL_CC");
        }
        try {
            return getService().getCcMode();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return -1;
        }
    }

    @Deprecated
    public int getNextAtscCcMode() {
        if (!TvCommonManager.getInstance().isSupportModule(8)) {
            throw new IllegalAccessError("Available only if Supernova Support CC");
        }
        int atscCcMode = (getAtscCcMode() + 1) % 3;
        setAtscCcMode(atscCcMode);
        return atscCcMode;
    }

    public int getNextClosedCaptionMode() {
        try {
            return getService().getNextClosedCaptionMode();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 0;
        }
    }

    @Deprecated
    public int getNextIsdbCcMode() {
        int i2;
        if (!TvCommonManager.getInstance().isSupportModule(9)) {
            throw new IllegalAccessError("Available only if Supernova Support BRAZIL_CC");
        }
        int isdbCcMode = getIsdbCcMode();
        int currentTvInputSource = TvCommonManager.getInstance().getCurrentTvInputSource();
        if (currentTvInputSource != 28) {
            if (currentTvInputSource == 1) {
                i2 = 10;
            }
            return isdbCcMode;
        }
        i2 = 2;
        isdbCcMode = (isdbCcMode + 1) % i2;
        if (isdbCcMode == 1 && (currentTvInputSource == 1 || currentTvInputSource == 2)) {
            isdbCcMode++;
        }
        setIsdbCcMode(isdbCcMode);
        return isdbCcMode;
    }

    @Deprecated
    public int getPreviousAtscCcMode() {
        if (!TvCommonManager.getInstance().isSupportModule(8)) {
            throw new IllegalAccessError("Available only if Supernova Support CC");
        }
        int atscCcMode = (getAtscCcMode() + 2) % 3;
        setAtscCcMode(atscCcMode);
        return atscCcMode;
    }

    public int getPreviousClosedCaptionMode() {
        try {
            return getService().getPreviousClosedCaptionMode();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return 0;
        }
    }

    @Deprecated
    public int getPreviousIsdbCcMode() {
        int i2;
        if (!TvCommonManager.getInstance().isSupportModule(9)) {
            throw new IllegalAccessError("Available only if Supernova Support BRAZIL_CC");
        }
        int isdbCcMode = getIsdbCcMode();
        int currentTvInputSource = TvCommonManager.getInstance().getCurrentTvInputSource();
        if (currentTvInputSource != 28) {
            i2 = currentTvInputSource == 1 ? 10 : 2;
            return isdbCcMode;
        }
        isdbCcMode = ((isdbCcMode - 1) + i2) % i2;
        if (isdbCcMode == 1 && currentTvInputSource == 1) {
            isdbCcMode--;
        }
        setIsdbCcMode(isdbCcMode);
        return isdbCcMode;
    }

    @Deprecated
    public int nextCcMode() {
        return getNextIsdbCcMode();
    }

    @Deprecated
    public int previousCcMode() {
        return getPreviousIsdbCcMode();
    }

    public void setAdvancedSetting(CaptionOptionSetting captionOptionSetting, int i2) {
        try {
            getService().setAdvancedSetting(captionOptionSetting, i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    @Deprecated
    public void setAtscCcMode(int i2) {
        if (!TvCommonManager.getInstance().isSupportModule(8)) {
            throw new IllegalAccessError("Available only if Supernova Support CC");
        }
        CCSetting cCSetting = getCCSetting();
        short s2 = cCSetting.ccMode;
        if (s2 != i2) {
            if (s2 == 0) {
                stopCc();
            }
            cCSetting.ccMode = (short) i2;
            setCCSetting(cCSetting);
            if (i2 == 0 || i2 == 2) {
                startCc();
            }
        }
    }

    public void setCCSetting(CCSetting cCSetting) {
        try {
            getService().setCCSetting(cCSetting);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    @Deprecated
    public void setCcMode(int i2) {
        setIsdbCcMode(i2);
    }

    public void setClosedCaptionMode(int i2) {
        try {
            getService().setClosedCaptionMode(i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    @Deprecated
    public void setIsdbCcMode(int i2) {
        if (!TvCommonManager.getInstance().isSupportModule(9)) {
            throw new IllegalAccessError("Available only if Supernova Support BRAZIL_CC");
        }
        try {
            getService().setCcMode(i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public boolean startCc() {
        try {
            return getService().startCc();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    public boolean stopCc() {
        try {
            return getService().stopCc();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return false;
        }
    }
}
