package com.seewo.libmcuservice;

import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
import com.seewo.libmcuservice.aidl.IMcuService;
import com.seewo.libmcuservice.aidl.IServiceCallback;
import com.seewo.libmcuservice.aidl.ITouchService;
import com.seewo.libmcuservice.constant.ITouchConstants;

/* JADX INFO: loaded from: classes.dex */
public class TouchBox extends AbstractMailbox {
    private static final String TAG = "TouchBox";
    private AbsTouchCallback mCallback;
    private ITouchService mService;
    private IServiceCallback mServiceCallback = new IServiceCallback.Stub() { // from class: com.seewo.libmcuservice.TouchBox.1
        @Override // com.seewo.libmcuservice.aidl.IServiceCallback
        public void onCallback(int i, Bundle bundle) throws RemoteException {
            if (i == 1) {
                TouchBox.this.mCallback.onTouchSet();
                return;
            }
            if (i == 102) {
                if (TouchBox.this.mCallback != null) {
                    TouchBox.this.mCallback.onSetTouchSourceBack(bundle.getInt(ITouchConstants.KEY_TOUCH_SOURCE));
                    return;
                }
                return;
            }
            if (i == 104) {
                if (TouchBox.this.mCallback != null) {
                    TouchBox.this.mCallback.onGetTouchSourceBack(bundle.getInt(ITouchConstants.KEY_TOUCH_SOURCE));
                    return;
                }
                return;
            }
            if (i == 3) {
                TouchBox.this.mCallback.onTouchEnable(bundle.getBoolean(ITouchConstants.KEY_TOUCH_STATUS_BACK));
                return;
            }
            if (i == 4) {
                TouchBox.this.mCallback.onTouchRemoteSwitch(bundle.getInt(ITouchConstants.KEY_REMOTE_STATUS_BACK));
                return;
            }
            if (i == 6) {
                TouchBox.this.mCallback.onCheckTouchInPC(bundle.getInt(ITouchConstants.KEY_CHEK_TOUCH_STATUS_BACK));
                return;
            }
            if (i == 7) {
                TouchBox.this.mCallback.onU73Gesture(bundle.getInt(ITouchConstants.KEY_GESTURE));
                return;
            }
            if (i == 8) {
                TouchBox.this.mCallback.onTouchPadLightHelloBack(bundle.getInt(ITouchConstants.TOUCHPAD_LIGHT_DATA_TYPE), bundle.getInt(ITouchConstants.TOUCHPAD_LIGHT_COLLECT_TIME));
            } else if (i == 112) {
                if (TouchBox.this.mCallback != null) {
                    TouchBox.this.mCallback.onGetCapTouchUpgradeBack((ITouchConstants.CapTouchUpgradeType) bundle.getSerializable(ITouchConstants.KEY_CAP_TOUCH_UPGRADE_TYPE));
                }
            } else if (i == 113 && TouchBox.this.mCallback != null) {
                TouchBox.this.mCallback.onSetCapTouchUpgradeBack((ITouchConstants.CapTouchUpgradeType) bundle.getSerializable(ITouchConstants.KEY_CAP_TOUCH_UPGRADE_TYPE));
            }
        }
    };

    public static abstract class AbsTouchCallback {
        protected void onCheckTouchInPC(int i) {
        }

        protected void onGetCapTouchUpgradeBack(ITouchConstants.CapTouchUpgradeType capTouchUpgradeType) {
        }

        protected void onGetTouchSourceBack(int i) {
        }

        protected void onSetCapTouchUpgradeBack(ITouchConstants.CapTouchUpgradeType capTouchUpgradeType) {
        }

        protected void onSetTouchSourceBack(int i) {
        }

        protected void onTouchEnable(boolean z) {
        }

        protected void onTouchPadLightHelloBack(int i, int i2) {
        }

        protected void onTouchRemoteSwitch(int i) {
        }

        protected void onTouchSet() {
        }

        protected void onU73Gesture(int i) {
        }
    }

    TouchBox(AbsTouchCallback absTouchCallback) {
        this.mCallback = absTouchCallback;
    }

    @Override // com.seewo.libmcuservice.AbstractMailbox
    protected void clearService() {
        this.mService = null;
    }

    @Override // com.seewo.libmcuservice.AbstractMailbox
    protected void initService(IMcuService iMcuService) {
        try {
            ITouchService touchService = iMcuService.getTouchService();
            this.mService = touchService;
            if (this.mCallback != null) {
                touchService.registerCallback(this.mServiceCallback);
            }
        } catch (RemoteException e2) {
            Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
        }
    }

    @Override // com.seewo.libmcuservice.AbstractMailbox
    protected void onWorkDone() {
    }

    public void postCheckTouchInPC() {
        ITouchService iTouchService = this.mService;
        if (iTouchService != null) {
            try {
                iTouchService.sendMessage(McuMailboxes.getID(), 6, new Bundle());
            } catch (RemoteException e2) {
                Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
            }
        }
    }

    public void postGetCapTouchUpgrade() {
        ITouchService iTouchService = this.mService;
        if (iTouchService != null) {
            try {
                iTouchService.sendMessage(McuMailboxes.getID(), ITouchConstants.ACTION_IN_GET_CAP_TOUCH_UPGRADE, new Bundle());
            } catch (RemoteException e2) {
                Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
            }
        }
    }

    public void postGetTouchSource() {
        ITouchService iTouchService = this.mService;
        if (iTouchService != null) {
            try {
                iTouchService.sendMessage(McuMailboxes.getID(), 103, new Bundle());
            } catch (RemoteException e2) {
                Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
            }
        }
    }

    public void postResetTouchpad() {
        ITouchService iTouchService = this.mService;
        if (iTouchService != null) {
            try {
                iTouchService.sendMessage(McuMailboxes.getID(), 1, new Bundle());
            } catch (RemoteException e2) {
                Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
            }
        }
    }

    public void postSetAgingTouch(boolean z) {
        ITouchService iTouchService = this.mService;
        if (iTouchService != null) {
            try {
                if (z) {
                    iTouchService.sendMessage(McuMailboxes.getID(), 105, new Bundle());
                } else {
                    iTouchService.sendMessage(McuMailboxes.getID(), ITouchConstants.ACTION_IN_SET_AGING_TOUCH_OFF, new Bundle());
                }
            } catch (RemoteException e2) {
                Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
            }
        }
    }

    public void postSetCapTouchUpgrade(ITouchConstants.CapTouchUpgradeType capTouchUpgradeType) {
        if (this.mService != null) {
            try {
                Bundle bundle = new Bundle();
                bundle.putSerializable(ITouchConstants.KEY_CAP_TOUCH_UPGRADE_TYPE, capTouchUpgradeType);
                this.mService.sendMessage(McuMailboxes.getID(), 111, bundle);
            } catch (RemoteException e2) {
                Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
            }
        }
    }

    public void postSetTouchAGC() {
        ITouchService iTouchService = this.mService;
        if (iTouchService != null) {
            try {
                iTouchService.sendMessage(McuMailboxes.getID(), 7, new Bundle());
            } catch (RemoteException e2) {
                Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
            }
        }
    }

    public void postSetTouchSource(int i) {
        if (this.mService != null) {
            try {
                Bundle bundle = new Bundle();
                bundle.putInt(ITouchConstants.KEY_TOUCH_SOURCE, i);
                this.mService.sendMessage(McuMailboxes.getID(), 101, bundle);
            } catch (RemoteException e2) {
                Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
            }
        }
    }

    public void postSetTouchSwitch(boolean z) {
        if (this.mService != null) {
            Bundle bundle = new Bundle();
            bundle.putBoolean(ITouchConstants.KEY_TOUCH_SWITCH_INFO, z);
            try {
                this.mService.sendMessage(McuMailboxes.getID(), 5, bundle);
            } catch (RemoteException e2) {
                Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
            }
        }
    }

    public void postTouchDisable() {
        ITouchService iTouchService = this.mService;
        if (iTouchService != null) {
            try {
                iTouchService.sendMessage(McuMailboxes.getID(), 3, new Bundle());
            } catch (RemoteException e2) {
                Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
            }
        }
    }

    public void postTouchEnable() {
        ITouchService iTouchService = this.mService;
        if (iTouchService != null) {
            try {
                iTouchService.sendMessage(McuMailboxes.getID(), 2, new Bundle());
            } catch (RemoteException e2) {
                Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
            }
        }
    }

    public void postTouchForceSwitch(int i) {
        if (this.mService != null) {
            Bundle bundle = new Bundle();
            bundle.putInt(ITouchConstants.KEY_REMOTE_STATUS, i);
            try {
                this.mService.sendMessage(McuMailboxes.getID(), 4, bundle);
            } catch (RemoteException e2) {
                Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
            }
        }
    }

    public void postTouchPadHello(int i, int i2, int i3, int i4) {
        if (this.mService != null) {
            try {
                Bundle bundle = new Bundle();
                bundle.putInt(ITouchConstants.KEY_TOUCHPAD_LIGHT_LT, i);
                bundle.putInt(ITouchConstants.KEY_TOUCHPAD_LIGHT_RT, i2);
                bundle.putInt(ITouchConstants.KEY_TOUCHPAD_LIGHT_RB, i3);
                bundle.putInt(ITouchConstants.KEY_TOUCHPAD_LIGHT_LB, i4);
                this.mService.sendMessage(McuMailboxes.getID(), 8, bundle);
            } catch (RemoteException e2) {
                Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
            }
        }
    }

    public void postTouchPadRawData(int i, int i2, int i3, int i4) {
        if (this.mService != null) {
            try {
                Bundle bundle = new Bundle();
                bundle.putInt(ITouchConstants.KEY_TOUCHPAD_LIGHT_LT, i);
                bundle.putInt(ITouchConstants.KEY_TOUCHPAD_LIGHT_RT, i2);
                bundle.putInt(ITouchConstants.KEY_TOUCHPAD_LIGHT_RB, i3);
                bundle.putInt(ITouchConstants.KEY_TOUCHPAD_LIGHT_LB, i4);
                this.mService.sendMessage(McuMailboxes.getID(), 10, bundle);
            } catch (RemoteException e2) {
                Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
            }
        }
    }

    public void postTouchPadStatusData(int i, int i2, int i3, int i4) {
        if (this.mService != null) {
            try {
                Bundle bundle = new Bundle();
                bundle.putInt(ITouchConstants.KEY_TOUCHPAD_LIGHT_LT, i);
                bundle.putInt(ITouchConstants.KEY_TOUCHPAD_LIGHT_RT, i2);
                bundle.putInt(ITouchConstants.KEY_TOUCHPAD_LIGHT_RB, i3);
                bundle.putInt(ITouchConstants.KEY_TOUCHPAD_LIGHT_LB, i4);
                this.mService.sendMessage(McuMailboxes.getID(), 9, bundle);
            } catch (RemoteException e2) {
                Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
            }
        }
    }

    @Override // com.seewo.libmcuservice.AbstractMailbox
    protected void release() {
        ITouchService iTouchService;
        if (this.mCallback == null || (iTouchService = this.mService) == null) {
            return;
        }
        try {
            iTouchService.unregisterCallback(this.mServiceCallback);
        } catch (RemoteException e2) {
            Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
        }
    }
}
