#filter substitution
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="@ANDROID_PACKAGE_NAME@"
      android:installLocation="auto"
      android:versionCode="@ANDROID_VERSION_CODE@"
      android:versionName="@MOZ_APP_VERSION@"
#ifdef MOZ_ANDROID_SHARED_ID
      android:sharedUserId="@MOZ_ANDROID_SHARED_ID@"
#endif
      >
    <uses-sdk android:minSdkVersion="@MOZ_ANDROID_MIN_SDK_VERSION@"
#ifdef MOZ_ANDROID_MAX_SDK_VERSION
              android:maxSdkVersion="@MOZ_ANDROID_MAX_SDK_VERSION@"
#endif
              android:targetSdkVersion="23"/>

<!-- The bouncer APK and the main APK should define the same set of
     <permission>, <uses-permission>, and <uses-feature> elements.  This reduces
     the likelihood of permission-related surprises when installing the main APK
     on top of a pre-installed bouncer APK.  Add such shared elements in the
     fileincluded here, so that they can be referenced by both APKs. -->
#include FennecManifest_permissions.xml.in

    <application android:label="@string/moz_app_displayname"
                 android:icon="@drawable/icon"
                 android:logo="@drawable/logo"
                 android:name="@MOZ_ANDROID_APPLICATION_CLASS@"
                 android:hardwareAccelerated="true"
                 android:allowBackup="false"
# The preprocessor does not yet support arbitrary parentheses, so this cannot
# be parenthesized thus to clarify that the logical AND operator has precedence:
#   !defined(MOZILLA_OFFICIAL) || (defined(NIGHTLY_BUILD) && defined(MOZ_DEBUG))
#if !defined(MOZILLA_OFFICIAL) || defined(NIGHTLY_BUILD) && defined(MOZ_DEBUG)
                 android:debuggable="true">
#else
                 android:debuggable="false">
#endif

        <meta-data android:name="com.sec.android.support.multiwindow" android:value="true"/>

#ifdef MOZ_NATIVE_DEVICES
        <!-- This resources comes from Google Play Services. Required for casting support. -->
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
        <service android:name="org.mozilla.gecko.RemotePresentationService" android:exported="false"/>

#endif

        <!-- This activity handles all incoming Intents and dispatches them to other activities. -->
        <activity android:name="org.mozilla.gecko.LauncherActivity"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            android:relinquishTaskIdentity="true"
            android:taskAffinity=""
            android:excludeFromRecents="true" />

        <!-- Fennec is shipped as the Android package named
             org.mozilla.{fennec,firefox,firefox_beta}.  The internal Java
             package hierarchy inside the Android package used to have an
             org.mozilla.{fennec,firefox,firefox_beta} subtree *and* an
             org.mozilla.gecko subtree; it now only has org.mozilla.gecko. -->
        <activity android:name="@MOZ_ANDROID_BROWSER_INTENT_CLASS@"
                  android:label="@string/moz_app_displayname"
                  android:taskAffinity="@ANDROID_PACKAGE_NAME@.BROWSER"
                  android:alwaysRetainTaskState="true"
                  android:configChanges="keyboard|keyboardHidden|mcc|mnc|orientation|screenSize|locale|layoutDirection|smallestScreenSize|screenLayout"
                  android:windowSoftInputMode="stateUnspecified|adjustResize"
                  android:launchMode="singleTask"
                  android:exported="true"
                  android:theme="@style/Gecko.App" />

        <!-- Bug 1256615 / Bug 1268455: We published an .App alias and we need to maintain it
             forever.  If we don't, home screen shortcuts will disappear because the intent
             filter details change. -->
        <activity-alias android:name=".App"
                        android:label="@MOZ_APP_DISPLAYNAME@"
                        android:targetActivity="org.mozilla.gecko.LauncherActivity">

            <!-- android:priority ranges between -1000 and 1000.  We never want
                 another activity to usurp the MAIN action, so we ratchet our
                 priority up. -->
            <intent-filter android:priority="999">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.MULTIWINDOW_LAUNCHER"/>
                <category android:name="android.intent.category.APP_BROWSER" />
                <category android:name="android.intent.category.DEFAULT" />
            </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="http" />
                <data android:scheme="https" />
                <data android:scheme="about" />
                <data android:scheme="javascript" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="file" />
                <data android:scheme="http" />
                <data android:scheme="https" />
                <data android:mimeType="text/html"/>
                <data android:mimeType="text/plain"/>
                <data android:mimeType="application/xhtml+xml"/>
            </intent-filter>

            <meta-data android:name="com.sec.minimode.icon.portrait.normal"
                       android:resource="@drawable/icon"/>

            <meta-data android:name="com.sec.minimode.icon.landscape.normal"
                       android:resource="@drawable/icon" />

            <intent-filter>
                <action android:name="org.mozilla.gecko.ACTION_ALERT_CALLBACK" />
            </intent-filter>

            <intent-filter>
                <action android:name="org.mozilla.gecko.GUEST_SESSION_INPROGRESS" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

            <intent-filter>
                <action android:name="org.mozilla.gecko.UPDATE"/>
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.WEB_SEARCH" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="" />
                <data android:scheme="http" />
                <data android:scheme="https" />
            </intent-filter>

            <!-- For XPI installs from websites and the download manager. -->
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="file" />
                <data android:scheme="http" />
                <data android:scheme="https" />
                <data android:mimeType="application/x-xpinstall" />
            </intent-filter>

            <!-- For XPI installs from file: URLs. -->
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:host="" />
                <data android:scheme="file" />
                <data android:pathPattern=".*\\.xpi" />
            </intent-filter>

