Merge SP1A.211205.008

Bug: 205056467
Merged-In: Id5cd4123f1bb7bdd85e564fc6997dfbc50652a5f
Change-Id: I2b614d13e18b8a03aaab041c058c1b2f0a21fcab
This commit is contained in:
Xin Li
2021-12-20 14:06:43 -08:00
8 changed files with 148 additions and 5 deletions

View File

@@ -323,6 +323,46 @@
</FrameLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/wifi_scan_notify_layout"
style="@style/InternetDialog.Network"
android:orientation="vertical"
android:layout_height="wrap_content"
android:paddingBottom="4dp"
android:clickable="false"
android:focusable="false">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="56dp"
android:gravity="start|top"
android:orientation="horizontal"
android:paddingEnd="12dp"
android:paddingTop="16dp"
android:paddingBottom="4dp">
<ImageView
android:src="@drawable/ic_info_outline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="?android:attr/textColorTertiary"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/wifi_scan_notify_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingBottom="8dp"
android:textColor="?android:attr/textColorSecondary"
android:clickable="true"/>
</LinearLayout>
</LinearLayout>
<FrameLayout
android:id="@+id/done_layout"
android:layout_width="67dp"

View File

@@ -3033,4 +3033,6 @@
<string name="see_all_networks">See all</string>
<!-- Summary for warning to disconnect ethernet first then switch to other networks. [CHAR LIMIT=60] -->
<string name="to_switch_networks_disconnect_ethernet">To switch networks, disconnect ethernet</string>
<!-- Message to describe "Wi-Fi scan always available feature" when Wi-Fi is off and Wi-Fi scanning is on. [CHAR LIMIT=NONE] -->
<string name="wifi_scan_notify_message">To improve device experience, apps and services can still scan for Wi\u2011Fi networks at any time, even when Wi\u2011Fi is off. You can change this in Wi\u2011Fi scanning settings. <annotation id="link">Change</annotation></string>
</resources>

View File

