导航菜单

页面标题

页面副标题

Petal Maps v4.7.0.310001 - IntentionExecutorCallBackImpl.java 源代码

正在查看: Petal Maps v4.7.0.310001 应用的 IntentionExecutorCallBackImpl.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.huawei.hiassistant.platform.framework.intentionexecutor;

import android.content.Intent;
import android.os.Parcelable;
import com.huawei.hiassistant.platform.base.messagebus.SwitchConsumer;
import com.huawei.hiassistant.platform.base.module.IntentionExecutorInterface;
import com.huawei.hiassistant.platform.base.module.PlatformModule;
import com.huawei.hiassistant.platform.base.module.TimerInfo;
import com.huawei.hiassistant.platform.base.msg.PlatformMsg;
import com.huawei.hiassistant.platform.base.util.KitLog;
import com.huawei.hiassistant.platform.base.util.SecureIntentUtil;
import com.huawei.hiassistant.platform.framework.bus.FrameworkBus;
import com.huawei.hiassistant.platform.framework.bus.msg.MessageSenderInterface;
import com.huawei.hiassistant.platform.framework.intentionexecutor.IntentionExecutorCallBackImpl;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;

public class IntentionExecutorCallBackImpl implements IntentionExecutorInterface.CallBack {
    private static final String TAG = "IntentionExecutorCallBackImpl";
    private SwitchConsumer<Object> consumers;

    public static class a {
        public static final int[] a;
        public static final int[] b;

