导航菜单

页面标题

页面副标题

迅 唔 v1.3.9 - FloatingWindowService.java 源代码

正在查看: 迅 唔 v1.3.9 应用的 FloatingWindowService.java JAVA 源代码文件

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


package com.uixxpi.ercpqxo;

import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.util.Log;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.PopupMenu;
import com.uixxpi.ercpqxo.FloatingWindowService;
import ffi.FFI;
import g.j;
import x6.g;
import x6.k;

public final class FloatingWindowService extends Service implements View.OnTouchListener {
    public static int C;
    public static int D;
    public static int E;
    public static Context F;

    public static boolean f1691z;

    public WindowManager f1692h;

    public WindowManager.LayoutParams f1693i;

    public ImageView f1694j;

    public Drawable f1695k;

    public Drawable f1696l;

    public Drawable f1697m;

    public boolean f1698n;

    public float f1699o;

    public float f1700p;

    public boolean f1701q;

    public b f1702r = b.f1706i;

    public final Handler f1703s = new Handler(Looper.getMainLooper());

    public final c f1704t = new c();

    public static final a f1686u = new a(null);

    public static final String f1687v = "floatingService";

    public static boolean f1688w = true;

    public static int f1689x = j.G0;

    public static int f1690y = j.G0;
    public static float A = 1.0f;
    public static String B = "";

    public static final class a {
        public a() {
        }

        public a(g gVar) {
            this();
        }

        public final Context a() {
            return FloatingWindowService.F;
        }
    }

    public static final class b {

        public static final b f1705h = new b("NEVER", 0);

        public static final b f1706i = new b("DURING_CONTROLLED", 1);

        public static final b f1707j = new b("SERVICE_ON", 2);

        public static final b[] f1708k;

        public static final p6.a f1709l;

        static {
            b[] a8 = a();
            f1708k = a8;
            f1709l = p6.b.a(a8);
        }

        public b(String str, int i8) {
        }

        public static final b[] a() {
            return new b[]{f1705h, f1706i, f1707j};
        }

        public static b valueOf(String str) {
            return (b) Enum.valueOf(b.class, str);
        }

        public static b[] values() {
            return (b[]) f1708k.clone();
        }
    }

    public static final class c implements Runnable {
        public c() {
        }

        @Override
        public void run() {
            if (FloatingWindowService.this.t()) {
                WindowManager windowManager = FloatingWindowService.this.f1692h;
                WindowManager.LayoutParams layoutParams = null;
                if (windowManager == null) {
                    k.n("windowManager");
                    windowManager = null;
                }
                ImageView imageView = FloatingWindowService.this.f1694j;
                if (imageView == null) {
                    k.n("floatingView");
                    imageView = null;
                }
                WindowManager.LayoutParams layoutParams2 = FloatingWindowService.this.f1693i;
                if (layoutParams2 == null) {
                    k.n("layoutParams");
                } else {
                    layoutParams = layoutParams2;
                }
                windowManager.updateViewLayout(imageView, layoutParams);
            }
            FloatingWindowService.this.f1703s.postDelayed(this, 1000L);
        }
    }

    public static void k(FloatingWindowService floatingWindowService, boolean z7, int i8, Object obj) {
        if ((i8 & 1) != 0) {
            z7 = false;
        }
        floatingWindowService.j(z7);
    }

    public static final boolean p(int i8, FloatingWindowService floatingWindowService, int i9, int i10, MenuItem menuItem) {
        k.e(floatingWindowService, "this$0");
        int itemId = menuItem.getItemId();
        if (itemId == i8) {
            floatingWindowService.m();
            return true;
        }
        if (itemId == i9) {
            floatingWindowService.s();
            return true;
        }
        if (itemId != i10) {
            return false;
        }
        floatingWindowService.r();
        return true;
    }

    public static final void q(FloatingWindowService floatingWindowService, PopupMenu popupMenu) {
        k.e(floatingWindowService, "this$0");
        k(floatingWindowService, false, 1, null);
    }

    public final void i(android.view.WindowManager r13) {
        throw new UnsupportedOperationException("Method not decompiled: com.uixxpi.ercpqxo.FloatingWindowService.i(android.view.WindowManager):void");
    }