#ifdef MOZ_ANDROID_BEAM
            <intent-filter>
                <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="http" />
                <data android:scheme="https" />
            </intent-filter>
#endif

            <!-- For debugging -->
            <intent-filter>
                <action android:name="org.mozilla.gecko.DEBUG" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity-alias>

        <service android:name="org.mozilla.gecko.GeckoService" />

        <activity android:name="org.mozilla.gecko.trackingprotection.TrackingProtectionPrompt"
                  android:launchMode="singleTop"
                  android:theme="@style/OverlayActivity" />

        <activity android:name="org.mozilla.gecko.promotion.SimpleHelperUI"
                  android:launchMode="singleTop"
                  android:theme="@style/OverlayActivity" />

        <activity android:name="org.mozilla.gecko.promotion.HomeScreenPrompt"
                  android:launchMode="singleTop"
                  android:theme="@style/OverlayActivity" />

        <!-- The main reason for the Tab Queue build flag is to not mess with the VIEW intent filter
             before the rest of the plumbing is in place -->

        <service android:name="org.mozilla.gecko.tabqueue.TabQueueService" />

        <activity android:name="org.mozilla.gecko.tabqueue.TabQueuePrompt"
                  android:launchMode="singleTop"
                  android:theme="@style/OverlayActivity" />

        <receiver android:name="org.mozilla.gecko.restrictions.RestrictionProvider">
          <intent-filter>
            <action android:name="android.intent.action.GET_RESTRICTION_ENTRIES" />
          </intent-filter>
        </receiver>

        <!-- Masquerade as the Resolver so that we can be opened from the Marketplace. -->
        <activity-alias
            android:name="com.android.internal.app.ResolverActivity"
            android:targetActivity="@MOZ_ANDROID_BROWSER_INTENT_CLASS@"
            android:exported="true" />

        <receiver android:name="org.mozilla.gecko.GeckoUpdateReceiver">
            <intent-filter>
                <action android:name="@ANDROID_PACKAGE_NAME@.CHECK_UPDATE_RESULT" />
            </intent-filter>
        </receiver>

        <receiver android:name="org.mozilla.gecko.GeckoMessageReceiver"
                  android:exported="false">
        </receiver>

        <!-- Catch install referrer so we can do post-install work. -->
        <receiver android:name="org.mozilla.gecko.distribution.ReferrerReceiver"
                  android:exported="true">
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>

        <service android:name="org.mozilla.gecko.Restarter"
                 android:exported="false"
                 android:process="@MANGLED_ANDROID_PACKAGE_NAME@.Restarter">
        </service>

        <service android:name="org.mozilla.gecko.media.MediaControlService"
                 android:exported="false">
        </service>

        <receiver android:name="org.mozilla.gecko.AlarmReceiver" >
        </receiver>

        <receiver
            android:name="org.mozilla.gecko.notifications.WhatsNewReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_REPLACED" />
                <data android:scheme="package" android:path="org.mozilla.gecko" />
            </intent-filter>
        </receiver>

        <receiver
            android:name="org.mozilla.gecko.notifications.NotificationReceiver"
            android:exported="false">
            <!-- Notification API V2 -->
            <intent-filter>
                <action android:name="@ANDROID_PACKAGE_NAME@.helperBroadcastAction" />
                <action android:name="@ANDROID_PACKAGE_NAME@.NOTIFICATION_CLICK" />
                <action android:name="@ANDROID_PACKAGE_NAME@.NOTIFICATION_CLOSE" />
                <data android:scheme="moz-notification" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </receiver>