        static {
            int[] iArr = new int[IntentionExecutorInterface.ExecutorCode.values().length];
            b = iArr;
            try {
                iArr[IntentionExecutorInterface.ExecutorCode.DISMISS_GUARD.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                b[IntentionExecutorInterface.ExecutorCode.CALLBACK_RESULT.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            int[] iArr2 = new int[IntentionExecutorInterface.CommanderCode.values().length];
            a = iArr2;
            try {
                iArr2[IntentionExecutorInterface.CommanderCode.START_ACQUISITION.ordinal()] = 1;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                a[IntentionExecutorInterface.CommanderCode.START_INTENT_ACQUISITION.ordinal()] = 2;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                a[IntentionExecutorInterface.CommanderCode.CANCEL_INTERRUPT_RECOGNIZE.ordinal()] = 3;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                a[IntentionExecutorInterface.CommanderCode.CANCEL_FULLDUPLEX_RECOGNIZE.ordinal()] = 4;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                a[IntentionExecutorInterface.CommanderCode.UPDATE_VOICE_CONTEXT.ordinal()] = 5;
            } catch (NoSuchFieldError unused7) {
            }
            try {
                a[IntentionExecutorInterface.CommanderCode.RESEND_NLU.ordinal()] = 6;
            } catch (NoSuchFieldError unused8) {
            }
            try {
                a[IntentionExecutorInterface.CommanderCode.UPDATE_EVENT.ordinal()] = 7;
            } catch (NoSuchFieldError unused9) {
            }
            try {
                a[IntentionExecutorInterface.CommanderCode.SEND_SPEAK_DIRECTIVE.ordinal()] = 8;
            } catch (NoSuchFieldError unused10) {
            }
            try {
                a[IntentionExecutorInterface.CommanderCode.SEND_STREAM_SPEAK_DIRECTIVE.ordinal()] = 9;
            } catch (NoSuchFieldError unused11) {
            }
        }
    }

    public IntentionExecutorCallBackImpl() {
        SwitchConsumer<Object> switchConsumer = new SwitchConsumer<>();
        this.consumers = switchConsumer;
        switchConsumer.addCommand(IntentionExecutorInterface.CommanderCode.CALL_DECISION_SERVICE.name(), new Consumer() {
            @Override
            public final void accept(Object obj) {
                IntentionExecutorCallBackImpl.this.handleCallDecisionService(obj);
            }
        });
        this.consumers.addCommand(IntentionExecutorInterface.CommanderCode.EXECUTOR_FINISHED.name(), new Consumer() {
            @Override
            public final void accept(Object obj) {
                IntentionExecutorCallBackImpl.this.handleExecutorFinished(obj);
            }
        });
        this.consumers.addCommand(IntentionExecutorInterface.CommanderCode.START_TIMER.name(), new Consumer() {
            @Override
            public final void accept(Object obj) {
                IntentionExecutorCallBackImpl.this.handleStartTimer(obj);
            }
        });
        this.consumers.addCommand(IntentionExecutorInterface.CommanderCode.REMOVE_TIMER.name(), new Consumer() {
            @Override
            public final void accept(Object obj) {
                IntentionExecutorCallBackImpl.this.handleRemoveTimer(obj);
            }
        });
        this.consumers.addCommand(IntentionExecutorInterface.CommanderCode.SEND_ACTION_TO_EXECUTOR.name(), new Consumer() {
            @Override
            public final void accept(Object obj) {
                IntentionExecutorCallBackImpl.this.handleSendActionToExecutor(obj);
            }
        });
        this.consumers.addCommand(IntentionExecutorInterface.CommanderCode.SEND_INSERT_RESULT.name(), new Consumer() {
            @Override
            public final void accept(Object obj) {
                IntentionExecutorCallBackImpl.this.handleSendInsertResult(obj);
            }
        });
        this.consumers.addCommand(IntentionExecutorInterface.CommanderCode.UPLOAD_CLIENT_INFO.name(), new Consumer() {
            @Override
            public final void accept(Object obj) {
                IntentionExecutorCallBackImpl.this.handleUploadClientInfo(obj);
            }
        });
        this.consumers.addCommand(IntentionExecutorInterface.CommanderCode.SEND_APP_DIALOG_FINISHED.name(), new Consumer() {
            @Override
            public final void accept(Object obj) {
                IntentionExecutorCallBackImpl.this.handleSendAppDialogFinished(obj);
            }
        });
        this.consumers.addCommand(IntentionExecutorInterface.CommanderCode.SEND_APP_CONTINUE_DIALOG.name(), new Consumer() {
            @Override
            public final void accept(Object obj) {
                IntentionExecutorCallBackImpl.this.handleSendAppContinueDialog(obj);
            }
        });
        this.consumers.addCommand(IntentionExecutorInterface.CommanderCode.SEND_POST_MESSAGE.name(), new Consumer() {
            @Override
            public final void accept(Object obj) {
                IntentionExecutorCallBackImpl.this.handlePostMessage(obj);
            }
        });
        this.consumers.addCommand(IntentionExecutorInterface.CommanderCode.SEND_APP_REJECT_RECOGNIZE.name(), new Consumer() {
            @Override
            public final void accept(Object obj) {
                IntentionExecutorCallBackImpl.this.handleSendAppRejectRecognize(obj);
            }
        });
    }

    public void handleCallDecisionService(Object obj) {
        FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_EXECUTOR, PlatformModule.INTENTION_HANDLER, PlatformMsg.Data.INTENTION_HANDLER_CALL_DECISION_SERVICE, obj);
    }

    public void handleExecutorFinished(Object obj) {
        Parcelable parcelable;
        long j;
        if (obj instanceof Intent) {
            Intent intent = (Intent) obj;
            long secureIntentLong = SecureIntentUtil.getSecureIntentLong(intent, "delayTime", 0L);
            parcelable = intent.getParcelableExtra("body");
            j = secureIntentLong;
        } else {
            parcelable = null;
            j = 0;
        }
        if (j <= 0 || parcelable == null) {
            FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_EXECUTOR, PlatformModule.INTENTION_HANDLER, PlatformMsg.Ctl.INTENTION_EXECUTOR_RESULT, obj);
        } else {
            FrameworkBus.msg().sendMsgDelayed(PlatformModule.INTENTION_EXECUTOR, PlatformModule.INTENTION_HANDLER, PlatformMsg.Ctl.INTENTION_EXECUTOR_RESULT, j, parcelable);
        }
    }

    public <T> void handlePostMessage(T t) {
        FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_EXECUTOR, PlatformModule.ASSISTANT_CONTROLLER, PlatformMsg.Ctl.NORTH_INTERFACE_POST_MESSAGE, t);
    }

