Skip to content

Commit

Permalink
Fix status
Browse files Browse the repository at this point in the history
  • Loading branch information
keeramis committed Jun 13, 2024
1 parent fafeb5e commit 9bc891a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/cmd/device-protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,28 @@ module.exports = class DeviceProtectionCommands extends CLICommandBase {
// then the device is not pretected. For now though, let's assume the device is in normal mode and not in dfu mode.

return this._withDevice(async () => {
let status;
let s;
try {
status = await this.device.getProtectionState();
s = await this.device.getProtectionState();
} catch (error) {
if (error.message === 'Not implemented') {
throw new Error('Device protection status is not supported on this device${os.EOL}${os.EOL}');
}
throw new Error('Failed to get device protection status');
}

this.ui.stdout.write(`Device Protection: ${status.protected ? 'Active' : 'Not active'}${os.EOL}${os.EOL}`);
let res;
if (!s.protected && !s.overridden) {
res = 'Not Active';
} else if (s.protected && !s.overridden) {
res = 'Active';
} else if (s.overridden) {
res = 'Temporarily Not Active';
}

this.ui.stdout.write(`Device Protection: ${res}${os.EOL}${os.EOL}`);

return status;
return s;
});
}

Expand Down

0 comments on commit 9bc891a

Please sign in to comment.