Skip to content

Document Upload feature silently fails on modern Android 13+ tablets due to deprecated Storage Permissions #1058

Description

@vibhutomer

Description

The application utilizes permission_handler, file_picker, and image_picker to handle document uploads for resident registration (e.g., within document_upload_control.dart).

Currently, the application relies on the standard Permission.storage request. However, on Android 13 (API Level 33) and above, Google has completely deprecated READ_EXTERNAL_STORAGE. If the application requests Permission.storage to access the gallery or file system, the OS will automatically and silently deny it without ever showing a permission prompt to the user.

Because the core registration flow requires capturing and attaching documents, this silent failure means operators using modern Android tablets will be completely blocked from completing registrations.

Steps to Reproduce

  1. Install the APK on a physical tablet or emulator running Android 13 or 14 (API 33+).
  2. Navigate to a registration flow that requires document upload.
  3. Tap the button to select a document from the gallery or storage.
  4. Observe that no permission dialog appears, the file picker fails to launch, and the action silently fails.

Expected Behavior

The application must detect the Android SDK version at runtime. On Android 13+ devices, it should request the new granular media permissions (READ_MEDIA_IMAGES / READ_MEDIA_VIDEO) instead of the deprecated legacy storage permission.

Environment

  • Target Files: document_upload_control.dart, AndroidManifest.xml
  • Impacted Devices: Any device running Android 13 or higher.

Proposed Solution

  1. Update android/app/src/main/AndroidManifest.xml to include the granular permissions:
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
  2. Update the Dart permission logic to conditionally request the correct permission based on the device's OS version:
    import 'dart:io';
    import 'package:device_info_plus/device_info_plus.dart';
    import 'package:permission_handler/permission_handler.dart';
    
    Future<bool> requestStoragePermission() async {
      if (Platform.isAndroid) {
        final androidInfo = await DeviceInfoPlugin().androidInfo;
        if (androidInfo.version.sdkInt >= 33) {
          // Use granular permissions for Android 13+
          final photosStatus = await Permission.photos.request();
          return photosStatus.isGranted;
        } else {
          // Use legacy storage permission for Android 12 and below
          final storageStatus = await Permission.storage.request();
          return storageStatus.isGranted;
        }
      }
      return true; // Handle iOS/other platforms accordingly
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions