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 i2, Bundle bundle) {
            if (i2 == 1) {
                TouchBox.this.mCallback.onTouchSet();
                return;
            }
            if (i2 == 102) {
                if (TouchBox.this.mCallback != null) {
                    TouchBox.this.mCallback.onSetTouchSourceBack(bundle.getInt(ITouchConstants.KEY_TOUCH_SOURCE));
                    return;
                }
                return;
            }
            if (i2 == 104) {
                if (TouchBox.this.mCallback != null) {
                    TouchBox.this.mCallback.onGetTouchSourceBack(bundle.getInt(ITouchConstants.KEY_TOUCH_SOURCE));
                    return;
                }
                return;
            }
            if (i2 == 3) {
                TouchBox.this.mCallback.onTouchEnable(bundle.getBoolean(ITouchConstants.KEY_TOUCH_STATUS_BACK));
                return;
            }
            if (i2 == 4) {
                TouchBox.this.mCallback.onTouchRemoteSwitch(bundle.getInt(ITouchConstants.KEY_REMOTE_STATUS_BACK));
                return;
            }
            if (i2 == 6) {
                TouchBox.this.mCallback.onCheckTouchInPC(bundle.getInt(ITouchConstants.KEY_CHEK_TOUCH_STATUS_BACK));
                return;
            }
            if (i2 == 7) {
                TouchBox.this.mCallback.onU73Gesture(bundle.getInt(ITouchConstants.KEY_GESTURE));
                return;
            }
            if (i2 == 8) {
                TouchBox.this.mCallback.onTouchPadLightHelloBack(bundle.getInt(ITouchConstants.TOUCHPAD_LIGHT_DATA_TYPE), bundle.getInt(ITouchConstants.TOUCHPAD_LIGHT_COLLECT_TIME));
            } else if (i2 == 112) {
                if (TouchBox.this.mCallback != null) {
                    TouchBox.this.mCallback.onGetCapTouchUpgradeBack((ITouchConstants.CapTouchUpgradeType) bundle.getSerializable(ITouchConstants.KEY_CAP_TOUCH_UPGRADE_TYPE));
                }
            } else if (i2 == 113 && TouchBox.this.mCallback != null) {
                TouchBox.this.mCallback.onSetCapTouchUpgradeBack((ITouchConstants.CapTouchUpgradeType) bundle.getSerializable(ITouchConstants.KEY_CAP_TOUCH_UPGRADE_TYPE));
            }
        }
    };

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

        public void onGetCapTouchUpgradeBack(ITouchConstants.CapTouchUpgradeType capTouchUpgradeType) {
        }

        public void onGetTouchSourceBack(int i2) {
        }

        public void onSetCapTouchUpgradeBack(ITouchConstants.CapTouchUpgradeType capTouchUpgradeType) {
        }

        public void onSetTouchSourceBack(int i2) {
        }

        public void onTouchEnable(boolean z) {
        }

        public void onTouchPadLightHelloBack(int i2, int i3) {
        }

        public void onTouchRemoteSwitch(int i2) {
        }

        public void onTouchSet() {
        }

        public void onU73Gesture(int i2) {
        }
    }

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

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

    @Override // com.seewo.libmcuservice.AbstractMailbox
    public 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
    public 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(), 110, 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) {
        String id;
        int i2;
        Bundle bundle;
        ITouchService iTouchService = this.mService;
        if (iTouchService != null) {
            try {
                if (z) {
                    id = McuMailboxes.getID();
                    i2 = 105;
                    bundle = new Bundle();
                } else {
                    id = McuMailboxes.getID();
                    i2 = 106;
                    bundle = new Bundle();
                }
                iTouchService.sendMessage(id, i2, 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 i2) {
        if (this.mService != null) {
            try {
                Bundle bundle = new Bundle();
                bundle.putInt(ITouchConstants.KEY_TOUCH_SOURCE, i2);
                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 i2) {
        if (this.mService != null) {
            Bundle bundle = new Bundle();
            bundle.putInt(ITouchConstants.KEY_REMOTE_STATUS, i2);
            try {
                this.mService.sendMessage(McuMailboxes.getID(), 4, bundle);
            } catch (RemoteException e2) {
                Log.e(TAG, LibMcuApplication.REMOTE_EXCEPTION, e2);
            }
        }
    }

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

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

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

    @Override // com.seewo.libmcuservice.AbstractMailbox
    public 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);
        }
    }
}
