Merge changes from topic "launch_wifi_details-sc-v2" into sc-v2-dev
* changes: [RESTRICT AUTOMERGE][Provider Model] Cherry-pick from ag/15243691, ag/15287619, ag/15287620 and ag/15270751 [RESTRICT AUTOMERGE] [ProviderModel] Cherry-pick from master ag/15207286, ag/15216391 and ag/15205988
This commit is contained in:
@@ -20,10 +20,12 @@ import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_
|
|||||||
import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.getMaxNetworkSelectionDisableReason;
|
import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.getMaxNetworkSelectionDisableReason;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.net.wifi.ScanResult;
|
import android.net.wifi.ScanResult;
|
||||||
import android.net.wifi.WifiConfiguration;
|
import android.net.wifi.WifiConfiguration;
|
||||||
import android.net.wifi.WifiConfiguration.NetworkSelectionStatus;
|
import android.net.wifi.WifiConfiguration.NetworkSelectionStatus;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -36,6 +38,23 @@ public class WifiUtils {
|
|||||||
|
|
||||||
private static final int INVALID_RSSI = -127;
|
private static final int INVALID_RSSI = -127;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The intent action shows network details settings to allow configuration of Wi-Fi.
|
||||||
|
* <p>
|
||||||
|
* In some cases, a matching Activity may not exist, so ensure you
|
||||||
|
* safeguard against this.
|
||||||
|
* <p>
|
||||||
|
* Input: The calling package should put the chosen
|
||||||
|
* com.android.wifitrackerlib.WifiEntry#getKey() to a string extra in the request bundle into
|
||||||
|
* the {@link #KEY_CHOSEN_WIFIENTRY_KEY}.
|
||||||
|
* <p>
|
||||||
|
* Output: Nothing.
|
||||||
|
*/
|
||||||
|
public static final String ACTION_WIFI_DETAILS_SETTINGS =
|
||||||
|
"android.settings.WIFI_DETAILS_SETTINGS";
|
||||||
|
public static final String KEY_CHOSEN_WIFIENTRY_KEY = "key_chosen_wifientry_key";
|
||||||
|
public static final String EXTRA_SHOW_FRAGMENT_ARGUMENTS = ":settings:show_fragment_args";
|
||||||
|
|
||||||
static final int[] WIFI_PIE = {
|
static final int[] WIFI_PIE = {
|
||||||
com.android.internal.R.drawable.ic_wifi_signal_0,
|
com.android.internal.R.drawable.ic_wifi_signal_0,
|
||||||
com.android.internal.R.drawable.ic_wifi_signal_1,
|
com.android.internal.R.drawable.ic_wifi_signal_1,
|
||||||
@@ -278,4 +297,17 @@ public class WifiUtils {
|
|||||||
public static boolean isMeteredOverridden(WifiConfiguration config) {
|
public static boolean isMeteredOverridden(WifiConfiguration config) {
|
||||||
return config.meteredOverride != WifiConfiguration.METERED_OVERRIDE_NONE;
|
return config.meteredOverride != WifiConfiguration.METERED_OVERRIDE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Intent for Wi-Fi network details settings.
|
||||||
|
*
|
||||||
|
* @param key The Wi-Fi entry key
|
||||||
|
*/
|
||||||
|
public static Intent getWifiDetailsSettingsIntent(String key) {
|
||||||
|
final Intent intent = new Intent(ACTION_WIFI_DETAILS_SETTINGS);
|
||||||
|
final Bundle bundle = new Bundle();
|
||||||
|
bundle.putString(KEY_CHOSEN_WIFIENTRY_KEY, key);
|
||||||
|
intent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, bundle);
|
||||||
|
return intent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import static org.mockito.Mockito.doReturn;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.net.NetworkKey;
|
import android.net.NetworkKey;
|
||||||
import android.net.RssiCurve;
|
import android.net.RssiCurve;
|
||||||
import android.net.ScoredNetwork;
|
import android.net.ScoredNetwork;
|
||||||
@@ -148,6 +149,17 @@ public class WifiUtilsTest {
|
|||||||
assertThat(WifiUtils.isMeteredOverridden(mWifiConfig)).isTrue();
|
assertThat(WifiUtils.isMeteredOverridden(mWifiConfig)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getWifiDetailsSettingsIntent_returnsCorrectValues() {
|
||||||
|
final String key = "test_key";
|
||||||
|
|
||||||
|
final Intent intent = WifiUtils.getWifiDetailsSettingsIntent(key);
|
||||||
|
|
||||||
|
assertThat(intent.getAction()).isEqualTo(WifiUtils.ACTION_WIFI_DETAILS_SETTINGS);
|
||||||
|
final Bundle bundle = intent.getBundleExtra(WifiUtils.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
|
||||||
|
assertThat(bundle.getString(WifiUtils.KEY_CHOSEN_WIFIENTRY_KEY)).isEqualTo(key);
|
||||||
|
}
|
||||||
|
|
||||||
private static ArrayList<ScanResult> buildScanResultCache() {
|
private static ArrayList<ScanResult> buildScanResultCache() {
|
||||||
ArrayList<ScanResult> scanResults = new ArrayList<>();
|
ArrayList<ScanResult> scanResults = new ArrayList<>();
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
|
|||||||
@@ -27,15 +27,16 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
style="@style/Widget.SliceView.Panel"
|
style="@style/Widget.SliceView.Panel"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="24dp"
|
||||||
android:layout_height="64dp"
|
android:layout_marginBottom="24dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/internet_dialog_title"
|
android:id="@+id/internet_dialog_title"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="32dp"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:fontFamily="google-sans"
|
android:fontFamily="google-sans"
|
||||||
android:textSize="24sp"/>
|
android:textSize="24sp"/>
|
||||||
@@ -44,7 +45,8 @@
|
|||||||
android:id="@+id/internet_dialog_subtitle"
|
android:id="@+id/internet_dialog_subtitle"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="20dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:fontFamily="google-sans"
|
android:fontFamily="google-sans"
|
||||||
@@ -56,6 +58,24 @@
|
|||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="?android:attr/listDivider"/>
|
android:background="?android:attr/listDivider"/>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/wifi_searching_progress"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="1dp"
|
||||||
|
android:maxHeight="1dp"
|
||||||
|
style="@*android:style/Widget.Material.ProgressBar.Horizontal"/>
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:id="@+id/scroll_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/scroll_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/internet_list"
|
android:id="@+id/internet_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -69,18 +89,18 @@
|
|||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_marginRight="@dimen/settingslib_switchbar_margin"
|
android:layout_marginRight="@dimen/settingslib_switchbar_margin"
|
||||||
android:layout_marginLeft="@dimen/settingslib_switchbar_margin"
|
android:layout_marginLeft="@dimen/settingslib_switchbar_margin"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:layout_marginBottom="4dp"
|
android:layout_marginBottom="4dp"
|
||||||
android:paddingStart="@dimen/settingslib_switchbar_padding_left"
|
android:paddingStart="19dp"
|
||||||
android:paddingEnd="@dimen/settingslib_switchbar_padding_right">
|
android:paddingEnd="@dimen/settingslib_switchbar_padding_right">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="36dp"
|
android:layout_width="24dp"
|
||||||
android:layout_height="36dp"
|
android:layout_height="24dp"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:layout_gravity="center_vertical|start">
|
android:layout_gravity="center_vertical|start">
|
||||||
<ImageView
|
<ImageView
|
||||||
@@ -95,12 +115,12 @@
|
|||||||
android:id="@+id/mobile_network_list"
|
android:id="@+id/mobile_network_list"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:layout_marginLeft="3dp"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="start|center_vertical">
|
android:gravity="start|center_vertical">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/mobile_title"
|
android:id="@+id/mobile_title"
|
||||||
|
android:layout_marginLeft="17dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
@@ -111,6 +131,7 @@
|
|||||||
android:fontFamily="google-sans"/>
|
android:fontFamily="google-sans"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/mobile_summary"
|
android:id="@+id/mobile_summary"
|
||||||
|
android:layout_marginLeft="17dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
@@ -123,7 +144,8 @@
|
|||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp">
|
android:layout_height="48dp"
|
||||||
|
android:layout_gravity="end|center_vertical">
|
||||||
<Switch
|
<Switch
|
||||||
android:id="@+id/mobile_toggle"
|
android:id="@+id/mobile_toggle"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
@@ -136,15 +158,6 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/wifi_searching_progress"
|
|
||||||
android:indeterminate="true"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:minHeight="1dp"
|
|
||||||
android:maxHeight="1dp"
|
|
||||||
style="@*android:style/Widget.Material.ProgressBar.Horizontal"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/turn_on_wifi_layout"
|
android:id="@+id/turn_on_wifi_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -155,6 +168,7 @@
|
|||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
android:layout_marginRight="@dimen/settingslib_switchbar_margin"
|
android:layout_marginRight="@dimen/settingslib_switchbar_margin"
|
||||||
android:layout_marginLeft="@dimen/settingslib_switchbar_margin"
|
android:layout_marginLeft="@dimen/settingslib_switchbar_margin"
|
||||||
android:paddingStart="@dimen/settingslib_switchbar_padding_left"
|
android:paddingStart="@dimen/settingslib_switchbar_padding_left"
|
||||||
@@ -203,7 +217,6 @@
|
|||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:layout_marginRight="@dimen/settingslib_switchbar_margin"
|
android:layout_marginRight="@dimen/settingslib_switchbar_margin"
|
||||||
android:layout_marginLeft="@dimen/settingslib_switchbar_margin"
|
android:layout_marginLeft="@dimen/settingslib_switchbar_margin"
|
||||||
android:paddingStart="@dimen/settingslib_switchbar_padding_left"
|
android:paddingStart="@dimen/settingslib_switchbar_padding_left"
|
||||||
@@ -349,3 +362,5 @@
|
|||||||
android:fontFamily="google-sans"/>
|
android:fontFamily="google-sans"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
</LinearLayout>
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import com.android.systemui.qs.logging.QSLogger;
|
|||||||
import com.android.systemui.qs.tileimpl.QSTileImpl;
|
import com.android.systemui.qs.tileimpl.QSTileImpl;
|
||||||
import com.android.systemui.qs.tiles.dialog.InternetDialogFactory;
|
import com.android.systemui.qs.tiles.dialog.InternetDialogFactory;
|
||||||
import com.android.systemui.statusbar.policy.NetworkController;
|
import com.android.systemui.statusbar.policy.NetworkController;
|
||||||
|
import com.android.systemui.statusbar.policy.NetworkController.AccessPointController;
|
||||||
import com.android.systemui.statusbar.policy.NetworkController.IconState;
|
import com.android.systemui.statusbar.policy.NetworkController.IconState;
|
||||||
import com.android.systemui.statusbar.policy.NetworkController.MobileDataIndicators;
|
import com.android.systemui.statusbar.policy.NetworkController.MobileDataIndicators;
|
||||||
import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
|
import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
|
||||||
@@ -69,6 +70,7 @@ public class InternetTile extends QSTileImpl<SignalState> {
|
|||||||
private static final Intent WIFI_SETTINGS = new Intent(Settings.ACTION_WIFI_SETTINGS);
|
private static final Intent WIFI_SETTINGS = new Intent(Settings.ACTION_WIFI_SETTINGS);
|
||||||
|
|
||||||
protected final NetworkController mController;
|
protected final NetworkController mController;
|
||||||
|
private final AccessPointController mAccessPointController;
|
||||||
private final DataUsageController mDataController;
|
private final DataUsageController mDataController;
|
||||||
// The last updated tile state, 0: mobile, 1: wifi, 2: ethernet.
|
// The last updated tile state, 0: mobile, 1: wifi, 2: ethernet.
|
||||||
private int mLastTileState = -1;
|
private int mLastTileState = -1;
|
||||||
@@ -88,6 +90,7 @@ public class InternetTile extends QSTileImpl<SignalState> {
|
|||||||
ActivityStarter activityStarter,
|
ActivityStarter activityStarter,
|
||||||
QSLogger qsLogger,
|
QSLogger qsLogger,
|
||||||
NetworkController networkController,
|
NetworkController networkController,
|
||||||
|
AccessPointController accessPointController,
|
||||||
InternetDialogFactory internetDialogFactory
|
InternetDialogFactory internetDialogFactory
|
||||||
) {
|
) {
|
||||||
super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
|
super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
|
||||||
@@ -95,6 +98,7 @@ public class InternetTile extends QSTileImpl<SignalState> {
|
|||||||
mInternetDialogFactory = internetDialogFactory;
|
mInternetDialogFactory = internetDialogFactory;
|
||||||
mHandler = mainHandler;
|
mHandler = mainHandler;
|
||||||
mController = networkController;
|
mController = networkController;
|
||||||
|
mAccessPointController = accessPointController;
|
||||||
mDataController = mController.getMobileDataController();
|
mDataController = mController.getMobileDataController();
|
||||||
mController.observe(getLifecycle(), mSignalCallback);
|
mController.observe(getLifecycle(), mSignalCallback);
|
||||||
}
|
}
|
||||||
@@ -118,9 +122,8 @@ public class InternetTile extends QSTileImpl<SignalState> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleClick(@Nullable View view) {
|
protected void handleClick(@Nullable View view) {
|
||||||
mHandler.post(() -> {
|
boolean canConfigMobileData = mAccessPointController.canConfigMobileData();
|
||||||
mInternetDialogFactory.create(true);
|
mHandler.post(() -> mInternetDialogFactory.create(true, canConfigMobileData));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -174,10 +174,7 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
|
|||||||
Html.fromHtml(wifiEntry.getSummary(false), Html.FROM_HTML_MODE_LEGACY));
|
Html.fromHtml(wifiEntry.getSummary(false), Html.FROM_HTML_MODE_LEGACY));
|
||||||
|
|
||||||
mWifiListLayout.setOnClickListener(v -> {
|
mWifiListLayout.setOnClickListener(v -> {
|
||||||
if (!isOpenNetwork(security)) {
|
if (wifiEntry.shouldEditBeforeConnect()) {
|
||||||
// Popup Wi-Fi password dialog condition:
|
|
||||||
// 1. The access point is a non-open network.
|
|
||||||
// 2. The Wi-Fi connection is not connected with this access point.
|
|
||||||
final Intent intent = new Intent(ACTION_WIFI_DIALOG);
|
final Intent intent = new Intent(ACTION_WIFI_DIALOG);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
|
|||||||
@@ -15,8 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.systemui.qs.tiles.dialog;
|
package com.android.systemui.qs.tiles.dialog;
|
||||||
|
|
||||||
import static android.view.WindowInsets.Type.navigationBars;
|
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
|
||||||
import static android.view.WindowInsets.Type.statusBars;
|
|
||||||
|
|
||||||
import static com.android.systemui.Prefs.Key.QS_HAS_TURNED_OFF_MOBILE_DATA;
|
import static com.android.systemui.Prefs.Key.QS_HAS_TURNED_OFF_MOBILE_DATA;
|
||||||
|
|
||||||
@@ -56,6 +55,10 @@ import android.widget.Space;
|
|||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.android.internal.logging.UiEvent;
|
import com.android.internal.logging.UiEvent;
|
||||||
import com.android.internal.logging.UiEventLogger;
|
import com.android.internal.logging.UiEventLogger;
|
||||||
import com.android.settingslib.Utils;
|
import com.android.settingslib.Utils;
|
||||||
@@ -68,10 +71,6 @@ import com.android.wifitrackerlib.WifiEntry;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog for showing mobile network, connected Wi-Fi network and Wi-Fi networks.
|
* Dialog for showing mobile network, connected Wi-Fi network and Wi-Fi networks.
|
||||||
*/
|
*/
|
||||||
@@ -127,6 +126,7 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
private int mListMaxHeight;
|
private int mListMaxHeight;
|
||||||
private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
private boolean mIsProgressBarVisible;
|
private boolean mIsProgressBarVisible;
|
||||||
|
private boolean mCanConfigMobileData;
|
||||||
|
|
||||||
private final ViewTreeObserver.OnGlobalLayoutListener mInternetListLayoutListener = () -> {
|
private final ViewTreeObserver.OnGlobalLayoutListener mInternetListLayoutListener = () -> {
|
||||||
// Set max height for list
|
// Set max height for list
|
||||||
@@ -138,7 +138,7 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
};
|
};
|
||||||
|
|
||||||
public InternetDialog(Context context, InternetDialogFactory internetDialogFactory,
|
public InternetDialog(Context context, InternetDialogFactory internetDialogFactory,
|
||||||
InternetDialogController internetDialogController,
|
InternetDialogController internetDialogController, boolean canConfigMobileData,
|
||||||
boolean aboveStatusBar, UiEventLogger uiEventLogger, @Main Handler handler) {
|
boolean aboveStatusBar, UiEventLogger uiEventLogger, @Main Handler handler) {
|
||||||
super(context, R.style.Theme_SystemUI_Dialog_Internet);
|
super(context, R.style.Theme_SystemUI_Dialog_Internet);
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
@@ -152,6 +152,7 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
mDefaultDataSubId = mInternetDialogController.getDefaultDataSubscriptionId();
|
mDefaultDataSubId = mInternetDialogController.getDefaultDataSubscriptionId();
|
||||||
mTelephonyManager = mInternetDialogController.getTelephonyManager();
|
mTelephonyManager = mInternetDialogController.getTelephonyManager();
|
||||||
mWifiManager = mInternetDialogController.getWifiManager();
|
mWifiManager = mInternetDialogController.getWifiManager();
|
||||||
|
mCanConfigMobileData = canConfigMobileData;
|
||||||
|
|
||||||
mLayoutManager = new LinearLayoutManager(mContext) {
|
mLayoutManager = new LinearLayoutManager(mContext) {
|
||||||
@Override
|
@Override
|
||||||
@@ -166,7 +167,6 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
if (!aboveStatusBar) {
|
if (!aboveStatusBar) {
|
||||||
getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
|
getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
|
||||||
}
|
}
|
||||||
show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -179,16 +179,19 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
mDialogView = LayoutInflater.from(mContext).inflate(R.layout.internet_connectivity_dialog,
|
mDialogView = LayoutInflater.from(mContext).inflate(R.layout.internet_connectivity_dialog,
|
||||||
null);
|
null);
|
||||||
final Window window = getWindow();
|
final Window window = getWindow();
|
||||||
final WindowManager.LayoutParams lp = window.getAttributes();
|
final WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||||
lp.gravity = Gravity.BOTTOM;
|
layoutParams.gravity = Gravity.BOTTOM;
|
||||||
lp.setFitInsetsTypes(statusBars() | navigationBars());
|
// Move down the dialog to overlay the navigation bar.
|
||||||
lp.setFitInsetsSides(WindowInsets.Side.all());
|
layoutParams.setFitInsetsTypes(
|
||||||
lp.setFitInsetsIgnoringVisibility(true);
|
layoutParams.getFitInsetsTypes() & ~WindowInsets.Type.navigationBars());
|
||||||
window.setAttributes(lp);
|
layoutParams.setFitInsetsSides(WindowInsets.Side.all());
|
||||||
|
layoutParams.setFitInsetsIgnoringVisibility(true);
|
||||||
|
window.setAttributes(layoutParams);
|
||||||
window.setContentView(mDialogView);
|
window.setContentView(mDialogView);
|
||||||
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
window.setWindowAnimations(R.style.Animation_InternetDialog);
|
window.setWindowAnimations(R.style.Animation_InternetDialog);
|
||||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
|
window.addFlags(FLAG_LAYOUT_NO_LIMITS);
|
||||||
|
|
||||||
mInternetDialogTitle = mDialogView.requireViewById(R.id.internet_dialog_title);
|
mInternetDialogTitle = mDialogView.requireViewById(R.id.internet_dialog_title);
|
||||||
mInternetDialogSubTitle = mDialogView.requireViewById(R.id.internet_dialog_subtitle);
|
mInternetDialogSubTitle = mDialogView.requireViewById(R.id.internet_dialog_subtitle);
|
||||||
@@ -297,9 +300,7 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
isChecked, false);
|
isChecked, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mConnectedWifListLayout.setOnClickListener(v -> {
|
mConnectedWifListLayout.setOnClickListener(v -> onClickConnectedWifi());
|
||||||
// TODO(b/191475923): Need to launch the detailed page of Wi-Fi entry.
|
|
||||||
});
|
|
||||||
mSeeAllLayout.setOnClickListener(v -> onClickSeeMoreButton());
|
mSeeAllLayout.setOnClickListener(v -> onClickSeeMoreButton());
|
||||||
mWiFiToggle.setOnCheckedChangeListener(
|
mWiFiToggle.setOnCheckedChangeListener(
|
||||||
(buttonView, isChecked) -> {
|
(buttonView, isChecked) -> {
|
||||||
@@ -318,8 +319,13 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
mMobileDataToggle.setChecked(mInternetDialogController.isMobileDataEnabled());
|
mMobileDataToggle.setChecked(mInternetDialogController.isMobileDataEnabled());
|
||||||
mMobileNetworkLayout.setVisibility(View.VISIBLE);
|
mMobileNetworkLayout.setVisibility(View.VISIBLE);
|
||||||
mMobileTitleText.setText(getMobileNetworkTitle());
|
mMobileTitleText.setText(getMobileNetworkTitle());
|
||||||
|
if (!TextUtils.isEmpty(getMobileNetworkSummary())) {
|
||||||
mMobileSummaryText.setText(
|
mMobileSummaryText.setText(
|
||||||
Html.fromHtml(getMobileNetworkSummary(), Html.FROM_HTML_MODE_LEGACY));
|
Html.fromHtml(getMobileNetworkSummary(), Html.FROM_HTML_MODE_LEGACY));
|
||||||
|
mMobileSummaryText.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
mMobileSummaryText.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
mSignalIcon.setImageDrawable(getSignalStrengthDrawable());
|
mSignalIcon.setImageDrawable(getSignalStrengthDrawable());
|
||||||
int titleColor = isCellularNetwork ? mContext.getColor(
|
int titleColor = isCellularNetwork ? mContext.getColor(
|
||||||
R.color.connected_network_primary_color) : Utils.getColorAttrDefaultColor(
|
R.color.connected_network_primary_color) : Utils.getColorAttrDefaultColor(
|
||||||
@@ -330,6 +336,8 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
mMobileTitleText.setTextColor(titleColor);
|
mMobileTitleText.setTextColor(titleColor);
|
||||||
mMobileSummaryText.setTextColor(summaryColor);
|
mMobileSummaryText.setTextColor(summaryColor);
|
||||||
mMobileNetworkLayout.setBackground(isCellularNetwork ? mBackgroundOn : null);
|
mMobileNetworkLayout.setBackground(isCellularNetwork ? mBackgroundOn : null);
|
||||||
|
|
||||||
|
mMobileDataToggle.setVisibility(mCanConfigMobileData ? View.VISIBLE : View.INVISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,6 +361,10 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
mConnectedWifListLayout.setBackground(mBackgroundOn);
|
mConnectedWifListLayout.setBackground(mBackgroundOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onClickConnectedWifi() {
|
||||||
|
mInternetDialogController.launchWifiNetworkDetailsSetting();
|
||||||
|
}
|
||||||
|
|
||||||
void onClickSeeMoreButton() {
|
void onClickSeeMoreButton() {
|
||||||
mInternetDialogController.launchNetworkSetting();
|
mInternetDialogController.launchNetworkSetting();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ import android.net.wifi.ScanResult;
|
|||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.telephony.AccessNetworkConstants;
|
||||||
|
import android.telephony.NetworkRegistrationInfo;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SignalStrength;
|
import android.telephony.SignalStrength;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
@@ -48,6 +50,10 @@ import android.util.Log;
|
|||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.internal.logging.UiEventLogger;
|
import com.android.internal.logging.UiEventLogger;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
||||||
@@ -56,6 +62,7 @@ import com.android.settingslib.Utils;
|
|||||||
import com.android.settingslib.graph.SignalDrawable;
|
import com.android.settingslib.graph.SignalDrawable;
|
||||||
import com.android.settingslib.mobile.MobileMappings;
|
import com.android.settingslib.mobile.MobileMappings;
|
||||||
import com.android.settingslib.net.SignalStrengthUtil;
|
import com.android.settingslib.net.SignalStrengthUtil;
|
||||||
|
import com.android.settingslib.wifi.WifiUtils;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
@@ -78,10 +85,6 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
|
||||||
|
|
||||||
public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||||
NetworkController.AccessPointController.AccessPointCallback {
|
NetworkController.AccessPointController.AccessPointCallback {
|
||||||
|
|
||||||
@@ -104,7 +107,6 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
|
|
||||||
private WifiManager mWifiManager;
|
private WifiManager mWifiManager;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private ActivityStarter mActivityStarter;
|
|
||||||
private SubscriptionManager mSubscriptionManager;
|
private SubscriptionManager mSubscriptionManager;
|
||||||
private TelephonyManager mTelephonyManager;
|
private TelephonyManager mTelephonyManager;
|
||||||
private ConnectivityManager mConnectivityManager;
|
private ConnectivityManager mConnectivityManager;
|
||||||
@@ -115,16 +117,19 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
private MobileMappings.Config mConfig = null;
|
private MobileMappings.Config mConfig = null;
|
||||||
private Executor mExecutor;
|
private Executor mExecutor;
|
||||||
private AccessPointController mAccessPointController;
|
private AccessPointController mAccessPointController;
|
||||||
private IntentFilter mWifiStateFilter;
|
private IntentFilter mConnectionStateFilter;
|
||||||
private InternetDialogCallback mCallback;
|
private InternetDialogCallback mCallback;
|
||||||
private List<WifiEntry> mWifiEntry;
|
private List<WifiEntry> mWifiEntry;
|
||||||
private WifiEntry mConnectedEntry;
|
|
||||||
private UiEventLogger mUiEventLogger;
|
private UiEventLogger mUiEventLogger;
|
||||||
private BroadcastDispatcher mBroadcastDispatcher;
|
private BroadcastDispatcher mBroadcastDispatcher;
|
||||||
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||||
private GlobalSettings mGlobalSettings;
|
private GlobalSettings mGlobalSettings;
|
||||||
private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
protected ActivityStarter mActivityStarter;
|
||||||
|
@VisibleForTesting
|
||||||
|
protected WifiEntry mConnectedEntry;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected SubscriptionManager.OnSubscriptionsChangedListener mOnSubscriptionsChangedListener;
|
protected SubscriptionManager.OnSubscriptionsChangedListener mOnSubscriptionsChangedListener;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -168,8 +173,10 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
mSubscriptionManager = subscriptionManager;
|
mSubscriptionManager = subscriptionManager;
|
||||||
mBroadcastDispatcher = broadcastDispatcher;
|
mBroadcastDispatcher = broadcastDispatcher;
|
||||||
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
||||||
mWifiStateFilter = new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
mConnectionStateFilter = new IntentFilter();
|
||||||
mWifiStateFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
|
mConnectionStateFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||||
|
mConnectionStateFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
|
||||||
|
mConnectionStateFilter.addAction(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
|
||||||
mUiEventLogger = uiEventLogger;
|
mUiEventLogger = uiEventLogger;
|
||||||
mActivityStarter = starter;
|
mActivityStarter = starter;
|
||||||
mAccessPointController = accessPointController;
|
mAccessPointController = accessPointController;
|
||||||
@@ -183,12 +190,16 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
mCallback = callback;
|
mCallback = callback;
|
||||||
mKeyguardUpdateMonitor.registerCallback(mKeyguardUpdateCallback);
|
mKeyguardUpdateMonitor.registerCallback(mKeyguardUpdateCallback);
|
||||||
mAccessPointController.addAccessPointCallback(this);
|
mAccessPointController.addAccessPointCallback(this);
|
||||||
mBroadcastDispatcher.registerReceiver(mWifiStateReceiver, mWifiStateFilter, mExecutor);
|
mBroadcastDispatcher.registerReceiver(mConnectionStateReceiver, mConnectionStateFilter,
|
||||||
|
mExecutor);
|
||||||
// Listen the subscription changes
|
// Listen the subscription changes
|
||||||
mOnSubscriptionsChangedListener = new InternetOnSubscriptionChangedListener();
|
mOnSubscriptionsChangedListener = new InternetOnSubscriptionChangedListener();
|
||||||
mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor,
|
mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor,
|
||||||
mOnSubscriptionsChangedListener);
|
mOnSubscriptionsChangedListener);
|
||||||
mDefaultDataSubId = getDefaultDataSubscriptionId();
|
mDefaultDataSubId = getDefaultDataSubscriptionId();
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "Init, SubId: " + mDefaultDataSubId);
|
||||||
|
}
|
||||||
mTelephonyManager = mTelephonyManager.createForSubscriptionId(mDefaultDataSubId);
|
mTelephonyManager = mTelephonyManager.createForSubscriptionId(mDefaultDataSubId);
|
||||||
mInternetTelephonyCallback = new InternetTelephonyCallback();
|
mInternetTelephonyCallback = new InternetTelephonyCallback();
|
||||||
mTelephonyManager.registerTelephonyCallback(mExecutor, mInternetTelephonyCallback);
|
mTelephonyManager.registerTelephonyCallback(mExecutor, mInternetTelephonyCallback);
|
||||||
@@ -203,7 +214,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "onStop");
|
Log.d(TAG, "onStop");
|
||||||
}
|
}
|
||||||
mBroadcastDispatcher.unregisterReceiver(mWifiStateReceiver);
|
mBroadcastDispatcher.unregisterReceiver(mConnectionStateReceiver);
|
||||||
mTelephonyManager.unregisterTelephonyCallback(mInternetTelephonyCallback);
|
mTelephonyManager.unregisterTelephonyCallback(mInternetTelephonyCallback);
|
||||||
mSubscriptionManager.removeOnSubscriptionsChangedListener(
|
mSubscriptionManager.removeOnSubscriptionsChangedListener(
|
||||||
mOnSubscriptionsChangedListener);
|
mOnSubscriptionsChangedListener);
|
||||||
@@ -226,6 +237,17 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
return new Intent(ACTION_NETWORK_PROVIDER_SETTINGS).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
return new Intent(ACTION_NETWORK_PROVIDER_SETTINGS).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Intent getWifiDetailsSettingsIntent() {
|
||||||
|
String key = mConnectedEntry == null ? null : mConnectedEntry.getKey();
|
||||||
|
if (TextUtils.isEmpty(key)) {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "connected entry's key is empty");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return WifiUtils.getWifiDetailsSettingsIntent(key);
|
||||||
|
}
|
||||||
|
|
||||||
CharSequence getDialogTitleText() {
|
CharSequence getDialogTitleText() {
|
||||||
if (isAirplaneModeEnabled()) {
|
if (isAirplaneModeEnabled()) {
|
||||||
return mContext.getText(R.string.airplane_mode);
|
return mContext.getText(R.string.airplane_mode);
|
||||||
@@ -533,6 +555,14 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
mActivityStarter.postStartActivityDismissingKeyguard(getSettingsIntent(), 0);
|
mActivityStarter.postStartActivityDismissingKeyguard(getSettingsIntent(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void launchWifiNetworkDetailsSetting() {
|
||||||
|
Intent intent = getWifiDetailsSettingsIntent();
|
||||||
|
if (intent != null) {
|
||||||
|
mCallback.dismissDialog();
|
||||||
|
mActivityStarter.postStartActivityDismissingKeyguard(intent, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void connectCarrierNetwork() {
|
void connectCarrierNetwork() {
|
||||||
final MergedCarrierEntry mergedCarrierEntry =
|
final MergedCarrierEntry mergedCarrierEntry =
|
||||||
mAccessPointController.getMergedCarrierEntry();
|
mAccessPointController.getMergedCarrierEntry();
|
||||||
@@ -626,13 +656,12 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean isDataStateInService() {
|
boolean isDataStateInService() {
|
||||||
if (mTelephonyManager == null) {
|
final ServiceState serviceState = mTelephonyManager.getServiceState();
|
||||||
if (DEBUG) {
|
NetworkRegistrationInfo regInfo =
|
||||||
Log.d(TAG, "TelephonyManager is null, can not detect mobile state.");
|
(serviceState == null) ? null : serviceState.getNetworkRegistrationInfo(
|
||||||
}
|
NetworkRegistrationInfo.DOMAIN_PS,
|
||||||
return false;
|
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
||||||
}
|
return (regInfo == null) ? false : regInfo.isRegistered();
|
||||||
return mTelephonyManager.getDataState() == TelephonyManager.DATA_CONNECTED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isVoiceStateInService() {
|
boolean isVoiceStateInService() {
|
||||||
@@ -793,15 +822,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSubscriptionsChanged() {
|
public void onSubscriptionsChanged() {
|
||||||
mDefaultDataSubId = getDefaultDataSubscriptionId();
|
updateListener();
|
||||||
if (SubscriptionManager.isUsableSubscriptionId(mDefaultDataSubId)) {
|
|
||||||
mTelephonyManager.unregisterTelephonyCallback(mInternetTelephonyCallback);
|
|
||||||
|
|
||||||
mTelephonyManager = mTelephonyManager.createForSubscriptionId(mDefaultDataSubId);
|
|
||||||
mTelephonyManager.registerTelephonyCallback(mHandler::post,
|
|
||||||
mInternetTelephonyCallback);
|
|
||||||
mCallback.onSubscriptionsChanged(mDefaultDataSubId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -817,13 +838,46 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final BroadcastReceiver mWifiStateReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver mConnectionStateReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
final String action = intent.getAction();
|
||||||
|
if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)
|
||||||
|
|| action.equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) {
|
||||||
mCallback.onWifiStateReceived(context, intent);
|
mCallback.onWifiStateReceived(context, intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (action.equals(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED)) {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED");
|
||||||
|
}
|
||||||
|
updateListener();
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private void updateListener() {
|
||||||
|
int defaultDataSubId = getDefaultDataSubscriptionId();
|
||||||
|
if (mDefaultDataSubId == getDefaultDataSubscriptionId()) {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "DDS: no change");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mDefaultDataSubId = defaultDataSubId;
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "DDS: defaultDataSubId:" + mDefaultDataSubId);
|
||||||
|
}
|
||||||
|
if (SubscriptionManager.isUsableSubscriptionId(mDefaultDataSubId)) {
|
||||||
|
mTelephonyManager.unregisterTelephonyCallback(mInternetTelephonyCallback);
|
||||||
|
mTelephonyManager = mTelephonyManager.createForSubscriptionId(mDefaultDataSubId);
|
||||||
|
mTelephonyManager.registerTelephonyCallback(mHandler::post,
|
||||||
|
mInternetTelephonyCallback);
|
||||||
|
mCallback.onSubscriptionsChanged(mDefaultDataSubId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface InternetDialogCallback {
|
interface InternetDialogCallback {
|
||||||
|
|
||||||
void onRefreshCarrierInfo();
|
void onRefreshCarrierInfo();
|
||||||
|
|||||||
@@ -41,15 +41,16 @@ class InternetDialogFactory @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Creates a [InternetDialog]. */
|
/** Creates a [InternetDialog]. */
|
||||||
fun create(aboveStatusBar: Boolean) {
|
fun create(aboveStatusBar: Boolean, canConfigMobileData: Boolean) {
|
||||||
if (internetDialog != null) {
|
if (internetDialog != null) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "InternetDialog is showing, do not create it twice.")
|
Log.d(TAG, "InternetDialog is showing, do not create it twice.")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
internetDialog = InternetDialog(context, this, internetDialogController, aboveStatusBar,
|
internetDialog = InternetDialog(context, this, internetDialogController,
|
||||||
uiEventLogger, handler)
|
canConfigMobileData, aboveStatusBar, uiEventLogger, handler)
|
||||||
|
internetDialog?.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,11 @@ public class AccessPointControllerImpl
|
|||||||
new UserHandle(mCurrentUser));
|
new UserHandle(mCurrentUser));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canConfigMobileData() {
|
||||||
|
return !mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS,
|
||||||
|
UserHandle.of(mCurrentUser));
|
||||||
|
}
|
||||||
|
|
||||||
public void onUserSwitched(int newUserId) {
|
public void onUserSwitched(int newUserId) {
|
||||||
mCurrentUser = newUserId;
|
mCurrentUser = newUserId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,6 +228,7 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
|
|||||||
int getIcon(WifiEntry ap);
|
int getIcon(WifiEntry ap);
|
||||||
boolean connect(WifiEntry ap);
|
boolean connect(WifiEntry ap);
|
||||||
boolean canConfigWifi();
|
boolean canConfigWifi();
|
||||||
|
boolean canConfigMobileData();
|
||||||
|
|
||||||
public interface AccessPointCallback {
|
public interface AccessPointCallback {
|
||||||
void onAccessPointsChanged(List<WifiEntry> accessPoints);
|
void onAccessPointsChanged(List<WifiEntry> accessPoints);
|
||||||
|
|||||||
@@ -793,7 +793,8 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
|||||||
mReceiverHandler.post(this::handleConfigurationChanged);
|
mReceiverHandler.post(this::handleConfigurationChanged);
|
||||||
break;
|
break;
|
||||||
case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
|
case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
|
||||||
mMainHandler.post(() -> mInternetDialogFactory.create(true));
|
boolean canConfigMobileData = mAccessPoints.canConfigMobileData();
|
||||||
|
mMainHandler.post(() -> mInternetDialogFactory.create(true, canConfigMobileData));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
|
int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
|
||||||
|
|||||||
@@ -3,11 +3,16 @@ package com.android.systemui.qs.tiles.dialog;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.wifi.ScanResult;
|
import android.net.wifi.ScanResult;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
@@ -20,6 +25,9 @@ import android.testing.AndroidTestingRunner;
|
|||||||
import android.testing.TestableLooper;
|
import android.testing.TestableLooper;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
import com.android.internal.logging.UiEventLogger;
|
import com.android.internal.logging.UiEventLogger;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
@@ -33,9 +41,6 @@ import com.android.systemui.util.settings.GlobalSettings;
|
|||||||
import com.android.systemui.util.time.FakeSystemClock;
|
import com.android.systemui.util.time.FakeSystemClock;
|
||||||
import com.android.wifitrackerlib.WifiEntry;
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.test.filters.SmallTest;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -68,13 +73,15 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
@Mock
|
@Mock
|
||||||
|
private ActivityStarter mActivityStarter;
|
||||||
|
@Mock
|
||||||
private GlobalSettings mGlobalSettings;
|
private GlobalSettings mGlobalSettings;
|
||||||
@Mock
|
@Mock
|
||||||
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||||
@Mock
|
@Mock
|
||||||
private NetworkController.AccessPointController mAccessPointController;
|
private NetworkController.AccessPointController mAccessPointController;
|
||||||
@Mock
|
@Mock
|
||||||
private WifiEntry mWifiEntryConnected = mock(WifiEntry.class);
|
private WifiEntry mConnectedEntry;
|
||||||
@Mock
|
@Mock
|
||||||
private WifiInfo mWifiInfo;
|
private WifiInfo mWifiInfo;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -94,6 +101,8 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor,
|
mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor,
|
||||||
mInternetDialogController.mOnSubscriptionsChangedListener);
|
mInternetDialogController.mOnSubscriptionsChangedListener);
|
||||||
mInternetDialogController.onStart(mCallback);
|
mInternetDialogController.onStart(mCallback);
|
||||||
|
mInternetDialogController.mActivityStarter = mActivityStarter;
|
||||||
|
mInternetDialogController.mConnectedEntry = mConnectedEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -188,7 +197,7 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getConnectedWifiTitle_withNoConnectedEntry_returnNull() {
|
public void getConnectedWifiTitle_withNoConnectedEntry_returnNull() {
|
||||||
mInternetDialogController.setConnectedWifiEntry(null);
|
mInternetDialogController.mConnectedEntry = null;
|
||||||
|
|
||||||
assertTrue(TextUtils.equals(mInternetDialogController.getConnectedWifiTitle(),
|
assertTrue(TextUtils.equals(mInternetDialogController.getConnectedWifiTitle(),
|
||||||
""));
|
""));
|
||||||
@@ -196,8 +205,7 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getConnectedWifiTitle_withConnectedEntry_returnTitle() {
|
public void getConnectedWifiTitle_withConnectedEntry_returnTitle() {
|
||||||
mInternetDialogController.setConnectedWifiEntry(mWifiEntryConnected);
|
when(mConnectedEntry.getTitle()).thenReturn(CONNECTED_TITLE);
|
||||||
when(mWifiEntryConnected.getTitle()).thenReturn(CONNECTED_TITLE);
|
|
||||||
|
|
||||||
assertTrue(TextUtils.equals(mInternetDialogController.getConnectedWifiTitle(),
|
assertTrue(TextUtils.equals(mInternetDialogController.getConnectedWifiTitle(),
|
||||||
CONNECTED_TITLE));
|
CONNECTED_TITLE));
|
||||||
@@ -205,7 +213,7 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getConnectedWifiSummary_withNoConnectedEntry_returnNull() {
|
public void getConnectedWifiSummary_withNoConnectedEntry_returnNull() {
|
||||||
mInternetDialogController.setConnectedWifiEntry(null);
|
mInternetDialogController.mConnectedEntry = null;
|
||||||
|
|
||||||
assertTrue(TextUtils.equals(mInternetDialogController.getConnectedWifiSummary(),
|
assertTrue(TextUtils.equals(mInternetDialogController.getConnectedWifiSummary(),
|
||||||
""));
|
""));
|
||||||
@@ -213,13 +221,52 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getConnectedWifiSummary_withConnectedEntry_returnSummary() {
|
public void getConnectedWifiSummary_withConnectedEntry_returnSummary() {
|
||||||
mInternetDialogController.setConnectedWifiEntry(mWifiEntryConnected);
|
when(mConnectedEntry.getSummary(false)).thenReturn(CONNECTED_SUMMARY);
|
||||||
when(mWifiEntryConnected.getSummary(false)).thenReturn(CONNECTED_SUMMARY);
|
|
||||||
|
|
||||||
assertTrue(TextUtils.equals(mInternetDialogController.getConnectedWifiSummary(),
|
assertTrue(TextUtils.equals(mInternetDialogController.getConnectedWifiSummary(),
|
||||||
CONNECTED_SUMMARY));
|
CONNECTED_SUMMARY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getWifiDetailsSettingsIntent_withNoConnectedEntry_returnNull() {
|
||||||
|
mInternetDialogController.mConnectedEntry = null;
|
||||||
|
|
||||||
|
assertThat(mInternetDialogController.getWifiDetailsSettingsIntent()).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getWifiDetailsSettingsIntent_withNoConnectedEntryKey_returnNull() {
|
||||||
|
when(mConnectedEntry.getKey()).thenReturn(null);
|
||||||
|
|
||||||
|
assertThat(mInternetDialogController.getWifiDetailsSettingsIntent()).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getWifiDetailsSettingsIntent_withConnectedEntryKey_returnIntent() {
|
||||||
|
when(mConnectedEntry.getKey()).thenReturn("test_key");
|
||||||
|
|
||||||
|
assertThat(mInternetDialogController.getWifiDetailsSettingsIntent()).isNotNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void launchWifiNetworkDetailsSetting_withNoConnectedEntry_doNothing() {
|
||||||
|
mInternetDialogController.mConnectedEntry = null;
|
||||||
|
|
||||||
|
mInternetDialogController.launchWifiNetworkDetailsSetting();
|
||||||
|
|
||||||
|
verify(mActivityStarter, never())
|
||||||
|
.postStartActivityDismissingKeyguard(any(Intent.class), anyInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void launchWifiNetworkDetailsSetting_withConnectedEntryKey_startActivity() {
|
||||||
|
when(mConnectedEntry.getKey()).thenReturn("test_key");
|
||||||
|
|
||||||
|
mInternetDialogController.launchWifiNetworkDetailsSetting();
|
||||||
|
|
||||||
|
verify(mActivityStarter).postStartActivityDismissingKeyguard(any(Intent.class), anyInt());
|
||||||
|
}
|
||||||
|
|
||||||
private String getResourcesString(String name) {
|
private String getResourcesString(String name) {
|
||||||
return mContext.getResources().getString(getResourcesId(name));
|
return mContext.getResources().getString(getResourcesId(name));
|
||||||
}
|
}
|
||||||
@@ -231,7 +278,6 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
private class MockInternetDialogController extends InternetDialogController {
|
private class MockInternetDialogController extends InternetDialogController {
|
||||||
|
|
||||||
private WifiEntry mConnectedEntry;
|
|
||||||
private GlobalSettings mGlobalSettings;
|
private GlobalSettings mGlobalSettings;
|
||||||
private boolean mIsAirplaneModeOn;
|
private boolean mIsAirplaneModeOn;
|
||||||
|
|
||||||
@@ -256,14 +302,5 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
public void setAirplaneModeEnabled(boolean enabled) {
|
public void setAirplaneModeEnabled(boolean enabled) {
|
||||||
mIsAirplaneModeOn = enabled;
|
mIsAirplaneModeOn = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
WifiEntry getConnectedWifiEntry() {
|
|
||||||
return mConnectedEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConnectedWifiEntry(WifiEntry connectedEntry) {
|
|
||||||
mConnectedEntry = connectedEntry;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mInternetDialog = new MockInternetDialog(mContext, mInternetDialogFactory,
|
mInternetDialog = new MockInternetDialog(mContext, mInternetDialogFactory,
|
||||||
mInternetDialogController, true, mUiEventLogger, mHandler);
|
mInternetDialogController, true, true, mUiEventLogger, mHandler);
|
||||||
|
mInternetDialog.show();
|
||||||
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
|
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
|
||||||
when(mMockWifiManager.isWifiEnabled()).thenReturn(true);
|
when(mMockWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
when(mMockWifiManager.getConnectionInfo()).thenReturn(mWifiInfo);
|
when(mMockWifiManager.getConnectionInfo()).thenReturn(mWifiInfo);
|
||||||
@@ -177,10 +178,10 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
private String mConnectedWifiSummary;
|
private String mConnectedWifiSummary;
|
||||||
|
|
||||||
MockInternetDialog(Context context, InternetDialogFactory internetDialogFactory,
|
MockInternetDialog(Context context, InternetDialogFactory internetDialogFactory,
|
||||||
InternetDialogController internetDialogController,
|
InternetDialogController internetDialogController, boolean canConfigMobileData,
|
||||||
boolean aboveStatusBar, UiEventLogger uiEventLogger, @Main Handler handler) {
|
boolean aboveStatusBar, UiEventLogger uiEventLogger, @Main Handler handler) {
|
||||||
super(context, internetDialogFactory, internetDialogController, aboveStatusBar,
|
super(context, internetDialogFactory, internetDialogController, canConfigMobileData,
|
||||||
uiEventLogger, handler);
|
aboveStatusBar, uiEventLogger, handler);
|
||||||
mAdapter = mInternetAdapter;
|
mAdapter = mInternetAdapter;
|
||||||
mWifiManager = mMockWifiManager;
|
mWifiManager = mMockWifiManager;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user