    public void handleRemoveTimer(Object obj) {
        Optional.ofNullable(obj).filter(new Predicate() {
            @Override
            public final boolean test(Object obj2) {
                boolean lambda$handleRemoveTimer$0;
                lambda$handleRemoveTimer$0 = IntentionExecutorCallBackImpl.lambda$handleRemoveTimer$0(obj2);
                return lambda$handleRemoveTimer$0;
            }
        }).map(new Function() {
            @Override
            public final Object apply(Object obj2) {
                Integer lambda$handleRemoveTimer$1;
                lambda$handleRemoveTimer$1 = IntentionExecutorCallBackImpl.lambda$handleRemoveTimer$1(obj2);
                return lambda$handleRemoveTimer$1;
            }
        }).ifPresent(new Consumer() {
            @Override
            public final void accept(Object obj2) {
                IntentionExecutorCallBackImpl.lambda$handleRemoveTimer$2((Integer) obj2);
            }
        });
    }

    public void handleSendActionToExecutor(Object obj) {
        MessageSenderInterface msg = FrameworkBus.msg();
        PlatformModule platformModule = PlatformModule.INTENTION_EXECUTOR;
        msg.sendMsg(platformModule, platformModule, PlatformMsg.Data.INTENTION_EXECUTOR_SEND_ACTION_TO_EXECUTOR, obj);
    }

