导航菜单

页面标题

页面副标题

050 IP Phone v2.3.0 - CallAutomationService.java 源代码

正在查看: 050 IP Phone v2.3.0 应用的 CallAutomationService.java JAVA 源代码文件

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


package com.ntt.voip.android.test;

import android.app.Activity;
import android.app.Application;
import android.app.Dialog;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentActivity;
import com.ntt.voip.android.client.MainActivity;
import com.oki_access.android.ims.call.client.CallActivity;
import java.lang.ref.WeakReference;
import java.text.MessageFormat;
import l4.j;
import t4.z;
import w3.f;

public class CallAutomationService extends Service {
    private long A0;
    private long B0;
    private long C0;
    private long D0;
    private boolean E0;
    private int F0;
    private int G0;
    private boolean X;
    private Handler s0;
    private f t0;
    private d u0;
    private NotificationManager w0;
    private String x;
    private long y0;

    private long f45z0;
    private int y = 0;
    private WeakReference<Activity> Y = null;
    private b Z = null;
    private e v0 = null;
    private final long x0 = 5000;

    static class a {
        static final int[] a;

        static {
            int[] iArr = new int[c.values().length];
            a = iArr;
            try {
                iArr[c.NONE.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                a[c.DIAL.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                a[c.START.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                a[c.STOP.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                a[c.CLOSE_OTOKU_DIALOG.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
        }
    }

    private class b implements Application.ActivityLifecycleCallbacks {
        private b() {
        }

        @Override
        public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle bundle) {
        }

        @Override
        public void onActivityDestroyed(@NonNull Activity activity) {
        }

        @Override
        public void onActivityPaused(@NonNull Activity activity) {
            z.n("CallAutomationService", "onActivityPaused, activity=[" + activity + "]");
            if (CallAutomationService.this.Y == null || activity != ((Activity) CallAutomationService.this.Y.get())) {
                return;
            }
            CallAutomationService.this.Y.clear();
            z.a("CallAutomationService", "onActivityPaused, activity=[" + activity + "] ref is cleared");
        }

        @Override
        public void onActivityResumed(@NonNull Activity activity) {
            z.n("CallAutomationService", "onActivityResumed, activity=[" + activity + "]");
            CallAutomationService.this.Y = new WeakReference(activity);
        }

        @Override
        public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle bundle) {
        }

        @Override
        public void onActivityStarted(@NonNull Activity activity) {
            z.n("CallAutomationService", "onActivityStarted, activity=[" + activity + "]");
            if ((activity instanceof CallActivity) && !CallAutomationService.this.X) {
                CallAutomationService.this.y();
            } else if ((activity instanceof MainActivity) && CallAutomationService.this.X) {
                CallAutomationService callAutomationService = CallAutomationService.this;
                callAutomationService.A(c.NONE, callAutomationService.y0);
            }
        }

        @Override
        public void onActivityStopped(@NonNull Activity activity) {
        }

        b(CallAutomationService callAutomationService, a aVar) {
            this();
        }
    }

    enum c {
        NONE,
        DIAL,
        START,
        STOP,
        CLOSE_OTOKU_DIALOG
    }

    private class d extends BroadcastReceiver {
        private d() {
        }

        @Override
        public void onReceive(Context context, Intent intent) {
            CallAutomationService.this.y();
        }

        d(CallAutomationService callAutomationService, a aVar) {
            this();
        }
    }

    private class e implements Runnable {
        private final c x;

        public e(c cVar) {
            this.x = cVar;
        }

        private void b() {
            z.n("CallAutomationService", "clickAcceptCallButton");
            CallAutomationService.this.t0.h(w3.d.ACCEPT_CALL.c(), null);
        }

        private boolean c() {
            throw new UnsupportedOperationException("Method not decompiled: com.ntt.voip.android.test.CallAutomationService.e.c():boolean");
        }

        private boolean d() {
            z.n("CallAutomationService", "clickStartCallButton");
            return j(com.oki_access.android.ims.call.d.d.k1());
        }

        private boolean e() {
            z.n("CallAutomationService", "clickStopCallButton");
            return j(com.oki_access.android.ims.call.d.d.j3());
        }

        private boolean f() {
            z.n("CallAutomationService", "closeOtokuDialog");
            return k("CallActivity:dialog:9", com.oki_access.android.ims.call.d.d.m2());
        }

        private View g(int i) {
            Activity i8 = i();
            if (i8 != null) {
                return i8.findViewById(i);
            }
            return null;
        }

        private String h() {
            if (CallAutomationService.this.x == null || CallAutomationService.this.x.length() < 1 || CallAutomationService.this.y >= CallAutomationService.this.x.length()) {
                return null;
            }
            return CallAutomationService.this.x.substring(CallAutomationService.this.y, CallAutomationService.this.y + 1);
        }

        private Activity i() {
            if (CallAutomationService.this.Y != null) {
                return (Activity) CallAutomationService.this.Y.get();
            }
            return null;
        }

        private boolean j(int i) {
            View g;
            if (i <= 0 || (g = g(i)) == null || !g.isEnabled()) {
                return false;
            }
            g.performClick();
            return true;
        }

        private boolean k(String str, int i) {
            DialogFragment findFragmentByTag;
            Dialog dialog;
            View findViewById;
            if (i <= 0) {
                return false;
            }
            FragmentActivity i8 = i();
            if (!(i8 instanceof FragmentActivity) || (findFragmentByTag = i8.getSupportFragmentManager().findFragmentByTag(str)) == null || (dialog = findFragmentByTag.getDialog()) == null || (findViewById = dialog.findViewById(i)) == null || !findViewById.isEnabled()) {
                return false;
            }
            return findViewById.performClick();
        }

        private boolean l(int i) {
            View g;
            if (i <= 0 || (g = g(i)) == null || !g.isEnabled()) {
                return false;
            }
            g.performLongClick();
            return true;
        }

        @Override
        public void run() {
            throw new UnsupportedOperationException("Method not decompiled: com.ntt.voip.android.test.CallAutomationService.e.run():void");
        }
    }

    public synchronized void A(c cVar, long j) {
        try {
            z.n("CallAutomationService", "scheduleNextAction, nextAction=[" + cVar + "], delay=[" + j + "]");
            if (cVar != null) {
                if (this.v0 != null) {
                    z.a("CallAutomationService", "skip scheduleNextAction, nextAction=[" + this.v0.x + "] is already scheduled");
                } else if (!c.NONE.equals(cVar) || v()) {
                    e eVar = new e(cVar);
                    this.s0.postDelayed(eVar, j);
                    this.v0 = eVar;
                } else {
                    z.a("CallAutomationService", "test is complete");
                    stopSelf();
                }
            }
        } catch (Throwable th) {
            throw th;
        }
    }

    private String B(String str) {
        if (str == null || str.length() < 1) {
            return str;
        }
        char[] charArray = str.toCharArray();
        StringBuilder sb = new StringBuilder();
        for (char c8 : charArray) {
            if (c8 != '#' && c8 != '*' && c8 != '+') {
                switch (c8) {
                }
            }
            sb.append(c8);
        }
        return sb.toString();
    }

    static int p(CallAutomationService callAutomationService) {
        int i = callAutomationService.y;
        callAutomationService.y = i + 1;
        return i;
    }

    static int q(CallAutomationService callAutomationService) {
        int i = callAutomationService.G0;
        callAutomationService.G0 = i + 1;
        return i;
    }

    private synchronized void u() {
        z.n("CallAutomationService", "cancelNextAction");
        e eVar = this.v0;
        if (eVar != null) {
            this.s0.removeCallbacks(eVar);
            this.v0 = null;
        }
    }

    private boolean v() {
        int i = this.F0;
        return i <= 0 || this.G0 < i;
    }

    private Notification w(String str) {
        NotificationCompat.Builder contentText = new NotificationCompat.Builder(this, getString(j.e.x1())).setSmallIcon(com.oki_access.android.ims.call.d.b.L()).setTicker(str).setWhen(System.currentTimeMillis()).setShowWhen(true).setOngoing(true).setContentTitle(getString(com.oki_access.android.ims.call.d.e.Yb())).setContentText(str);
        if (Build.VERSION.SDK_INT >= 29) {
            contentText.setAllowSystemGeneratedContextualActions(false);
        }
        return contentText.build();
    }

    public void x() {
        this.w0.notify(5, w(this.X ? MessageFormat.format(getString(com.oki_access.android.ims.call.d.e.D1()), this.x, Integer.valueOf(this.G0), Integer.valueOf(this.F0)) : getString(com.oki_access.android.ims.call.d.e.C1())));
    }

    public void y() {
        z.n("CallAutomationService", "onRinging");
        A(c.START, this.f45z0);
    }

    public void z(c cVar) {
        A(cVar, 5000L);
    }

    @Override
    @Nullable
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onCreate() {
        z.n("CallAutomationService", "onCreate");
        super.onCreate();
        a aVar = null;
        this.Z = new b(this, aVar);
        getApplication().registerActivityLifecycleCallbacks(this.Z);
        this.s0 = new Handler(Looper.getMainLooper());
        f fVar = new f(getApplicationContext());
        this.t0 = fVar;
        fVar.g();
        d dVar = new d(this, aVar);
        this.u0 = dVar;
        ContextCompat.registerReceiver(this, dVar, new IntentFilter(e4.a.m), 4);
        NotificationManager notificationManager = (NotificationManager) getSystemService("notification");
        this.w0 = notificationManager;
        notificationManager.notify(5, w(""));
    }

    @Override
    public void onDestroy() {
        z.n("CallAutomationService", "onDestroy");
        super.onDestroy();
        u();
        if (this.Z != null) {
            getApplication().unregisterActivityLifecycleCallbacks(this.Z);
        }
        f fVar = this.t0;
        if (fVar != null) {
            fVar.j();
        }
        d dVar = this.u0;
        if (dVar != null) {
            unregisterReceiver(dVar);
        }
        NotificationManager notificationManager = this.w0;
        if (notificationManager != null) {
            notificationManager.cancel(5);
        }
    }

    @Override
    public int onStartCommand(Intent intent, int i, int i8) {
        z.n("CallAutomationService", "onStartCommand");
        if (this.v0 != null) {
            z.a("CallAutomationService", "service is already running, cancel next action");
            u();
        }
        if (intent != null) {
            boolean booleanExtra = intent.getBooleanExtra("is_outgoing", true);
            this.X = booleanExtra;
            if (booleanExtra) {
                this.x = B(intent.getStringExtra("remote_number"));
                this.y0 = intent.getIntExtra("delay_initial", 5) * 1000;
                this.B0 = intent.getIntExtra("delay_dial", 1) * 1000;
                this.C0 = intent.getIntExtra("delay_start_call", 5) * 1000;
                this.A0 = intent.getIntExtra("delay_stop_call", 30) * 1000;
                this.D0 = intent.getIntExtra("delay_close_otoku", 5) * 1000;
                this.E0 = intent.getBooleanExtra("show_otoku", false);
                this.F0 = intent.getIntExtra("max_test_count", 0);
                z.a("CallAutomationService", "mRemoteNumber=[" + this.x + "], mInitialDelay=[" + this.y0 + "], mDialActionDelay=[" + this.B0 + "], mStartActionDelay=[" + this.C0 + "], mStopActionDelay=[" + this.A0 + "], mCloseOtokuDialogActionDelay=[" + this.D0 + "], mShowOtoku=[" + this.E0 + "], mMaxTestCount=[" + this.F0 + "]");
                this.y = 0;
                this.G0 = 0;
            } else {
                this.f45z0 = intent.getIntExtra("delay_accept_call", 5) * 1000;
                z.a("CallAutomationService", "mAcceptActionDelay=[" + this.f45z0 + "]");
            }
            x();
        }
        return super.onStartCommand(intent, i, i8);
    }
}