Snap for 6766785 from 4d00b8b57a
to rvc-qpr1-release
Change-Id: I858dd812991abc7f4924e105757aa86664a3da27
This commit is contained in:
@@ -348,6 +348,7 @@
|
||||
<dimen name="contextual_half_card_padding_top">12dp</dimen>
|
||||
<dimen name="contextual_half_card_padding_bottom">16dp</dimen>
|
||||
<dimen name="contextual_half_card_title_margin_top">12dp</dimen>
|
||||
<dimen name="contextual_card_preallocated_height">0dp</dimen>
|
||||
|
||||
<!-- Homepage dismissal cards size and padding -->
|
||||
<dimen name="contextual_card_dismissal_margin_top">12dp</dimen>
|
||||
|
@@ -4321,6 +4321,20 @@
|
||||
result from their use.
|
||||
</string>
|
||||
|
||||
<!-- eSIM erase warning dialog. -->
|
||||
<!-- Factory data reset erase eSIM failure title [CHAR LIMIT=50] -->
|
||||
<string name="fdr_esim_failure_title" >There is an issue erasing the downloaded SIMs</string>
|
||||
<!-- Factory data reset erase eSIM failure text [CHAR LIMIT=none] -->
|
||||
<string name="fdr_esim_failure_text">Please reboot the device and try again. If you continue factory reset, the downloaded SIMs may remain on the device.</string>
|
||||
<!-- Factory data reset erase eSIM failure reboot button text [CHAR LIMIT=none] -->
|
||||
<string name="fdr_esim_failure_reboot_btn">Reboot</string>
|
||||
<!-- Factory data reset continue factory data reset title [CHAR LIMIT=35] -->
|
||||
<string name="fdr_continue_title" >Continue factory reset?</string>
|
||||
<!-- Factory data reset continue factory data reset text [CHAR LIMIT=none] -->
|
||||
<string name="fdr_continue_text">Downloaded SIMs will remain on device.</string>
|
||||
<!-- Factory data reset continue factory data reset button text [CHAR LIMIT=none] -->
|
||||
<string name="fdr_continue_btn">Factory reset</string>
|
||||
|
||||
<!-- Warning that appears below the unknown sources switch in settings -->
|
||||
<string name="install_all_warning" product="device">
|
||||
Your device and personal data are more vulnerable
|
||||
|
@@ -21,20 +21,26 @@ import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.app.admin.FactoryResetProtectionPolicy;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.graphics.Color;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.service.oemlock.OemLockManager;
|
||||
import android.service.persistentdata.PersistentDataBlockManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.UiccSlotInfo;
|
||||
import android.telephony.euicc.EuiccManager;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -54,6 +60,8 @@ import com.google.android.setupcompat.template.FooterButton.ButtonType;
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
import com.google.android.setupdesign.GlifLayout;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Confirm and execute a reset of the device to a clean "just out of the box"
|
||||
* state. Multiple confirmations are required: first, a general "are you sure
|
||||
@@ -83,6 +91,89 @@ public class MasterClearConfirm extends InstrumentedFragment {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the eSIM slot is in an error state, display a dialog to warn users that their eSIM
|
||||
// profiles may not be fully deleted during FDR.
|
||||
if (shouldShowEsimEraseFailureDialog()) {
|
||||
Log.e(TAG, "eUICC card is in an error state. Display a dialog to warn the user.");
|
||||
showEsimErrorDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
performFactoryReset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the user choose to erase eSIM profile but the eUICC card is in an error
|
||||
* state.
|
||||
*/
|
||||
private boolean shouldShowEsimEraseFailureDialog() {
|
||||
EuiccManager euiccManager = getActivity().getSystemService(EuiccManager.class);
|
||||
TelephonyManager telephonyManager =
|
||||
getActivity().getSystemService(TelephonyManager.class);
|
||||
|
||||
if (euiccManager == null || !euiccManager.isEnabled()) {
|
||||
Log.i(
|
||||
TAG,
|
||||
"eSIM manager is disabled. No need to check eSIM slot before FDR.");
|
||||
return false;
|
||||
}
|
||||
if (!mEraseEsims) {
|
||||
Log.i(
|
||||
TAG,
|
||||
"eSIM does not need to be reset. No need to check eSIM slot before FDR.");
|
||||
return false;
|
||||
}
|
||||
UiccSlotInfo[] slotInfos = telephonyManager.getUiccSlotsInfo();
|
||||
if (slotInfos == null) {
|
||||
Log.i(TAG, "Unable to get UICC slots.");
|
||||
return false;
|
||||
}
|
||||
// If getIsEuicc() returns false for an eSIM slot, it means the eSIM is in the error
|
||||
// state.
|
||||
return Arrays.stream(slotInfos).anyMatch(
|
||||
slot -> slot != null && !slot.isRemovable() && !slot.getIsEuicc());
|
||||
}
|
||||
|
||||
private void showEsimErrorDialog() {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.fdr_esim_failure_title)
|
||||
.setMessage(R.string.fdr_esim_failure_text)
|
||||
.setNeutralButton(R.string.dlg_cancel,
|
||||
(DialogInterface.OnClickListener) (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
})
|
||||
.setNegativeButton(R.string.fdr_esim_failure_reboot_btn,
|
||||
(DialogInterface.OnClickListener) (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
PowerManager pm = (PowerManager) getActivity()
|
||||
.getSystemService(Context.POWER_SERVICE);
|
||||
pm.reboot(null);
|
||||
})
|
||||
.setPositiveButton(R.string.lockpassword_continue_label,
|
||||
(DialogInterface.OnClickListener) (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
showContinueFdrDialog();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void showContinueFdrDialog() {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.fdr_continue_title)
|
||||
.setMessage(R.string.fdr_continue_text)
|
||||
.setNegativeButton(R.string.dlg_cancel,
|
||||
(DialogInterface.OnClickListener) (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
})
|
||||
.setPositiveButton(R.string.fdr_continue_btn,
|
||||
(DialogInterface.OnClickListener) (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
performFactoryReset();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void performFactoryReset() {
|
||||
final PersistentDataBlockManager pdbManager = (PersistentDataBlockManager)
|
||||
getActivity().getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
|
||||
|
||||
|
@@ -24,6 +24,9 @@ public interface ContextualCardFeatureProvider {
|
||||
/** Get contextual cards from the card provider */
|
||||
Cursor getContextualCards();
|
||||
|
||||
/** Get the default contextual card to display */
|
||||
ContextualCard getDefaultContextualCard();
|
||||
|
||||
/**
|
||||
* Mark a specific {@link ContextualCard} as dismissed with dismissal signal in the database
|
||||
* to indicate that the card has been dismissed.
|
||||
|
@@ -54,6 +54,11 @@ public class ContextualCardFeatureProviderImpl implements ContextualCardFeatureP
|
||||
return cursor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContextualCard getDefaultContextualCard() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int markCardAsDismissed(Context context, String cardName) {
|
||||
final SQLiteDatabase db = CardDatabaseHelper.getInstance(mContext).getWritableDatabase();
|
||||
|
@@ -50,7 +50,7 @@ import java.util.stream.Collectors;
|
||||
public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>> {
|
||||
|
||||
@VisibleForTesting
|
||||
static final int DEFAULT_CARD_COUNT = 3;
|
||||
static final int DEFAULT_CARD_COUNT = 1;
|
||||
@VisibleForTesting
|
||||
static final String CONTEXTUAL_CARD_COUNT = "contextual_card_count";
|
||||
static final int CARD_CONTENT_LOADER_ID = 1;
|
||||
@@ -131,7 +131,7 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
final List<ContextualCard> visibleCards = new ArrayList<>();
|
||||
final List<ContextualCard> hiddenCards = new ArrayList<>();
|
||||
|
||||
final int maxCardCount = getCardCount();
|
||||
final int maxCardCount = getCardCount(mContext);
|
||||
eligibleCards.forEach(card -> {
|
||||
if (card.getCategory() != STICKY_VALUE) {
|
||||
return;
|
||||
@@ -164,14 +164,23 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
SettingsEnums.ACTION_CONTEXTUAL_CARD_NOT_SHOW,
|
||||
ContextualCardLogUtils.buildCardListLog(hiddenCards));
|
||||
}
|
||||
|
||||
// Add a default card if no other visible cards
|
||||
if (visibleCards.isEmpty() && maxCardCount == 1) {
|
||||
final ContextualCard defaultCard = FeatureFactory.getFactory(mContext)
|
||||
.getContextualCardFeatureProvider(mContext).getDefaultContextualCard();
|
||||
if (defaultCard != null) {
|
||||
Log.i(TAG, "Default card: " + defaultCard.getSliceUri());
|
||||
visibleCards.add(defaultCard);
|
||||
}
|
||||
}
|
||||
return visibleCards;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
int getCardCount() {
|
||||
static int getCardCount(Context context) {
|
||||
// Return the card count if Settings.Global has KEY_CONTEXTUAL_CARD_COUNT key,
|
||||
// otherwise return the default one.
|
||||
return Settings.Global.getInt(mContext.getContentResolver(),
|
||||
return Settings.Global.getInt(context.getContentResolver(),
|
||||
CONTEXTUAL_CARD_COUNT, DEFAULT_CARD_COUNT);
|
||||
}
|
||||
|
||||
|
@@ -122,6 +122,10 @@ public class ContextualCardManager implements ContextualCardLoader.CardContentLo
|
||||
Log.w(TAG, "Legacy suggestion contextual card enabled, skipping contextual cards.");
|
||||
return;
|
||||
}
|
||||
if (ContextualCardLoader.getCardCount(mContext) <= 0) {
|
||||
Log.w(TAG, "Card count is zero, skipping contextual cards.");
|
||||
return;
|
||||
}
|
||||
mStartTime = System.currentTimeMillis();
|
||||
final CardContentLoaderCallbacks cardContentLoaderCallbacks =
|
||||
new CardContentLoaderCallbacks(mContext);
|
||||
|
@@ -16,7 +16,10 @@
|
||||
|
||||
package com.android.settings.homepage.contextualcards;
|
||||
|
||||
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -131,7 +134,22 @@ public class ContextualCardsAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
diffResult.dispatchUpdatesTo(this);
|
||||
}
|
||||
|
||||
if (mRecyclerView != null && previouslyEmpty && !nowEmpty) {
|
||||
if (mRecyclerView == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// When no card gets displayed either because a card's condition no longer meets
|
||||
// or when it's dismissed, the height should be rearranged.
|
||||
if (mContextualCards.isEmpty()) {
|
||||
final ViewGroup.LayoutParams params = mRecyclerView.getLayoutParams();
|
||||
if (params.height != WRAP_CONTENT) {
|
||||
Log.d(TAG, "mContextualCards is empty. Set the RV to wrap_content");
|
||||
params.height = WRAP_CONTENT;
|
||||
mRecyclerView.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
|
||||
if (previouslyEmpty && !nowEmpty) {
|
||||
// Adding items to empty list, should animate.
|
||||
mRecyclerView.scheduleLayoutAnimation();
|
||||
}
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.homepage.contextualcards;
|
||||
|
||||
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
|
||||
import static com.android.settings.homepage.contextualcards.ContextualCardsAdapter.SPAN_COUNT;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
@@ -34,6 +36,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
import androidx.loader.app.LoaderManager;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.InstrumentedFragment;
|
||||
@@ -105,8 +108,20 @@ public class ContextualCardsFragment extends InstrumentedFragment implements
|
||||
final View rootView = inflater.inflate(R.layout.settings_homepage, container, false);
|
||||
mCardsContainer = rootView.findViewById(R.id.card_container);
|
||||
mLayoutManager = new GridLayoutManager(getActivity(), SPAN_COUNT,
|
||||
GridLayoutManager.VERTICAL, false /* reverseLayout */);
|
||||
GridLayoutManager.VERTICAL, false /* reverseLayout */) {
|
||||
@Override
|
||||
public void onLayoutCompleted(RecyclerView.State state) {
|
||||
super.onLayoutCompleted(state);
|
||||
// Once cards finish laying out, make the RV back to wrap content for flexibility.
|
||||
final ViewGroup.LayoutParams params = mCardsContainer.getLayoutParams();
|
||||
if (params.height != WRAP_CONTENT) {
|
||||
params.height = WRAP_CONTENT;
|
||||
mCardsContainer.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
};
|
||||
mCardsContainer.setLayoutManager(mLayoutManager);
|
||||
preAllocateHeight(context);
|
||||
mContextualCardsAdapter = new ContextualCardsAdapter(context, this /* lifecycleOwner */,
|
||||
mContextualCardManager);
|
||||
mCardsContainer.setItemAnimator(null);
|
||||
@@ -159,6 +174,25 @@ public class ContextualCardsFragment extends InstrumentedFragment implements
|
||||
FeatureFactory.getFactory(context).getSlicesFeatureProvider().newUiSession();
|
||||
}
|
||||
|
||||
private void preAllocateHeight(Context context) {
|
||||
final int cardCount = ContextualCardLoader.getCardCount(context);
|
||||
if (cardCount != 1) {
|
||||
// only pre-allocate space when card count is one
|
||||
Log.d(TAG, "Skip height pre-allocating. card count = " + cardCount);
|
||||
return;
|
||||
}
|
||||
|
||||
final int preAllocatedHeight = getResources().getDimensionPixelSize(
|
||||
R.dimen.contextual_card_preallocated_height);
|
||||
if (preAllocatedHeight == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ViewGroup.LayoutParams params = mCardsContainer.getLayoutParams();
|
||||
params.height = preAllocatedHeight;
|
||||
mCardsContainer.setLayoutParams(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Receiver for updating UI session when home key or recent app key is pressed.
|
||||
*/
|
||||
|
@@ -47,7 +47,6 @@ import com.android.settings.homepage.contextualcards.CardContentProvider;
|
||||
import com.android.settings.homepage.contextualcards.ContextualCard;
|
||||
import com.android.settings.homepage.contextualcards.ContextualCardRenderer;
|
||||
import com.android.settings.homepage.contextualcards.ControllerRendererPool;
|
||||
import com.android.settings.homepage.contextualcards.slices.SliceFullCardRendererHelper.SliceViewHolder;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -105,7 +104,7 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
|
||||
|
||||
// Show cached slice first before slice binding completed to avoid jank.
|
||||
if (holder.getItemViewType() != VIEW_TYPE_HALF_WIDTH) {
|
||||
((SliceViewHolder) holder).sliceView.setSlice(card.getSlice());
|
||||
mFullCardHelper.bindView(holder, card, card.getSlice());
|
||||
}
|
||||
|
||||
LiveData<Slice> sliceLiveData = mSliceLiveDataMap.get(uri);
|
||||
|
@@ -25,6 +25,7 @@ import android.net.NetworkInfo.State;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
@@ -44,6 +45,9 @@ import com.android.settingslib.wifi.AccessPoint;
|
||||
*/
|
||||
public class ContextualWifiSlice extends WifiSlice {
|
||||
|
||||
@VisibleForTesting
|
||||
static final String CONTEXTUAL_WIFI_EXPANDABLE = "contextual_wifi_expandable";
|
||||
|
||||
@VisibleForTesting
|
||||
static final int COLLAPSED_ROW_COUNT = 0;
|
||||
|
||||
@@ -63,13 +67,17 @@ public class ContextualWifiSlice extends WifiSlice {
|
||||
|
||||
@Override
|
||||
public Slice getSlice() {
|
||||
final long currentUiSession = FeatureFactory.getFactory(mContext)
|
||||
.getSlicesFeatureProvider().getUiSessionToken();
|
||||
if (currentUiSession != sActiveUiSession) {
|
||||
sActiveUiSession = currentUiSession;
|
||||
sApRowCollapsed = hasWorkingNetwork();
|
||||
} else if (!mWifiManager.isWifiEnabled()) {
|
||||
sApRowCollapsed = false;
|
||||
if (isExpandable()) {
|
||||
final long currentUiSession = FeatureFactory.getFactory(mContext)
|
||||
.getSlicesFeatureProvider().getUiSessionToken();
|
||||
if (currentUiSession != sActiveUiSession) {
|
||||
sActiveUiSession = currentUiSession;
|
||||
sApRowCollapsed = hasWorkingNetwork();
|
||||
} else if (!mWifiManager.isWifiEnabled()) {
|
||||
sApRowCollapsed = false;
|
||||
}
|
||||
} else {
|
||||
sApRowCollapsed = true;
|
||||
}
|
||||
return super.getSlice();
|
||||
}
|
||||
@@ -87,12 +95,18 @@ public class ContextualWifiSlice extends WifiSlice {
|
||||
protected ListBuilder.RowBuilder getHeaderRow(boolean isWifiEnabled, AccessPoint accessPoint) {
|
||||
final ListBuilder.RowBuilder builder = super.getHeaderRow(isWifiEnabled, accessPoint);
|
||||
builder.setTitleItem(getHeaderIcon(isWifiEnabled, accessPoint), ListBuilder.ICON_IMAGE);
|
||||
if (sApRowCollapsed) {
|
||||
if (sApRowCollapsed && isWifiEnabled) {
|
||||
builder.setSubtitle(getSubtitle(accessPoint));
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
private boolean isExpandable() {
|
||||
// Return whether this slice can be expandable.
|
||||
return Settings.Global.getInt(mContext.getContentResolver(), CONTEXTUAL_WIFI_EXPANDABLE, 0)
|
||||
!= 0;
|
||||
}
|
||||
|
||||
private IconCompat getHeaderIcon(boolean isWifiEnabled, AccessPoint accessPoint) {
|
||||
final Drawable drawable;
|
||||
final int tint;
|
||||
|
@@ -71,25 +71,25 @@ public class ContextualCardLoaderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDisplayableCards_twoEligibleCards_shouldShowAll() {
|
||||
public void getDisplayableCards_twoEligibleCards_notExceedDefaultCardCount() {
|
||||
final List<ContextualCard> cards = getContextualCardList().stream().limit(2)
|
||||
.collect(Collectors.toList());
|
||||
doReturn(cards).when(mContextualCardLoader).filterEligibleCards(anyList());
|
||||
|
||||
final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(cards);
|
||||
|
||||
assertThat(result).hasSize(cards.size());
|
||||
assertThat(result).hasSize(Math.min(cards.size(), DEFAULT_CARD_COUNT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDisplayableCards_fourEligibleCards_shouldShowDefaultCardCount() {
|
||||
public void getDisplayableCards_fourEligibleCards_notExceedDefaultCardCount() {
|
||||
final List<ContextualCard> cards = getContextualCardList().stream().limit(4)
|
||||
.collect(Collectors.toList());
|
||||
doReturn(cards).when(mContextualCardLoader).filterEligibleCards(anyList());
|
||||
|
||||
final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(cards);
|
||||
|
||||
assertThat(result).hasSize(DEFAULT_CARD_COUNT);
|
||||
assertThat(result).hasSize(Math.min(cards.size(), DEFAULT_CARD_COUNT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -139,7 +139,7 @@ public class ContextualCardLoaderTest {
|
||||
|
||||
@Test
|
||||
public void getCardCount_noConfiguredCardCount_returnDefaultCardCount() {
|
||||
assertThat(mContextualCardLoader.getCardCount()).isEqualTo(DEFAULT_CARD_COUNT);
|
||||
assertThat(mContextualCardLoader.getCardCount(mContext)).isEqualTo(DEFAULT_CARD_COUNT);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -148,7 +148,7 @@ public class ContextualCardLoaderTest {
|
||||
Settings.Global.putLong(mContext.getContentResolver(),
|
||||
ContextualCardLoader.CONTEXTUAL_CARD_COUNT, configCount);
|
||||
|
||||
assertThat(mContextualCardLoader.getCardCount()).isEqualTo(configCount);
|
||||
assertThat(mContextualCardLoader.getCardCount(mContext)).isEqualTo(configCount);
|
||||
}
|
||||
|
||||
private List<ContextualCard> getContextualCardList() {
|
||||
|
@@ -30,6 +30,7 @@ import android.content.Context;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.core.graphics.drawable.IconCompat;
|
||||
import androidx.slice.Slice;
|
||||
@@ -77,6 +78,9 @@ public class ContextualWifiSliceTest {
|
||||
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
|
||||
mWifiManager.setWifiEnabled(true);
|
||||
|
||||
// Set WifiSlice expandable
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
ContextualWifiSlice.CONTEXTUAL_WIFI_EXPANDABLE, 1);
|
||||
mWifiSlice = new ContextualWifiSlice(mContext);
|
||||
}
|
||||
|
||||
@@ -126,6 +130,18 @@ public class ContextualWifiSliceTest {
|
||||
assertThat(ContextualWifiSlice.getApRowCount()).isEqualTo(COLLAPSED_ROW_COUNT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWifiSlice_notExpandable_shouldCollapseSlice() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
ContextualWifiSlice.CONTEXTUAL_WIFI_EXPANDABLE, 0);
|
||||
mWifiSlice.sApRowCollapsed = false;
|
||||
|
||||
final Slice wifiSlice = mWifiSlice.getSlice();
|
||||
|
||||
assertWifiHeader(wifiSlice);
|
||||
assertThat(ContextualWifiSlice.getApRowCount()).isEqualTo(COLLAPSED_ROW_COUNT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWifiSlice_contextualWifiSlice_shouldReturnContextualWifiSliceUri() {
|
||||
mWifiSlice.sActiveUiSession = mFeatureFactory.slicesFeatureProvider.getUiSessionToken();
|
||||
|
Reference in New Issue
Block a user