Snap for 7526818 from a415ecb608 to sc-release
Change-Id: I0a3593965495f77c6be9316984ffa0c69fb36ec0
This commit is contained in:
@@ -2966,6 +2966,10 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The Wi-Fi result data will only be returned from WifiDialogActivity if the calling
|
||||||
|
package has ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission. (see b/185126813)
|
||||||
|
-->
|
||||||
<activity
|
<activity
|
||||||
android:name=".wifi.WifiDialogActivity"
|
android:name=".wifi.WifiDialogActivity"
|
||||||
android:label=""
|
android:label=""
|
||||||
|
|||||||
@@ -223,6 +223,24 @@
|
|||||||
<!-- This theme was applied to Settings pages which are running under SUW. -->
|
<!-- This theme was applied to Settings pages which are running under SUW. -->
|
||||||
<style name="SubSettings.SetupWizard" parent="SudThemeGlifV3.Light" />
|
<style name="SubSettings.SetupWizard" parent="SudThemeGlifV3.Light" />
|
||||||
|
|
||||||
|
<!-- This theme was applied to Settings pages which are running under SUW with DynamicColor. -->
|
||||||
|
<style name="SudDynamicColorThemeSettings.SetupWizard" parent="SudDynamicColorThemeGlifV3.Light">
|
||||||
|
<item name="android:textAppearanceListItem">@style/TextAppearance.PreferenceTitle.SettingsLib</item>
|
||||||
|
<item name="android:listPreferredItemPaddingStart">24dp</item>
|
||||||
|
<item name="android:listPreferredItemPaddingEnd">16dp</item>
|
||||||
|
<item name="preferenceTheme">@style/PreferenceTheme.SettingsLib</item>
|
||||||
|
<item name="android:switchStyle">@style/Switch.SettingsLib</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!-- This theme was applied to Settings pages which are running under SUW with DynamicColor. -->
|
||||||
|
<style name="SudDynamicColorThemeSettings.SetupWizard.DayNight" parent="SudDynamicColorThemeGlifV3.DayNight">
|
||||||
|
<item name="android:textAppearanceListItem">@style/TextAppearance.PreferenceTitle.SettingsLib</item>
|
||||||
|
<item name="android:listPreferredItemPaddingStart">24dp</item>
|
||||||
|
<item name="android:listPreferredItemPaddingEnd">16dp</item>
|
||||||
|
<item name="preferenceTheme">@style/PreferenceTheme.SettingsLib</item>
|
||||||
|
<item name="android:switchStyle">@style/Switch.SettingsLib</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<!-- DayNight themes -->
|
<!-- DayNight themes -->
|
||||||
<style name="GlifTheme.DayNight" parent="GlifTheme.Light" />
|
<style name="GlifTheme.DayNight" parent="GlifTheme.Light" />
|
||||||
<style name="GlifV2Theme.DayNight" parent="GlifV2Theme.Light" />
|
<style name="GlifV2Theme.DayNight" parent="GlifV2Theme.Light" />
|
||||||
|
|||||||
@@ -61,6 +61,7 @@
|
|||||||
|
|
||||||
<com.android.settings.accessibility.AccessibilityFooterPreference
|
<com.android.settings.accessibility.AccessibilityFooterPreference
|
||||||
android:key="accessibility_button_footer"
|
android:key="accessibility_button_footer"
|
||||||
|
android:title="@string/accessibility_button_description"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:selectable="false"
|
android:selectable="false"
|
||||||
settings:searchable="false"
|
settings:searchable="false"
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ package com.android.settings.accessibility;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,9 +38,16 @@ public class AccessibilityButtonFooterPreferenceController extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary() {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
return AccessibilityUtil.isGestureNavigateEnabled(mContext)
|
// Need to update footerPreference's data before super.displayPreference(), then it will use
|
||||||
? mContext.getString(R.string.accessibility_button_gesture_description)
|
// data to update related property of footerPreference.
|
||||||
: mContext.getString(R.string.accessibility_button_description);
|
if (AccessibilityUtil.isGestureNavigateEnabled(mContext)) {
|
||||||
|
final AccessibilityFooterPreference footerPreference =
|
||||||
|
screen.findPreference(getPreferenceKey());
|
||||||
|
footerPreference.setTitle(
|
||||||
|
mContext.getString(R.string.accessibility_button_gesture_description));
|
||||||
|
}
|
||||||
|
|
||||||
|
super.displayPreference(screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,12 +101,22 @@ public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivit
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedState) {
|
protected void onCreate(Bundle savedState) {
|
||||||
super.onCreate(savedState);
|
super.onCreate(savedState);
|
||||||
setTheme(SetupWizardUtils.getTheme(this, getIntent()));
|
applyTheme();
|
||||||
ThemeHelper.trySetDynamicColor(this);
|
|
||||||
tryLaunchFontSizeSettings();
|
tryLaunchFontSizeSettings();
|
||||||
findViewById(R.id.content_parent).setFitsSystemWindows(false);
|
findViewById(R.id.content_parent).setFitsSystemWindows(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void applyTheme() {
|
||||||
|
if (ThemeHelper.trySetDynamicColor(this)) {
|
||||||
|
final int appliedTheme = ThemeHelper.isSetupWizardDayNightEnabled(this)
|
||||||
|
? R.style.SudDynamicColorThemeSettings_SetupWizard_DayNight
|
||||||
|
: R.style.SudDynamicColorThemeSettings_SetupWizard;
|
||||||
|
setTheme(appliedTheme);
|
||||||
|
} else {
|
||||||
|
setTheme(SetupWizardUtils.getTheme(this, getIntent()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void tryLaunchFontSizeSettings() {
|
void tryLaunchFontSizeSettings() {
|
||||||
if (WizardManagerHelper.isAnySetupWizard(getIntent())
|
if (WizardManagerHelper.isAnySetupWizard(getIntent())
|
||||||
|
|||||||
@@ -91,10 +91,17 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa
|
|||||||
// Apply SetupWizard light theme during setup flow. This is for SubSettings pages.
|
// Apply SetupWizard light theme during setup flow. This is for SubSettings pages.
|
||||||
final boolean isAnySetupWizard = WizardManagerHelper.isAnySetupWizard(getIntent());
|
final boolean isAnySetupWizard = WizardManagerHelper.isAnySetupWizard(getIntent());
|
||||||
if (isAnySetupWizard && this instanceof SubSettings) {
|
if (isAnySetupWizard && this instanceof SubSettings) {
|
||||||
final int appliedTheme = ThemeHelper.isSetupWizardDayNightEnabled(this)
|
int appliedTheme;
|
||||||
? R.style.SubSettings_SetupWizard : R.style.SudThemeGlifV3_Light;
|
if (ThemeHelper.trySetDynamicColor(this)) {
|
||||||
|
appliedTheme = ThemeHelper.isSetupWizardDayNightEnabled(this)
|
||||||
|
? R.style.SudDynamicColorThemeSettings_SetupWizard_DayNight
|
||||||
|
: R.style.SudDynamicColorThemeSettings_SetupWizard;
|
||||||
|
} else {
|
||||||
|
appliedTheme = ThemeHelper.isSetupWizardDayNightEnabled(this)
|
||||||
|
? R.style.SubSettings_SetupWizard
|
||||||
|
: R.style.SudThemeGlifV3_Light;
|
||||||
|
}
|
||||||
setTheme(appliedTheme);
|
setTheme(appliedTheme);
|
||||||
ThemeHelper.trySetDynamicColor(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isToolbarEnabled() && !isAnySetupWizard) {
|
if (isToolbarEnabled() && !isAnySetupWizard) {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
import androidx.lifecycle.Lifecycle;
|
||||||
|
|
||||||
import com.android.internal.util.CollectionUtils;
|
import com.android.internal.util.CollectionUtils;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -68,6 +69,7 @@ public class MobileNetworkActivity extends SettingsBaseActivity
|
|||||||
// Set initial value to true allows subscription information fragment to be re-created when
|
// Set initial value to true allows subscription information fragment to be re-created when
|
||||||
// Activity re-create occur.
|
// Activity re-create occur.
|
||||||
private boolean mFragmentForceReload = true;
|
private boolean mFragmentForceReload = true;
|
||||||
|
private boolean mPendingSubscriptionChange = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
@@ -155,6 +157,10 @@ public class MobileNetworkActivity extends SettingsBaseActivity
|
|||||||
* Implementation of ProxySubscriptionManager.OnActiveSubscriptionChangedListener
|
* Implementation of ProxySubscriptionManager.OnActiveSubscriptionChangedListener
|
||||||
*/
|
*/
|
||||||
public void onChanged() {
|
public void onChanged() {
|
||||||
|
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
||||||
|
mPendingSubscriptionChange = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
SubscriptionInfo info = getSubscription();
|
SubscriptionInfo info = getSubscription();
|
||||||
int oldSubIndex = mCurSubscriptionId;
|
int oldSubIndex = mCurSubscriptionId;
|
||||||
updateSubscriptions(info, null);
|
updateSubscriptions(info, null);
|
||||||
@@ -180,6 +186,10 @@ public class MobileNetworkActivity extends SettingsBaseActivity
|
|||||||
super.onStart();
|
super.onStart();
|
||||||
// updateSubscriptions doesn't need to be called, onChanged will always be called after we
|
// updateSubscriptions doesn't need to be called, onChanged will always be called after we
|
||||||
// register a listener.
|
// register a listener.
|
||||||
|
if (mPendingSubscriptionChange) {
|
||||||
|
mPendingSubscriptionChange = false;
|
||||||
|
onChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings.wifi.calling;
|
package com.android.settings.wifi.calling;
|
||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -29,12 +30,14 @@ import android.view.ViewGroup;
|
|||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentPagerAdapter;
|
import androidx.fragment.app.FragmentPagerAdapter;
|
||||||
|
|
||||||
import com.android.internal.util.CollectionUtils;
|
import com.android.internal.util.CollectionUtils;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.InstrumentedFragment;
|
import com.android.settings.core.InstrumentedFragment;
|
||||||
|
import com.android.settings.network.ActiveSubscriptionsListener;
|
||||||
import com.android.settings.network.SubscriptionUtil;
|
import com.android.settings.network.SubscriptionUtil;
|
||||||
import com.android.settings.network.ims.WifiCallingQueryImsState;
|
import com.android.settings.network.ims.WifiCallingQueryImsState;
|
||||||
import com.android.settings.search.actionbar.SearchMenuController;
|
import com.android.settings.search.actionbar.SearchMenuController;
|
||||||
@@ -42,6 +45,9 @@ import com.android.settings.support.actionbar.HelpResourceProvider;
|
|||||||
import com.android.settings.widget.RtlCompatibleViewPager;
|
import com.android.settings.widget.RtlCompatibleViewPager;
|
||||||
import com.android.settings.widget.SlidingTabLayout;
|
import com.android.settings.widget.SlidingTabLayout;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,7 +56,10 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class WifiCallingSettings extends InstrumentedFragment implements HelpResourceProvider {
|
public class WifiCallingSettings extends InstrumentedFragment implements HelpResourceProvider {
|
||||||
private static final String TAG = "WifiCallingSettings";
|
private static final String TAG = "WifiCallingSettings";
|
||||||
|
private int mConstructionSubId;
|
||||||
private List<SubscriptionInfo> mSil;
|
private List<SubscriptionInfo> mSil;
|
||||||
|
private ActiveSubscriptionsListener mSubscriptionChangeListener;
|
||||||
|
private static final int [] EMPTY_SUB_ID_LIST = new int[0];
|
||||||
|
|
||||||
//UI objects
|
//UI objects
|
||||||
private RtlCompatibleViewPager mViewPager;
|
private RtlCompatibleViewPager mViewPager;
|
||||||
@@ -95,16 +104,26 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getConstructionSubId(Bundle bundle) {
|
||||||
|
int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
|
|
||||||
|
Intent intent = getActivity().getIntent();
|
||||||
|
if (intent != null) {
|
||||||
|
subId = intent.getIntExtra(Settings.EXTRA_SUB_ID,
|
||||||
|
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||||
|
}
|
||||||
|
if ((subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) && (bundle != null)) {
|
||||||
|
subId = bundle.getInt(Settings.EXTRA_SUB_ID,
|
||||||
|
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||||
|
}
|
||||||
|
return subId;
|
||||||
|
}
|
||||||
|
|
||||||
private void maybeSetViewForSubId() {
|
private void maybeSetViewForSubId() {
|
||||||
if (mSil == null) {
|
if (mSil == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Intent intent = getActivity().getIntent();
|
int subId = mConstructionSubId;
|
||||||
if (intent == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final int subId = intent.getIntExtra(Settings.EXTRA_SUB_ID,
|
|
||||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
|
||||||
if (SubscriptionManager.isValidSubscriptionId(subId)) {
|
if (SubscriptionManager.isValidSubscriptionId(subId)) {
|
||||||
for (SubscriptionInfo subInfo : mSil) {
|
for (SubscriptionInfo subInfo : mSil) {
|
||||||
if (subId == subInfo.getSubscriptionId()) {
|
if (subId == subInfo.getSubscriptionId()) {
|
||||||
@@ -117,11 +136,15 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
|
mConstructionSubId = getConstructionSubId(icicle);
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
Log.d(TAG, "SubId=" + mConstructionSubId);
|
||||||
|
|
||||||
// TODO: besides in onCreate, we should also update subList when SIM / Sub status
|
if (mConstructionSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||||
// changes.
|
// Only config Wfc if it's enabled by platform.
|
||||||
updateSubList();
|
mSubscriptionChangeListener = getSubscriptionChangeListener(getContext());
|
||||||
|
}
|
||||||
|
mSil = updateSubList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -135,6 +158,26 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateTitleForCurrentSub();
|
updateTitleForCurrentSub();
|
||||||
|
|
||||||
|
if (mSubscriptionChangeListener != null) {
|
||||||
|
mSubscriptionChangeListener.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
if (mSubscriptionChangeListener != null) {
|
||||||
|
mSubscriptionChangeListener.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
// keep subscription ID for recreation
|
||||||
|
outState.putInt(Settings.EXTRA_SUB_ID, mConstructionSubId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -160,11 +203,11 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Fragment getItem(int position) {
|
public Fragment getItem(int position) {
|
||||||
Log.d(TAG, "Adapter getItem " + position);
|
int subId = mSil.get(position).getSubscriptionId();
|
||||||
|
Log.d(TAG, "Adapter getItem " + position + " for subId=" + subId);
|
||||||
final Bundle args = new Bundle();
|
final Bundle args = new Bundle();
|
||||||
args.putBoolean(SearchMenuController.NEED_SEARCH_ICON_IN_ACTION_BAR, false);
|
args.putBoolean(SearchMenuController.NEED_SEARCH_ICON_IN_ACTION_BAR, false);
|
||||||
args.putInt(WifiCallingSettingsForSub.FRAGMENT_BUNDLE_SUBID,
|
args.putInt(WifiCallingSettingsForSub.FRAGMENT_BUNDLE_SUBID, subId);
|
||||||
mSil.get(position).getSubscriptionId());
|
|
||||||
final WifiCallingSettingsForSub fragment = new WifiCallingSettingsForSub();
|
final WifiCallingSettingsForSub fragment = new WifiCallingSettingsForSub();
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
|
|
||||||
@@ -190,22 +233,27 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSubList() {
|
@VisibleForTesting
|
||||||
mSil = SubscriptionUtil.getActiveSubscriptions(
|
protected List<SubscriptionInfo> getSelectableSubscriptions(Context context) {
|
||||||
getContext().getSystemService(SubscriptionManager.class));
|
return SubscriptionUtil.getSelectableSubscriptionInfoList(context);
|
||||||
|
}
|
||||||
|
|
||||||
// Only config Wfc if it's enabled by platform.
|
private List<SubscriptionInfo> updateSubList() {
|
||||||
if (mSil == null) {
|
List<SubscriptionInfo> subInfoList = getSelectableSubscriptions(getContext());
|
||||||
return;
|
|
||||||
|
if (subInfoList == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
for (int i = 0; i < mSil.size(); ) {
|
List<SubscriptionInfo> selectedList = new ArrayList<SubscriptionInfo>();
|
||||||
final SubscriptionInfo info = mSil.get(i);
|
for (SubscriptionInfo subInfo : subInfoList) {
|
||||||
if (!queryImsState(info.getSubscriptionId()).isWifiCallingProvisioned()) {
|
int subId = subInfo.getSubscriptionId();
|
||||||
mSil.remove(i);
|
try {
|
||||||
} else {
|
if (queryImsState(subId).isWifiCallingProvisioned()) {
|
||||||
i++;
|
selectedList.add(subInfo);
|
||||||
}
|
}
|
||||||
|
} catch (Exception exception) {}
|
||||||
}
|
}
|
||||||
|
return selectedList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTitleForCurrentSub() {
|
private void updateTitleForCurrentSub() {
|
||||||
@@ -218,7 +266,78 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
WifiCallingQueryImsState queryImsState(int subId) {
|
protected WifiCallingQueryImsState queryImsState(int subId) {
|
||||||
return new WifiCallingQueryImsState(getContext(), subId);
|
return new WifiCallingQueryImsState(getContext(), subId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
protected ActiveSubscriptionsListener getSubscriptionChangeListener(Context context) {
|
||||||
|
return new ActiveSubscriptionsListener(context.getMainLooper(), context) {
|
||||||
|
public void onChanged() {
|
||||||
|
onSubscriptionChange(context);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onSubscriptionChange(Context context) {
|
||||||
|
if (mSubscriptionChangeListener == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int [] previousSubIdList = subscriptionIdList(mSil);
|
||||||
|
List<SubscriptionInfo> updateList = updateSubList();
|
||||||
|
int [] currentSubIdList = subscriptionIdList(updateList);
|
||||||
|
|
||||||
|
if (currentSubIdList.length > 0) {
|
||||||
|
// only keep fragment when any provisioned subscription is available
|
||||||
|
if (previousSubIdList.length == 0) {
|
||||||
|
// initial loading of list
|
||||||
|
mSil = updateList;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (previousSubIdList.length == currentSubIdList.length) {
|
||||||
|
// same number of subscriptions
|
||||||
|
if ( (!containsSubId(previousSubIdList, mConstructionSubId))
|
||||||
|
// original request not yet appears in list
|
||||||
|
|| containsSubId(currentSubIdList, mConstructionSubId) )
|
||||||
|
// original request appears in list
|
||||||
|
{
|
||||||
|
mSil = updateList;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Log.d(TAG, "Closed subId=" + mConstructionSubId
|
||||||
|
+ " due to subscription change: " + Arrays.toString(previousSubIdList)
|
||||||
|
+ " -> " + Arrays.toString(currentSubIdList));
|
||||||
|
|
||||||
|
// close this fragment when no provisioned subscriptions available
|
||||||
|
if (mSubscriptionChangeListener != null) {
|
||||||
|
mSubscriptionChangeListener.stop();
|
||||||
|
mSubscriptionChangeListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// close this fragment
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void finish() {
|
||||||
|
FragmentActivity activity = getActivity();
|
||||||
|
if (activity == null) return;
|
||||||
|
if (getFragmentManager().getBackStackEntryCount() > 0) {
|
||||||
|
getFragmentManager().popBackStack();
|
||||||
|
} else {
|
||||||
|
activity.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int [] subscriptionIdList(List<SubscriptionInfo> subInfoList) {
|
||||||
|
return (subInfoList == null) ? EMPTY_SUB_ID_LIST :
|
||||||
|
subInfoList.stream().mapToInt(subInfo -> (subInfo == null) ?
|
||||||
|
SubscriptionManager.INVALID_SUBSCRIPTION_ID : subInfo.getSubscriptionId())
|
||||||
|
.toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean containsSubId(int [] subIdArray, int subIdLookUp) {
|
||||||
|
return Arrays.stream(subIdArray).anyMatch(subId -> (subId == subIdLookUp));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.accessibility;
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
|
|
||||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
@@ -26,6 +25,7 @@ import static org.mockito.Mockito.when;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -34,6 +34,7 @@ import org.junit.Before;
|
|||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
import org.mockito.Spy;
|
import org.mockito.Spy;
|
||||||
import org.mockito.junit.MockitoJUnit;
|
import org.mockito.junit.MockitoJUnit;
|
||||||
import org.mockito.junit.MockitoRule;
|
import org.mockito.junit.MockitoRule;
|
||||||
@@ -50,30 +51,29 @@ public class AccessibilityButtonFooterPreferenceControllerTest {
|
|||||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||||
@Spy
|
@Spy
|
||||||
private final Resources mResources = mContext.getResources();
|
private final Resources mResources = mContext.getResources();
|
||||||
|
@Mock
|
||||||
|
private PreferenceScreen mScreen;
|
||||||
private AccessibilityButtonFooterPreferenceController mController;
|
private AccessibilityButtonFooterPreferenceController mController;
|
||||||
|
private AccessibilityFooterPreference mPreference;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mController = new AccessibilityButtonFooterPreferenceController(mContext,
|
mController = new AccessibilityButtonFooterPreferenceController(mContext, "test_key");
|
||||||
"test_key");
|
mPreference = new AccessibilityFooterPreference(mContext);
|
||||||
|
mPreference.setKey("test_key");
|
||||||
|
|
||||||
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
when(mContext.getResources()).thenReturn(mResources);
|
when(mContext.getResources()).thenReturn(mResources);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_navigationGestureEnabled_shouldReturnButtonAndGestureSummary() {
|
public void displayPreference_navigationGestureEnabled_setCorrectTitle() {
|
||||||
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
||||||
.thenReturn(NAV_BAR_MODE_GESTURAL);
|
.thenReturn(NAV_BAR_MODE_GESTURAL);
|
||||||
|
|
||||||
assertThat(mController.getSummary()).isEqualTo(
|
mController.displayPreference(mScreen);
|
||||||
|
|
||||||
|
assertThat(mPreference.getTitle()).isEqualTo(
|
||||||
mContext.getText(R.string.accessibility_button_gesture_description));
|
mContext.getText(R.string.accessibility_button_gesture_description));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getSummary_navigationGestureDisabled_shouldReturnButtonSummary() {
|
|
||||||
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
|
|
||||||
.thenReturn(NAV_BAR_MODE_2BUTTON);
|
|
||||||
|
|
||||||
assertThat(mController.getSummary()).isEqualTo(
|
|
||||||
mContext.getText(R.string.accessibility_button_description));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user