<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">

    <!-- Signature permission: only same-signed apps (e.g. our app via PendingIntent) can start call UI.
         Uses ${applicationId} so prod/stg/dev can coexist on the same device. -->
    <permission
        android:name="${applicationId}.permission.INCOMING_CALL"
        android:protectionLevel="signature" />

    <!-- Android App Permissions -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" tools:replace="android:maxSdkVersion" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="32" tools:replace="android:maxSdkVersion" />
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
    <!-- Required for Android 14+ (API 34+) partial photo/video access via Photo Picker -->
    <uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
    <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
    <uses-permission android:name="android.permission.READ_CALENDAR" />
    <uses-permission android:name="android.permission.WRITE_CALENDAR" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    <!-- Remove ad-related permissions merged from Firebase/AdServices; we do not collect advertising ID -->
    <uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove" />
    <uses-permission android:name="android.permission.ACCESS_ADSERVICES_AD_ID" tools:node="remove" />
    <uses-permission android:name="android.permission.ACCESS_ADSERVICES_ATTRIBUTION" tools:node="remove" />
    <!-- Needed for using foreground service to keep call alive -->
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" tools:node="remove" />

    <!-- Android App Features -->
    <uses-feature android:name="android.hardware.camera" android:required="false" />
    <uses-feature android:name="android.hardware.camera.front" android:required="false" />
    <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
    <uses-feature android:name="android.hardware.audio.output" android:required="false" />
    <uses-feature android:name="android.hardware.microphone" android:required="false" />

    <application
      android:name=".MainApplication"
      android:launchMode="singleTask"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_circle"
      android:allowBackup="false"
      android:largeHeap="true"
      android:theme="@style/BootTheme"
      android:requestLegacyExternalStorage="true"
      android:usesCleartextTraffic="${usesCleartextTraffic}"
      tools:replace="android:theme,android:allowBackup">

      <!-- Remove GetStream's default call UI activity - we use our own React Native UI -->
      <!-- Tapping ongoing call notification will open MainActivity instead -->
      <activity
        android:name="io.getstream.video.android.compose.ui.ComposeStreamCallActivity"
        tools:node="remove" />

      <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/GOOGLE_MAPS_KEY_ANDROID"/>
      <!-- Disable ad-related analytics by default for enterprise PII/privacy compliance (no AAID or ad personalization) -->
      <meta-data android:name="google_analytics_adid_collection_enabled" android:value="false" tools:replace="android:value"/>
      <meta-data android:name="google_analytics_default_allow_ad_storage" android:value="false" tools:replace="android:value"/>
      <meta-data android:name="google_analytics_default_allow_ad_user_data" android:value="false" tools:replace="android:value"/>
      <meta-data android:name="google_analytics_default_allow_ad_personalization_signals" android:value="false" tools:replace="android:value"/>
      <activity
        android:name=".MainActivity"
        android:supportsPictureInPicture="true"
        android:exported="true"
        android:launchMode="singleTask"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
        android:windowSoftInputMode="adjustPan"
        android:screenOrientation="portrait">
        <intent-filter>
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <data android:scheme="humand" />
        </intent-filter>
        <intent-filter android:autoVerify="true">
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <data android:scheme="https" android:host="app.humand.co"/>
        </intent-filter>
        <intent-filter android:autoVerify="true">
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <data android:scheme="https" android:host="app.stg.humand.co"/>
        </intent-filter>
        <intent-filter android:autoVerify="true">
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <data android:scheme="https" android:host="app.dev.humand.co"/>
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:pathPrefix="/${applicationId}/android/callback" android:scheme="${applicationId}" />
        </intent-filter>
      </activity>
      <activity
            android:name=".modules.IncomingCallMessagingService.activity.FullScreenCallActivity"
            android:excludeFromRecents="true"
            android:exported="true"
            android:permission="${applicationId}.permission.INCOMING_CALL"
            android:launchMode="singleTop"
            android:showWhenLocked="true"
            android:showOnLockScreen="true"
            android:taskAffinity=""
            android:theme="@style/IncomingCall.Transparent"
            android:turnScreenOn="true"
            android:windowDisablePreview="true"
        >
          <meta-data
              android:name="android.app.backgroundActivityStarts"
              android:value="allowed" />
      </activity>
        <activity
            android:name=".modules.IncomingCallMessagingService.activity.AcceptCallActivity"
            android:exported="true"
            android:permission="${applicationId}.permission.INCOMING_CALL"
            android:launchMode="singleTop"
            android:showWhenLocked="true"
            android:showOnLockScreen="true"
            android:turnScreenOn="true"
            android:excludeFromRecents="true"
            android:taskAffinity=""
        >
            <meta-data
                android:name="android.app.backgroundActivityStarts"
                android:value="allowed" />
        </activity>
      <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_stat_humand" />
      <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/notification" tools:replace="android:resource" />
      <meta-data android:name="expo.modules.updates.ENABLED" android:value="true" />
      <meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://u.expo.dev/0ddc93a5-a4f7-4f4e-a61b-e98b4a5f40cd" />
      <meta-data android:name="expo.modules.updates.EXPO_RUNTIME_VERSION" android:value="@string/expo_runtime_version" />
      <meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS" />
      <meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0" />
      <meta-data android:name="expo.modules.updates.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY" android:value="{&quot;expo-channel-name&quot;:&quot;${expoChannelName}&quot;}"/>
      <service android:name=".modules.IncomingCallMessagingService.IncomingCallMessagingService" android:exported="false">
        <intent-filter>
          <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
      </service>
      <service
        android:name="app.notifee.core.ForegroundService"
        tools:replace="android:foregroundServiceType"
        android:stopWithTask="true"
        android:foregroundServiceType="shortService|camera|microphone|mediaPlayback"
      />
    <receiver
        android:name=".modules.IncomingCallMessagingService.receiver.CallActionReceiver"
        android:exported="false">
        <intent-filter>
            <action android:name="CALL_ACCEPT" />
            <action android:name="CALL_DECLINE" />
        </intent-filter>
    </receiver>
      <!-- expo-clipboard requires exported=true at runtime (assertion check) -->
      <provider
        android:name="expo.modules.clipboard.ClipboardFileProvider"
        android:authorities="${applicationId}.ClipboardFileProvider"
        android:exported="true"
        tools:node="merge"
        tools:replace="android:exported" />
    </application>
    <queries>
      <intent>
        <action android:name="android.intent.action.VIEW" />
        <!-- If you don't know the MIME type in advance, set "mimeType" to "*/*". -->
        <data android:mimeType="application/pdf" />
      </intent>
      <intent>
          <action android:name="android.intent.action.VIEW" />
          <data android:scheme="https" android:host="*" />
      </intent>
      <intent>
          <action android:name="android.intent.action.VIEW" />
          <data android:scheme="http" android:host="*" />
      </intent>
    </queries>
</manifest>