#include ../services/manifests/FxAccountAndroidManifest_activities.xml.in
#ifdef MOZ_ANDROID_SEARCH_ACTIVITY
#include ../search/manifests/SearchAndroidManifest_activities.xml.in
#endif

#if MOZ_CRASHREPORTER
  <activity android:name="org.mozilla.gecko.CrashReporter"
            android:process="@ANDROID_PACKAGE_NAME@.CrashReporter"
            android:label="@string/crash_reporter_title"
            android:icon="@drawable/crash_reporter"
            android:theme="@style/Gecko"
            android:exported="false"
            android:excludeFromRecents="true">
          <intent-filter>
            <action android:name="org.mozilla.gecko.reportCrash" />
          </intent-filter>
  </activity>
#endif

        <activity android:name="org.mozilla.gecko.preferences.GeckoPreferences"
                  android:theme="@style/Gecko.Preferences"
                  android:configChanges="orientation|screenSize|locale|layoutDirection"
                  android:excludeFromRecents="true"/>

        <provider android:name="org.mozilla.gecko.db.BrowserProvider"
                  android:authorities="@ANDROID_PACKAGE_NAME@.db.browser"
                  android:exported="false"/>

        <provider android:name="org.mozilla.gecko.distribution.PartnerBookmarksProviderProxy"
                  android:authorities="@ANDROID_PACKAGE_NAME@.partnerbookmarks"
                  android:exported="false"/>

        <!-- Share overlay activity

             Setting launchMode="singleTop" ensures onNewIntent is called when the Activity is
             reused. Ideally we create a new instance but Android L breaks this (bug 1137928). -->
        <activity android:name="org.mozilla.gecko.overlays.ui.ShareDialog"
                  android:label="@string/overlay_share_label"
                  android:theme="@style/OverlayActivity"
                  android:configChanges="keyboard|keyboardHidden|mcc|mnc|locale|layoutDirection"
                  android:launchMode="singleTop"
                  android:windowSoftInputMode="stateAlwaysHidden|adjustResize">

            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="text/plain" />
            </intent-filter>

        </activity>

#ifdef MOZ_ANDROID_CUSTOM_TABS
        <activity android:name="org.mozilla.gecko.customtabs.CustomTabsActivity"
            android:theme="@style/Theme.AppCompat.NoActionBar" />
