Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18fb750c authored by Tianjie's avatar Tianjie
Browse files

Clear caller id when reading device config

Reading the DeviceConfig with the gmscore call id will result in a
security exception.

Also clear the caller identity when before calling into locksettings
to armRebootEscrow. This is inline with the other usage for RoR
preparation.

Bug: 183475757
Test: trigger RoR from gmscore
Change-Id: Ifc65625fc7aba05d016c127cf6672922a5ffb000
parent fb5d22ff
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -734,7 +734,15 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
            return REBOOT_ERROR_SLOT_MISMATCH;
        }

        if (!mInjector.getLockSettingsService().armRebootEscrow()) {
        final long origId = Binder.clearCallingIdentity();
        boolean result;
        try {
            result = mInjector.getLockSettingsService().armRebootEscrow();
        } finally {
            Binder.restoreCallingIdentity(origId);
        }

        if (!result) {
            Slog.w(TAG, "Failure to escrow key for reboot");
            return REBOOT_ERROR_ARM_REBOOT_ESCROW_FAILURE;
        }
@@ -742,11 +750,20 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
        return REBOOT_ERROR_NONE;
    }

    private boolean useServerBasedRoR() {
        final long origId = Binder.clearCallingIdentity();
        try {
            return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_OTA,
                    "server_based_ror_enabled", false);
        } finally {
            Binder.restoreCallingIdentity(origId);
        }
    }

    private void reportMetricsOnRebootWithLskf(String packageName, boolean slotSwitch,
            @ResumeOnRebootRebootErrorCode int errorCode) {
        int uid = mInjector.getUidFromPackageName(packageName);
        boolean serverBased = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_OTA,
                "server_based_ror_enabled", false);
        boolean serverBased = useServerBasedRoR();
        int preparedClientCount;
        synchronized (this) {
            preparedClientCount = mCallerPreparedForReboot.size();