Snap for 7549382 from 8bb404d5ae to sc-v2-release
Change-Id: I2c3a5c9ae13f584f89cf76ebed0ed1e0eb3782bb
This commit is contained in:
@@ -5258,10 +5258,18 @@
|
|||||||
<string name="select_to_speak_summary">Tap items on your screen to hear them read aloud</string>
|
<string name="select_to_speak_summary">Tap items on your screen to hear them read aloud</string>
|
||||||
<!-- Title for the accessibility preference screen to enable video captioning. [CHAR LIMIT=35] -->
|
<!-- Title for the accessibility preference screen to enable video captioning. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_captioning_title">Caption preferences</string>
|
<string name="accessibility_captioning_title">Caption preferences</string>
|
||||||
|
<!-- Title for accessibility captioning footer. [CHAR LIMIT=60] -->
|
||||||
|
<string name="accessibility_captioning_about_title">About caption preferences</string>
|
||||||
|
<!-- Accessibility captioning footer link content description [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_captioning_footer_learn_more_content_description">Learn more about caption preferences</string>
|
||||||
<!-- Title for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=35] -->
|
<!-- Title for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_screen_magnification_title">Magnification</string>
|
<string name="accessibility_screen_magnification_title">Magnification</string>
|
||||||
<!-- Title for accessibility shortcut preference for magnification. [CHAR LIMIT=60] -->
|
<!-- Title for accessibility shortcut preference for magnification. [CHAR LIMIT=60] -->
|
||||||
<string name="accessibility_screen_magnification_shortcut_title">Magnification shortcut</string>
|
<string name="accessibility_screen_magnification_shortcut_title">Magnification shortcut</string>
|
||||||
|
<!-- Title for screen magnification footer. [CHAR LIMIT=60] -->
|
||||||
|
<string name="accessibility_screen_magnification_about_title">About magnification</string>
|
||||||
|
<!-- Screen magnification footer link content description [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_screen_magnification_footer_learn_more_content_description">Learn more about magnification</string>
|
||||||
<!-- Title for the accessibility preference screen to edit magnification area. [CHAR LIMIT=35] -->
|
<!-- Title for the accessibility preference screen to edit magnification area. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_magnification_mode_title">Magnification type</string>
|
<string name="accessibility_magnification_mode_title">Magnification type</string>
|
||||||
<!-- Message for the accessibility preference screen to edit magnification area dialog. [CHAR LIMIT=none] -->
|
<!-- Message for the accessibility preference screen to edit magnification area dialog. [CHAR LIMIT=none] -->
|
||||||
@@ -5412,6 +5420,12 @@
|
|||||||
<string name="accessibility_button_title">Accessibility button</string>
|
<string name="accessibility_button_title">Accessibility button</string>
|
||||||
<!-- Title for the accessibility button & gesture page. [CHAR LIMIT=35] -->
|
<!-- Title for the accessibility button & gesture page. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_button_gesture_title">Accessibility button & gesture</string>
|
<string name="accessibility_button_gesture_title">Accessibility button & gesture</string>
|
||||||
|
<!-- Title for the accessibility button footer. [CHAR LIMIT=35] -->
|
||||||
|
<string name="accessibility_button_about_title">About accessibility button</string>
|
||||||
|
<!-- Title for the accessibility button & gesture footer. [CHAR LIMIT=55] -->
|
||||||
|
<string name="accessibility_button_gesture_about_title">About accessibility button & gesture</string>
|
||||||
|
<!-- Accessibility button & gestures footer link content description [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_button_gesture_footer_learn_more_content_description">Learn more about accessibility button & gesture</string>
|
||||||
<!-- Intro for the accessibility button page. [CHAR LIMIT=100] -->
|
<!-- Intro for the accessibility button page. [CHAR LIMIT=100] -->
|
||||||
<string name="accessibility_button_intro">Using the accessibility button. The gesture isn\u2019t available with 3-button navigation.</string>
|
<string name="accessibility_button_intro">Using the accessibility button. The gesture isn\u2019t available with 3-button navigation.</string>
|
||||||
<!-- Summary text for the accessibility button preference. [CHAR LIMIT=50] -->
|
<!-- Summary text for the accessibility button preference. [CHAR LIMIT=50] -->
|
||||||
@@ -5473,6 +5487,10 @@
|
|||||||
<string name="accessibility_timeout_2mins">2 minutes</string>
|
<string name="accessibility_timeout_2mins">2 minutes</string>
|
||||||
<!-- Title for accessibility settings timeout item. [CHAR LIMIT=43] -->
|
<!-- Title for accessibility settings timeout item. [CHAR LIMIT=43] -->
|
||||||
<string name="accessibility_setting_item_control_timeout_title">Time to take action (Accessibility timeout)</string>
|
<string name="accessibility_setting_item_control_timeout_title">Time to take action (Accessibility timeout)</string>
|
||||||
|
<!-- Title for accessibility timeout footer. [CHAR LIMIT=65] -->
|
||||||
|
<string name="accessibility_control_timeout_about_title">About time to take action (Accessibility timeout)</string>
|
||||||
|
<!-- Accessibility timeout footer link content description [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_control_timeout_footer_learn_more_content_description">Learn more about time to take action (Accessibility timeout)</string>
|
||||||
<!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
|
<!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_control_timeout_preference_title">Time to take action</string>
|
<string name="accessibility_control_timeout_preference_title">Time to take action</string>
|
||||||
<!-- Descriptive text for accessibility preference to accessibility control timeout. [CHAR LIMIT=NONE] -->
|
<!-- Descriptive text for accessibility preference to accessibility control timeout. [CHAR LIMIT=NONE] -->
|
||||||
@@ -5499,6 +5517,10 @@
|
|||||||
</string>
|
</string>
|
||||||
<!-- Title for accessibility preference for configuring feature that performs click action soon after mouse/trackpad pointer stops moving. [CHAR LIMIT=NONE] -->
|
<!-- Title for accessibility preference for configuring feature that performs click action soon after mouse/trackpad pointer stops moving. [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_autoclick_preference_title">Autoclick (dwell timing)</string>
|
<string name="accessibility_autoclick_preference_title">Autoclick (dwell timing)</string>
|
||||||
|
<!-- Title for accessibility dwell timing footer. [CHAR LIMIT=35] -->
|
||||||
|
<string name="accessibility_autoclick_about_title">About autoclick (dwell timing)</string>
|
||||||
|
<!-- Accessibility dwell timing footer link content description [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_autoclick_footer_learn_more_content_description">Learn more about autoclick (dwell timing)</string>
|
||||||
<!-- Footer text to explain what autoclick does -->
|
<!-- Footer text to explain what autoclick does -->
|
||||||
<string name="accessibility_autoclick_description">Autoclick works with a connected mouse. You can set the mouse cursor to click automatically when the cursor stops moving for a certain amount of time.</string>
|
<string name="accessibility_autoclick_description">Autoclick works with a connected mouse. You can set the mouse cursor to click automatically when the cursor stops moving for a certain amount of time.</string>
|
||||||
<!-- Option heading to leave the auto click requirement for accessibility users at its default level. [CHAR LIMIT=50] -->
|
<!-- Option heading to leave the auto click requirement for accessibility users at its default level. [CHAR LIMIT=50] -->
|
||||||
@@ -5539,6 +5561,14 @@
|
|||||||
<string name="accessibility_daltonizer_primary_switch_title">Use color correction</string>
|
<string name="accessibility_daltonizer_primary_switch_title">Use color correction</string>
|
||||||
<!-- Title for accessibility shortcut preference for color correction. [CHAR LIMIT=60] -->
|
<!-- Title for accessibility shortcut preference for color correction. [CHAR LIMIT=60] -->
|
||||||
<string name="accessibility_daltonizer_shortcut_title">Color correction shortcut</string>
|
<string name="accessibility_daltonizer_shortcut_title">Color correction shortcut</string>
|
||||||
|
<!-- Title for Color correction footer. [CHAR LIMIT=35] -->
|
||||||
|
<string name="accessibility_daltonizer_about_title">About color correction</string>
|
||||||
|
<!-- Color inversion footer link content description [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_daltonizer_footer_learn_more_content_description">Learn more about color correction</string>
|
||||||
|
<!-- Title for Color inversion footer. [CHAR LIMIT=35] -->
|
||||||
|
<string name="accessibility_color_inversion_about_title">About color inversion</string>
|
||||||
|
<!-- Color correction footer link content description [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_color_inversion_footer_learn_more_content_description">Learn more about color inversion</string>
|
||||||
<!-- Title for Captions settings screen to control turning on/off the feature entirely [CHAR LIMIT=60] -->
|
<!-- Title for Captions settings screen to control turning on/off the feature entirely [CHAR LIMIT=60] -->
|
||||||
<string name="accessibility_caption_primary_switch_title">Show captions</string>
|
<string name="accessibility_caption_primary_switch_title">Show captions</string>
|
||||||
<!-- Summary for Captions settings screen to control turning on/off the feature entirely [CHAR LIMIT=NONE] -->
|
<!-- Summary for Captions settings screen to control turning on/off the feature entirely [CHAR LIMIT=NONE] -->
|
||||||
@@ -5620,6 +5650,8 @@
|
|||||||
<string name="reduce_bright_colors_switch_title">Make screen extra dim</string>
|
<string name="reduce_bright_colors_switch_title">Make screen extra dim</string>
|
||||||
<!-- Title for accessibility shortcut preference for Reduce Brightness. [CHAR LIMIT=60] -->
|
<!-- Title for accessibility shortcut preference for Reduce Brightness. [CHAR LIMIT=60] -->
|
||||||
<string name="reduce_bright_colors_shortcut_title">Extra dim shortcut</string>
|
<string name="reduce_bright_colors_shortcut_title">Extra dim shortcut</string>
|
||||||
|
<!-- Title for Reduce Brightness feature footer. [CHAR LIMIT=35] -->
|
||||||
|
<string name="reduce_bright_colors_about_title">About extra dim</string>
|
||||||
<!-- Summary for the accessibility preference to configure Reduce Brightness feature. [CHAR LIMIT=NONE] -->
|
<!-- Summary for the accessibility preference to configure Reduce Brightness feature. [CHAR LIMIT=NONE] -->
|
||||||
<string name="reduce_bright_colors_preference_summary" product="default">Dim screen beyond your phone\u2019s minimum brightness</string>
|
<string name="reduce_bright_colors_preference_summary" product="default">Dim screen beyond your phone\u2019s minimum brightness</string>
|
||||||
<!-- Summary for the accessibility preference to configure Reduce Brightness feature. [CHAR LIMIT=NONE] -->
|
<!-- Summary for the accessibility preference to configure Reduce Brightness feature. [CHAR LIMIT=NONE] -->
|
||||||
|
|||||||
@@ -33,8 +33,14 @@ public class AccessibilityButtonFooterPreferenceController extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getLabelName() {
|
protected String getLearnMoreContentDescription() {
|
||||||
return mContext.getString(R.string.accessibility_button_title);
|
return mContext.getString(
|
||||||
|
R.string.accessibility_button_gesture_footer_learn_more_content_description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getIntroductionTitle() {
|
||||||
|
return mContext.getString(R.string.accessibility_button_about_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -31,8 +31,14 @@ public class AccessibilityControlTimeoutFooterPreferenceController extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getLabelName() {
|
protected String getLearnMoreContentDescription() {
|
||||||
return mContext.getString(R.string.accessibility_setting_item_control_timeout_title);
|
return mContext.getString(
|
||||||
|
R.string.accessibility_control_timeout_footer_learn_more_content_description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getIntroductionTitle() {
|
||||||
|
return mContext.getString(R.string.accessibility_control_timeout_about_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -21,14 +21,18 @@ import android.content.Intent;
|
|||||||
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settingslib.HelpUtils;
|
import com.android.settingslib.HelpUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for accessibility preference footer.
|
* Preference controller that controls the help link and customizes the preference title in {@link
|
||||||
|
* AccessibilityFooterPreference}.
|
||||||
*/
|
*/
|
||||||
public abstract class AccessibilityFooterPreferenceController extends BasePreferenceController {
|
public class AccessibilityFooterPreferenceController extends BasePreferenceController {
|
||||||
|
|
||||||
|
private int mHelpResource;
|
||||||
|
private String mLearnMoreContentDescription;
|
||||||
|
private String mIntroductionTitle;
|
||||||
|
|
||||||
public AccessibilityFooterPreferenceController(Context context, String key) {
|
public AccessibilityFooterPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
@@ -49,23 +53,55 @@ public abstract class AccessibilityFooterPreferenceController extends BasePrefer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override this if showing a help item in the footer bar, by returning the resource id.
|
* Setups a help item in the {@link AccessibilityFooterPreference} with specific content
|
||||||
|
* description.
|
||||||
|
*/
|
||||||
|
public void setupHelpLink(int helpResource, String learnMoreContentDescription) {
|
||||||
|
mHelpResource = helpResource;
|
||||||
|
mLearnMoreContentDescription = learnMoreContentDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overrides this if showing a help item in the {@link AccessibilityFooterPreference}, by
|
||||||
|
* returning the resource id.
|
||||||
*
|
*
|
||||||
* @return the resource id for the help url
|
* @return the resource id for the help url
|
||||||
*/
|
*/
|
||||||
protected int getHelpResource() {
|
protected int getHelpResource() {
|
||||||
return 0;
|
return mHelpResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the accessibility feature name. */
|
/**
|
||||||
protected abstract String getLabelName();
|
* Overrides this if showing a help item in the {@link AccessibilityFooterPreference} with
|
||||||
|
* specific content description.
|
||||||
|
*
|
||||||
|
* @return the content description for the help url
|
||||||
|
*/
|
||||||
|
protected String getLearnMoreContentDescription() {
|
||||||
|
return mLearnMoreContentDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the announcement the specific features introduction in the {@link
|
||||||
|
* AccessibilityFooterPreference}.
|
||||||
|
*/
|
||||||
|
public void setIntroductionTitle(String introductionTitle) {
|
||||||
|
mIntroductionTitle = introductionTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overrides this if announcement the specific features introduction in the {@link
|
||||||
|
* AccessibilityFooterPreference}.
|
||||||
|
*
|
||||||
|
* @return the extended content description for specific features introduction
|
||||||
|
*/
|
||||||
|
protected String getIntroductionTitle() {
|
||||||
|
return mIntroductionTitle;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateFooterPreferences(AccessibilityFooterPreference footerPreference) {
|
private void updateFooterPreferences(AccessibilityFooterPreference footerPreference) {
|
||||||
final StringBuffer sb = new StringBuffer();
|
final StringBuffer sb = new StringBuffer();
|
||||||
sb.append(mContext.getString(
|
sb.append(getIntroductionTitle()).append("\n\n").append(footerPreference.getTitle());
|
||||||
R.string.accessibility_introduction_title, getLabelName()))
|
|
||||||
.append("\n\n")
|
|
||||||
.append(footerPreference.getTitle());
|
|
||||||
footerPreference.setContentDescription(sb);
|
footerPreference.setContentDescription(sb);
|
||||||
|
|
||||||
if (getHelpResource() != 0) {
|
if (getHelpResource() != 0) {
|
||||||
@@ -75,10 +111,10 @@ public abstract class AccessibilityFooterPreferenceController extends BasePrefer
|
|||||||
mContext.getClass().getName());
|
mContext.getClass().getName());
|
||||||
view.startActivityForResult(helpIntent, 0);
|
view.startActivityForResult(helpIntent, 0);
|
||||||
});
|
});
|
||||||
|
footerPreference.setLearnMoreContentDescription(getLearnMoreContentDescription());
|
||||||
final String learnMoreContentDescription = mContext.getString(
|
footerPreference.setLinkEnabled(true);
|
||||||
R.string.footer_learn_more_content_description, getLabelName());
|
} else {
|
||||||
footerPreference.setLearnMoreContentDescription(learnMoreContentDescription);
|
footerPreference.setLinkEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,14 @@ public class CaptionFooterPreferenceController extends AccessibilityFooterPrefer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getLabelName() {
|
protected String getLearnMoreContentDescription() {
|
||||||
return mContext.getString(R.string.accessibility_captioning_title);
|
return mContext.getString(
|
||||||
|
R.string.accessibility_captioning_footer_learn_more_content_description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getIntroductionTitle() {
|
||||||
|
return mContext.getString(R.string.accessibility_captioning_about_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -31,8 +31,14 @@ public class ToggleAutoclickFooterPreferenceController extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getLabelName() {
|
protected String getLearnMoreContentDescription() {
|
||||||
return mContext.getString(R.string.accessibility_autoclick_preference_title);
|
return mContext.getString(
|
||||||
|
R.string.accessibility_autoclick_footer_learn_more_content_description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getIntroductionTitle() {
|
||||||
|
return mContext.getString(R.string.accessibility_autoclick_about_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -38,8 +38,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** Settings page for color inversion. */
|
/** Settings page for color inversion. */
|
||||||
public class ToggleColorInversionPreferenceFragment extends
|
public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePreferenceFragment {
|
||||||
ToggleFeaturePreferenceFragment {
|
|
||||||
|
|
||||||
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED;
|
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED;
|
||||||
private final Handler mHandler = new Handler();
|
private final Handler mHandler = new Handler();
|
||||||
@@ -95,7 +94,20 @@ public class ToggleColorInversionPreferenceFragment extends
|
|||||||
updateSwitchBarToggleSwitch();
|
updateSwitchBarToggleSwitch();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return super.onCreateView(inflater, container, savedInstanceState);
|
|
||||||
|
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
updateFooterPreference();
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateFooterPreference() {
|
||||||
|
final String title = getPrefContext().getString(
|
||||||
|
R.string.accessibility_color_inversion_about_title);
|
||||||
|
final String learnMoreContentDescription = getPrefContext().getString(
|
||||||
|
R.string.accessibility_color_inversion_footer_learn_more_content_description);
|
||||||
|
mFooterPreferenceController.setIntroductionTitle(title);
|
||||||
|
mFooterPreferenceController.setupHelpLink(getHelpResource(), learnMoreContentDescription);
|
||||||
|
mFooterPreferenceController.displayPreference(getPreferenceScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -92,12 +92,20 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
|||||||
updateSwitchBarToggleSwitch();
|
updateSwitchBarToggleSwitch();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return super.onCreateView(inflater, container, savedInstanceState);
|
|
||||||
|
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
updateFooterPreference();
|
||||||
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void updateFooterPreference() {
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
final String title = getPrefContext()
|
||||||
super.onViewCreated(view, savedInstanceState);
|
.getString(R.string.accessibility_daltonizer_about_title);
|
||||||
|
final String learnMoreContentDescription = getPrefContext()
|
||||||
|
.getString(R.string.accessibility_daltonizer_footer_learn_more_content_description);
|
||||||
|
mFooterPreferenceController.setIntroductionTitle(title);
|
||||||
|
mFooterPreferenceController.setupHelpLink(getHelpResource(), learnMoreContentDescription);
|
||||||
|
mFooterPreferenceController.displayPreference(getPreferenceScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Customizes the order by preference key. */
|
/** Customizes the order by preference key. */
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
|
|||||||
import com.android.settings.utils.LocaleUtils;
|
import com.android.settings.utils.LocaleUtils;
|
||||||
import com.android.settings.widget.SettingsMainSwitchBar;
|
import com.android.settings.widget.SettingsMainSwitchBar;
|
||||||
import com.android.settings.widget.SettingsMainSwitchPreference;
|
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||||
import com.android.settingslib.HelpUtils;
|
|
||||||
import com.android.settingslib.accessibility.AccessibilityUtils;
|
import com.android.settingslib.accessibility.AccessibilityUtils;
|
||||||
import com.android.settingslib.widget.IllustrationPreference;
|
import com.android.settingslib.widget.IllustrationPreference;
|
||||||
import com.android.settingslib.widget.OnMainSwitchChangeListener;
|
import com.android.settingslib.widget.OnMainSwitchChangeListener;
|
||||||
@@ -78,6 +77,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
protected SettingsMainSwitchPreference mToggleServiceSwitchPreference;
|
protected SettingsMainSwitchPreference mToggleServiceSwitchPreference;
|
||||||
protected ShortcutPreference mShortcutPreference;
|
protected ShortcutPreference mShortcutPreference;
|
||||||
protected Preference mSettingsPreference;
|
protected Preference mSettingsPreference;
|
||||||
|
protected AccessibilityFooterPreferenceController mFooterPreferenceController;
|
||||||
protected String mPreferenceKey;
|
protected String mPreferenceKey;
|
||||||
|
|
||||||
protected CharSequence mSettingsTitle;
|
protected CharSequence mSettingsTitle;
|
||||||
@@ -469,33 +469,19 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
final PreferenceScreen screen = getPreferenceScreen();
|
final PreferenceScreen screen = getPreferenceScreen();
|
||||||
final CharSequence htmlDescription = Html.fromHtml(mHtmlDescription.toString(),
|
final CharSequence htmlDescription = Html.fromHtml(mHtmlDescription.toString(),
|
||||||
Html.FROM_HTML_MODE_COMPACT, mImageGetter, /* tagHandler= */ null);
|
Html.FROM_HTML_MODE_COMPACT, mImageGetter, /* tagHandler= */ null);
|
||||||
final String iconContentDescription =
|
|
||||||
getString(R.string.accessibility_introduction_title, mPackageName);
|
|
||||||
|
|
||||||
final AccessibilityFooterPreference htmlFooterPreference =
|
final AccessibilityFooterPreference htmlFooterPreference =
|
||||||
new AccessibilityFooterPreference(screen.getContext());
|
new AccessibilityFooterPreference(screen.getContext());
|
||||||
htmlFooterPreference.setKey(KEY_HTML_DESCRIPTION_PREFERENCE);
|
htmlFooterPreference.setKey(KEY_HTML_DESCRIPTION_PREFERENCE);
|
||||||
htmlFooterPreference.setSummary(htmlDescription);
|
htmlFooterPreference.setSummary(htmlDescription);
|
||||||
htmlFooterPreference.setContentDescription(
|
|
||||||
generateFooterContentDescription(htmlDescription));
|
|
||||||
|
|
||||||
// Only framework tools support help link
|
|
||||||
if (getHelpResource() != 0) {
|
|
||||||
htmlFooterPreference.setLearnMoreAction(view -> {
|
|
||||||
final Intent helpIntent = HelpUtils.getHelpIntent(
|
|
||||||
getContext(), getContext().getString(getHelpResource()),
|
|
||||||
getContext().getClass().getName());
|
|
||||||
view.startActivityForResult(helpIntent, 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
final String learnMoreContentDescription = getPrefContext().getString(
|
|
||||||
R.string.footer_learn_more_content_description, mPackageName);
|
|
||||||
htmlFooterPreference.setLearnMoreContentDescription(learnMoreContentDescription);
|
|
||||||
htmlFooterPreference.setLinkEnabled(true);
|
|
||||||
} else {
|
|
||||||
htmlFooterPreference.setLinkEnabled(false);
|
|
||||||
}
|
|
||||||
screen.addPreference(htmlFooterPreference);
|
screen.addPreference(htmlFooterPreference);
|
||||||
|
|
||||||
|
// TODO(b/171272809): Migrate to DashboardFragment.
|
||||||
|
final String title = getString(R.string.accessibility_introduction_title, mPackageName);
|
||||||
|
mFooterPreferenceController = new AccessibilityFooterPreferenceController(
|
||||||
|
screen.getContext(), htmlFooterPreference.getKey());
|
||||||
|
mFooterPreferenceController.setIntroductionTitle(title);
|
||||||
|
mFooterPreferenceController.displayPreference(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initFooterPreference() {
|
private void initFooterPreference() {
|
||||||
@@ -518,41 +504,22 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
*
|
*
|
||||||
* @param screen The preference screen to add the footer preference
|
* @param screen The preference screen to add the footer preference
|
||||||
* @param summary The summary of the preference summary.
|
* @param summary The summary of the preference summary.
|
||||||
* @param iconContentDescription The content description of icon in the footer.
|
* @param introductionTitle The title of introduction in the footer.
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void createFooterPreference(PreferenceScreen screen, CharSequence summary,
|
void createFooterPreference(PreferenceScreen screen, CharSequence summary,
|
||||||
String iconContentDescription) {
|
String introductionTitle) {
|
||||||
final AccessibilityFooterPreference footerPreference =
|
final AccessibilityFooterPreference footerPreference =
|
||||||
new AccessibilityFooterPreference(screen.getContext());
|
new AccessibilityFooterPreference(screen.getContext());
|
||||||
footerPreference.setSummary(summary);
|
footerPreference.setSummary(summary);
|
||||||
footerPreference.setContentDescription(
|
|
||||||
generateFooterContentDescription(summary));
|
|
||||||
|
|
||||||
// Only framework tools support help link
|
|
||||||
if (getHelpResource() != 0) {
|
|
||||||
footerPreference.setLearnMoreAction(view -> {
|
|
||||||
final Intent helpIntent = HelpUtils.getHelpIntent(
|
|
||||||
getContext(), getContext().getString(getHelpResource()),
|
|
||||||
getContext().getClass().getName());
|
|
||||||
view.startActivityForResult(helpIntent, 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
final String learnMoreContentDescription = getPrefContext().getString(
|
|
||||||
R.string.footer_learn_more_content_description, mPackageName);
|
|
||||||
footerPreference.setLearnMoreContentDescription(learnMoreContentDescription);
|
|
||||||
}
|
|
||||||
screen.addPreference(footerPreference);
|
screen.addPreference(footerPreference);
|
||||||
|
|
||||||
|
mFooterPreferenceController = new AccessibilityFooterPreferenceController(
|
||||||
|
screen.getContext(), footerPreference.getKey());
|
||||||
|
mFooterPreferenceController.setIntroductionTitle(introductionTitle);
|
||||||
|
mFooterPreferenceController.displayPreference(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CharSequence generateFooterContentDescription(CharSequence footerContent) {
|
|
||||||
final StringBuffer sb = new StringBuffer();
|
|
||||||
sb.append(getPrefContext().getString(
|
|
||||||
R.string.accessibility_introduction_title, mPackageName))
|
|
||||||
.append("\n\n")
|
|
||||||
.append(footerContent);
|
|
||||||
return sb;
|
|
||||||
}
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void setupEditShortcutDialog(Dialog dialog) {
|
void setupEditShortcutDialog(Dialog dialog) {
|
||||||
final View dialogSoftwareView = dialog.findViewById(R.id.software_shortcut);
|
final View dialogSoftwareView = dialog.findViewById(R.id.software_shortcut);
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre
|
|||||||
// Parent sets the title when creating the view, so set it after calling super
|
// Parent sets the title when creating the view, so set it after calling super
|
||||||
mToggleServiceSwitchPreference.setTitle(R.string.reduce_bright_colors_switch_title);
|
mToggleServiceSwitchPreference.setTitle(R.string.reduce_bright_colors_switch_title);
|
||||||
updateGeneralCategoryOrder();
|
updateGeneralCategoryOrder();
|
||||||
|
updateFooterPreference();
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +102,12 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre
|
|||||||
generalCategory.addPreference(persist);
|
generalCategory.addPreference(persist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateFooterPreference() {
|
||||||
|
final String title = getPrefContext().getString(R.string.reduce_bright_colors_about_title);
|
||||||
|
mFooterPreferenceController.setIntroductionTitle(title);
|
||||||
|
mFooterPreferenceController.displayPreference(getPreferenceScreen());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
@@ -135,7 +142,6 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre
|
|||||||
return R.xml.reduce_bright_colors_settings;
|
return R.xml.reduce_bright_colors_settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
||||||
AccessibilityStatsLogUtils.logAccessibilityServiceEnabled(mComponentName, enabled);
|
AccessibilityStatsLogUtils.logAccessibilityServiceEnabled(mComponentName, enabled);
|
||||||
|
|||||||
@@ -95,7 +95,20 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
removeDialog(DialogEnums.EDIT_SHORTCUT);
|
removeDialog(DialogEnums.EDIT_SHORTCUT);
|
||||||
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
||||||
};
|
};
|
||||||
return super.onCreateView(inflater, container, savedInstanceState);
|
|
||||||
|
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
updateFooterPreference();
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateFooterPreference() {
|
||||||
|
final String title = getPrefContext().getString(
|
||||||
|
R.string.accessibility_screen_magnification_about_title);
|
||||||
|
final String learnMoreContentDescription = getPrefContext().getString(
|
||||||
|
R.string.accessibility_screen_magnification_footer_learn_more_content_description);
|
||||||
|
mFooterPreferenceController.setIntroductionTitle(title);
|
||||||
|
mFooterPreferenceController.setupHelpLink(getHelpResource(), learnMoreContentDescription);
|
||||||
|
mFooterPreferenceController.displayPreference(getPreferenceScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -24,8 +24,10 @@ import android.os.UserManager;
|
|||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.Slog;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -222,27 +224,19 @@ public class AppStateNotificationBridge extends AppStateBaseBridge {
|
|||||||
return userId + "|" + pkg;
|
return userId + "|" + pkg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public View.OnClickListener getSwitchOnClickListener(final AppEntry entry) {
|
public CompoundButton.OnCheckedChangeListener getSwitchOnCheckedListener(final AppEntry entry) {
|
||||||
if (entry != null) {
|
if (entry == null) {
|
||||||
return v -> {
|
return null;
|
||||||
ViewGroup view = (ViewGroup) v;
|
|
||||||
Switch toggle = view.findViewById(R.id.switchWidget);
|
|
||||||
if (toggle != null) {
|
|
||||||
if (!toggle.isEnabled()) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
toggle.toggle();
|
return (buttonView, isChecked) -> {
|
||||||
mBackend.setNotificationsEnabledForPackage(
|
mBackend.setNotificationsEnabledForPackage(
|
||||||
entry.info.packageName, entry.info.uid, toggle.isChecked());
|
entry.info.packageName, entry.info.uid, isChecked);
|
||||||
NotificationsSentState stats = getNotificationsSentState(entry);
|
NotificationsSentState stats = getNotificationsSentState(entry);
|
||||||
if (stats != null) {
|
if (stats != null) {
|
||||||
stats.blocked = !toggle.isChecked();
|
stats.blocked = !isChecked;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final AppFilter FILTER_APP_NOTIFICATION_RECENCY = new AppFilter() {
|
public static final AppFilter FILTER_APP_NOTIFICATION_RECENCY = new AppFilter() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -155,13 +155,13 @@ public class ApplicationViewHolder extends RecyclerView.ViewHolder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateSwitch(View.OnClickListener listener, boolean enabled, boolean checked) {
|
void updateSwitch(Switch.OnCheckedChangeListener listener, boolean enabled, boolean checked) {
|
||||||
if (mSwitch != null && mWidgetContainer != null) {
|
if (mSwitch != null && mWidgetContainer != null) {
|
||||||
mWidgetContainer.setOnClickListener(listener);
|
|
||||||
mWidgetContainer.setFocusable(false);
|
mWidgetContainer.setFocusable(false);
|
||||||
mWidgetContainer.setClickable(false);
|
mWidgetContainer.setClickable(false);
|
||||||
mSwitch.setFocusable(true);
|
mSwitch.setFocusable(true);
|
||||||
mSwitch.setClickable(true);
|
mSwitch.setClickable(true);
|
||||||
|
mSwitch.setOnCheckedChangeListener(listener);
|
||||||
mSwitch.setChecked(checked);
|
mSwitch.setChecked(checked);
|
||||||
mSwitch.setEnabled(enabled);
|
mSwitch.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1505,7 +1505,7 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
switch (mManageApplications.mListType) {
|
switch (mManageApplications.mListType) {
|
||||||
case LIST_TYPE_NOTIFICATION:
|
case LIST_TYPE_NOTIFICATION:
|
||||||
holder.updateSwitch(((AppStateNotificationBridge) mExtraInfoBridge)
|
holder.updateSwitch(((AppStateNotificationBridge) mExtraInfoBridge)
|
||||||
.getSwitchOnClickListener(entry),
|
.getSwitchOnCheckedListener(entry),
|
||||||
AppStateNotificationBridge.enableSwitch(entry),
|
AppStateNotificationBridge.enableSwitch(entry),
|
||||||
AppStateNotificationBridge.checkSwitch(entry));
|
AppStateNotificationBridge.checkSwitch(entry));
|
||||||
if (entry.extraInfo != null
|
if (entry.extraInfo != null
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import android.graphics.Color;
|
|||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
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;
|
||||||
@@ -106,7 +108,12 @@ public class ProviderModelSliceHelper {
|
|||||||
* @return whether the ServiceState's data state is in-service.
|
* @return whether the ServiceState's data state is in-service.
|
||||||
*/
|
*/
|
||||||
public boolean isDataStateInService() {
|
public boolean isDataStateInService() {
|
||||||
return mTelephonyManager.getDataState() == mTelephonyManager.DATA_CONNECTED;
|
final ServiceState serviceState = mTelephonyManager.getServiceState();
|
||||||
|
NetworkRegistrationInfo regInfo =
|
||||||
|
(serviceState == null) ? null : serviceState.getNetworkRegistrationInfo(
|
||||||
|
NetworkRegistrationInfo.DOMAIN_PS,
|
||||||
|
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
||||||
|
return (regInfo == null) ? false : regInfo.isRegistered();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ import android.graphics.drawable.Drawable;
|
|||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
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;
|
||||||
@@ -274,9 +276,16 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
|||||||
if (!tmForSubId.isDataEnabled()) {
|
if (!tmForSubId.isDataEnabled()) {
|
||||||
return mContext.getString(R.string.mobile_data_off_summary);
|
return mContext.getString(R.string.mobile_data_off_summary);
|
||||||
}
|
}
|
||||||
|
final ServiceState serviceState = tmForSubId.getServiceState();
|
||||||
|
final NetworkRegistrationInfo regInfo = (serviceState == null)
|
||||||
|
? null
|
||||||
|
: serviceState.getNetworkRegistrationInfo(
|
||||||
|
NetworkRegistrationInfo.DOMAIN_PS,
|
||||||
|
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
||||||
|
|
||||||
final boolean isDataInService = tmForSubId.getDataState()
|
final boolean isDataInService = (regInfo == null)
|
||||||
== TelephonyManager.DATA_CONNECTED;
|
? false
|
||||||
|
: regInfo.isRegistered();
|
||||||
final boolean isCarrierNetworkActive =
|
final boolean isCarrierNetworkActive =
|
||||||
(mWifiPickerTrackerHelper != null)
|
(mWifiPickerTrackerHelper != null)
|
||||||
&& mWifiPickerTrackerHelper.isCarrierNetworkActive();
|
&& mWifiPickerTrackerHelper.isCarrierNetworkActive();
|
||||||
@@ -311,9 +320,16 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
|||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean isDataInService = tmForSubId.getDataState()
|
|
||||||
== TelephonyManager.DATA_CONNECTED;
|
|
||||||
final ServiceState serviceState = tmForSubId.getServiceState();
|
final ServiceState serviceState = tmForSubId.getServiceState();
|
||||||
|
final NetworkRegistrationInfo regInfo = (serviceState == null)
|
||||||
|
? null
|
||||||
|
: serviceState.getNetworkRegistrationInfo(
|
||||||
|
NetworkRegistrationInfo.DOMAIN_PS,
|
||||||
|
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
||||||
|
|
||||||
|
final boolean isDataInService = (regInfo == null)
|
||||||
|
? false
|
||||||
|
: regInfo.isRegistered();
|
||||||
final boolean isVoiceInService = (serviceState == null)
|
final boolean isVoiceInService = (serviceState == null)
|
||||||
? false
|
? false
|
||||||
: (serviceState.getState() == ServiceState.STATE_IN_SERVICE);
|
: (serviceState.getState() == ServiceState.STATE_IN_SERVICE);
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
import androidx.preference.PreferenceViewHolder;
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.Spy;
|
||||||
|
import org.mockito.junit.MockitoJUnit;
|
||||||
|
import org.mockito.junit.MockitoRule;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link AccessibilityFooterPreferenceController}.
|
||||||
|
*/
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class AccessibilityFooterPreferenceControllerTest {
|
||||||
|
|
||||||
|
private static final String TEST_KEY = "test_pref_key";
|
||||||
|
private static final String TEST_TITLE = "test_title";
|
||||||
|
private static final String TEST_INTRODUCTION_TITLE = "test_introduction_title";
|
||||||
|
private static final String TEST_CONTENT_DESCRIPTION = "test_content_description";
|
||||||
|
private static final int TEST_HELP_ID = 12345;
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final MockitoRule mockito = MockitoJUnit.rule();
|
||||||
|
|
||||||
|
@Spy
|
||||||
|
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||||
|
@Mock
|
||||||
|
private PreferenceScreen mScreen;
|
||||||
|
private AccessibilityFooterPreferenceController mController;
|
||||||
|
private AccessibilityFooterPreference mPreference;
|
||||||
|
private PreferenceViewHolder mPreferenceViewHolder;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
mController = new AccessibilityFooterPreferenceController(mContext, TEST_KEY);
|
||||||
|
mPreference = new AccessibilityFooterPreference(mContext);
|
||||||
|
mPreference.setKey(TEST_KEY);
|
||||||
|
mPreference.setTitle(TEST_TITLE);
|
||||||
|
|
||||||
|
final LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||||
|
final View view = inflater.inflate(R.layout.preference_footer, null);
|
||||||
|
mPreferenceViewHolder = PreferenceViewHolder.createInstanceForTests(view);
|
||||||
|
mPreference.onBindViewHolder(mPreferenceViewHolder);
|
||||||
|
|
||||||
|
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setIntroductionTitle_setCorrectIntroductionTitle() {
|
||||||
|
mController.setIntroductionTitle(TEST_INTRODUCTION_TITLE);
|
||||||
|
|
||||||
|
assertThat(mController.getIntroductionTitle()).isEqualTo(TEST_INTRODUCTION_TITLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onBindViewHolder_setIntroductionTitle_setCorrectIntroductionTitle() {
|
||||||
|
mController.setIntroductionTitle(TEST_INTRODUCTION_TITLE);
|
||||||
|
mController.displayPreference(mScreen);
|
||||||
|
|
||||||
|
mPreference.onBindViewHolder(mPreferenceViewHolder);
|
||||||
|
|
||||||
|
final TextView summaryView = (TextView) mPreferenceViewHolder
|
||||||
|
.findViewById(android.R.id.title);
|
||||||
|
assertThat(summaryView.getContentDescription().toString())
|
||||||
|
.contains(TEST_INTRODUCTION_TITLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setupHelpLink_setCorrectHelpLinkAndContentDescription() {
|
||||||
|
mController.setupHelpLink(TEST_HELP_ID, TEST_CONTENT_DESCRIPTION);
|
||||||
|
|
||||||
|
assertThat(mController.getHelpResource()).isEqualTo(TEST_HELP_ID);
|
||||||
|
assertThat(mController.getLearnMoreContentDescription())
|
||||||
|
.isEqualTo(TEST_CONTENT_DESCRIPTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onBindViewHolder_setupHelpLink_setCorrectHelpLinkAndContentDescription() {
|
||||||
|
mController.setupHelpLink(TEST_HELP_ID, TEST_CONTENT_DESCRIPTION);
|
||||||
|
mController.displayPreference(mScreen);
|
||||||
|
|
||||||
|
mPreference.onBindViewHolder(mPreferenceViewHolder);
|
||||||
|
|
||||||
|
final TextView learnMoreView = (TextView) mPreferenceViewHolder
|
||||||
|
.findViewById(com.android.settingslib.R.id.settingslib_learn_more);
|
||||||
|
assertThat(learnMoreView.getContentDescription().toString())
|
||||||
|
.contains(TEST_CONTENT_DESCRIPTION);
|
||||||
|
assertThat(mPreference.isLinkEnabled()).isTrue();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -53,6 +53,7 @@ import android.os.RemoteException;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -550,12 +551,10 @@ public class AppStateNotificationBridgeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSwitchOnClickListener() {
|
public void testSwitchOnChangeListener() {
|
||||||
ViewGroup parent = mock(ViewGroup.class);
|
|
||||||
Switch toggle = mock(Switch.class);
|
Switch toggle = mock(Switch.class);
|
||||||
when(toggle.isChecked()).thenReturn(true);
|
when(toggle.isChecked()).thenReturn(true);
|
||||||
when(toggle.isEnabled()).thenReturn(true);
|
when(toggle.isEnabled()).thenReturn(true);
|
||||||
when(parent.findViewById(anyInt())).thenReturn(toggle);
|
|
||||||
|
|
||||||
AppEntry entry = mock(AppEntry.class);
|
AppEntry entry = mock(AppEntry.class);
|
||||||
entry.info = new ApplicationInfo();
|
entry.info = new ApplicationInfo();
|
||||||
@@ -563,10 +562,9 @@ public class AppStateNotificationBridgeTest {
|
|||||||
entry.info.uid = 1356;
|
entry.info.uid = 1356;
|
||||||
entry.extraInfo = new NotificationsSentState();
|
entry.extraInfo = new NotificationsSentState();
|
||||||
|
|
||||||
ViewGroup.OnClickListener listener = mBridge.getSwitchOnClickListener(entry);
|
CompoundButton.OnCheckedChangeListener listener = mBridge.getSwitchOnCheckedListener(entry);
|
||||||
listener.onClick(parent);
|
listener.onCheckedChanged(toggle, true);
|
||||||
|
|
||||||
verify(toggle).toggle();
|
|
||||||
verify(mBackend).setNotificationsEnabledForPackage(
|
verify(mBackend).setNotificationsEnabledForPackage(
|
||||||
entry.info.packageName, entry.info.uid, true);
|
entry.info.packageName, entry.info.uid, true);
|
||||||
assertThat(((NotificationsSentState) entry.extraInfo).blocked).isFalse();
|
assertThat(((NotificationsSentState) entry.extraInfo).blocked).isFalse();
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ import org.junit.runner.RunWith;
|
|||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class ApplicationViewHolderTest {
|
public class ApplicationViewHolderTest {
|
||||||
|
|
||||||
@@ -123,13 +125,16 @@ public class ApplicationViewHolderTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateSwitch() {
|
public void updateSwitch() {
|
||||||
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
mView = ApplicationViewHolder.newView(new FrameLayout(mContext), true);
|
mView = ApplicationViewHolder.newView(new FrameLayout(mContext), true);
|
||||||
mHolder = new ApplicationViewHolder(mView);
|
mHolder = new ApplicationViewHolder(mView);
|
||||||
mHolder.updateSwitch(v -> {
|
mHolder.updateSwitch((buttonView, isChecked) -> latch.countDown(), true, true);
|
||||||
} /* listener */, true, true);
|
|
||||||
|
|
||||||
assertThat(mHolder.mSwitch.isChecked()).isTrue();
|
assertThat(mHolder.mSwitch.isChecked()).isTrue();
|
||||||
assertThat(mHolder.mSwitch.isEnabled()).isTrue();
|
assertThat(mHolder.mSwitch.isEnabled()).isTrue();
|
||||||
assertThat(mHolder.mWidgetContainer.hasOnClickListeners()).isTrue();
|
assertThat(mHolder.mSwitch.isFocusable()).isTrue();
|
||||||
|
assertThat(mHolder.mSwitch.isClickable()).isTrue();
|
||||||
|
mHolder.mSwitch.callOnClick();
|
||||||
|
assertThat(latch.getCount()).isEqualTo(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ import android.net.NetworkCapabilities;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.PersistableBundle;
|
import android.os.PersistableBundle;
|
||||||
|
import android.telephony.AccessNetworkConstants;
|
||||||
import android.telephony.CarrierConfigManager;
|
import android.telephony.CarrierConfigManager;
|
||||||
|
import android.telephony.NetworkRegistrationInfo;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
@@ -169,7 +171,7 @@ public class ProviderModelSliceHelperTest {
|
|||||||
CharSequence expectedSubtitle = Html.fromHtml("5G", Html.FROM_HTML_MODE_LEGACY);
|
CharSequence expectedSubtitle = Html.fromHtml("5G", Html.FROM_HTML_MODE_LEGACY);
|
||||||
String networkType = "5G";
|
String networkType = "5G";
|
||||||
mockConnections(true, ServiceState.STATE_IN_SERVICE, expectDisplayName,
|
mockConnections(true, ServiceState.STATE_IN_SERVICE, expectDisplayName,
|
||||||
mTelephonyManager.DATA_CONNECTED, true);
|
true, true);
|
||||||
addNetworkTransportType(NetworkCapabilities.TRANSPORT_WIFI);
|
addNetworkTransportType(NetworkCapabilities.TRANSPORT_WIFI);
|
||||||
|
|
||||||
ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
|
ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
|
||||||
@@ -189,7 +191,7 @@ public class ProviderModelSliceHelperTest {
|
|||||||
"preference_summary_default_combination", connectedText, networkType),
|
"preference_summary_default_combination", connectedText, networkType),
|
||||||
Html.FROM_HTML_MODE_LEGACY);
|
Html.FROM_HTML_MODE_LEGACY);
|
||||||
mockConnections(true, ServiceState.STATE_IN_SERVICE, expectDisplayName,
|
mockConnections(true, ServiceState.STATE_IN_SERVICE, expectDisplayName,
|
||||||
mTelephonyManager.DATA_CONNECTED, true);
|
true, true);
|
||||||
addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
|
addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
|
||||||
|
|
||||||
ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
|
ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
|
||||||
@@ -208,7 +210,7 @@ public class ProviderModelSliceHelperTest {
|
|||||||
String networkType = "";
|
String networkType = "";
|
||||||
|
|
||||||
mockConnections(true, ServiceState.STATE_OUT_OF_SERVICE, expectDisplayName,
|
mockConnections(true, ServiceState.STATE_OUT_OF_SERVICE, expectDisplayName,
|
||||||
mTelephonyManager.DATA_DISCONNECTED, false);
|
false, false);
|
||||||
addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
|
addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
|
||||||
|
|
||||||
ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
|
ListBuilder.RowBuilder testRowBuild = mProviderModelSliceHelper.createCarrierRow(
|
||||||
@@ -221,7 +223,7 @@ public class ProviderModelSliceHelperTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getMobileDrawable_noCarrierData_getMobileDrawable() throws Throwable {
|
public void getMobileDrawable_noCarrierData_getMobileDrawable() throws Throwable {
|
||||||
mockConnections(false, ServiceState.STATE_OUT_OF_SERVICE, "",
|
mockConnections(false, ServiceState.STATE_OUT_OF_SERVICE, "",
|
||||||
mTelephonyManager.DATA_DISCONNECTED, true);
|
false, true);
|
||||||
when(mConnectivityManager.getActiveNetwork()).thenReturn(null);
|
when(mConnectivityManager.getActiveNetwork()).thenReturn(null);
|
||||||
Drawable expectDrawable = mock(Drawable.class);
|
Drawable expectDrawable = mock(Drawable.class);
|
||||||
|
|
||||||
@@ -232,7 +234,7 @@ public class ProviderModelSliceHelperTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getMobileDrawable_hasCarrierDataAndDataIsOnCellular_getMobileDrawable()
|
public void getMobileDrawable_hasCarrierDataAndDataIsOnCellular_getMobileDrawable()
|
||||||
throws Throwable {
|
throws Throwable {
|
||||||
mockConnections(true, ServiceState.STATE_IN_SERVICE, "", mTelephonyManager.DATA_CONNECTED,
|
mockConnections(true, ServiceState.STATE_IN_SERVICE, "", true,
|
||||||
true);
|
true);
|
||||||
addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
|
addNetworkTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
|
||||||
Drawable drawable = mock(Drawable.class);
|
Drawable drawable = mock(Drawable.class);
|
||||||
@@ -246,7 +248,7 @@ public class ProviderModelSliceHelperTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getMobileDrawable_hasCarrierDataAndDataIsOnWifi_getMobileDrawable()
|
public void getMobileDrawable_hasCarrierDataAndDataIsOnWifi_getMobileDrawable()
|
||||||
throws Throwable {
|
throws Throwable {
|
||||||
mockConnections(true, ServiceState.STATE_IN_SERVICE, "", mTelephonyManager.DATA_CONNECTED,
|
mockConnections(true, ServiceState.STATE_IN_SERVICE, "", true,
|
||||||
true);
|
true);
|
||||||
Drawable drawable = mock(Drawable.class);
|
Drawable drawable = mock(Drawable.class);
|
||||||
addNetworkTransportType(NetworkCapabilities.TRANSPORT_WIFI);
|
addNetworkTransportType(NetworkCapabilities.TRANSPORT_WIFI);
|
||||||
@@ -263,12 +265,22 @@ public class ProviderModelSliceHelperTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void mockConnections(boolean isDataEnabled, int serviceState, String expectDisplayName,
|
private void mockConnections(boolean isDataEnabled, int serviceState, String expectDisplayName,
|
||||||
int getDataState, boolean isWifiEnabled) {
|
boolean dataRegState, boolean isWifiEnabled) {
|
||||||
when(mTelephonyManager.isDataEnabled()).thenReturn(isDataEnabled);
|
when(mTelephonyManager.isDataEnabled()).thenReturn(isDataEnabled);
|
||||||
when(mWifiManager.isWifiEnabled()).thenReturn(isWifiEnabled);
|
when(mWifiManager.isWifiEnabled()).thenReturn(isWifiEnabled);
|
||||||
when(mTelephonyManager.getDataState()).thenReturn(getDataState);
|
|
||||||
|
|
||||||
when(mServiceState.getState()).thenReturn(serviceState);
|
when(mServiceState.getState()).thenReturn(serviceState);
|
||||||
|
|
||||||
|
NetworkRegistrationInfo regInfo = new NetworkRegistrationInfo.Builder()
|
||||||
|
.setDomain(NetworkRegistrationInfo.DOMAIN_PS)
|
||||||
|
.setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
|
||||||
|
.setRegistrationState(dataRegState ? NetworkRegistrationInfo.REGISTRATION_STATE_HOME
|
||||||
|
: NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_SEARCHING)
|
||||||
|
.setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
|
||||||
|
.build();
|
||||||
|
when(mServiceState.getNetworkRegistrationInfo(NetworkRegistrationInfo.DOMAIN_PS,
|
||||||
|
AccessNetworkConstants.TRANSPORT_TYPE_WWAN)).thenReturn(regInfo);
|
||||||
|
|
||||||
when(mDefaultDataSubscriptionInfo.getDisplayName()).thenReturn(expectDisplayName);
|
when(mDefaultDataSubscriptionInfo.getDisplayName()).thenReturn(expectDisplayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ import android.net.NetworkCapabilities;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
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;
|
||||||
@@ -430,7 +432,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
||||||
setupGetIconConditions(sub.get(0).getSubscriptionId(), true, true,
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), true, true,
|
||||||
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
true, ServiceState.STATE_IN_SERVICE);
|
||||||
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
||||||
@@ -451,7 +453,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
||||||
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
||||||
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
true, ServiceState.STATE_IN_SERVICE);
|
||||||
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(true));
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(true));
|
||||||
@@ -476,7 +478,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
||||||
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, false,
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, false,
|
||||||
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
true, ServiceState.STATE_IN_SERVICE);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
||||||
|
|
||||||
@@ -496,7 +498,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
||||||
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
||||||
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
true, ServiceState.STATE_IN_SERVICE);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
||||||
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
|
when(mTelephonyManager.isDataEnabled()).thenReturn(true);
|
||||||
@@ -532,7 +534,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
||||||
setupGetIconConditions(sub.get(0).getSubscriptionId(), true, true,
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), true, true,
|
||||||
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
true, ServiceState.STATE_IN_SERVICE);
|
||||||
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
||||||
@@ -558,7 +560,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
||||||
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
||||||
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
true, ServiceState.STATE_IN_SERVICE);
|
||||||
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
||||||
@@ -585,7 +587,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
doReturn(true).when(sInjector).isProviderModelEnabled(mContext);
|
||||||
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
|
||||||
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), false, true,
|
||||||
TelephonyManager.DATA_DISCONNECTED, ServiceState.STATE_OUT_OF_SERVICE);
|
false, ServiceState.STATE_OUT_OF_SERVICE);
|
||||||
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
doReturn(mock(MobileMappings.Config.class)).when(sInjector).getConfig(mContext);
|
||||||
doReturn(networkType)
|
doReturn(networkType)
|
||||||
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
.when(sInjector).getNetworkType(any(), any(), any(), anyInt(), eq(false));
|
||||||
@@ -665,7 +667,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
Drawable icon = mock(Drawable.class);
|
Drawable icon = mock(Drawable.class);
|
||||||
doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false));
|
doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false));
|
||||||
setupGetIconConditions(sub.get(0).getSubscriptionId(), true, true,
|
setupGetIconConditions(sub.get(0).getSubscriptionId(), true, true,
|
||||||
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
true, ServiceState.STATE_IN_SERVICE);
|
||||||
|
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
@@ -683,7 +685,7 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
Drawable icon = mock(Drawable.class);
|
Drawable icon = mock(Drawable.class);
|
||||||
doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false));
|
doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false));
|
||||||
setupGetIconConditions(subId, false, true,
|
setupGetIconConditions(subId, false, true,
|
||||||
TelephonyManager.DATA_CONNECTED, ServiceState.STATE_IN_SERVICE);
|
true, ServiceState.STATE_IN_SERVICE);
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
Drawable actualIcon = mPreferenceCategory.getPreference(0).getIcon();
|
Drawable actualIcon = mPreferenceCategory.getPreference(0).getIcon();
|
||||||
@@ -702,12 +704,22 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false));
|
doReturn(icon).when(sInjector).getIcon(any(), anyInt(), anyInt(), eq(false));
|
||||||
|
|
||||||
setupGetIconConditions(subId, false, false,
|
setupGetIconConditions(subId, false, false,
|
||||||
TelephonyManager.DATA_DISCONNECTED, ServiceState.STATE_IN_SERVICE);
|
false, ServiceState.STATE_IN_SERVICE);
|
||||||
|
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
Drawable actualIcon = mPreferenceCategory.getPreference(0).getIcon();
|
Drawable actualIcon = mPreferenceCategory.getPreference(0).getIcon();
|
||||||
doReturn(TelephonyManager.DATA_CONNECTED).when(mTelephonyManagerForSub).getDataState();
|
ServiceState ss = mock(ServiceState.class);
|
||||||
|
NetworkRegistrationInfo regInfo = new NetworkRegistrationInfo.Builder()
|
||||||
|
.setDomain(NetworkRegistrationInfo.DOMAIN_PS)
|
||||||
|
.setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
|
||||||
|
.setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
|
||||||
|
.setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
|
||||||
|
.build();
|
||||||
|
doReturn(ss).when(mTelephonyManagerForSub).getServiceState();
|
||||||
|
doReturn(regInfo).when(ss).getNetworkRegistrationInfo(
|
||||||
|
NetworkRegistrationInfo.DOMAIN_PS,
|
||||||
|
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
||||||
|
|
||||||
assertThat(icon).isEqualTo(actualIcon);
|
assertThat(icon).isEqualTo(actualIcon);
|
||||||
}
|
}
|
||||||
@@ -733,14 +745,23 @@ public class SubscriptionsPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupGetIconConditions(int subId, boolean isActiveCellularNetwork,
|
private void setupGetIconConditions(int subId, boolean isActiveCellularNetwork,
|
||||||
boolean isDataEnable, int dataState, int servicestate) {
|
boolean isDataEnable, boolean dataState, int servicestate) {
|
||||||
doReturn(mTelephonyManagerForSub).when(mTelephonyManager).createForSubscriptionId(subId);
|
doReturn(mTelephonyManagerForSub).when(mTelephonyManager).createForSubscriptionId(subId);
|
||||||
doReturn(isActiveCellularNetwork).when(sInjector).isActiveCellularNetwork(mContext);
|
doReturn(isActiveCellularNetwork).when(sInjector).isActiveCellularNetwork(mContext);
|
||||||
doReturn(isDataEnable).when(mTelephonyManagerForSub).isDataEnabled();
|
doReturn(isDataEnable).when(mTelephonyManagerForSub).isDataEnabled();
|
||||||
doReturn(dataState).when(mTelephonyManagerForSub).getDataState();
|
|
||||||
ServiceState ss = mock(ServiceState.class);
|
ServiceState ss = mock(ServiceState.class);
|
||||||
|
NetworkRegistrationInfo regInfo = new NetworkRegistrationInfo.Builder()
|
||||||
|
.setDomain(NetworkRegistrationInfo.DOMAIN_PS)
|
||||||
|
.setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
|
||||||
|
.setRegistrationState(dataState ? NetworkRegistrationInfo.REGISTRATION_STATE_HOME
|
||||||
|
: NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_SEARCHING)
|
||||||
|
.setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
|
||||||
|
.build();
|
||||||
doReturn(ss).when(mTelephonyManagerForSub).getServiceState();
|
doReturn(ss).when(mTelephonyManagerForSub).getServiceState();
|
||||||
doReturn(servicestate).when(ss).getState();
|
doReturn(servicestate).when(ss).getState();
|
||||||
|
doReturn(regInfo).when(ss).getNetworkRegistrationInfo(
|
||||||
|
NetworkRegistrationInfo.DOMAIN_PS,
|
||||||
|
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SubscriptionInfo> setupMockSubscriptions(int count) {
|
private List<SubscriptionInfo> setupMockSubscriptions(int count) {
|
||||||
|
|||||||
Reference in New Issue
Block a user