    public void handleSendAppContinueDialog(Object obj) {
        FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_EXECUTOR, PlatformModule.INTENTION_HANDLER, PlatformMsg.Ctl.INTENTION_EXECUTOR_SEND_APP_CONTINUE_DIALOG, obj);
    }

    public void handleSendAppDialogFinished(Object obj) {
        Parcelable parcelable;
        long j;
        if (obj instanceof Intent) {
            Intent intent = (Intent) obj;
            long secureIntentLong = SecureIntentUtil.getSecureIntentLong(intent, "delayTime", 0L);
            parcelable = intent.getParcelableExtra("body");
            j = secureIntentLong;
        } else {
            parcelable = null;
            j = 0;
        }
        if (j <= 0 || parcelable == null) {
            FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_EXECUTOR, PlatformModule.INTENTION_HANDLER, PlatformMsg.Ctl.INTENTION_EXECUTOR_SEND_APP_DIALOG_FINISHED, obj);
        } else {
            FrameworkBus.msg().sendMsgDelayed(PlatformModule.INTENTION_EXECUTOR, PlatformModule.INTENTION_HANDLER, PlatformMsg.Ctl.INTENTION_EXECUTOR_SEND_APP_DIALOG_FINISHED, j, parcelable);
        }
    }

    public void handleSendAppRejectRecognize(Object obj) {
        FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_EXECUTOR, PlatformModule.INTENTION_HANDLER, PlatformMsg.Ctl.INTENTION_EXECUTOR_SEND_APP_REJECT_RECOGNIZE, obj);
    }

    public void handleSendInsertResult(Object obj) {
        MessageSenderInterface msg = FrameworkBus.msg();
        PlatformModule platformModule = PlatformModule.INTENTION_EXECUTOR;
        msg.sendMsg(platformModule, platformModule, PlatformMsg.Data.INTENTION_HANDLER_RESULT, obj);
    }

    public void handleStartTimer(Object obj) {
        Optional.ofNullable(obj).filter(new Predicate() {
            @Override
            public final boolean test(Object obj2) {
                boolean lambda$handleStartTimer$3;
                lambda$handleStartTimer$3 = IntentionExecutorCallBackImpl.lambda$handleStartTimer$3(obj2);
                return lambda$handleStartTimer$3;
            }
        }).map(new Function() {
            @Override
            public final Object apply(Object obj2) {
                TimerInfo lambda$handleStartTimer$4;
                lambda$handleStartTimer$4 = IntentionExecutorCallBackImpl.lambda$handleStartTimer$4(obj2);
                return lambda$handleStartTimer$4;
            }
        }).ifPresent(new Consumer() {
            @Override
            public final void accept(Object obj2) {
                IntentionExecutorCallBackImpl.lambda$handleStartTimer$5((TimerInfo) obj2);
            }
        });
    }

    public void handleUploadClientInfo(Object obj) {
        FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_EXECUTOR, PlatformModule.INTENTION_HANDLER, PlatformMsg.Data.INTENTION_EXECUTOR_UPLOAD_CLIENT_INFO, obj);
    }

    public static boolean lambda$handleRemoveTimer$0(Object obj) {
        return obj instanceof Integer;
    }

    public static Integer lambda$handleRemoveTimer$1(Object obj) {
        return (Integer) obj;
    }

    public static void lambda$handleRemoveTimer$2(Integer num) {
        KitLog.debug(TAG, "onCommanderProcess REMOVE_TIMER {}", num);
        MessageSenderInterface msg = FrameworkBus.msg();
        PlatformModule platformModule = PlatformModule.INTENTION_EXECUTOR;
        msg.removeMsg(platformModule, platformModule, num.intValue());
    }

    public static boolean lambda$handleStartTimer$3(Object obj) {
        return obj instanceof TimerInfo;
    }

    public static TimerInfo lambda$handleStartTimer$4(Object obj) {
        return (TimerInfo) obj;
    }

    public static void lambda$handleStartTimer$5(TimerInfo timerInfo) {
        KitLog.debug(TAG, "onCommanderProcess START_TIMER {} {}", Integer.valueOf(timerInfo.getTimerCode()), Long.valueOf(timerInfo.getDelayTimeLength()));
        MessageSenderInterface msg = FrameworkBus.msg();
        PlatformModule platformModule = PlatformModule.INTENTION_EXECUTOR;
        msg.sendMsgDelayed(platformModule, platformModule, timerInfo.getTimerCode(), timerInfo.getDelayTimeLength(), timerInfo.getObject());
    }

    @Override
    public void onCommanderProcess(IntentionExecutorInterface.CommanderCode commanderCode, Object obj) {
        int i;
        if (commanderCode == null || this.consumers.process(commanderCode.name(), obj)) {
            return;
        }
        switch (a.a[commanderCode.ordinal()]) {
            case 1:
                i = PlatformMsg.CtlExt.INTENTION_EXECUTOR_START_ACQUISITION;
                break;
            case 2:
                i = PlatformMsg.CtlExt.INTENTION_EXECUTOR_START_INTENT_ACQUISITION;
                break;
            case 3:
                i = PlatformMsg.CtlExt.INTENTION_EXECUTOR_INTERRUPT_ABORT;
                break;
            case 4:
                i = PlatformMsg.CtlExt.INTENTION_EXECUTOR_FULLDUPLEX_ABORT;
                break;
            case 5:
                i = PlatformMsg.Ctl.INTENTION_EXECUTOR_UPDATE_VOICE_CONTEXT;
                break;
            case 6:
                i = PlatformMsg.Ctl.INTENTION_EXECUTOR_RESEND_NLU;
                break;
            case 7:
                i = PlatformMsg.Ctl.INTENTION_EXECUTOR_UPDATE_EVENT;
                break;
            case 8:
                i = PlatformMsg.Ctl.INTENTION_EXECUTOR_TEXT_TO_SPEAK;
                break;
            case 9:
                i = PlatformMsg.Ctl.INTENTION_EXECUTOR_STREAM_TEXT_TO_SPEAK;
                break;
            default:
                i = 0;
                break;
        }
        FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_EXECUTOR, PlatformModule.ASSISTANT_CONTROLLER, i, obj);
    }

    @Override
    public void onError(IntentionExecutorInterface.ErrorCode errorCode, String str) {
        KitLog.info(TAG, "onError = " + errorCode + " ,errMsg: " + str);
    }

    @Override
    public void onExecutorResult(IntentionExecutorInterface.ExecutorCode executorCode, Object obj) {
        int i = a.b[executorCode.ordinal()];
        if (i == 1) {
            MessageSenderInterface msg = FrameworkBus.msg();
            PlatformModule platformModule = PlatformModule.INTENTION_EXECUTOR;
            msg.sendMsg(platformModule, platformModule, PlatformMsg.Ctl.INTENTION_EXECUTOR_DISMISS_GUARD_COMPLETED, obj);
        } else {
            if (i != 2) {
                return;
            }
            MessageSenderInterface msg2 = FrameworkBus.msg();
            PlatformModule platformModule2 = PlatformModule.INTENTION_EXECUTOR;
            msg2.sendMsg(platformModule2, platformModule2, PlatformMsg.CtlExt.INTENTION_EXECUTOR_CALL_RETURN, obj);
        }
    }

    @Override
    public void onUiProcess(Object obj) {
        FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_EXECUTOR, PlatformModule.NORTH_INTERFACE, PlatformMsg.CtlExt.INTENTION_EXECUTOR_UI_MESSAGE, obj);
    }
}