salvogiangri / KnoxPatch

LSPosed module to get Samsung apps/features working again in your rooted Galaxy device.
GNU General Public License v3.0
759 stars 31 forks source link

Fix OTA updates possible? #40

Closed high3eam closed 1 year ago

high3eam commented 1 year ago

I was wondering if it was possible to bring back OTA updates with this module or if there is a way to bring it back to life using lsposed modules? Would this be a good feature for KnoxPatch?

salvogiangri commented 1 year ago

Receiving (and also downloading) OTA updates is possible when spoofing the bootloader lock prop (ro.boot.flash.locked) since that's all the FotaAgent app checks for:

package com.idm.fotaagent.enabler.utils;

import android.os.SemSystemProperties;
import com.samsung.android.fotaagent.common.log.Log;

enum BinaryStatusByFlashLocked implements BinaryStatus {
    OFFICIAL,
    CUSTOM,
    UNKNOWN;

    static final String KEY_PROPERTY = "ro.boot.flash.locked";

    static final int FLASH_UNKNOWN = -1;
    static final int FLASH_UNLOCKED = 0;
    static final int FLASH_LOCKED = 1;

    static BinaryStatus getBinaryStatus() {
        return valueOf(getFlashLocked());
    }

    private static int getFlashLocked() {
        return SemSystemProperties.getInt(KEY_PROPERTY, FLASH_UNKNOWN);
    }

    @Override
    public String toString() {
        return name().charAt(0) + name().substring(1).toLowerCase() + " (checked by " + KEY_PROPERTY + ")";
    }

    private static BinaryStatus valueOf(int flashLocked) {
        switch(flashLocked) {
            case FLASH_UNKNOWN:
                return UNKNOWN;
            case FLASH_UNLOCKED:
                return CUSTOM;
            case FLASH_LOCKED:
                return OFFICIAL;
            default:
                Log.W("unexpected flashLocked (" + flashLocked + "), fallback as FLASH_UNKNOWN");
                return UNKNOWN;
        }
    }
}

Issue is they can't be installed due to how block-based OTAs work, so the only way to update a rooted device is via flashing a full firmware package with Odin (BL+CP+AP+HOME_CSC).

high3eam commented 1 year ago

@BlackMesa123 Thanks for the detailed explanation.