    public final void j(boolean z7) {
        ImageView imageView;
        Drawable drawable;
        String str;
        Object systemService = getSystemService("window");
        k.c(systemService, "null cannot be cast to non-null type android.view.WindowManager");
        WindowManager windowManager = (WindowManager) systemService;
        j6.g<Integer, Integer> i8 = com.uixxpi.ercpqxo.a.i(windowManager);
        int intValue = i8.c().intValue();
        WindowManager.LayoutParams layoutParams = this.f1693i;
        WindowManager.LayoutParams layoutParams2 = null;
        if (layoutParams == null) {
            k.n("layoutParams");
            layoutParams = null;
        }
        if (layoutParams.x < intValue / 2) {
            WindowManager.LayoutParams layoutParams3 = this.f1693i;
            if (layoutParams3 == null) {
                k.n("layoutParams");
                layoutParams3 = null;
            }
            layoutParams3.x = 0;
            imageView = this.f1694j;
            if (imageView == null) {
                k.n("floatingView");
                imageView = null;
            }
            drawable = this.f1697m;
            if (drawable == null) {
                str = "rightHalfDrawable";
                k.n(str);
                drawable = null;
            }
        } else {
            WindowManager.LayoutParams layoutParams4 = this.f1693i;
            if (layoutParams4 == null) {
                k.n("layoutParams");
                layoutParams4 = null;
            }
            layoutParams4.x = intValue - (f1689x / 2);
            imageView = this.f1694j;
            if (imageView == null) {
                k.n("floatingView");
                imageView = null;
            }
            drawable = this.f1696l;
            if (drawable == null) {
                str = "leftHalfDrawable";
                k.n(str);
                drawable = null;
            }
        }
        imageView.setImageDrawable(drawable);
        if (z7) {
            WindowManager.LayoutParams layoutParams5 = this.f1693i;
            if (layoutParams5 == null) {
                k.n("layoutParams");
                layoutParams5 = null;
            }
            layoutParams5.y = (i8.d().intValue() - f1690y) / 2;
        }
        WindowManager.LayoutParams layoutParams6 = this.f1693i;
        if (layoutParams6 == null) {
            k.n("layoutParams");
            layoutParams6 = null;
        }
        layoutParams6.width = f1689x / 2;
        ImageView imageView2 = this.f1694j;
        if (imageView2 == null) {
            k.n("floatingView");
            imageView2 = null;
        }
        WindowManager.LayoutParams layoutParams7 = this.f1693i;
        if (layoutParams7 == null) {
            k.n("layoutParams");
            layoutParams7 = null;
        }
        windowManager.updateViewLayout(imageView2, layoutParams7);
        WindowManager.LayoutParams layoutParams8 = this.f1693i;
        if (layoutParams8 == null) {
            k.n("layoutParams");
            layoutParams8 = null;
        }
        C = layoutParams8.x;
        WindowManager.LayoutParams layoutParams9 = this.f1693i;
        if (layoutParams9 == null) {
            k.n("layoutParams");
        } else {
            layoutParams2 = layoutParams9;
        }
        D = layoutParams2.y;
    }

    public final void l(WindowManager windowManager) {
        j6.g<Integer, Integer> i8 = com.uixxpi.ercpqxo.a.i(windowManager);
        int intValue = i8.c().intValue();
        int intValue2 = i8.d().intValue();
        String localOption = FFI.f2946a.getLocalOption("floating-window-size");
        if (localOption.length() > 0) {
            try {
                int parseInt = Integer.parseInt(localOption);
                if ((32 <= parseInt && parseInt < 321) && parseInt <= intValue / 2 && parseInt <= intValue2 / 2) {
                    f1689x = parseInt;
                    f1690y = parseInt;
                }
            } catch (Exception e8) {
                e8.printStackTrace();
            }
        }
        FFI ffi2 = FFI.f2946a;
        f1691z = k.a(ffi2.getLocalOption("floating-window-untouchable"), "Y");
        String localOption2 = ffi2.getLocalOption("floating-window-transparency");
        if (localOption2.length() > 0) {
            try {
                int parseInt2 = Integer.parseInt(localOption2);
                if (parseInt2 >= 0 && parseInt2 < 11) {
                    A = (parseInt2 * 1.0f) / 10;
                }
            } catch (Exception e9) {
                e9.printStackTrace();
            }
        }
        String localOption3 = FFI.f2946a.getLocalOption("floating-window-svg");
        if (localOption3.length() > 0) {
            B = localOption3;
        }
        C = 0;
        D = (i8.d().intValue() - f1690y) / 2;
        E = getResources().getConfiguration().orientation;
    }

    public final void m() {
        Intent intent = new Intent(this, (Class<?>) MainActivity.class);
        intent.addFlags(268435456);
        try {
            PendingIntent.getActivity(this, 0, intent, 1140850688).send();
        } catch (PendingIntent.CanceledException e8) {
            e8.printStackTrace();
        }
    }

    public final void n() {
        o();
    }

