Exploit database

GH-14fb583d3d1bd2da10251bb1a37b93d6

gitchw/ghostlock-cve-2026-43499

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-43499

166 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files3

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

workspace/decomp/HeyOTA/sources/com/heytap/wearable/ota/install/OTAInstallRunnable.java

Java · 7,537 bytes
package com.heytap.wearable.ota.install;

import android.content.Context;
import android.os.Handler;
import android.os.PowerManager;
import android.text.TextUtils;
import com.heytap.wearable.ota.db.DbHelper;
import com.heytap.wearable.ota.db.SharedPrefManager;
import com.heytap.wearable.ota.strategy.OTAStrategy;
import com.heytap.wearable.ota.util.CommonUtil;
import com.heytap.wearable.ota.util.FileManager;
import com.heytap.wearable.ota.util.Md5SumUtil;
import com.heytap.wearable.ota.util.NearmeUploadUtil;
import com.heytap.wearable.ota.util.OppoLog;
import com.heytap.wearable.ota.util.RecoveryUtils;
import java.io.File;
import java.io.IOException;

/* loaded from: classes.dex */
public class OTAInstallRunnable implements Runnable {
    private static boolean sIsInstalling = false;
    private Context mContext;
    private Handler mHandler;
    private PowerManager.WakeLock mWakelock = null;
    private Md5SumUtil.onProgressListener mOnVerifyProgressListener = new Md5SumUtil.onProgressListener() { // from class: com.heytap.wearable.ota.install.OTAInstallRunnable.1
        @Override // com.heytap.wearable.ota.util.Md5SumUtil.onProgressListener
        public void onProgress(int i) {
            OTAInstallRunnable.this.mHandler.obtainMessage(6004, i, 0).sendToTarget();
        }
    };

    public OTAInstallRunnable(Context context, Handler handler) {
        this.mContext = context;
        this.mHandler = handler;
    }

    @Override // java.lang.Runnable
    public void run() {
        PowerManager.WakeLock wakeLock;
        PackageInstallInfo packageInstallInfo;
        synchronized (OTAInstallRunnable.class) {
            if (sIsInstalling) {
                OppoLog.i("OTAInstallRunnable", "already install!");
                return;
            }
            sIsInstalling = true;
            if (this.mWakelock == null) {
                PowerManager.WakeLock newWakeLock = ((PowerManager) this.mContext.getSystemService("power")).newWakeLock(536870913, "ota:OTAInstall");
                this.mWakelock = newWakeLock;
                newWakeLock.acquire();
            }
            try {
                try {
                    OppoLog.i("OTAInstallRunnable", "ota start install!");
                    packageInstallInfo = DbHelper.getPackageInstallInfo(this.mContext);
                } catch (IOException e) {
                    OppoLog.e("OTAInstallRunnable", "OTAInstallRunnable  exception:" + e.toString());
                    e.printStackTrace();
                    sendStopVerifyMsg();
                    installFail("exception_file_broken");
                    wakeLock = this.mWakelock;
                    if (wakeLock == null) {
                        return;
                    }
                }
                if (packageInstallInfo.status < 7) {
                    OppoLog.e("OTAInstallRunnable", "not downloaded, return " + packageInstallInfo.status);
                    installFail("");
                    PowerManager.WakeLock wakeLock2 = this.mWakelock;
                    if (wakeLock2 != null) {
                        wakeLock2.release();
                        this.mWakelock = null;
                        return;
                    }
                    return;
                }
                if (packageInstallInfo.path == null) {
                    OppoLog.e("OTAInstallRunnable", "get install info exception!" + packageInstallInfo);
                    installFail("file_broken");
                    PowerManager.WakeLock wakeLock3 = this.mWakelock;
                    if (wakeLock3 != null) {
                        wakeLock3.release();
                        this.mWakelock = null;
                        return;
                    }
                    return;
                }
                if (!new File(packageInstallInfo.path).exists()) {
                    OppoLog.e("OTAInstallRunnable", "ota patch file has been deleted");
                    installFail("file_deleted");
                    PowerManager.WakeLock wakeLock4 = this.mWakelock;
                    if (wakeLock4 != null) {
                        wakeLock4.release();
                        this.mWakelock = null;
                        return;
                    }
                    return;
                }
                String str = packageInstallInfo.oldVersion;
                String otaVersion = CommonUtil.getOtaVersion();
                if (str != null && otaVersion != null && !str.equals(otaVersion)) {
                    OppoLog.e("OTAInstallRunnable", " ota version not match!");
                    installFail("ota version not match!");
                    PowerManager.WakeLock wakeLock5 = this.mWakelock;
                    if (wakeLock5 != null) {
                        wakeLock5.release();
                        this.mWakelock = null;
                        return;
                    }
                    return;
                }
                OppoLog.i("OTAInstallRunnable", "ota verifyOriginalPackage!");
                sendStartVerifyMsg();
                if (!FileManager.verifyOriginalPackage(this.mContext, packageInstallInfo.path, packageInstallInfo.md5, packageInstallInfo.size, this.mOnVerifyProgressListener)) {
                    sendStopVerifyMsg();
                    installFail("md5_not_match");
                    PowerManager.WakeLock wakeLock6 = this.mWakelock;
                    if (wakeLock6 != null) {
                        wakeLock6.release();
                        this.mWakelock = null;
                        return;
                    }
                    return;
                }
                SharedPrefManager sharedPrefManager = new SharedPrefManager(this.mContext, 1);
                sharedPrefManager.writePref("last_start_install_time", System.currentTimeMillis());
                String str2 = packageInstallInfo.type == 0 ? "nomal_patch" : "nomal_full";
                OppoLog.d("OTAInstallRunnable", "installMode = " + str2);
                sharedPrefManager.writePref("ota_update_type", str2);
                CommonUtil.setNewFlag(this.mContext, false);
                DbHelper.changeUpdateStatus(this.mContext, 14);
                OppoLog.i("OTAInstallRunnable", "will enter recovery to install");
                RecoveryUtils.installPackage(this.mContext, packageInstallInfo.path);
                wakeLock = this.mWakelock;
                if (wakeLock == null) {
                    return;
                }
                wakeLock.release();
                this.mWakelock = null;
            } catch (Throwable th) {
                PowerManager.WakeLock wakeLock7 = this.mWakelock;
                if (wakeLock7 != null) {
                    wakeLock7.release();
                    this.mWakelock = null;
                }
                throw th;
            }
        }
    }

    private void sendShownVerifyFailMsg(String str) {
        this.mHandler.sendEmptyMessage(7002);
    }

    private void sendStartVerifyMsg() {
        this.mHandler.sendEmptyMessage(6002);
    }

    private void sendStopVerifyMsg() {
        this.mHandler.sendEmptyMessage(6003);
    }

    private void installFail(String str) {
        synchronized (OTAInstallRunnable.class) {
            sIsInstalling = false;
        }
        if (TextUtils.isEmpty(str)) {
            return;
        }
        sendShownVerifyFailMsg(str);
        NearmeUploadUtil.sendNearmeInstallVerifyFailed(this.mContext, str);
        OTAStrategy.clearOtaData(this.mContext);
    }
}