Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add ios 14 and above case #351

Merged
merged 12 commits into from
Jan 9, 2023
Prev Previous commit
Next Next commit
use limited for newer version
  • Loading branch information
KazuCocoa committed Jan 9, 2023
commit 6527f30c4628022f1f97e436250aa32b56ebd504
33 changes: 16 additions & 17 deletions lib/extensions/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { fs, util } from '@appium/support';
import { exec } from 'teen_process';
import path from 'path';

const STATUS_UNSET = 'unset';
const STATUS_NO = 'no';
const STATUS_YES = 'yes';
const STATUS_LIMITED = 'limited';
const STATUS = Object.freeze({
UNSET: 'unset',
NO: 'no',
YES: 'yes',
LIMITED: 'limited',
});

const WIX_SIM_UTILS = 'applesimutils';
const SERVICES = Object.freeze({
calendar: 'kTCCServiceCalendar',
Expand All @@ -34,7 +37,7 @@ function toInternalServiceName (serviceName) {
}

function formatStatus (status) {
return [STATUS_UNSET, STATUS_NO].includes(status) ? _.toUpper(status) : status;
return [STATUS.UNSET, STATUS.NO].includes(status) ? _.toUpper(status) : status;
}

/**
Expand Down Expand Up @@ -119,25 +122,21 @@ async function getAccess (bundleId, serviceName, simDataRoot) {
return status;
}
}
return STATUS_UNSET;
return STATUS.UNSET;
};

try {
// iOS 14 and above
return await getAccessStatus(
[['0', STATUS_NO], ['2', STATUS_YES], ['3', STATUS_LIMITED]],
const xcodeVersion = await getVersion(true);
return xcodeVersion.major >= 13 ?
await getAccessStatus(
[['0', UNSET.NO], ['2', UNSET.YES], ['3', STATUS.LIMITED]],
'auth_value'
);
} catch {
// iOS 13 and below
return await getAccessStatus(
[['0', STATUS_NO], ['1', STATUS_YES]],
) :
await getAccessStatus(
[['0', UNSET.NO], ['1', UNSET.YES]],
'allowed'
);
}
}


const extensions = {};

/**
Expand Down