Commit 631e5e4c authored by clairehurst's avatar clairehurst 🌱
Browse files

[android] Disable features and functionality

tb#44175: Remove all default browser functionality (Android)
parent 7846ef4d
Loading
Loading
Loading
Loading
Loading
+0 −49
Original line number Diff line number Diff line
@@ -521,7 +521,6 @@
                <data android:host="home"/>
                <data android:host="home_collections"/>
                <data android:host="install_search_widget"/>
                <data android:host="make_default_browser"/>
                <data android:host="open"/>
                <data android:host="settings"/>
                <data android:host="settings_accessibility"/>
@@ -560,54 +559,6 @@
            android:exported="true"
            android:excludeFromRecents="true" >

            <!--
              Respond to `Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, Intent.CATEGORY_APP_BROWSER)`
            -->
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <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" />
                <category android:name="mozilla.components.pwa.category.SHORTCUT" />
                <data android:scheme="http" />
                <data android:scheme="https" />
            </intent-filter>

            <!--Exposed specific deep links for third-party apps to open wallpaper settings.-->
            <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="${deepLinkScheme}"
                    android:host="settings_wallpapers"/>
            </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="http" />
                <data android:scheme="https" />
                <data android:mimeType="text/html" />
                <data android:mimeType="text/plain" />
                <data android:mimeType="application/xhtml+xml" />
            </intent-filter>

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

            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
+0 −32
Original line number Diff line number Diff line
@@ -615,8 +615,6 @@ class SettingsFragment : PreferenceFragmentCompat(), SystemInsetsPaddedFragment,
        val debuggingKey = getPreferenceKey(R.string.pref_key_remote_debugging)
        val preferenceLeakCanary = findPreference<Preference>(leakKey)
        val preferenceRemoteDebugging = findPreference<Preference>(debuggingKey)
        val preferenceMakeDefaultBrowser =
            requirePreference<DefaultBrowserPreference>(R.string.pref_key_make_default_browser)

        // Copied from PrivateBrowsingFragment with some removals
        requirePreference<SwitchPreferenceCompat>(R.string.pref_key_allow_screenshots_in_private_mode).apply {
@@ -648,12 +646,6 @@ class SettingsFragment : PreferenceFragmentCompat(), SystemInsetsPaddedFragment,
            true
        }

        preferenceMakeDefaultBrowser.apply {
            updateSwitch()
            onPreferenceClickListener =
                getClickListenerForMakeDefaultBrowser()
        }

        val preferenceStartProfiler =
            findPreference<Preference>(getPreferenceKey(R.string.pref_key_start_profiler))

@@ -700,30 +692,6 @@ class SettingsFragment : PreferenceFragmentCompat(), SystemInsetsPaddedFragment,
        setupConnectionPreferences()
    }

    private val setToDefaultPromptRequestLauncher: ActivityResultLauncher<Intent> =
        registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
            with(requireContext()) {
                maybeNavigateToSystemSetToDefaultAction(result.resultCode, settings(), dateTimeProvider) {
                    navigateToDefaultBrowserAppsSettings(BuildManufacturerChecker())
                }
            }
        }

    /**
     * For >=Q -> Use new RoleManager API to show in-app browser switching dialog.
     * For <Q && >=N -> Navigate user to Android Default Apps Settings.
     * For <N -> Open sumo page to show user how to change default app.
     */
    private fun getClickListenerForMakeDefaultBrowser(): Preference.OnPreferenceClickListener {
        return Preference.OnPreferenceClickListener {
            maybeRequestDefaultBrowserPrompt(
                WeakReference((requireActivity() as? HomeActivity)),
                setToDefaultPromptRequestLauncher,
            )
            true
        }
    }

    private fun navigateFromSettings(directions: NavDirections) {
        view?.findNavController()?.let { navController ->
            if (navController.currentDestination?.id == R.id.settingsFragment) {
+0 −5
Original line number Diff line number Diff line
@@ -108,11 +108,6 @@
            app:iconSpaceReserved="false"
            app:isPreferenceVisible="false"
            android:title="@string/preferences_import_bookmarks" />

        <org.mozilla.fenix.settings.DefaultBrowserPreference
            android:key="@string/pref_key_make_default_browser"
            app:iconSpaceReserved="false"
            android:title="@string/preferences_set_as_default_browser" />
    </androidx.preference.PreferenceCategory>

    <androidx.preference.PreferenceCategory