@@ -30,7 +30,7 @@ import java.util.Optional;
/**
* A span that turns the text wrapped by annotation tag into the clickable link text.
*/
class AnnotationLinkSpan extends ClickableSpan {
public class AnnotationLinkSpan extends ClickableSpan {
private final Optional<View.OnClickListener> mClickListener;
private AnnotationLinkSpan(View.OnClickListener listener) {
@@ -50,7 +50,7 @@ class AnnotationLinkSpan extends ClickableSpan {
* @param linkInfos used to attach the click action into the corresponding span
* @return the text attached with the span
*/
static CharSequence linkify(CharSequence text, LinkInfo... linkInfos) {
public static CharSequence linkify(CharSequence text, LinkInfo... linkInfos) {
final SpannableString msg = new SpannableString(text);
final Annotation[] spans =
msg.getSpans(/* queryStart= */ 0, msg.length(), Annotation.class);
@@ -78,12 +78,12 @@ class AnnotationLinkSpan extends ClickableSpan {
/**
* Data class to store the annotation and the click action.
*/
static class LinkInfo {
static final String DEFAULT_ANNOTATION = "link";
public static class LinkInfo {
public static final String DEFAULT_ANNOTATION = "link";
private final Optional<String> mAnnotation;
private final Optional<View.OnClickListener> mListener;
LinkInfo(@NonNull String annotation, View.OnClickListener listener) {
public LinkInfo(@NonNull String annotation, View.OnClickListener listener) {
mAnnotation = Optional.of(annotation);
mListener = Optional.ofNullable(listener);
}

View File

@@ -36,6 +36,7 @@ import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
import android.text.Html;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -63,6 +64,7 @@ import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.accessibility.floatingmenu.AnnotationLinkSpan;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.statusbar.phone.SystemUIDialog;
@@ -110,6 +112,8 @@ public class InternetDialog extends SystemUIDialog implements
private LinearLayout mTurnWifiOnLayout;
private LinearLayout mEthernetLayout;
private TextView mWifiToggleTitleText;
private LinearLayout mWifiScanNotifyLayout;
private TextView mWifiScanNotifyText;
private LinearLayout mSeeAllLayout;
private RecyclerView mWifiRecyclerView;
private ImageView mConnectedWifiIcon;
@@ -220,6 +224,8 @@ public class InternetDialog extends SystemUIDialog implements
mMobileNetworkLayout = mDialogView.requireViewById(R.id.mobile_network_layout);
mTurnWifiOnLayout = mDialogView.requireViewById(R.id.turn_on_wifi_layout);
mWifiToggleTitleText = mDialogView.requireViewById(R.id.wifi_toggle_title);
mWifiScanNotifyLayout = mDialogView.requireViewById(R.id.wifi_scan_notify_layout);
mWifiScanNotifyText = mDialogView.requireViewById(R.id.wifi_scan_notify_text);
mConnectedWifListLayout = mDialogView.requireViewById(R.id.wifi_connected_layout);
mConnectedWifiIcon = mDialogView.requireViewById(R.id.wifi_connected_icon);
mConnectedWifiTitleText = mDialogView.requireViewById(R.id.wifi_connected_title);
@@ -313,8 +319,10 @@ public class InternetDialog extends SystemUIDialog implements
showProgressBar();
final boolean isDeviceLocked = mInternetDialogController.isDeviceLocked();
final boolean isWifiEnabled = mWifiManager.isWifiEnabled();
final boolean isWifiScanEnabled = mWifiManager.isScanAlwaysAvailable();
updateWifiToggle(isWifiEnabled, isDeviceLocked);
updateConnectedWifi(isWifiEnabled, isDeviceLocked);
updateWifiScanNotify(isWifiEnabled, isWifiScanEnabled, isDeviceLocked);
final int visibility = (isDeviceLocked || !isWifiEnabled || mWifiEntriesCount <= 0)
? View.GONE : View.VISIBLE;
@@ -411,6 +419,24 @@ public class InternetDialog extends SystemUIDialog implements
mContext.getColor(R.color.connected_network_primary_color));
}
@MainThread
private void updateWifiScanNotify(boolean isWifiEnabled, boolean isWifiScanEnabled,
boolean isDeviceLocked) {
if (isWifiEnabled || !isWifiScanEnabled || isDeviceLocked) {
mWifiScanNotifyLayout.setVisibility(View.GONE);
return;
}
if (TextUtils.isEmpty(mWifiScanNotifyText.getText())) {
final AnnotationLinkSpan.LinkInfo linkInfo = new AnnotationLinkSpan.LinkInfo(
AnnotationLinkSpan.LinkInfo.DEFAULT_ANNOTATION,
v -> mInternetDialogController.launchWifiScanningSetting());
mWifiScanNotifyText.setText(AnnotationLinkSpan.linkify(
getContext().getText(R.string.wifi_scan_notify_message), linkInfo));
mWifiScanNotifyText.setMovementMethod(LinkMovementMethod.getInstance());
}
mWifiScanNotifyLayout.setVisibility(View.VISIBLE);
}
void onClickConnectedWifi() {
if (mConnectedWifiEntry == null) {
return;

View File

@@ -103,6 +103,8 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
private static final String TAG = "InternetDialogController";
private static final String ACTION_NETWORK_PROVIDER_SETTINGS =
"android.settings.NETWORK_PROVIDER_SETTINGS";
private static final String ACTION_WIFI_SCANNING_SETTINGS =
"android.settings.WIFI_SCANNING_SETTINGS";
private static final String EXTRA_CHOSEN_WIFI_ENTRY_KEY = "key_chosen_wifientry_key";
public static final Drawable EMPTY_DRAWABLE = new ColorDrawable(Color.TRANSPARENT);
public static final int NO_CELL_DATA_TYPE_ICON = 0;
@@ -603,6 +605,13 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
}
}
void launchWifiScanningSetting() {
mCallback.dismissDialog();
final Intent intent = new Intent(ACTION_WIFI_SCANNING_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mActivityStarter.postStartActivityDismissingKeyguard(intent, 0);
}
void connectCarrierNetwork() {
final MergedCarrierEntry mergedCarrierEntry =
mAccessPointController.getMergedCarrierEntry();

View File

@@ -19,6 +19,7 @@ import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import androidx.test.filters.SmallTest;
@@ -73,6 +74,7 @@ public class InternetDialogTest extends SysuiTestCase {
private LinearLayout mConnectedWifi;
private RecyclerView mWifiList;
private LinearLayout mSeeAll;
private LinearLayout mWifiScanNotify;
@Before
public void setUp() {
@@ -104,6 +106,7 @@ public class InternetDialogTest extends SysuiTestCase {
mConnectedWifi = mDialogView.requireViewById(R.id.wifi_connected_layout);
mWifiList = mDialogView.requireViewById(R.id.wifi_list_layout);
mSeeAll = mDialogView.requireViewById(R.id.see_all_layout);
mWifiScanNotify = mDialogView.requireViewById(R.id.wifi_scan_notify_layout);
}
@After
@@ -263,6 +266,50 @@ public class InternetDialogTest extends SysuiTestCase {
assertThat(mSeeAll.getVisibility()).isEqualTo(View.GONE);
}
@Test
public void updateDialog_wifiOn_hideWifiScanNotify() {
// The preconditions WiFi ON and Internet WiFi are already in setUp()
mInternetDialog.updateDialog();
assertThat(mWifiScanNotify.getVisibility()).isEqualTo(View.GONE);
}
@Test
public void updateDialog_wifiOffAndWifiScanOff_hideWifiScanNotify() {
when(mWifiManager.isWifiEnabled()).thenReturn(false);
when(mWifiManager.isScanAlwaysAvailable()).thenReturn(false);
mInternetDialog.updateDialog();
assertThat(mWifiScanNotify.getVisibility()).isEqualTo(View.GONE);
}
@Test
public void updateDialog_wifiOffAndWifiScanOnAndDeviceLocked_hideWifiScanNotify() {
when(mWifiManager.isWifiEnabled()).thenReturn(false);
when(mWifiManager.isScanAlwaysAvailable()).thenReturn(true);
when(mInternetDialogController.isDeviceLocked()).thenReturn(true);
mInternetDialog.updateDialog();
assertThat(mWifiScanNotify.getVisibility()).isEqualTo(View.GONE);
}
@Test
public void updateDialog_wifiOffAndWifiScanOnAndDeviceUnlocked_showWifiScanNotify() {
when(mWifiManager.isWifiEnabled()).thenReturn(false);
when(mWifiManager.isScanAlwaysAvailable()).thenReturn(true);
when(mInternetDialogController.isDeviceLocked()).thenReturn(false);
mInternetDialog.updateDialog();
assertThat(mWifiScanNotify.getVisibility()).isEqualTo(View.VISIBLE);
TextView wifiScanNotifyText = mDialogView.requireViewById(R.id.wifi_scan_notify_text);
assertThat(wifiScanNotifyText.getText().length()).isNotEqualTo(0);
assertThat(wifiScanNotifyText.getMovementMethod()).isNotNull();
}
@Test
public void onClickSeeMoreButton_clickSeeAll_verifyLaunchNetworkSetting() {
mSeeAll.performClick();

View File

@@ -2125,6 +2125,9 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
final Task rootTask;
if (singleActivity) {
rootTask = task;
// Apply the last recents animation leash transform to the task entering PIP
rootTask.maybeApplyLastRecentsAnimationTransaction();
} else {
// In the case of multiple activities, we will create a new task for it and then
// move the PIP activity into the task. Note that we explicitly defer the task

View File

@@ -963,6 +963,21 @@ public class CarrierConfigManager {
public static final String KEY_CARRIER_USE_IMS_FIRST_FOR_EMERGENCY_BOOL
= "carrier_use_ims_first_for_emergency_bool";
/**
* When {@code true}, the determination of whether to place a call as an emergency call will be
* based on the known {@link android.telephony.emergency.EmergencyNumber}s for the SIM on which
* the call is being placed. In a dual SIM scenario, if Sim A has the emergency numbers
* 123, 456 and Sim B has the emergency numbers 789, and the user places a call on SIM A to 789,
* it will not be treated as an emergency call in this case.
* When {@code false}, the determination is based on the emergency numbers from all device SIMs,
* regardless of which SIM the call is being placed on. If Sim A has the emergency numbers
* 123, 456 and Sim B has the emergency numbers 789, and the user places a call on SIM A to 789,
* the call will be dialed as an emergency number, but with an unspecified routing.
* @hide
*/
public static final String KEY_USE_ONLY_DIALED_SIM_ECC_LIST_BOOL =
"use_only_dialed_sim_ecc_list_bool";
/**
* When IMS instant lettering is available for a carrier (see
* {@link #KEY_CARRIER_INSTANT_LETTERING_AVAILABLE_BOOL}), determines the list of characters
@@ -5339,6 +5354,7 @@ public class CarrierConfigManager {
sDefaults.putBoolean(KEY_CARRIER_IMS_GBA_REQUIRED_BOOL, false);
sDefaults.putBoolean(KEY_CARRIER_INSTANT_LETTERING_AVAILABLE_BOOL, false);
sDefaults.putBoolean(KEY_CARRIER_USE_IMS_FIRST_FOR_EMERGENCY_BOOL, true);
sDefaults.putBoolean(KEY_USE_ONLY_DIALED_SIM_ECC_LIST_BOOL, false);
sDefaults.putString(KEY_CARRIER_NETWORK_SERVICE_WWAN_PACKAGE_OVERRIDE_STRING, "");
sDefaults.putString(KEY_CARRIER_NETWORK_SERVICE_WLAN_PACKAGE_OVERRIDE_STRING, "");
sDefaults.putString(KEY_CARRIER_QUALIFIED_NETWORKS_SERVICE_PACKAGE_OVERRIDE_STRING, "");