Commit Graph

30 Commits

Author SHA1 Message Date
Chaohui Wang
71d1f021af Migrate to CompoundButton.OnCheckedChangeListener
Switch and SwitchCompat are both CompoundButton.

Using CompoundButton in Java will helps migration in the future.

Bug: 306658427
Test: manual - check Settings pages
Change-Id: If2e08a9a9557ec66a3b31ef18cd2e15943098a59
2023-11-07 20:22:27 +08:00
Chaohui Wang
12ea5afdf1 Not call MainSwitchBar.getSwitch()
This is private implement details, will be removed in future.

Should call MainSwitchBar's isChecked() and setChecked() to ensure
main switch bar's style is set correctly.

Bug: 306658427
Test: manual - on wifi tether
Test: manual - on developer options
Test: m RunSettingsRoboTests
Change-Id: I292ffbcf73da0721fc206e3dac7610a0aeb20047
2023-10-25 13:52:43 +08:00
Les Lee
c6c6ef3a58 wifi: Handle wifi ap initial state before register intent
The intent WIFI_AP_STATE_CHANGED_ACTION is not sticky intent after
SC-V2, query wifi ap state and run intent handling after registering intent.

Bug: 231214355
Test: make RunSettingsRoboTests ROBOTEST_FILTER=Hotspot
Test: make RunSettingsRoboTests ROBOTEST_FILTER=Tether
Test: Manual test, the state shows correctly even if resume hotspot settings page from recent app.
Change-Id: Iab6b2b8628d725b003d5e5c4086420a329611745
2022-08-25 23:07:40 +08:00
Weng Su
b1795081da Avoid unnecessary stopTethering when startTethering fails
- If Wi-Fi tethering is enabled or enabling, avoid to startTethering again.

- If Wi-Fi tethering is disabled or disabling, avoid to stopTethering again.

- Add more logs to know which module stopped Tethering.

Bug: 230457055
Test: manual test
make RunSettingsRoboTests ROBOTEST_FILTER=WifiTetherSwitchBarControllerTest

Change-Id: I51d42ac0117d935ecaa9fa7312acc646b43d3593
2022-05-13 05:21:28 +08:00
Weng Su
6c42636cb8 Fix unexpected Wi-Fi hotspot shutdown
- Filter out unnecessary onSwitchChanged callbacks when the switch is
  disabled, which should not be triggered by user input.

- Refine the state handling function to avoid unnecessary
  onSwitchChanged callback.

- Refine the error handling of isHotspotPasswordValid function.

Bug: 227719584
Test: manual test
make RunSettingsRoboTests \
  ROBOTEST_FILTER=WifiTetherSwitchBarControllerTest

Change-Id: If62aaadc8ddb214769b1367d7801b6125bb5377c
2022-04-08 05:35:14 +08:00
Weng Su
b844a7a920 Fix Wi-Fi hotspot switch UI issue
- The Wi-Fi hotspot switch only handles the click event from the UI.

- Use the onSwitchChanged callback to handle click and swipe events.

Bug: 218891956
Test: manual test
make RunSettingsRoboTests \
  ROBOTEST_FILTER=WifiTetherSwitchBarControllerTest

Change-Id: Ie4136443845489be295a8ee0f3058f493a3b5829
2022-03-24 20:09:29 +08:00
Michael Groover
911f7e7aa9 Add unaudited exported flag to exposed runtime receivers
Android T allows apps to declare a runtime receiver as not exported
by invoking registerReceiver with a new RECEIVER_NOT_EXPORTED flag;
receivers registered with this flag will only receive broadcasts from
the platform and the app itself. However to ensure developers can
properly protect their receivers, all apps targeting T or later
registering a receiver for non-system broadcasts must specify either
the exported or not exported flag when invoking #registerReceiver;
if one of these flags is not provided, the platform will throw a
SecurityException. This commit updates all the exposed receivers
with a new RECEIVER_EXPORTED_UNAUDITED flag to maintain the existing
behavior of exporting the receiver while also flagging the receiver
for audit before the T release.

Bug: 161145287
Test: Build
Change-Id: Ie97372efebd8258d9a4c503771d55109a85e6ae9
2021-12-09 20:34:02 -08:00
Bonian Chen
234b698fb2 Revert "[Settings] Support getSystemService(Class<T>)"
This reverts commit d5ccde31a8.

Reason for revert: failure on test cases

