[Provider model] Add "Turn off/on Wi-Fi" link to Internet Panel
- Replace the left menu button with "Turn off/on Wi-Fi" - Remove the TurnOnWifiSlice - Show "Wi-Fi is off" sub-title when Wi-Fi is disabled - Remove the "Wi\u-Fi is turned on" sub-title when APM is on. Bug: 188710392 Test: manual test atest -c InternetConnectivityPanelTest make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.panel Change-Id: I53e200f6cadf8b712bf794bcbd5ff79f0f239cc0
This commit is contained in:
@@ -19,8 +19,6 @@ package com.android.settings.panel;
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_PAUSE;
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
|
||||
|
||||
import static com.android.settings.network.NetworkProviderSettings.ACTION_NETWORK_PROVIDER_SETTINGS;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@@ -32,7 +30,6 @@ import android.net.wifi.WifiManager;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerExecutor;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyCallback;
|
||||
@@ -41,6 +38,7 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
|
||||
@@ -64,7 +62,7 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
SubscriptionsChangeListener.SubscriptionsChangeListenerClient {
|
||||
private static final String TAG = "InternetConnectivityPanel";
|
||||
private static final int SUBTITLE_TEXT_NONE = -1;
|
||||
private static final int SUBTITLE_TEXT_WIFI_IS_TURNED_ON = R.string.wifi_is_turned_on_subtitle;
|
||||
private static final int SUBTITLE_TEXT_WIFI_IS_OFF = R.string.wifi_is_off;
|
||||
private static final int SUBTITLE_TEXT_TAP_A_NETWORK_TO_CONNECT =
|
||||
R.string.tap_a_network_to_connect;
|
||||
private static final int SUBTITLE_TEXT_SEARCHING_FOR_NETWORKS =
|
||||
@@ -198,7 +196,6 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
final List<Uri> uris = new ArrayList<>();
|
||||
if (mIsProviderModelEnabled) {
|
||||
uris.add(CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI);
|
||||
uris.add(CustomSliceRegistry.TURN_ON_WIFI_SLICE_URI);
|
||||
} else {
|
||||
uris.add(CustomSliceRegistry.WIFI_SLICE_URI);
|
||||
uris.add(CustomSliceRegistry.MOBILE_DATA_SLICE_URI);
|
||||
@@ -209,9 +206,7 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
|
||||
@Override
|
||||
public Intent getSeeMoreIntent() {
|
||||
return new Intent(mIsProviderModelEnabled
|
||||
? ACTION_NETWORK_PROVIDER_SETTINGS : Settings.ACTION_WIRELESS_SETTINGS)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -221,15 +216,14 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
|
||||
@Override
|
||||
public CharSequence getCustomizedButtonTitle() {
|
||||
if (mInternetUpdater.isAirplaneModeOn() && !mInternetUpdater.isWifiEnabled()) {
|
||||
return null;
|
||||
}
|
||||
return mContext.getText(R.string.settings_button);
|
||||
return mContext.getText(
|
||||
mInternetUpdater.isWifiEnabled() ? R.string.turn_off_wifi : R.string.turn_on_wifi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickCustomizedButton() {
|
||||
mContext.startActivity(getSeeMoreIntent());
|
||||
public void onClickCustomizedButton(FragmentActivity panelActivity) {
|
||||
// Don't finish the panel activity
|
||||
mWifiManager.setWifiEnabled(!mInternetUpdater.isWifiEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -290,15 +284,7 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
return;
|
||||
}
|
||||
updateSubtitleText();
|
||||
|
||||
log("Subtitle:" + mSubtitle);
|
||||
if (mSubtitle != SUBTITLE_TEXT_NONE) {
|
||||
mCallback.onHeaderChanged();
|
||||
} else {
|
||||
// Other situations.
|
||||
// Title: Airplane mode / Internet
|
||||
mCallback.onTitleChanged();
|
||||
}
|
||||
mCallback.onHeaderChanged();
|
||||
mCallback.onCustomizedButtonStateChanged();
|
||||
}
|
||||
|
||||
@@ -310,15 +296,23 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
private void updateSubtitleText() {
|
||||
mSubtitle = SUBTITLE_TEXT_NONE;
|
||||
if (!mInternetUpdater.isWifiEnabled()) {
|
||||
if (!mInternetUpdater.isAirplaneModeOn()) {
|
||||
// When the airplane mode is off and Wi-Fi is disabled.
|
||||
// Sub-Title: Wi-Fi is off
|
||||
log("Airplane mode off + Wi-Fi off.");
|
||||
mSubtitle = SUBTITLE_TEXT_WIFI_IS_OFF;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIsProgressBarVisible) {
|
||||
// When the Wi-Fi scan result callback is received
|
||||
// Sub-Title: Searching for networks...
|
||||
mSubtitle = SUBTITLE_TEXT_SEARCHING_FOR_NETWORKS;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mInternetUpdater.isAirplaneModeOn()) {
|
||||
// When the airplane mode is on and Wi-Fi is enabled.
|
||||
// Title: Airplane mode
|
||||
// Sub-Title: Wi-Fi is turned on
|
||||
log("Airplane mode is on + Wi-Fi on.");
|
||||
mSubtitle = SUBTITLE_TEXT_WIFI_IS_TURNED_ON;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -330,13 +324,6 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIsProgressBarVisible) {
|
||||
// When the Wi-Fi scan result callback is received
|
||||
// Sub-Title: Searching for networks...
|
||||
mSubtitle = SUBTITLE_TEXT_SEARCHING_FOR_NETWORKS;
|
||||
return;
|
||||
}
|
||||
|
||||
// Sub-Title:
|
||||
// show non_carrier_network_unavailable
|
||||
// - while Wi-Fi on + no Wi-Fi item
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.core.graphics.drawable.IconCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.android.settingslib.core.instrumentation.Instrumentable;
|
||||
|
||||
@@ -94,8 +95,11 @@ public interface PanelContent extends Instrumentable {
|
||||
|
||||
/**
|
||||
* Implement the click event for custom button.
|
||||
*
|
||||
* @param panelActivity the FragmentActivity from PanelFragment, the user can decide whether
|
||||
* to finish activity or not.
|
||||
*/
|
||||
default void onClickCustomizedButton() {}
|
||||
default void onClickCustomizedButton(FragmentActivity panelActivity) {}
|
||||
|
||||
/**
|
||||
* Register to start receiving callbacks for custom button events.
|
||||
|
||||
@@ -491,11 +491,11 @@ public class PanelFragment extends Fragment {
|
||||
mPanelClosedKey = PanelClosedKeys.KEY_SEE_MORE;
|
||||
final FragmentActivity activity = getActivity();
|
||||
if (mPanel.isCustomizedButtonUsed()) {
|
||||
mPanel.onClickCustomizedButton();
|
||||
mPanel.onClickCustomizedButton(activity);
|
||||
} else {
|
||||
activity.startActivityForResult(mPanel.getSeeMoreIntent(), 0);
|
||||
activity.finish();
|
||||
}
|
||||
activity.finish();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user