#endif

        <!-- Service to handle requests from overlays. -->
        <service android:name="org.mozilla.gecko.overlays.service.OverlayActionService" />

        <!--
          Ensure that passwords provider runs in its own process. (Bug 718760.)
          Process name is per-application to avoid loading CPs from multiple
          Fennec versions into the same process. (Bug 749727.)
          Process name is a mangled version to avoid a Talos bug. (Bug 750548.)
          -->
        <provider android:name="org.mozilla.gecko.db.PasswordsProvider"
                  android:label="@string/sync_configure_engines_title_passwords"
                  android:authorities="@ANDROID_PACKAGE_NAME@.db.passwords"
                  android:exported="false"
                  android:process="@MANGLED_ANDROID_PACKAGE_NAME@.PasswordsProvider"/>

        <provider android:name="org.mozilla.gecko.db.LoginsProvider"
                  android:label="@string/sync_configure_engines_title_passwords"
                  android:authorities="@ANDROID_PACKAGE_NAME@.db.logins"
                  android:exported="false"/>

        <provider android:name="org.mozilla.gecko.db.FormHistoryProvider"
                  android:label="@string/sync_configure_engines_title_history"
                  android:authorities="@ANDROID_PACKAGE_NAME@.db.formhistory"
                  android:exported="false"/>

        <provider android:name="org.mozilla.gecko.GeckoProfilesProvider"
                  android:authorities="@ANDROID_PACKAGE_NAME@.profiles"
                  android:exported="false"/>

        <provider android:name="org.mozilla.gecko.db.TabsProvider"
                  android:label="@string/sync_configure_engines_title_tabs"
                  android:authorities="@ANDROID_PACKAGE_NAME@.db.tabs"
                  android:exported="false"/>

        <provider android:name="org.mozilla.gecko.db.HomeProvider"
                  android:authorities="@ANDROID_PACKAGE_NAME@.db.home"
                  android:exported="false"/>

        <provider android:name="org.mozilla.gecko.db.SearchHistoryProvider"
                  android:authorities="@ANDROID_PACKAGE_NAME@.db.searchhistory"
                  android:exported="false"/>

        <service
            android:exported="false"
            android:name="org.mozilla.gecko.updater.UpdateService"
            android:process="@MANGLED_ANDROID_PACKAGE_NAME@.UpdateService">
        </service>

        <service
            android:exported="false"
            android:name="org.mozilla.gecko.notifications.NotificationService">
        </service>

        <service
            android:exported="false"
            android:name="org.mozilla.gecko.dlc.DownloadContentService">
        </service>

        <service
            android:exported="false"
            android:name="org.mozilla.gecko.feeds.FeedService">
        </service>

        <!-- DON'T EXPORT THIS, please! An attacker could delete arbitrary files. -->
        <service
            android:exported="false"
            android:name="org.mozilla.gecko.cleanup.FileCleanupService">
        </service>

        <receiver
            android:name="org.mozilla.gecko.feeds.FeedAlarmReceiver"
            android:exported="false" />

        <receiver
            android:name="org.mozilla.gecko.BootReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"></action>
            </intent-filter>
        </receiver>

        <receiver
            android:name="org.mozilla.gecko.PackageReplacedReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED"></action>
            </intent-filter>
        </receiver>

        <service
          android:name="org.mozilla.gecko.telemetry.TelemetryUploadService"
          android:exported="false"/>

#ifdef MOZ_ANDROID_CUSTOM_TABS
        <service
            android:name="org.mozilla.gecko.customtabs.GeckoCustomTabsService"
            android:exported="true">
            <intent-filter>
                <action android:name="android.support.customtabs.action.CustomTabsService" />
            </intent-filter>
        </service>
#endif

#include ../services/manifests/FxAccountAndroidManifest_services.xml.in

        <service
            android:name="org.mozilla.gecko.tabqueue.TabReceivedService"
            android:exported="false" />


#ifdef MOZ_ANDROID_SEARCH_ACTIVITY
#include ../search/manifests/SearchAndroidManifest_services.xml.in
#endif
#ifdef MOZ_ANDROID_MLS_STUMBLER
#include ../stumbler/manifests/StumblerManifest_services.xml.in
#endif

#ifdef MOZ_ANDROID_GCM
#include GcmAndroidManifest_services.xml.in
#endif

        <service
            android:name="org.mozilla.gecko.media.MediaManager"
            android:enabled="true"
            android:exported="false"
            android:process=":media"
            android:isolatedProcess="false">
        </service>

    </application>
</manifest>