Change-Id: I0a179a6ebb5ef1dec566ce6e8facd5f3b82d7c8a
2021-03-30 00:51:15 +00:00
Bonian Chen
d5ccde31a8 [Settings] Support getSystemService(Class<T>)
Add getSystemService(Class<T>) to align the capability with framework
part.

This is a back port from aosp/1639943, aosp/1645152 and aosp/1648047

Bug: 179640862
Test: local
Change-Id: I035db55a71f94000ca35f8d71f03c19208423c73
2021-03-24 00:59:46 +08:00
Stanley Wang
b87ddba6cd Use SettingsLib's MainSwitchBar to replace SwitchBar in Settings.
To log Settings metrics, the MainSwitch extends MainSwitchBar and
replace the SwitchBar in SettingsActivity.

Bug: 175181773
Test: Run robotest and apply the widget in Settings and see the ui

Change-Id: I3add3702e9058ad9192b5172c7cf0e2ccfb55a70
2021-01-14 22:48:31 +08:00
Bonian Chen
a5f08854e3 [Settings] Inclusive language for Data Usage
Change wordings in data usage part into inclusive language.

Bug: 160707804
Test: make RunSettingsRoboTests
Change-Id: I713e52df8201413b884257a51bc1f71a0d43179d
2020-07-15 02:52:32 +00:00
Arc Wang
4fafe6716c [Wi-Fi] Fix Wi-Fi broken tests
Bug: 150910070
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.wifi
Change-Id: Ie9b9384610857e2999fe4642a93c2d31ce3315f3
2020-03-20 15:41:29 +08:00
Arc Wang
ac5e1acfba [Wi-Fi] Control Wi-Fi Hotspot Settings using onClick instead of onSwitchToggled
In the current Settings framework onSwitchToggled has been implemented
to monitor the change in Settings done by user but its getting called
even when Settings is changed using setChecked where under certain
condition like rotation during config changed,
Tether Settings is disabled and then enabled and later before Rotation
Settings remained false due to stop Tethering with Tether Enabled
After Rotation when settings is initialized it is set as disabled
and even after receiving the Tether Enabled it remains Off.
Hence used onClick to monitor user ON/OFF Settings

Bug: 142625203
Test: make RunSettingsRoboTests ROBOTEST_FILTER=WifiTetherSwitchBarControllerTest.java
Test: Manual
1. Go to Wifi Hotspot Settings
2. Turn ON
3. Change SSID and save
4. Rotate screen soon after saving
Result: Hotspot does not turn ON, remains in OFF state.
Signed-off-by:JeiFeng Lee <linger.lee@mediatek.com>

Change-Id: Ibddacdf35eb3196f40cdb2c240efa902f9123646
2020-03-05 18:21:39 +08:00
Salvador Martinez
b94251ad07 Remove airplane mode restriction on hotspot
This isn't needed anymore since we support this now.

Test: robotests
Bug: 111681176
Change-Id: I0292f0a38347e4fa3414170e0351a53f5997a192
2019-03-08 16:34:57 -08:00
Fan Zhang
23f8d59d02 Sort imports
Having consistent import order will reduce chance of merge
conflict between internal and external master

Test: rebuild
Change-Id: I0b1a170967ddcce7f388603fd521f6ed1eeba30b
2018-08-28 22:13:15 +00:00
Fan Zhang
c7162cd24d Reorder and clean up imports.
Test: rebuild
Change-Id: I178485c84ae7146f991fd77b6d7504b029942a68
2018-06-18 15:45:09 -07:00
Meng Wang
3a4e213037 Merge "Revert "Remove provisioning dialog from wifi-tethering"" into pi-dev am: 6fcafbe5bf
am: ed6037dffa

Change-Id: I163fb4c27334f64362033a94ebaad55387c8da61
2018-05-10 12:10:09 -07:00
TreeHugger Robot
6fcafbe5bf Merge "Revert "Remove provisioning dialog from wifi-tethering"" into pi-dev 2018-05-10 18:57:39 +00:00
Meng Wang
6de3389b92 Revert "Remove provisioning dialog from wifi-tethering"
This reverts commit 81ca3dd4c0.

Reason for revert:
This breaks carrier requirement to show error dialog/roaming warning.
Will make an entitlement app change to suppress the progress dialog
so that if the entitlement check succeeds no dialog will be shown
in most cases.

Bug: 78680359
Change-Id: I98d2aa5cc676308b1e2d16bf877dc6878a7bf4cb
2018-05-10 05:15:43 +00:00
Salvador Martinez
60c513d908 Merge "Only start tether when not already enabled" into pi-dev am: f62f91b0b6
am: 964d107491

