package com.mstar.android.tv;

import android.os.RemoteException;
import android.util.Log;
import java.util.List;
import java.util.Map;

/* JADX INFO: loaded from: classes.dex */
public class TvParentalControlManager {
    public static final int PARENTAL_CONTENT_DRUGS = 1;
    public static final int PARENTAL_CONTENT_NONE = 0;
    public static final int PARENTAL_CONTENT_SEX = 4;
    public static final int PARENTAL_CONTENT_SEX_DRUGS = 5;
    public static final int PARENTAL_CONTENT_VIOLENCE = 2;
    public static final int PARENTAL_CONTENT_VIOLENCE_DRUGS = 3;
    public static final int PARENTAL_CONTENT_VIOLENCE_SEX = 6;
    public static final int PARENTAL_CONTENT_VIOLENCE_SEX_DRUGS = 7;
    private static final String TAG = "TvParentalControlManager";
    static TvParentalControlManager mInstance;
    private static ITvParentalControl mService;

    private TvParentalControlManager() {
    }

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

    private static ITvParentalControl getService() {
        ITvParentalControl iTvParentalControl = mService;
        if (iTvParentalControl != null) {
            return iTvParentalControl;
        }
        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.getTvParentalControl();
            } catch (RemoteException e2) {
                e2.printStackTrace();
            }
        } else {
            mService = TvManager.getInstance().getTvParentalControl();
        }
        return mService;
    }

    private void setMheg5CommandType(boolean z2, int i2) {
        try {
            TvChannelManager.getInstance().sendMheg5IcsCommand(z2 ? getInstance().getParentalControlRating() < 4 ? 7 : 6 : 5, TvLanguage.ESPERANTO);
            TvChannelManager.getInstance().sendMheg5IcsCommand(i2, TvLanguage.EWE);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public Map constructParentalRatingCollection() {
        try {
            return getService().constructParentalRatingCollection();
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return null;
        }
    }

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

    public List<String> getCountryParentalRatingEnumeration(int i2) {
        try {
            return getService().getCountryParentalRatingEnumeration(i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return null;
        }
    }

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

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

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

    public int getParentalRatingByAge(int i2, int i3, boolean z2) {
        try {
            return getService().getParentalRatingByAge(i2, i3, z2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
            return -1;
        }
    }

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

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

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

    public void setParentalPassword(int i2) {
        ITvParentalControl service = getService();
        setMheg5CommandType(getInstance().isSystemLock(), i2);
        try {
            service.setParentalPassword(i2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void setSystemLock(boolean z2) {
        ITvParentalControl service = getService();
        setMheg5CommandType(z2, getInstance().getParentalPassword());
        try {
            service.setSystemLock(z2);
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }

    public void unlockChannel() {
        try {
            getService().unlockChannel();
        } catch (RemoteException e2) {
            e2.printStackTrace();
        }
    }
}
