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

Commit 33957a5a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Catch IllegalStateException in DPM.isFinancedDevice" into main

parents 816e6be6 888bc2c1
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -17647,9 +17647,17 @@ public class DevicePolicyManager {
            android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS
    })
    public boolean isFinancedDevice() {
        try {
            return isDeviceManaged()
                    && getDeviceOwnerType(getDeviceOwnerComponentOnAnyUser())
                    == DEVICE_OWNER_TYPE_FINANCED;
        } catch (IllegalStateException e) {
            // getDeviceOwnerType() will throw IllegalStateException if the device does not have a
            // DO. This can happen under a race condition when the DO is removed after
            // isDeviceManaged() (so it still returns true) but before getDeviceOwnerType().
            // In this case, the device should not be considered a financed device.
            return false;
        }
    }
    // TODO(b/315298076): revert ag/25574027 and update the doc