    public final void o() {
        ImageView imageView = this.f1694j;
        if (imageView == null) {
            k.n("floatingView");
            imageView = null;
        }
        PopupMenu popupMenu = new PopupMenu(this, imageView);
        final int i8 = 0;
        popupMenu.getMenu().add(0, 0, 0, com.uixxpi.ercpqxo.a.t("Show RustDesk"));
        RdClipboardManager b8 = MainActivity.f1735s.b();
        final int i9 = 1;
        if ((b8 != null ? b8.b() : false) && FFI.f2946a.isServiceClipboardEnabled()) {
            popupMenu.getMenu().add(0, 1, 0, com.uixxpi.ercpqxo.a.t("Update client clipboard"));
        }
        final int i10 = 2;
        popupMenu.getMenu().add(0, 2, 0, com.uixxpi.ercpqxo.a.t("Stop service"));
        popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            @Override
            public final boolean onMenuItemClick(MenuItem menuItem) {
                boolean p8;
                p8 = FloatingWindowService.p(i8, this, i9, i10, menuItem);
                return p8;
            }
        });
        popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() {
            @Override
            public final void onDismiss(PopupMenu popupMenu2) {
                FloatingWindowService.q(FloatingWindowService.this, popupMenu2);
            }
        });
        popupMenu.show();
    }

    @Override
    public IBinder onBind(Intent intent) {
        k.e(intent, "intent");
        return null;
    }

    @Override
    public void onConfigurationChanged(Configuration configuration) {
        k.e(configuration, "newConfig");
        super.onConfigurationChanged(configuration);
        int i8 = configuration.orientation;
        if (i8 != E) {
            E = i8;
            WindowManager windowManager = this.f1692h;
            if (windowManager == null) {
                k.n("windowManager");
                windowManager = null;
            }
            j6.g<Integer, Integer> i9 = com.uixxpi.ercpqxo.a.i(windowManager);
            Log.d(f1687v, "orientation: " + E + ", screen size: " + i9.c().intValue() + " x " + i9.d().intValue());
            int intValue = i9.c().intValue();
            int intValue2 = i9.d().intValue();
            int i10 = configuration.orientation;
            if (i10 == 2 || i10 == 1) {
                WindowManager.LayoutParams layoutParams = this.f1693i;
                if (layoutParams == null) {
                    k.n("layoutParams");
                    layoutParams = null;
                }
                WindowManager.LayoutParams layoutParams2 = this.f1693i;
                if (layoutParams2 == null) {
                    k.n("layoutParams");
                    layoutParams2 = null;
                }
                float f8 = intValue2;
                float f9 = intValue;
                layoutParams.x = (int) ((layoutParams2.x / f8) * f9);
                WindowManager.LayoutParams layoutParams3 = this.f1693i;
                if (layoutParams3 == null) {
                    k.n("layoutParams");
                    layoutParams3 = null;
                }
                WindowManager.LayoutParams layoutParams4 = this.f1693i;
                if (layoutParams4 == null) {
                    k.n("layoutParams");
                    layoutParams4 = null;
                }
                layoutParams3.y = (int) ((layoutParams4.y / f9) * f8);
            }
            k(this, false, 1, null);
        }
    }

    @Override
    public void onCreate() {
        super.onCreate();
        F = getApplicationContext();
        Object systemService = getSystemService("window");
        k.c(systemService, "null cannot be cast to non-null type android.view.WindowManager");
        WindowManager windowManager = (WindowManager) systemService;
        this.f1692h = windowManager;
        try {
            WindowManager windowManager2 = null;
            if (f1688w) {
                f1688w = false;
                if (windowManager == null) {
                    k.n("windowManager");
                    windowManager = null;
                }
                l(windowManager);
            }
            String str = f1687v;
            Log.d(str, "floating window size: " + f1689x + " x " + f1690y + ", transparency: " + A + ", lastLayoutX: " + C + ", lastLayoutY: " + D + ", customSvg: " + B);
            WindowManager windowManager3 = this.f1692h;
            if (windowManager3 == null) {
                k.n("windowManager");
            } else {
                windowManager2 = windowManager3;
            }
            i(windowManager2);
            this.f1703s.postDelayed(this.f1704t, 1000L);
            Log.d(str, "onCreate success");
        } catch (Exception e8) {
            Log.d(f1687v, "onCreate failed: " + e8);
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (this.f1701q) {
            WindowManager windowManager = this.f1692h;
            ImageView imageView = null;
            if (windowManager == null) {
                k.n("windowManager");
                windowManager = null;
            }
            ImageView imageView2 = this.f1694j;
            if (imageView2 == null) {
                k.n("floatingView");
            } else {
                imageView = imageView2;
            }
            windowManager.removeView(imageView);
        }
        this.f1703s.removeCallbacks(this.f1704t);
    }

    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
        WindowManager.LayoutParams layoutParams = null;
        Integer valueOf = motionEvent != null ? Integer.valueOf(motionEvent.getAction()) : null;
        if (valueOf != null && valueOf.intValue() == 0) {
            this.f1698n = false;
            this.f1699o = motionEvent.getRawX();
            this.f1700p = motionEvent.getRawY();
        } else if (valueOf != null && valueOf.intValue() == 1) {
            if (Math.abs(motionEvent.getRawX() - this.f1699o) >= 10.0f || Math.abs(motionEvent.getRawY() - this.f1700p) >= 10.0f) {
                k(this, false, 1, null);
            } else {
                n();
            }
        } else if (valueOf != null && valueOf.intValue() == 2) {
            float rawX = motionEvent.getRawX() - this.f1699o;
            float rawY = motionEvent.getRawY() - this.f1700p;
            if (!this.f1698n && (rawX * rawX) + (rawY * rawY) < 25.0f) {
                return false;
            }
            this.f1698n = true;
            WindowManager.LayoutParams layoutParams2 = this.f1693i;
            if (layoutParams2 == null) {
                k.n("layoutParams");
                layoutParams2 = null;
            }
            layoutParams2.x = (int) motionEvent.getRawX();
            WindowManager.LayoutParams layoutParams3 = this.f1693i;
            if (layoutParams3 == null) {
                k.n("layoutParams");
                layoutParams3 = null;
            }
            layoutParams3.y = (int) motionEvent.getRawY();
            WindowManager.LayoutParams layoutParams4 = this.f1693i;
            if (layoutParams4 == null) {
                k.n("layoutParams");
                layoutParams4 = null;
            }
            layoutParams4.width = f1689x;
            ImageView imageView = this.f1694j;
            if (imageView == null) {
                k.n("floatingView");
                imageView = null;
            }
            Drawable drawable = this.f1695k;
            if (drawable == null) {
                k.n("originalDrawable");
                drawable = null;
            }
            imageView.setImageDrawable(drawable);
            WindowManager windowManager = this.f1692h;
            if (windowManager == null) {
                k.n("windowManager");
                windowManager = null;
            }
            WindowManager.LayoutParams layoutParams5 = this.f1693i;
            if (layoutParams5 == null) {
                k.n("layoutParams");
                layoutParams5 = null;
            }
            windowManager.updateViewLayout(view, layoutParams5);
            WindowManager.LayoutParams layoutParams6 = this.f1693i;
            if (layoutParams6 == null) {
                k.n("layoutParams");
                layoutParams6 = null;
            }
            C = layoutParams6.x;
            WindowManager.LayoutParams layoutParams7 = this.f1693i;
            if (layoutParams7 == null) {
                k.n("layoutParams");
            } else {
                layoutParams = layoutParams7;
            }
            D = layoutParams.y;
        }
        return false;
    }

    public final void r() {
        z5.k a8 = MainActivity.f1735s.a();
        if (a8 != null) {
            a8.c("stop_service", null);
        }
    }

    public final void s() {
        RdClipboardManager b8 = MainActivity.f1735s.b();
        if (b8 != null) {
            b8.f(false);
        }
    }

    public final boolean t() {
        int i8;
        WindowManager.LayoutParams layoutParams = this.f1693i;
        WindowManager.LayoutParams layoutParams2 = null;
        if (layoutParams == null) {
            k.n("layoutParams");
            layoutParams = null;
        }
        boolean z7 = (layoutParams.flags & 128) != 0;
        b bVar = this.f1702r;
        boolean z8 = bVar == b.f1707j || (bVar == b.f1706i && MainService.C.d());
        if (z7 == z8) {
            return false;
        }
        Log.d(f1687v, "change keep screen on to " + z8);
        WindowManager.LayoutParams layoutParams3 = this.f1693i;
        if (z8) {
            if (layoutParams3 == null) {
                k.n("layoutParams");
                layoutParams3 = null;
            }
            WindowManager.LayoutParams layoutParams4 = this.f1693i;
            if (layoutParams4 == null) {
                k.n("layoutParams");
            } else {
                layoutParams2 = layoutParams4;
            }
            i8 = layoutParams2.flags | 128;
        } else {
            if (layoutParams3 == null) {
                k.n("layoutParams");
                layoutParams3 = null;
            }
            WindowManager.LayoutParams layoutParams5 = this.f1693i;
            if (layoutParams5 == null) {
                k.n("layoutParams");
            } else {
                layoutParams2 = layoutParams5;
            }
            i8 = layoutParams2.flags & (-129);
        }
        layoutParams3.flags = i8;
        return true;
    }
}