Merge "Refine TetherSettings"
This commit is contained in:
committed by
Android (Google) Code Review
commit
ee3c5500f6
@@ -761,7 +761,7 @@
|
|||||||
<category android:name="android.intent.category.VOICE_LAUNCH" />
|
<category android:name="android.intent.category.VOICE_LAUNCH" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.TetherSettings" />
|
android:value="com.android.settings.network.tether.TetherSettings" />
|
||||||
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
|
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
|
||||||
android:value="@string/menu_key_network"/>
|
android:value="@string/menu_key_network"/>
|
||||||
</activity>
|
</activity>
|
||||||
@@ -793,7 +793,7 @@
|
|||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:targetActivity="Settings$TetherSettingsActivity">
|
android:targetActivity="Settings$TetherSettingsActivity">
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.TetherSettings" />
|
android:value="com.android.settings.network.tether.TetherSettings" />
|
||||||
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
|
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
|
||||||
android:value="@string/menu_key_network"/>
|
android:value="@string/menu_key_network"/>
|
||||||
</activity-alias>
|
</activity-alias>
|
||||||
|
@@ -72,7 +72,7 @@
|
|||||||
settings:useAdminDisabledSummary="true" />
|
settings:useAdminDisabledSummary="true" />
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedPreference
|
<com.android.settingslib.RestrictedPreference
|
||||||
android:fragment="com.android.settings.TetherSettings"
|
android:fragment="com.android.settings.network.tether.TetherSettings"
|
||||||
android:key="tether_settings"
|
android:key="tether_settings"
|
||||||
android:title="@string/tether_settings_title_all"
|
android:title="@string/tether_settings_title_all"
|
||||||
android:icon="@drawable/ic_wifi_tethering"
|
android:icon="@drawable/ic_wifi_tethering"
|
||||||
|
@@ -23,7 +23,6 @@ import com.android.settings.MainClear;
|
|||||||
import com.android.settings.MainClearConfirm;
|
import com.android.settings.MainClearConfirm;
|
||||||
import com.android.settings.Settings;
|
import com.android.settings.Settings;
|
||||||
import com.android.settings.TestingSettings;
|
import com.android.settings.TestingSettings;
|
||||||
import com.android.settings.TetherSettings;
|
|
||||||
import com.android.settings.TrustedCredentialsSettings;
|
import com.android.settings.TrustedCredentialsSettings;
|
||||||
import com.android.settings.accessibility.AccessibilityDetailsSettingsFragment;
|
import com.android.settings.accessibility.AccessibilityDetailsSettingsFragment;
|
||||||
import com.android.settings.accessibility.AccessibilitySettings;
|
import com.android.settings.accessibility.AccessibilitySettings;
|
||||||
@@ -141,6 +140,7 @@ import com.android.settings.network.apn.ApnEditor;
|
|||||||
import com.android.settings.network.apn.ApnSettings;
|
import com.android.settings.network.apn.ApnSettings;
|
||||||
import com.android.settings.network.telephony.MobileNetworkSettings;
|
import com.android.settings.network.telephony.MobileNetworkSettings;
|
||||||
import com.android.settings.network.telephony.NetworkSelectSettings;
|
import com.android.settings.network.telephony.NetworkSelectSettings;
|
||||||
|
import com.android.settings.network.tether.TetherSettings;
|
||||||
import com.android.settings.nfc.AndroidBeam;
|
import com.android.settings.nfc.AndroidBeam;
|
||||||
import com.android.settings.nfc.PaymentSettings;
|
import com.android.settings.nfc.PaymentSettings;
|
||||||
import com.android.settings.notification.ConfigureNotificationSettings;
|
import com.android.settings.notification.ConfigureNotificationSettings;
|
||||||
|
@@ -28,9 +28,9 @@ import android.os.UserHandle;
|
|||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.TetherSettings;
|
|
||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
import com.android.settings.homepage.contextualcards.ContextualCard;
|
import com.android.settings.homepage.contextualcards.ContextualCard;
|
||||||
|
import com.android.settings.network.tether.TetherSettings;
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2008 The Android Open Source Project
|
* Copyright (C) 2022 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings.network.tether;
|
||||||
|
|
||||||
import static android.net.ConnectivityManager.TETHERING_BLUETOOTH;
|
import static android.net.ConnectivityManager.TETHERING_BLUETOOTH;
|
||||||
import static android.net.ConnectivityManager.TETHERING_USB;
|
import static android.net.ConnectivityManager.TETHERING_USB;
|
||||||
@@ -53,6 +53,9 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.RestrictedSettingsFragment;
|
||||||
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.core.FeatureFlags;
|
import com.android.settings.core.FeatureFlags;
|
||||||
import com.android.settings.datausage.DataSaverBackend;
|
import com.android.settings.datausage.DataSaverBackend;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
@@ -69,7 +72,7 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Displays preferences for Tethering.
|
* Displays preferences for Tethering.
|
||||||
*/
|
*/
|
||||||
@SearchIndexable
|
@SearchIndexable
|
||||||
@@ -368,8 +371,9 @@ public class TetherSettings extends RestrictedSettingsFragment
|
|||||||
registerReceiver();
|
registerReceiver();
|
||||||
|
|
||||||
mEthernetListener = new EthernetListener(this);
|
mEthernetListener = new EthernetListener(this);
|
||||||
if (mEm != null)
|
if (mEm != null) {
|
||||||
mEm.addInterfaceStateListener(r -> mHandler.post(r), mEthernetListener);
|
mEm.addInterfaceStateListener(r -> mHandler.post(r), mEthernetListener);
|
||||||
|
}
|
||||||
|
|
||||||
updateUsbState();
|
updateUsbState();
|
||||||
updateBluetoothAndEthernetState();
|
updateBluetoothAndEthernetState();
|
||||||
@@ -384,8 +388,9 @@ public class TetherSettings extends RestrictedSettingsFragment
|
|||||||
}
|
}
|
||||||
getActivity().unregisterReceiver(mTetherChangeReceiver);
|
getActivity().unregisterReceiver(mTetherChangeReceiver);
|
||||||
mTm.unregisterTetheringEventCallback(mTetheringEventCallback);
|
mTm.unregisterTetheringEventCallback(mTetheringEventCallback);
|
||||||
if (mEm != null)
|
if (mEm != null) {
|
||||||
mEm.removeInterfaceStateListener(mEthernetListener);
|
mEm.removeInterfaceStateListener(mEthernetListener);
|
||||||
|
}
|
||||||
mTetherChangeReceiver = null;
|
mTetherChangeReceiver = null;
|
||||||
mStartTetheringCallback = null;
|
mStartTetheringCallback = null;
|
||||||
mTetheringEventCallback = null;
|
mTetheringEventCallback = null;
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2018 The Android Open Source Project
|
* Copyright (C) 2022 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings.network.tether;
|
||||||
|
|
||||||
import static android.content.Intent.ACTION_MEDIA_SHARED;
|
import static android.content.Intent.ACTION_MEDIA_SHARED;
|
||||||
import static android.content.Intent.ACTION_MEDIA_UNSHARED;
|
import static android.content.Intent.ACTION_MEDIA_UNSHARED;
|
||||||
@@ -53,6 +53,7 @@ import androidx.fragment.app.FragmentActivity;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.FeatureFlags;
|
import com.android.settings.core.FeatureFlags;
|
||||||
import com.android.settingslib.RestrictedSwitchPreference;
|
import com.android.settingslib.RestrictedSwitchPreference;
|
||||||
|
|
||||||
@@ -141,7 +142,7 @@ public class TetherSettingsTest {
|
|||||||
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(new String[0]);
|
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(new String[0]);
|
||||||
|
|
||||||
final List<String> niks =
|
final List<String> niks =
|
||||||
TetherSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
|
TetherSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
|
||||||
|
|
||||||
assertThat(niks).contains(TetherSettings.KEY_USB_TETHER_SETTINGS);
|
assertThat(niks).contains(TetherSettings.KEY_USB_TETHER_SETTINGS);
|
||||||
}
|
}
|
||||||
@@ -154,7 +155,7 @@ public class TetherSettingsTest {
|
|||||||
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(new String[]{"fakeRegex"});
|
when(mTetheringManager.getTetherableUsbRegexs()).thenReturn(new String[]{"fakeRegex"});
|
||||||
|
|
||||||
final List<String> niks =
|
final List<String> niks =
|
||||||
TetherSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
|
TetherSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
|
||||||
|
|
||||||
assertThat(niks).doesNotContain(TetherSettings.KEY_USB_TETHER_SETTINGS);
|
assertThat(niks).doesNotContain(TetherSettings.KEY_USB_TETHER_SETTINGS);
|
||||||
}
|
}
|
||||||
@@ -164,7 +165,7 @@ public class TetherSettingsTest {
|
|||||||
when(mTetheringManager.getTetherableBluetoothRegexs()).thenReturn(new String[0]);
|
when(mTetheringManager.getTetherableBluetoothRegexs()).thenReturn(new String[0]);
|
||||||
|
|
||||||
final List<String> niks =
|
final List<String> niks =
|
||||||
TetherSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
|
TetherSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
|
||||||
|
|
||||||
assertThat(niks).contains(TetherSettings.KEY_ENABLE_BLUETOOTH_TETHERING);
|
assertThat(niks).contains(TetherSettings.KEY_ENABLE_BLUETOOTH_TETHERING);
|
||||||
}
|
}
|
||||||
@@ -176,7 +177,7 @@ public class TetherSettingsTest {
|
|||||||
.thenReturn(new String[]{"fakeRegex"});
|
.thenReturn(new String[]{"fakeRegex"});
|
||||||
|
|
||||||
final List<String> niks =
|
final List<String> niks =
|
||||||
TetherSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
|
TetherSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
|
||||||
|
|
||||||
assertThat(niks).doesNotContain(TetherSettings.KEY_ENABLE_BLUETOOTH_TETHERING);
|
assertThat(niks).doesNotContain(TetherSettings.KEY_ENABLE_BLUETOOTH_TETHERING);
|
||||||
}
|
}
|
||||||
@@ -362,7 +363,7 @@ public class TetherSettingsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateOnlyBluetoothState(TetherSettings tetherSettings) {
|
private void updateOnlyBluetoothState(TetherSettings tetherSettings) {
|
||||||
doReturn(mTetheringManager).when(tetherSettings)
|
doReturn(mTetheringManager).when(mContext)
|
||||||
.getSystemService(Context.TETHERING_SERVICE);
|
.getSystemService(Context.TETHERING_SERVICE);
|
||||||
when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[0]);
|
when(mTetheringManager.getTetherableIfaces()).thenReturn(new String[0]);
|
||||||
when(mTetheringManager.getTetheredIfaces()).thenReturn(new String[0]);
|
when(mTetheringManager.getTetheredIfaces()).thenReturn(new String[0]);
|
Reference in New Issue
Block a user