Change-Id: I0d325498e2ea8526fbc4e6ec4bf579331bf0848b
2018-04-26 14:30:25 -07:00
Salvador Martinez
a4fe5c9871 Only start tether when not already enabled
The toggle in the tether page currently tries to start tethering if
it gets turned on. However, changing a wifi config can cause
startTether to be called and also the toggle to switch leading to
a double call to startTether. This CL makes it so that if we are
already connected to tethering we don't try to start it again.

Test: robotests
Change-Id: I91085244c5d1fcc245a6b6480e638a32bc14f0ac
Fixes: 78028548
Fixes: 78441216
Fixes: 74368363
2018-04-26 10:14:54 -07:00
Aurimas Liutikas
e0069d332d Migrate Settings to androidx.
Test: make Settings
Bug: 76692459
Change-Id: I941dea40562170649bf056e675cc32e5163c0e39
2018-04-20 12:52:29 -07:00
Salvador Martinez
7ba65c39ae Make WifiTether listen to datasaver
Wifi Tethering is already turned off when appropriate. However
if you re-enable it you still can't toggle the tether switchbar.
This CL makes it so that if you disable data saver the toggle
becomes enabled again.

Test: robotests
Bug: 77860936
Change-Id: I03fa74c21674678a90cde7bd20fa68167f02ae3c
2018-04-20 02:56:47 +00:00
Salvador Martinez
81ca3dd4c0 Remove provisioning dialog from wifi-tethering
We no longer want this dialog to show when a user toggles tethering.
Failures to set up the AP will still be handled correctly.

Test: robotests pass
Bug: 62629055
Change-Id: Id3d0bf9694a1c8b6ae353bfd6634dd0b56813497
2018-04-09 15:27:02 -07:00
Lei Yu
0544fbd507 Add callback when tethering fails
Add real callback instead of using NoOpCallback. When it fails,
reset the switchbar.

Change-Id: I6f87d7cefa67ff8f9f59a815fd976940fb61c06c
Fixes: 72904303
Test: RunSettingsRoboTests
2018-03-22 13:07:59 -07:00
Lei Yu
592faf364d Update the toggle state in constructor.
Before this cl, the update of toggle depends on BroadcastReceiver.
However it is not called when toggle is inited, which make the toggle in
broken state sometimes.

This cl make it execute the update method in constructor, so toggle can
get the correct state when it is created.

Fixes: 73718975
Test: RunSettingsRoboTests
Change-Id: Icb798afaff0bdeedad3a966315441712be2e2523
2018-03-22 11:18:43 -07:00
jackqdyulei
dbaea5af63 Clean up WifiTetherPreferenceController
In previous code there are two main issues:
1. It listens to update from both WIFI_AP_STATE_CHANGED_ACTION and
ACTION_TETHER_STATE_CHANGED. It is unnecessary because they provides
same info(whether wifi hotspot is enabled, enabling...)

2. New API softApCallback already covers the
WIFI_AP_STATE_CHANGED_ACTION, so we don't need this broadcast anymore.

This cl fixes those two issues by cleaning up BroadcastReceiver and
update the tests.

Bug: 72702183
Test: RunSettingsRoboTests
Change-Id: I21c2818e0f0185172f34447a1716dc47ee065e23
2018-01-31 18:21:53 -08:00
Fan Zhang
657286112f Pre-set initial state to wifi tether switches.
The preset initial state helps eliminating animation jank when first
landing on the page.

Change-Id: Ia7ba83983f18409b1c653cc1ebb0f3aad281358c
Fixes: 64811322
Test: robotests
2017-09-05 13:57:14 -07:00
Fan Zhang
7686ef863c Misc tweak on wifi hotspot setting page
- Make hotspot password show in plain text
- Make main control into a master switch style

Change-Id: I8fdb293a617787f256fb663708cfc0e454f548d2
Fixes: 63865785
Test: robotests
2017-08-03 16:23:27 -07:00
Fan Zhang
78d5efdfea Refactor hotspot into a full page
- Deprecated WifiAPEnabler, and copied most of its logic into various
  controllers and WifiTetherSettings.
- Added tests

Fix: 37253404
Fix: 36181835

Test: make RunSettingsRoboTests
Change-Id: Iad994d61b694ad7f1113d045a3e7500eeaec178b
2017-06-14 12:32:44 -07:00