Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37e36825 authored by Xinyi Zhou's avatar Xinyi Zhou Committed by Android (Google) Code Review
Browse files

Merge "Use FAST_PAIR_SCAN_ENABLED in Nearby Manager" into tm-dev

parents b166e754 e8d3c429
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.nearby.NearbyManager;
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
@@ -56,9 +57,9 @@ public class FastPairSettingsFragment extends SettingsPreferenceFragment {
                findPreference(SCAN_SWITCH_KEY));
        mainSwitchPreference.addOnSwitchChangeListener(
                (switchView, isChecked) ->
                        Settings.Secure.putInt(getContentResolver(),
                                Settings.Secure.FAST_PAIR_SCAN_ENABLED, isChecked ? 1 : 0));
        mainSwitchPreference.setChecked(isFastPairScanAvailable());
                        NearbyManager.setFastPairScanEnabled(getContext(), isChecked));
        mainSwitchPreference.setChecked(
                NearbyManager.getFastPairScanEnabled(getContext(), false));

        Preference savedDevicePref = Objects.requireNonNull(
                findPreference(SAVED_DEVICES_PREF_KEY));
@@ -89,11 +90,6 @@ public class FastPairSettingsFragment extends SettingsPreferenceFragment {
    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
            new BaseSearchIndexProvider(R.xml.fast_pair_settings);

    private boolean isFastPairScanAvailable() {
        return Settings.Secure.getInt(getContentResolver(),
                Settings.Secure.FAST_PAIR_SCAN_ENABLED, 1) != 0;
    }

    @Nullable
    private ComponentName getSavedDevicesComponent() {
        String savedDevicesComponent = Settings.Secure.getString(