package com.seewo.ota;

import android.app.ActivityManager;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.UserManager;
import android.util.Log;
import com.seewo.adbcommons.model.CmdOTAEvent;
import com.seewo.adbcommons.model.base.ICmdMsg;
import com.seewo.aidl.model.OTAScheduleTaskGroup;
import com.seewo.libmyousdk.model.RomUpdateInfo;
import com.seewo.ota.OTARefreshService;
import com.seewo.ota.t.m;
import com.seewo.ota.t.n;
import com.seewo.ota.udi.server.OTAUdiService;
import com.seewo.ota.update.device.ui.DeviceUpgradeV2Activity;
import com.seewo.ota.util.n;
import com.seewo.ota.util.t;
import com.seewo.ota.util.u;
import com.seewo.ota.util.w;
import com.seewo.ota.v.p;
import com.seewo.ota.v.s.o;
import com.seewo.ota.v.u.r;
import com.seewo.sdk.interfaces.s;
import d.e.a.a;
import d.e.b.a.b;
import d.e.h.a.b;
import java.io.File;
import java.util.Calendar;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public class OTARefreshService extends Service implements com.seewo.ota.p.b, n.b {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private RemoteCallbackList<d.e.b.a.a> f1909f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private o f1910g;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private UserManager f1913j;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final Handler f1908b = new Handler();

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private boolean f1911h = true;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private boolean f1912i = false;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private final BroadcastReceiver f1914k = new a();
    private final BroadcastReceiver l = new b();
    private final BroadcastReceiver m = new com.seewo.ota.receiver.d();
    private final BroadcastReceiver n = new com.seewo.ota.receiver.c();
    private final b.a o = new c();

    class a extends BroadcastReceiver {
        a() {
        }

        @Override // android.content.BroadcastReceiver
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (!action.equals("com.seewo.ota.checkstatus")) {
                if (action.equals("com.seewo.ota.version") && com.seewo.ota.data.b.i().q()) {
                    OTARefreshService.this.q(context, intent);
                    return;
                }
                return;
            }
            int intExtra = intent.getIntExtra("key_check_status", 1);
            Log.d("OTARefreshService", "onReceive: checkStatus: " + intExtra);
            if (intExtra != 1) {
                OTARefreshService.this.i(1);
                return;
            }
            CmdOTAEvent cmdOTAEvent = new CmdOTAEvent();
            cmdOTAEvent.mEventCode = 3;
            d.e.a.a.g().j(cmdOTAEvent);
        }
    }

    class b extends BroadcastReceiver {

        class a implements t.a {
            final /* synthetic */ File a;

            a(File file) {
                this.a = file;
            }

            @Override // com.seewo.ota.util.t.a
            public void a(int i2) {
            }

            @Override // com.seewo.ota.util.t.a
            public void b() {
                Log.d("OTARefreshService", "sensor onCopyComplete, targetFile:" + this.a.getPath());
                com.seewo.ota.data.a.g().T(true);
                com.seewo.ota.data.a.g().U(this.a.getPath());
                OTARefreshService.this.s().K();
            }

            @Override // com.seewo.ota.util.t.a
            public void c(Throwable th) {
                Log.d("OTARefreshService", "sensor onCopyFailed");
            }
        }

        b() {
        }

        @Override // android.content.BroadcastReceiver
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if ("com.seewo.ota.ACTIOIN_SENSOR_BOX_VERSION_CHANGED".equals(action)) {
                Log.d("OTARefreshService", "onReceive: SensorBox version need update to /data/system/SENSOR.bin");
                com.seewo.ota.data.a.g().T(true);
                OTARefreshService.this.s().K();
                return;
            }
            if ("com.seewo.ota.action.DISABLE_SYSTEM_UPDATE_CHANGED".equals(action)) {
                Log.d("OTARefreshService", "ACTION_DISABLE_SYSTEM_UPDATE_CHANGED");
                p.r().f(1);
                return;
            }
            if (!"com.seewo.ota.ACTION_UPDATE_SENSOR_BOX".equals(action)) {
                if ("com.seewo.ota.action.UPDATE_SYSTEM".equals(action)) {
                    Log.d("OTARefreshService", "ACTION_UPDATE_SYSTEM: " + intent.getExtras());
                    String stringExtra = intent.getStringExtra("file_path");
                    boolean booleanExtra = intent.getBooleanExtra("is_auto_upgrade", false);
                    boolean booleanExtra2 = intent.getBooleanExtra("is_reboot", true);
                    if (stringExtra == null || stringExtra.isEmpty()) {
                        Log.e("OTARefreshService", "updateSystemByFile: filePath is null or empty.");
                        return;
                    } else {
                        p.r().H(new File(stringExtra), booleanExtra, booleanExtra2);
                        return;
                    }
                }
                return;
            }
            Log.d("OTARefreshService", "ACTION_UPDATE_SENSOR_BOX");
            String stringExtra2 = intent.getStringExtra("file_path");
            File file = new File(stringExtra2);
            if (!file.exists()) {
                Log.e("OTARefreshService", stringExtra2 + " not exist.");
                return;
            }
            File file2 = new File(OTARefreshService.this.getFilesDir().getPath() + File.separator + file.getName());
            t.a(new File(stringExtra2), file2, new a(file2));
        }
    }

    class c extends b.a {
        c() {
        }

        private String L(int i2) {
            String str = "";
            try {
                PackageManager packageManager = OTARefreshService.this.getPackageManager();
                for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : ((ActivityManager) OTARefreshService.this.getSystemService("activity")).getRunningAppProcesses()) {
                    if (runningAppProcessInfo.pid == i2) {
                        packageManager.getApplicationLabel(packageManager.getApplicationInfo(runningAppProcessInfo.processName, ICmdMsg.ACTION_START_ACTIVITY));
                        str = runningAppProcessInfo.processName;
                    }
                }
            } catch (Exception unused) {
            }
            return str;
        }

        static /* synthetic */ void P(d.e.b.a.c cVar, Calendar calendar) {
            try {
                cVar.p(calendar.getTimeInMillis());
            } catch (RemoteException e2) {
                Log.e("OTARefreshService", "notifyScheduleUpdateTime", e2);
            }
        }

        @Override // d.e.b.a.b
        public void A(String str, boolean z, boolean z2) {
            Log.d("OTARefreshService", "updateSystem filePath:" + str + "  ,isReboot:" + z2);
            p.r().H(new File(str), z, z2);
        }

        @Override // d.e.b.a.b
        public Bundle C(int i2) {
            return p.r().u(i2);
        }

        @Override // d.e.b.a.b
        public void D() {
            int callingPid = Binder.getCallingPid();
            Log.d("OTARefreshService", ">>>>> pid:" + callingPid + "  packageName:" + L(callingPid));
            p.r().m(OTARefreshService.this);
        }

        @Override // d.e.b.a.b
        public int E(OTAScheduleTaskGroup oTAScheduleTaskGroup) throws RemoteException {
            Log.i("OTARefreshService", "updateScheduleTaskGroup: " + oTAScheduleTaskGroup);
            return m.a.y(oTAScheduleTaskGroup);
        }

        @Override // d.e.b.a.b
        public void F() {
            Log.d("OTARefreshService", "directUpdate");
            OTARefreshService.this.f1908b.post(new Runnable() { // from class: com.seewo.ota.b
                @Override // java.lang.Runnable
                public final void run() {
                    p.r().n();
                }
            });
        }

        @Override // d.e.b.a.b
        public void G(d.e.b.a.a aVar, int i2) {
            Log.d("OTARefreshService", "registerCallback: ");
            OTARefreshService.this.f1909f.register(aVar, Integer.valueOf(i2));
        }

        @Override // d.e.b.a.b
        public int H(final int i2) {
            if (r.d().g()) {
                return b.a.UPGRADING.ordinal();
            }
            try {
                int iV = p.r().v(i2);
                if (iV == b.a.DOWNLOADING.ordinal()) {
                    OTARefreshService.this.f1908b.postDelayed(new Runnable() { // from class: com.seewo.ota.f
                        @Override // java.lang.Runnable
                        public final void run() {
                            this.f2122b.N(i2);
                        }
                    }, 500L);
                } else if (iV == b.a.DOWNLOAD_PAUSED.ordinal()) {
                    OTARefreshService.this.f1908b.postDelayed(new Runnable() { // from class: com.seewo.ota.d
                        @Override // java.lang.Runnable
                        public final void run() {
                            this.f2112b.O(i2);
                        }
                    }, 500L);
                }
                return iV;
            } catch (Exception e2) {
                Log.e("OTARefreshService", e2.getMessage(), e2);
                return b.a.NONE.ordinal();
            }
        }

        public /* synthetic */ void N(int i2) {
            OTARefreshService.this.y(1, p.r().q(i2), i2);
        }

        public /* synthetic */ void O(int i2) {
            OTARefreshService.this.y(3, p.r().q(i2), i2);
        }

        @Override // d.e.b.a.b
        public void cancel(int i2) {
            p.r().f(i2);
        }

        @Override // d.e.b.a.b
        public void f(final d.e.b.a.c cVar) {
            com.seewo.ota.t.n.j().G(new n.b() { // from class: com.seewo.ota.c
                @Override // com.seewo.ota.t.n.b
                public final void a(Calendar calendar) {
                    OTARefreshService.c.P(cVar, calendar);
                }
            });
            OTARefreshService.this.f1908b.post(new Runnable() { // from class: com.seewo.ota.e
                @Override // java.lang.Runnable
                public final void run() {
                    com.seewo.ota.t.n.j().J();
                }
            });
        }

        @Override // d.e.b.a.b
        public List<OTAScheduleTaskGroup> getScheduleTaskGroups(int i2) throws RemoteException {
            Log.i("OTARefreshService", "getScheduleTaskGroups: " + i2);
            return m.a.o(i2);
        }

        @Override // d.e.b.a.b
        public void m(int i2) {
            Log.d("OTARefreshService", "updateSystemNoUi: ");
            p.r().F(i2);
        }

        @Override // d.e.b.a.b
        public void n(d.e.b.a.a aVar) {
            Log.d("OTARefreshService", "unRegisterCallback: ");
            if (aVar != null) {
                OTARefreshService.this.f1909f.unregister(aVar);
            }
        }

        @Override // d.e.b.a.b
        public int o(OTAScheduleTaskGroup oTAScheduleTaskGroup) throws RemoteException {
            Log.i("OTARefreshService", "addScheduleTaskGroup: " + oTAScheduleTaskGroup);
            return m.a.b(oTAScheduleTaskGroup);
        }

        @Override // d.e.b.a.b
        public void r(int i2) {
            Log.d("OTARefreshService", "startUpdateNoDialog: ");
            p.r().C(i2);
        }

        @Override // d.e.b.a.b
        public int removeScheduleTaskGroup(int i2) throws RemoteException {
            Log.i("OTARefreshService", "removeScheduleTaskGroup: " + i2);
            return m.a.t(i2);
        }

        @Override // d.e.b.a.b
        public void s(int i2) {
            p.r().A(i2);
            OTARefreshService.this.y(1, p.r().q(i2), i2);
        }

        @Override // d.e.b.a.b
        public void v(String str) {
            Log.d("OTARefreshService", "updateSystem:" + str);
            p.r().G(new File(str));
        }

        @Override // d.e.b.a.b
        public void x(int i2, boolean z) {
            int callingPid = Binder.getCallingPid();
            String strL = L(callingPid);
            Log.d("OTARefreshService", ">>>>> pid:" + callingPid + "  packageName:" + strL);
            if (i2 == 1 && com.seewo.ota.util.h.a()) {
                OTARefreshService.this.C();
            } else {
                p.r().l(i2, z);
                p.r().z(i2, strL);
            }
        }

        @Override // d.e.b.a.b
        public void y(int i2) {
            p.r().B(i2);
        }
    }

    private void A(int i2) {
        int iBeginBroadcast = this.f1909f.beginBroadcast();
        for (int i3 = 0; i3 < iBeginBroadcast; i3++) {
            try {
                ((d.e.b.a.a) this.f1909f.getBroadcastItem(i3)).d(i2);
            } catch (RemoteException e2) {
                Log.e("OTARefreshService", "notifyUpgradeProgress", e2);
            }
        }
        this.f1909f.finishBroadcast();
    }

    private void B() {
        d.e.a.a.g().l(new a.c() { // from class: com.seewo.ota.h
            @Override // d.e.a.a.c
            public final void a(ComponentName componentName, boolean z) {
                this.a.v(componentName, z);
            }
        });
        if (d.e.a.a.g().i()) {
            C();
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void C() {
        Log.d("OTARefreshService", "postGetSystemVersion: ");
        CmdOTAEvent cmdOTAEvent = new CmdOTAEvent();
        cmdOTAEvent.mEventCode = 5;
        d.e.a.a.g().j(cmdOTAEvent);
    }

    private void D() {
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("com.seewo.ota.checkstatus");
        intentFilter.addAction("com.seewo.ota.version");
        registerReceiver(this.f1914k, intentFilter);
    }

    private void E() {
        IntentFilter intentFilter = new IntentFilter("com.seewo.ota.ACTIOIN_SENSOR_BOX_VERSION_CHANGED");
        intentFilter.addAction("com.seewo.ota.ACTION_UPDATE_SENSOR_BOX");
        intentFilter.addAction("com.seewo.ota.action.DISABLE_SYSTEM_UPDATE_CHANGED");
        intentFilter.addAction("com.seewo.ota.action.UPDATE_SYSTEM");
        registerReceiver(this.l, intentFilter);
        IntentFilter intentFilter2 = new IntentFilter();
        intentFilter2.addAction("com.seewo.HID.ADDDEVICES");
        intentFilter2.addAction("com.seewo.HID.REMOVEDEVICES");
        intentFilter2.addAction("com.cvte.usb.AUDIO_PLUGIN_STA");
        intentFilter2.addAction("com.cvte.usb.AUDIO_PLUGOUT_STA");
        intentFilter2.addAction("android.hardware.usb.action.USB_DEVICE_DETACHED");
        registerReceiver(this.m, intentFilter2);
        IntentFilter intentFilter3 = new IntentFilter();
        intentFilter3.addAction("com.seewo.ota.action.UPDATE_INFORMATION");
        registerReceiver(this.n, intentFilter3);
    }

    private void F() {
        Intent intent = new Intent("com.seewo.ota.action.RESTART_OTA_SERVICE");
        intent.setPackage(getPackageName());
        sendBroadcast(intent);
    }

    private void G() {
        if (u.b(getApplicationContext())) {
            return;
        }
        Log.d("OTARefreshService", "startCheckSystemUpdate:");
        if (!d.e.c.a.b.a(this)) {
            Log.d("OTARefreshService", "startCheckSystemUpdate: isNetworkConnected=false");
            return;
        }
        this.f1911h = false;
        if (com.seewo.ota.data.b.i().q() && com.seewo.ota.util.h.a()) {
            B();
        } else if (p.r().x()) {
            Log.d("OTARefreshService", "startCheckSystemUpdate: OTA_TYPE_PLATFORM");
            p.r().l(1, true);
        }
        if (com.seewo.ota.data.b.i().s()) {
            Log.d("OTARefreshService", "startCheckSystemUpdate: OTA_TYPE_SLOT");
        }
    }

    private void H() {
        final Intent intent = new Intent(this, (Class<?>) OTAUdiService.class);
        this.f1908b.post(new Runnable() { // from class: com.seewo.ota.g
            @Override // java.lang.Runnable
            public final void run() {
                this.f2124b.w(intent);
            }
        });
    }

    private void I() {
        int i2 = p.r().x() ? 1 : com.seewo.ota.data.b.i().s() ? 0 : -1;
        if (i2 == -1) {
            return;
        }
        boolean z = p.r().p(i2) == 4;
        Log.d("OTARefreshService", "tryRestartDownload: needRestartDownload=" + z);
        if (z && getResources().getBoolean(R.bool.support_disconnect_restart_download)) {
            p.r().A(i2);
        }
    }

    private void J() {
        if (!com.seewo.ota.util.h.a()) {
            d.e.g.a.o().n();
        }
        if (com.seewo.ota.data.b.i().r()) {
            K();
            d.e.a.a.g().m();
        }
    }

    private void K() {
        unregisterReceiver(this.f1914k);
    }

    private void L() {
        try {
            unregisterReceiver(this.l);
            unregisterReceiver(this.m);
            unregisterReceiver(this.n);
        } catch (Exception e2) {
            Log.e("OTARefreshService", "unregisterReceiver", e2);
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    @Deprecated
    public void q(Context context, Intent intent) {
        String stringExtra = intent.getStringExtra("key_device_id");
        String stringExtra2 = intent.getStringExtra("key_version");
        Log.d("OTARefreshService", "onReceive: deviceId: " + stringExtra + ",version: " + stringExtra2);
        com.seewo.vcommons.data.c.r(context, stringExtra);
        com.seewo.vcommons.data.c.s(context, stringExtra2);
        p.r().k(1);
        p.r().l(1, true);
    }

    private void r() {
        if (com.seewo.ota.data.b.i().r()) {
            D();
            d.e.a.a.g().e();
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public o s() {
        if (this.f1910g == null) {
            o oVar = new o(this);
            this.f1910g = oVar;
            oVar.w(com.seewo.ota.v.s.q.d.f2435b);
            this.f1910g.w(com.seewo.ota.v.s.q.g.f2441b);
            this.f1910g.w(com.seewo.ota.v.s.q.h.f2442b);
            this.f1910g.w(com.seewo.ota.v.s.q.f.f2440b);
            this.f1910g.w(com.seewo.ota.v.s.q.c.f2431b);
            if (getResources().getBoolean(R.bool.support_breath_light)) {
                this.f1910g.w(com.seewo.ota.v.s.q.b.f2430b);
            }
            this.f1910g.w(com.seewo.ota.v.s.q.e.f2436f);
        }
        return this.f1910g;
    }

    private String t(int i2) {
        return i2 == 1 ? "Platform" : "Slot";
    }

    private void x(int i2, int i3) {
        int iBeginBroadcast = this.f1909f.beginBroadcast();
        for (int i4 = 0; i4 < iBeginBroadcast; i4++) {
            if (((Integer) this.f1909f.getBroadcastCookie(i4)).intValue() == i3) {
                try {
                    ((d.e.b.a.a) this.f1909f.getBroadcastItem(i4)).g(i2);
                } catch (RemoteException e2) {
                    Log.e("OTARefreshService", "notifyCheckResult", e2);
                }
            }
        }
        this.f1909f.finishBroadcast();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void y(int i2, int i3, int i4) {
        int iBeginBroadcast = this.f1909f.beginBroadcast();
        for (int i5 = 0; i5 < iBeginBroadcast; i5++) {
            if (((Integer) this.f1909f.getBroadcastCookie(i5)).intValue() == i4) {
                try {
                    ((d.e.b.a.a) this.f1909f.getBroadcastItem(i5)).j(i2, i3);
                } catch (RemoteException e2) {
                    Log.e("OTARefreshService", "notifyDownloadResult", e2);
                }
            }
        }
        this.f1909f.finishBroadcast();
    }

    private void z(int i2) {
        int iBeginBroadcast = this.f1909f.beginBroadcast();
        for (int i3 = 0; i3 < iBeginBroadcast; i3++) {
            try {
                ((d.e.b.a.a) this.f1909f.getBroadcastItem(i3)).I(i2);
            } catch (RemoteException e2) {
                Log.e("OTARefreshService", "notifyUpgradeProgress", e2);
            }
        }
        this.f1909f.finishBroadcast();
    }

    @Override // com.seewo.ota.p.b
    public void a(int i2) {
    }

    @Override // com.seewo.ota.p.b
    public void b() {
    }

    @Override // com.seewo.ota.p.b
    public void c(int i2, Object obj) {
        Log.i("OTARefreshService", "onUpgradeCallback: " + i2);
        z(i2);
    }

    @Override // com.seewo.ota.p.b
    public void d(int i2) {
        Log.i("OTARefreshService", "onUpgradeProgress: " + i2);
        A(i2);
    }

    @Override // com.seewo.ota.p.b
    public void e(int i2, int i3) {
        Log.i("OTARefreshService", "onDownloadProgress: " + i2 + ",otaType: " + t(i3));
        y(1, i2, i3);
    }

    @Override // com.seewo.ota.util.n.b
    public void f(boolean z) {
        Log.d("OTARefreshService", "onNetworkChanged: " + z);
        if (z && this.f1911h) {
            if (com.seewo.ota.util.h.a() || w.a() || d.e.g.a.o().q()) {
                G();
            } else {
                Log.d("OTARefreshService", "onNetworkChanged: OpenSDK is not connected, don't startCheckSystemUpdate");
            }
        }
        if (z) {
            I();
        }
    }

    @Override // com.seewo.ota.p.b
    public void g(int i2, int i3, RomUpdateInfo romUpdateInfo, boolean z) {
        Log.i("OTARefreshService", "onCheckUpdateResult: " + i2 + ",otaType: " + t(i3));
        x(i2, i3);
    }

    @Override // com.seewo.ota.p.b
    public void h(int i2, int i3) {
        Log.i("OTARefreshService", "onDownloadPause: " + t(i2));
        y(3, i3, i2);
    }

    @Override // com.seewo.ota.p.b
    public void i(int i2) {
        Log.i("OTARefreshService", "onDownloadError: " + t(i2));
        y(0, 0, i2);
    }

    @Override // com.seewo.ota.p.b
    public void j(RomUpdateInfo romUpdateInfo, int i2, boolean z, boolean z2) {
        Log.i("OTARefreshService", "onDownloadSuccess: " + t(i2));
        y(2, 100, i2);
    }

    @Override // android.app.Service
    public IBinder onBind(Intent intent) {
        return this.o;
    }

    @Override // android.app.Service
    public void onCreate() {
        super.onCreate();
        Log.d("OTARefreshService", "onCreate: ");
        UserManager userManager = (UserManager) getSystemService("user");
        this.f1913j = userManager;
        if (!userManager.isAdminUser()) {
            Log.d("OTARefreshService", "onCreate: not admin user, return.");
            stopSelf();
            return;
        }
        r();
        E();
        com.seewo.ota.util.n.b().e(OTARefreshService.class.getName(), this);
        p.r().y(OTARefreshService.class.getName(), this);
        com.seewo.ota.view.f.a.d(this);
        this.f1909f = new RemoteCallbackList<>();
        if (com.seewo.ota.util.h.a() || w.a()) {
            G();
        } else if (d.e.g.a.o().q()) {
            Log.d("OTARefreshService", "onCreate: OpenSDK is connected.");
            G();
        } else {
            Log.w("OTARefreshService", "onCreate: OpenSDK not connected.");
            d.e.g.a.o().m(this, new s() { // from class: com.seewo.ota.a
                @Override // com.seewo.sdk.interfaces.s
                public final void a() {
                    this.a.u();
                }
            });
        }
        if (!com.seewo.ota.data.b.i().y()) {
            s().F();
        } else if (com.seewo.ota.v.s.t.e.f2573b.a().isEmpty()) {
            Log.d("OTARefreshService", "nothing file need to update.");
        } else {
            d.e.h.e.a.p(this, getPackageName(), DeviceUpgradeV2Activity.class.getName());
        }
        com.seewo.ota.t.n.j().O();
        m.a.q(com.seewo.ota.t.n.j());
        H();
    }

    @Override // android.app.Service
    public void onDestroy() {
        super.onDestroy();
        Log.d("OTARefreshService", "onDestroy: ");
        J();
        L();
        com.seewo.ota.util.n.b().f(OTARefreshService.class.getName());
        p.r().E(OTARefreshService.class.getName());
        o oVar = this.f1910g;
        if (oVar != null) {
            oVar.z();
        }
        if (this.f1913j.isAdminUser()) {
            F();
        }
    }

    @Override // android.app.Service
    public int onStartCommand(Intent intent, int i2, int i3) {
        Log.d("OTARefreshService", "onStartCommand: ");
        if (intent != null) {
            boolean z = false;
            boolean booleanExtra = intent.getBooleanExtra("com.seewo.ota.START_UPDATE_DEVICE", false);
            boolean booleanExtra2 = intent.getBooleanExtra("KEY_SYSTEM_OTA_UPDATED", false);
            com.seewo.sdk.interfaces.p pVarA = d.e.g.f.a.a();
            if (!com.seewo.ota.v.s.q.e.f2436f.b() || pVarA == com.seewo.sdk.interfaces.p.ANDROID) {
                z = booleanExtra;
            } else {
                Log.i("OTARefreshService", "onStartCommand: current source is not android, don't start update usb device.");
            }
            if (z) {
                s().I(new com.seewo.ota.v.s.r.c(intent.getIntExtra("pid", -1), intent.getIntExtra("vid", -1)));
            }
            synchronized (this) {
                if (booleanExtra2) {
                    if (!this.f1912i) {
                        this.f1912i = true;
                        if (d.e.g.a.o().q()) {
                            com.seewo.ota.v.r.b.f2376b.a(this).e();
                        } else {
                            d.e.g.a aVarO = d.e.g.a.o();
                            final com.seewo.ota.v.r.b bVarA = com.seewo.ota.v.r.b.f2376b.a(this);
                            bVarA.getClass();
                            aVarO.m(this, new s() { // from class: com.seewo.ota.i
                                @Override // com.seewo.sdk.interfaces.s
                                public final void a() {
                                    bVarA.e();
                                }
                            });
                        }
                    }
                }
            }
        }
        return 1;
    }

    public /* synthetic */ void u() {
        Log.d("OTARefreshService", "onSdkConnected.");
        G();
    }

    public /* synthetic */ void v(ComponentName componentName, boolean z) {
        if (z) {
            C();
        }
    }

    public /* synthetic */ void w(Intent intent) {
        startService(intent);
    }
}
