Fix EthernetManager.addListener dependency in Tethering settings.

Ethernet service related files are going to be moved into Connectivity
module. EthernetManager.addListener(listener, exectuor) will be exposed
out as module-lib API. Replace the current API usage with the one to be
exposed.

android.os.HandlerExecutor is a hidden API which isn't visible to modules,
try to replace HanlderExecutor class with Handler.post itself although
Setttings can still access this API.

Bug: 210586283
Test: m
Change-Id: I618b43769c68897f4724fae8213181be1cc770c6
This commit is contained in:
Xiao Ma
2022-01-18 06:44:52 +00:00
parent 0ccb8750b9
commit f621c4ba14
2 changed files with 8 additions and 10 deletions

View File

@@ -48,13 +48,12 @@ public final class EthernetTetherPreferenceController extends TetherBasePreferen
@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onStart() {
mEthernetListener = new EthernetManager.Listener() {
@Override
public void onAvailabilityChanged(String iface, boolean isAvailable) {
new Handler(Looper.getMainLooper()).post(() -> updateState(mPreference));
}
};
mEthernetManager.addListener(mEthernetListener);
mEthernetListener = (iface, isAvailable) -> updateState(mPreference);
final Handler handler = new Handler(Looper.getMainLooper());
// Executor will execute to post the updateState event to a new handler which is created
// from the main looper when the {@link EthernetManager.Listener.onAvailabilityChanged}
// is triggerd.
mEthernetManager.addListener(mEthernetListener, r -> handler.post(r));
}
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)