MCPcopy Index your code
hub / github.com/callstack/agent-device / parseAndroidPermissionTarget

Function parseAndroidPermissionTarget

src/platforms/android/settings.ts:286–321  ·  view source on GitHub ↗
(
  permissionTarget: string | undefined,
  permissionMode: string | undefined,
)

Source from the content-addressed store, hash-verified

284}
285
286function parseAndroidPermissionTarget(
287 permissionTarget: string | undefined,
288 permissionMode: string | undefined,
289):
290 | { kind: 'pm'; value: string; type: 'camera' | 'microphone' | 'photos' | 'contacts' }
291 | { kind: 'notifications'; appOps: string; permission: string } {
292 const normalized = parsePermissionTarget(permissionTarget);
293 if (permissionMode?.trim()) {
294 throw new AppError(
295 'INVALID_ARGS',
296 `Permission mode is only supported for photos. Received: ${permissionMode}.`,
297 );
298 }
299 if (normalized === 'camera')
300 return { kind: 'pm', value: 'android.permission.CAMERA', type: 'camera' };
301 if (normalized === 'microphone') {
302 return { kind: 'pm', value: 'android.permission.RECORD_AUDIO', type: 'microphone' };
303 }
304 if (normalized === 'photos') {
305 return { kind: 'pm', value: 'android.permission.READ_MEDIA_IMAGES', type: 'photos' };
306 }
307 if (normalized === 'contacts') {
308 return { kind: 'pm', value: 'android.permission.READ_CONTACTS', type: 'contacts' };
309 }
310 if (normalized === 'notifications') {
311 return {
312 kind: 'notifications',
313 appOps: 'POST_NOTIFICATION',
314 permission: 'android.permission.POST_NOTIFICATIONS',
315 };
316 }
317 throw new AppError(
318 'INVALID_ARGS',
319 `Unsupported permission target on Android: ${permissionTarget}. Use camera|microphone|photos|contacts|notifications.`,
320 );
321}
322
323async function setAndroidPhotoPermission(
324 device: DeviceInfo,

Callers 1

setAndroidSettingFunction · 0.85

Calls 1

parsePermissionTargetFunction · 0.90

Tested by

no test coverage detected