Merge "Implemented Settings.ACTION_REQUEST_ENABLE_CONTENT_CAPTURE"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 5ac60ca..7625e78 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1579,19 +1579,12 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="com.android.settings.suggested.category.FINGERPRINT_ENROLL" />
</intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="com.android.settings.suggested.category.FIRST_IMPRESSION" />
- </intent-filter>
- <meta-data android:name="com.android.settings.dismiss"
- android:value="5,9,30" />
<meta-data android:name="com.android.settings.require_feature"
android:value="android.hardware.fingerprint" />
<meta-data android:name="com.android.settings.title"
android:resource="@string/suggestion_additional_fingerprints" />
<meta-data android:name="com.android.settings.summary"
android:resource="@string/suggestion_additional_fingerprints_summary" />
- <meta-data android:name="com.android.settings.icon_tintable" android:value="true" />
</activity>
<!-- Note this must not be exported since it returns the password in the intent -->
@@ -1655,8 +1648,7 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="com.android.settings.suggested.category.FIRST_IMPRESSION" />
</intent-filter>
- <meta-data android:name="com.android.settings.dismiss"
- android:value="2,6,30" />
+ <meta-data android:name="com.android.settings.dismiss" android:value="2," />
<meta-data android:name="com.android.settings.require_feature"
android:value="android.hardware.fingerprint" />
<meta-data android:name="com.android.settings.title"
@@ -3033,11 +3025,15 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
- <action android:name="android.settings.panel.action.VOLUME" />
+ <action android:name="android.settings.panel.action.NFC" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
- <action android:name="android.settings.panel.action.NFC" />
+ <action android:name="android.settings.panel.action.WIFI" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.settings.panel.action.VOLUME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
diff --git a/res/layout/homepage_slice_tile.xml b/res/layout/homepage_slice_tile.xml
index 807c26b..e95129e 100644
--- a/res/layout/homepage_slice_tile.xml
+++ b/res/layout/homepage_slice_tile.xml
@@ -31,6 +31,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
+ android:animateLayoutChanges="true"
style="@style/SliceViewStyle"/>
<!--dismissal view-->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6cbe22b..f3fe1f0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5587,6 +5587,12 @@
<!-- Battery saver: Title for battery saver schedule screen [CHAR_LIMIT=40] -->
<string name="battery_saver_schedule_settings_title">Set a schedule</string>
+ <!-- Battery Saver: Title for sticky battery saver preference [CHAR_LIMIT=60] -->
+ <string name="battery_saver_sticky_title">Keep battery saver on</string>
+
+ <!-- Battery Saver: Description for sticky battery saver preference [CHAR_LIMIT=NONE] -->
+ <string name="battery_saver_sticky_description">Battery saver will stay on even after device is fully charged</string>
+
<!-- Battery saver: Label for seekbar to change battery saver threshold [CHAR_LIMIT=40] -->
<string name="battery_saver_seekbar_title"><xliff:g id="percent">%1$s</xliff:g></string>
@@ -7151,6 +7157,9 @@
<string name="keywords_ring_vibration">haptics, vibrate, phone, call, sensitivity, ring</string>
<!-- List of synonyms for notification vibration setting (changes whether your phone vibrates when it shows a notification), used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_notification_vibration">haptics, vibrate, sensitivity</string>
+ <!-- Battery Saver: Search terms for sticky battery saver preference [CHAR_LIMIT=NONE] -->
+ <string name="keywords_battery_saver_sticky">battery saver, sticky, persist, power saver, battery</string>
+
<!-- NFC Wi-Fi pairing/setup strings-->
@@ -10657,6 +10666,9 @@
<!-- Title for the Volume dialog (settings panel) with all volume streams[CHAR LIMIT=50] -->
<string name="volume_connectivity_panel_title">Volume</string>
+ <!-- Subtitle explaining that mobile data cannot be used while airplane mode is on [CHAR LIMIT=50] -->
+ <string name="mobile_data_ap_mode_disabled">Unavailable during airplane mode</string>
+
<!-- UI debug setting: force desktop mode [CHAR LIMIT=50] -->
<string name="force_desktop_mode">Force desktop mode</string>
<!-- UI debug setting: force desktop mode summary [CHAR LIMIT=NONE] -->
diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml
index 89f7eab..ae9d14d 100644
--- a/res/xml/battery_saver_settings.xml
+++ b/res/xml/battery_saver_settings.xml
@@ -26,6 +26,13 @@
android:title="@string/battery_saver_schedule_settings_title"
settings:controller="com.android.settings.fuelgauge.batterysaver.BatterySaverSchedulePreferenceController"/>
+ <SwitchPreference
+ android:key="battery_saver_sticky"
+ android:title="@string/battery_saver_sticky_title"
+ android:summary="@string/battery_saver_sticky_description"
+ settings:keywords="@string/keywords_battery_saver_sticky"
+ settings:controller="com.android.settings.fuelgauge.batterysaver.BatterySaverStickyPreferenceController"/>
+
<com.android.settings.widget.TwoStateButtonPreference
android:key="battery_saver"
android:title="@string/battery_saver"
diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml
index b04bdf8..e3690a9 100644
--- a/res/xml/language_and_input.xml
+++ b/res/xml/language_and_input.xml
@@ -94,7 +94,8 @@
<com.android.settings.widget.WorkOnlyCategory
android:key="language_and_input_for_work_category"
- android:title="@string/language_and_input_for_work_category_title">
+ android:title="@string/language_and_input_for_work_category_title"
+ settings:searchable="false">
<Preference
android:key="virtual_keyboards_for_work_pref"
diff --git a/res/xml/mobile_network_list.xml b/res/xml/mobile_network_list.xml
index 5bffa2f..b72540f 100644
--- a/res/xml/mobile_network_list.xml
+++ b/res/xml/mobile_network_list.xml
@@ -24,7 +24,10 @@
android:title="@string/mobile_network_list_add_more"
android:icon="@drawable/ic_menu_add"
android:order="100" >
- <intent android:action="android.telephony.euicc.action.PROVISION_EMBEDDED_SUBSCRIPTION" />
+ <intent android:action="android.telephony.euicc.action.PROVISION_EMBEDDED_SUBSCRIPTION">
+ <extra android:name="android.telephony.euicc.extra.FORCE_PROVISION"
+ android:value="true"/>
+ </intent>
</Preference>
</PreferenceScreen>
diff --git a/res/xml/top_level_settings.xml b/res/xml/top_level_settings.xml
index 64b620a..367f426 100644
--- a/res/xml/top_level_settings.xml
+++ b/res/xml/top_level_settings.xml
@@ -18,8 +18,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="top_level_settings"
- android:title="@string/settings_label_launcher">
+ android:key="top_level_settings">
<Preference
android:key="top_level_network"
diff --git a/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBase.java b/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBase.java
index ca8dda3..0663e2a 100644
--- a/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBase.java
+++ b/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBase.java
@@ -14,12 +14,12 @@
package com.android.settings.applications.appinfo;
+import android.app.role.RoleControllerManager;
import android.app.role.RoleManager;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.os.UserManager;
-import android.permission.PermissionControllerManager;
import android.text.TextUtils;
import androidx.preference.Preference;
@@ -58,14 +58,14 @@
mRoleManager = context.getSystemService(RoleManager.class);
- final PermissionControllerManager permissionControllerManager =
- mContext.getSystemService(PermissionControllerManager.class);
+ final RoleControllerManager roleControllerManager =
+ mContext.getSystemService(RoleControllerManager.class);
final Executor executor = mContext.getMainExecutor();
- permissionControllerManager.isRoleVisible(mRoleName, executor, visible -> {
+ roleControllerManager.isRoleVisible(mRoleName, executor, visible -> {
mRoleVisible = visible;
refreshAvailability();
});
- permissionControllerManager.isApplicationQualifiedForRole(mRoleName, mPackageName, executor,
+ roleControllerManager.isApplicationQualifiedForRole(mRoleName, mPackageName, executor,
qualified -> {
mAppQualified = qualified;
refreshAvailability();
diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
index b650c6c..1b41240 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollActivity.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
@@ -16,8 +16,6 @@
package com.android.settings.biometrics;
-import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
-
import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -25,8 +23,11 @@
import com.android.settings.biometrics.face.FaceEnrollIntroduction;
import com.android.settings.biometrics.fingerprint.FingerprintEnrollIntroduction;
+import com.android.settings.biometrics.fingerprint.SetupFingerprintEnrollIntroduction;
import com.android.settings.core.InstrumentedActivity;
+import com.google.android.setupcompat.util.WizardManagerHelper;
+
/**
* Trampoline activity launched by the {@code android.settings.BIOMETRIC_ENROLL} action which
* shows the user an appropriate enrollment flow depending on the device's biometric hardware.
@@ -40,20 +41,38 @@
super.onCreate(savedInstanceState);
final PackageManager pm = getApplicationContext().getPackageManager();
- final Intent intent = new Intent();
+ Intent intent = null;
// This logic may have to be modified on devices with multiple biometrics.
if (pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
- intent.setClassName(SETTINGS_PACKAGE_NAME,
- FingerprintEnrollIntroduction.class.getName());
+ intent = getFingerprintEnrollIntent();
} else if (pm.hasSystemFeature(PackageManager.FEATURE_FACE)) {
- intent.setClassName(SETTINGS_PACKAGE_NAME, FaceEnrollIntroduction.class.getName());
+ intent = getFaceEnrollIntent();
}
- startActivity(intent);
+ if (intent != null) {
+ intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+ startActivity(intent);
+ }
finish();
}
+ private Intent getFingerprintEnrollIntent() {
+ if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
+ Intent intent = new Intent(this, SetupFingerprintEnrollIntroduction.class);
+ WizardManagerHelper.copyWizardManagerExtras(getIntent(), intent);
+ return intent;
+ } else {
+ return new Intent(this, FingerprintEnrollIntroduction.class);
+ }
+ }
+
+ private Intent getFaceEnrollIntent() {
+ Intent intent = new Intent(this, FaceEnrollIntroduction.class);
+ WizardManagerHelper.copyWizardManagerExtras(getIntent(), intent);
+ return intent;
+ }
+
@Override
public int getMetricsCategory() {
return SettingsEnums.BIOMETRIC_ENROLL_ACTIVITY;
diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
index e8cf809..097ffe2 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
@@ -21,14 +21,19 @@
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
+import android.os.storage.StorageManager;
import android.view.View;
import android.widget.TextView;
+import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.password.ChooseLockGeneric;
+import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
import com.android.settings.password.ChooseLockSettingsHelper;
+import com.android.settings.password.SetupChooseLockGeneric;
import com.google.android.setupcompat.template.FooterButton;
+import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.span.LinkSpan;
/**
@@ -199,28 +204,39 @@
}
protected Intent getChooseLockIntent() {
- return new Intent(this, ChooseLockGeneric.class);
+ if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
+ // Default to PIN lock in setup wizard
+ Intent intent = new Intent(this, SetupChooseLockGeneric.class);
+ if (StorageManager.isFileEncryptedNativeOrEmulated()) {
+ intent.putExtra(
+ LockPatternUtils.PASSWORD_TYPE_KEY,
+ DevicePolicyManager.PASSWORD_QUALITY_NUMERIC);
+ intent.putExtra(ChooseLockGenericFragment.EXTRA_SHOW_OPTIONS_BUTTON, true);
+ }
+ WizardManagerHelper.copyWizardManagerExtras(getIntent(), intent);
+ return intent;
+ } else {
+ return new Intent(this, ChooseLockGeneric.class);
+ }
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- final boolean isResultFinished = resultCode == RESULT_FINISHED;
- final int result = isResultFinished ? RESULT_OK : RESULT_SKIP;
if (requestCode == BIOMETRIC_FIND_SENSOR_REQUEST) {
- if (isResultFinished || resultCode == RESULT_SKIP) {
- setResult(result, data);
+ if (resultCode == RESULT_FINISHED || resultCode == RESULT_SKIP) {
+ setResult(resultCode, data);
finish();
return;
}
} else if (requestCode == CHOOSE_LOCK_GENERIC_REQUEST) {
- if (isResultFinished) {
+ if (resultCode == RESULT_FINISHED) {
updatePasswordQuality();
mToken = data.getByteArrayExtra(
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
return;
} else {
- setResult(result, data);
+ setResult(resultCode, data);
finish();
}
} else if (requestCode == CONFIRM_REQUEST) {
@@ -228,7 +244,7 @@
mToken = data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
} else {
- setResult(result, data);
+ setResult(resultCode, data);
finish();
}
} else if (requestCode == LEARN_MORE_REQUEST) {
@@ -241,6 +257,11 @@
finish();
}
+ protected void onSkipButtonClick(View view) {
+ setResult(RESULT_SKIP);
+ finish();
+ }
+
@Override
protected void initViews() {
super.initViews();
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index e45817d..5f2b675 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -36,6 +36,7 @@
import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
+import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.span.LinkSpan;
public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
@@ -59,14 +60,25 @@
mSwitchDiversity = findViewById(R.id.toggle_diversity);
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
- mFooterBarMixin.setSecondaryButton(
- new FooterButton.Builder(this)
- .setText(R.string.security_settings_face_enroll_introduction_cancel)
- .setListener(this::onCancelButtonClick)
- .setButtonType(FooterButton.ButtonType.SKIP)
- .setTheme(R.style.SudGlifButton_Secondary)
- .build()
- );
+ if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
+ mFooterBarMixin.setSecondaryButton(
+ new FooterButton.Builder(this)
+ .setText(R.string.skip_label)
+ .setListener(this::onSkipButtonClick)
+ .setButtonType(FooterButton.ButtonType.SKIP)
+ .setTheme(R.style.SudGlifButton_Secondary)
+ .build()
+ );
+ } else {
+ mFooterBarMixin.setSecondaryButton(
+ new FooterButton.Builder(this)
+ .setText(R.string.security_settings_face_enroll_introduction_cancel)
+ .setListener(this::onCancelButtonClick)
+ .setButtonType(FooterButton.ButtonType.CANCEL)
+ .setTheme(R.style.SudGlifButton_Secondary)
+ .build()
+ );
+ }
mFooterBarMixin.setPrimaryButton(
new FooterButton.Builder(this)
@@ -166,6 +178,7 @@
intent.setClass(this, FaceEnrollEnrolling.class);
}
intent.putExtra(EXTRA_KEY_REQUIRE_DIVERSITY, mSwitchDiversity.isChecked());
+ WizardManagerHelper.copyWizardManagerExtras(getIntent(), intent);
return intent;
}
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index 490580d..ea5a303 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -156,6 +156,9 @@
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ if (!isAvailable(context)) {
+ return null;
+ }
final List<AbstractPreferenceController> controllers =
buildPreferenceControllers(context, getSettingsLifecycle());
// There's no great way of doing this right now :/
@@ -197,7 +200,11 @@
@Override
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
- return buildPreferenceControllers(context, null /* lifecycle */);
+ if (isAvailable(context)) {
+ return buildPreferenceControllers(context, null /* lifecycle */);
+ } else {
+ return null;
+ }
}
@Override
diff --git a/src/com/android/settings/core/FeatureFlags.java b/src/com/android/settings/core/FeatureFlags.java
index f2ffe22..6c2da07 100644
--- a/src/com/android/settings/core/FeatureFlags.java
+++ b/src/com/android/settings/core/FeatureFlags.java
@@ -23,7 +23,6 @@
public static final String AUDIO_SWITCHER_SETTINGS = "settings_audio_switcher";
public static final String HEARING_AID_SETTINGS = "settings_bluetooth_hearing_aid";
public static final String MOBILE_NETWORK_V2 = "settings_mobile_network_v2";
- public static final String WIFI_MAC_RANDOMIZATION = "settings_wifi_mac_randomization";
public static final String NETWORK_INTERNET_V2 = "settings_network_and_internet_v2";
public static final String SLICE_INJECTION = "settings_slice_injection";
public static final String MAINLINE_MODULE = "settings_mainline_module";
diff --git a/src/com/android/settings/fuelgauge/BatteryInfo.java b/src/com/android/settings/fuelgauge/BatteryInfo.java
index 1f11f5a..c851a71 100644
--- a/src/com/android/settings/fuelgauge/BatteryInfo.java
+++ b/src/com/android/settings/fuelgauge/BatteryInfo.java
@@ -47,6 +47,7 @@
public long averageTimeToDischarge = Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN;
public String batteryPercentString;
public String statusLabel;
+ public String suggestionLabel;
private boolean mCharging;
private BatteryStats mStats;
private static final String LOG_TAG = "BatteryInfo";
@@ -247,6 +248,7 @@
final int status = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_STATUS,
BatteryManager.BATTERY_STATUS_UNKNOWN);
info.discharging = false;
+ info.suggestionLabel = null;
if (chargeTime > 0 && status != BatteryManager.BATTERY_STATUS_FULL) {
info.remainingTimeUs = chargeTime;
CharSequence timeString = StringUtil.formatElapsedTime(context,
@@ -282,8 +284,11 @@
info.batteryPercentString,
estimate.isBasedOnUsage && !shortString
);
+ info.suggestionLabel = PowerUtil.getBatteryTipStringFormatted(
+ context, PowerUtil.convertUsToMs(drainTimeUs));
} else {
info.remainingLabel = null;
+ info.suggestionLabel = null;
info.chargeLabel = info.batteryPercentString;
}
}
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
new file mode 100644
index 0000000..b14fec9
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
@@ -0,0 +1,41 @@
+package com.android.settings.fuelgauge.batterysaver;
+
+import android.content.Context;
+import android.provider.Settings;
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.PreferenceControllerMixin;
+
+public class BatterySaverStickyPreferenceController extends BasePreferenceController implements
+ PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
+
+ public static final String LOW_POWER_STICKY_AUTO_DISABLE_ENABLED =
+ "low_power_sticky_auto_disable_enabled";
+
+ public BatterySaverStickyPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ int setting = Settings.System.getInt(mContext.getContentResolver(),
+ LOW_POWER_STICKY_AUTO_DISABLE_ENABLED, 1);
+
+ ((SwitchPreference) preference).setChecked(setting == 0);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ boolean keepActive = (Boolean) newValue;
+ Settings.System.putInt(mContext.getContentResolver(),
+ LOW_POWER_STICKY_AUTO_DISABLE_ENABLED,
+ keepActive ? 0 : 1);
+ return true;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+}
diff --git a/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetector.java b/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetector.java
index 21cc28a..ca9141d 100644
--- a/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetector.java
+++ b/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetector.java
@@ -62,6 +62,6 @@
}
return new LowBatteryTip(
- state, powerSaveModeOn, mBatteryInfo.remainingLabel);
+ state, powerSaveModeOn, mBatteryInfo.suggestionLabel);
}
}
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
index 12590ff..43e90e8 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
@@ -165,6 +165,7 @@
com.android.settings.intelligence.ContextualCardProto.ContextualCard.newBuilder()
.setSliceUri(card.getSliceUri().toString())
.setCardName(card.getName())
+ .setCardScore(card.getRankingScore())
.build()));
return builder.build().toByteArray();
}
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
index ea6ac43..13564b5 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
@@ -26,7 +26,6 @@
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
-import android.text.format.DateUtils;
import android.util.Log;
import androidx.annotation.NonNull;
@@ -50,7 +49,6 @@
@VisibleForTesting
static final int DEFAULT_CARD_COUNT = 4;
static final int CARD_CONTENT_LOADER_ID = 1;
- static final long CARD_CONTENT_LOADER_TIMEOUT_MS = DateUtils.SECOND_IN_MILLIS;
private static final String TAG = "ContextualCardLoader";
private static final long ELIGIBILITY_CHECKER_TIMEOUT_MS = 250;
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java b/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
index 3b8aacd..c829015 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
@@ -24,6 +24,8 @@
import android.content.Context;
import android.os.Bundle;
+import android.provider.Settings;
+import android.text.format.DateUtils;
import android.util.ArrayMap;
import android.util.Log;
import android.widget.BaseAdapter;
@@ -62,8 +64,12 @@
public class ContextualCardManager implements ContextualCardLoader.CardContentLoaderListener,
ContextualCardUpdateListener, LifecycleObserver, OnSaveInstanceState {
- private static final String KEY_CONTEXTUAL_CARDS = "key_contextual_cards";
+ @VisibleForTesting
+ static final long CARD_CONTENT_LOADER_TIMEOUT_MS = DateUtils.SECOND_IN_MILLIS;
+ @VisibleForTesting
+ static final String KEY_GLOBAL_CARD_LOADER_TIMEOUT = "global_card_loader_timeout_key";
+ private static final String KEY_CONTEXTUAL_CARDS = "key_contextual_cards";
private static final String TAG = "ContextualCardManager";
//The list for Settings Custom Card
@@ -201,7 +207,8 @@
}
//only log homepage display upon a fresh launch
- if (loadTime <= ContextualCardLoader.CARD_CONTENT_LOADER_TIMEOUT_MS) {
+ final long timeoutLimit = getCardLoaderTimeout(mContext);
+ if (loadTime <= timeoutLimit) {
onContextualCardUpdated(cards.stream()
.collect(groupingBy(ContextualCard::getCardType)));
}
@@ -239,6 +246,14 @@
return getCardsWithSuggestionViewType(result);
}
+ @VisibleForTesting
+ long getCardLoaderTimeout(Context context) {
+ // Return the timeout limit if Settings.Global has the KEY_GLOBAL_CARD_LOADER_TIMEOUT key,
+ // else return default timeout.
+ return Settings.Global.getLong(mContext.getContentResolver(),
+ KEY_GLOBAL_CARD_LOADER_TIMEOUT, CARD_CONTENT_LOADER_TIMEOUT_MS);
+ }
+
private List<ContextualCard> getCardsWithSuggestionViewType(List<ContextualCard> cards) {
// Shows as half cards if 2 suggestion type of cards are next to each other.
// Shows as full card if 1 suggestion type of card lives alone.
diff --git a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
index 95412a8..3320be0 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
@@ -179,14 +179,9 @@
final Collection<CachedBluetoothDevice> cachedDevices =
bluetoothManager.getCachedDeviceManager().getCachedDevicesCopy();
- /**
- * TODO(b/114807655): Contextual Home Page - Connected Device
- * It's under discussion for including available media devices and currently connected
- * devices from Bluetooth. Will update the devices list or remove TODO later.
- */
- // Get available media device list and sort them.
+ // Get all connected devices and sort them.
return cachedDevices.stream()
- .filter(device -> device.isConnected() && device.isConnectedA2dpDevice())
+ .filter(device -> device.getDevice().isConnected())
.sorted(COMPARATOR).collect(Collectors.toList());
}
@@ -217,7 +212,7 @@
return Utils.createIconWithDrawable(pair.first);
} else {
return IconCompat.createWithResource(mContext,
- com.android.internal.R.drawable.ic_settings_bluetooth);
+ com.android.internal.R.drawable.ic_settings_bluetooth);
}
}
@@ -226,18 +221,29 @@
final List<ListBuilder.RowBuilder> bluetoothRows = new ArrayList<>();
final List<CachedBluetoothDevice> bluetoothDevices = getConnectedBluetoothDevices();
for (CachedBluetoothDevice bluetoothDevice : bluetoothDevices) {
- bluetoothRows.add(new ListBuilder.RowBuilder()
+ final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder()
.setTitleItem(getBluetoothDeviceIcon(bluetoothDevice), ListBuilder.ICON_IMAGE)
.setTitle(bluetoothDevice.getName())
- .setSubtitle(bluetoothDevice.getConnectionSummary())
- .setPrimaryAction(buildBluetoothDeviceAction(bluetoothDevice))
- .addEndItem(buildBluetoothDetailDeepLinkAction(bluetoothDevice)));
+ .setSubtitle(bluetoothDevice.getConnectionSummary());
+
+ if (bluetoothDevice.isConnectedA2dpDevice()) {
+ // For available media devices, the primary action is to active audio stream and
+ // add setting icon to the end to link detail page.
+ rowBuilder.setPrimaryAction(buildMediaBluetoothAction(bluetoothDevice));
+ rowBuilder.addEndItem(buildBluetoothDetailDeepLinkAction(bluetoothDevice));
+ } else {
+ // For other devices, the primary action is to link detail page.
+ rowBuilder.setPrimaryAction(buildBluetoothDetailDeepLinkAction(bluetoothDevice));
+ }
+
+ bluetoothRows.add(rowBuilder);
}
return bluetoothRows;
}
- private SliceAction buildBluetoothDeviceAction(CachedBluetoothDevice bluetoothDevice) {
+ @VisibleForTesting
+ SliceAction buildMediaBluetoothAction(CachedBluetoothDevice bluetoothDevice) {
// Send broadcast to activate available media device.
final Intent intent = new Intent(getUri().toString())
.setClass(mContext, SliceBroadcastReceiver.class)
@@ -250,7 +256,8 @@
bluetoothDevice.getName());
}
- private SliceAction buildBluetoothDetailDeepLinkAction(CachedBluetoothDevice bluetoothDevice) {
+ @VisibleForTesting
+ SliceAction buildBluetoothDetailDeepLinkAction(CachedBluetoothDevice bluetoothDevice) {
return SliceAction.createDeeplink(
getBluetoothDetailIntent(bluetoothDevice),
IconCompat.createWithResource(mContext, R.drawable.ic_settings_24dp),
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java b/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
index ef0a67d..ee63536 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
@@ -16,6 +16,7 @@
package com.android.settings.homepage.contextualcards.slices;
+import android.animation.LayoutTransition;
import android.content.Context;
import android.view.View;
@@ -94,6 +95,7 @@
public SliceViewHolder(View view) {
super(view);
sliceView = view.findViewById(R.id.slice_view);
+ sliceView.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
}
}
}
diff --git a/src/com/android/settings/network/MobileNetworkSummaryController.java b/src/com/android/settings/network/MobileNetworkSummaryController.java
index dd282c6..a1fef4c 100644
--- a/src/com/android/settings/network/MobileNetworkSummaryController.java
+++ b/src/com/android/settings/network/MobileNetworkSummaryController.java
@@ -29,6 +29,7 @@
import android.telephony.euicc.EuiccManager;
import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.network.telephony.MobileNetworkActivity;
import com.android.settings.widget.AddPreference;
import com.android.settingslib.Utils;
@@ -43,7 +44,8 @@
import androidx.preference.PreferenceScreen;
public class MobileNetworkSummaryController extends AbstractPreferenceController implements
- SubscriptionsChangeListener.SubscriptionsChangeListenerClient, LifecycleObserver {
+ SubscriptionsChangeListener.SubscriptionsChangeListenerClient, LifecycleObserver,
+ PreferenceControllerMixin {
private static final String TAG = "MobileNetSummaryCtlr";
private static final String KEY = "mobile_network_list";
@@ -74,8 +76,10 @@
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
mTelephonyMgr = mContext.getSystemService(TelephonyManager.class);
mEuiccManager = mContext.getSystemService(EuiccManager.class);
- mChangeListener = new SubscriptionsChangeListener(context, this);
- lifecycle.addObserver(this);
+ if (lifecycle != null) {
+ mChangeListener = new SubscriptionsChangeListener(context, this);
+ lifecycle.addObserver(this);
+ }
}
@OnLifecycleEvent(ON_RESUME)
@@ -116,6 +120,7 @@
private void startAddSimFlow() {
final Intent intent = new Intent(EuiccManager.ACTION_PROVISION_EMBEDDED_SUBSCRIPTION);
+ intent.putExtra(EuiccManager.EXTRA_FORCE_PROVISION, true);
mContext.startActivity(intent);
}
diff --git a/src/com/android/settings/network/telephony/MobileDataSlice.java b/src/com/android/settings/network/telephony/MobileDataSlice.java
index 6efd8c3..5a5d6a2 100644
--- a/src/com/android/settings/network/telephony/MobileDataSlice.java
+++ b/src/com/android/settings/network/telephony/MobileDataSlice.java
@@ -74,8 +74,27 @@
final IconCompat icon = IconCompat.createWithResource(mContext,
R.drawable.ic_network_cell);
final String title = mContext.getText(R.string.mobile_data_settings_title).toString();
- final CharSequence summary = getSummary();
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
+
+ // Return a Slice without the mobile data toggle when airplane mode is on.
+ if (isAirplaneModeEnabled()) {
+ final CharSequence summary = mContext.getText(R.string.mobile_data_ap_mode_disabled);
+ // Intent does nothing, but we have to pass an intent to the Row.
+ final PendingIntent intent = PendingIntent.getActivity(mContext, 0 /* requestCode */,
+ new Intent(), 0 /* flags */);
+ final SliceAction deadAction =
+ SliceAction.create(intent, icon, ListBuilder.ICON_IMAGE, title);
+ final ListBuilder listBuilder = new ListBuilder(mContext, getUri(),
+ ListBuilder.INFINITY)
+ .setAccentColor(color)
+ .addRow(new ListBuilder.RowBuilder()
+ .setTitle(title)
+ .setSubtitle(summary)
+ .setPrimaryAction(deadAction));
+ return listBuilder.build();
+ }
+
+ final CharSequence summary = getSummary();
final PendingIntent toggleAction = getBroadcastIntent(mContext);
final PendingIntent primaryAction = getPrimaryAction();
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon,
@@ -101,11 +120,6 @@
@Override
public void onNotifyChange(Intent intent) {
- // Don't make a change if we are in Airplane Mode.
- if (isAirplaneModeEnabled()) {
- return;
- }
-
final boolean newState = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
isMobileDataEnabled());
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index 5553dd7..9f5ece2 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -16,6 +16,8 @@
package com.android.settings.notification;
+import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
import android.app.settings.SettingsEnums;
@@ -24,6 +26,8 @@
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
+import android.view.Window;
+import android.view.WindowManager;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
@@ -33,7 +37,6 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
-import com.android.settings.widget.MasterCheckBoxPreference;
import com.android.settingslib.RestrictedSwitchPreference;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -85,6 +88,8 @@
public void onResume() {
super.onResume();
+ getActivity().getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
+
if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null) {
Log.w(TAG, "Missing package or uid or packageinfo");
finish();
@@ -119,6 +124,15 @@
}
@Override
+ public void onPause() {
+ super.onPause();
+ final Window window = getActivity().getWindow();
+ final WindowManager.LayoutParams attrs = window.getAttributes();
+ attrs.privateFlags &= ~SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+ window.setAttributes(attrs);
+ }
+
+ @Override
protected String getLogTag() {
return TAG;
}
diff --git a/src/com/android/settings/panel/NfcPanel.java b/src/com/android/settings/panel/NfcPanel.java
index 8fa41d9..6a9c74d 100644
--- a/src/com/android/settings/panel/NfcPanel.java
+++ b/src/com/android/settings/panel/NfcPanel.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2019 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.panel;
import android.app.settings.SettingsEnums;
diff --git a/src/com/android/settings/panel/PanelFeatureProviderImpl.java b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
index 6b096a1..67c300f 100644
--- a/src/com/android/settings/panel/PanelFeatureProviderImpl.java
+++ b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
@@ -28,12 +28,14 @@
switch (panelType) {
case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
return InternetConnectivityPanel.create(context);
- case Settings.Panel.ACTION_VOLUME:
- return VolumePanel.create(context);
- case Settings.Panel.ACTION_NFC:
- return NfcPanel.create(context);
case ACTION_MEDIA_OUTPUT:
return MediaOutputPanel.create(context, mediaPackageName);
+ case Settings.Panel.ACTION_NFC:
+ return NfcPanel.create(context);
+ case Settings.Panel.ACTION_WIFI:
+ return WifiPanel.create(context);
+ case Settings.Panel.ACTION_VOLUME:
+ return VolumePanel.create(context);
}
throw new IllegalStateException("No matching panel for: " + panelType);
diff --git a/src/com/android/settings/panel/WifiPanel.java b/src/com/android/settings/panel/WifiPanel.java
new file mode 100644
index 0000000..6d83742
--- /dev/null
+++ b/src/com/android/settings/panel/WifiPanel.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2019 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.panel;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+
+import com.android.settings.R;
+import com.android.settings.SubSettings;
+import com.android.settings.network.NetworkDashboardFragment;
+import com.android.settings.slices.CustomSliceRegistry;
+import com.android.settings.slices.SliceBuilderUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Panel data class for Wifi settings.
+ */
+public class WifiPanel implements PanelContent {
+
+ private final Context mContext;
+
+ public static WifiPanel create(Context context) {
+ return new WifiPanel(context);
+ }
+
+ private WifiPanel(Context context) {
+ mContext = context.getApplicationContext();
+ }
+
+ @Override
+ public CharSequence getTitle() {
+ return mContext.getText(R.string.wifi_settings);
+ }
+
+ @Override
+ public List<Uri> getSlices() {
+ final List<Uri> uris = new ArrayList<>();
+ uris.add(CustomSliceRegistry.WIFI_SLICE_URI);
+ return uris;
+ }
+
+ @Override
+ public Intent getSeeMoreIntent() {
+ final String screenTitle =
+ mContext.getText(R.string.network_dashboard_title).toString();
+ final Intent intent = SliceBuilderUtils.buildSearchResultPageIntent(mContext,
+ NetworkDashboardFragment.class.getName(),
+ null /* key */,
+ screenTitle,
+ SettingsEnums.SETTINGS_NETWORK_CATEGORY);
+ intent.setClassName(mContext.getPackageName(), SubSettings.class.getName());
+ return intent;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.PANEL_WIFI;
+ }
+}
diff --git a/src/com/android/settings/print/PrintServiceSettingsFragment.java b/src/com/android/settings/print/PrintServiceSettingsFragment.java
index d120062..8d40175 100644
--- a/src/com/android/settings/print/PrintServiceSettingsFragment.java
+++ b/src/com/android/settings/print/PrintServiceSettingsFragment.java
@@ -143,6 +143,8 @@
@Override
public void onStart() {
super.onStart();
+ initComponents();
+ updateUiForArguments();
updateEmptyView();
updateUiForServiceState();
}
@@ -158,20 +160,9 @@
@Override
public void onStop() {
super.onStop();
- }
-
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- initComponents();
- updateUiForArguments();
- }
-
- @Override
- public void onDestroyView() {
- super.onDestroyView();
mSwitchBar.removeOnSwitchChangeListener(this);
mSwitchBar.hide();
+ mPrintersAdapter.unregisterAdapterDataObserver(mDataObserver);
}
private void onPreferenceToggled(String preferenceKey, boolean enabled) {
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index e7db5db..916d330 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -248,8 +248,8 @@
mMeteredSettingsSpinner = mView.findViewById(R.id.metered_settings);
mHiddenSettingsSpinner = mView.findViewById(R.id.hidden_settings);
mPrivacySettingsSpinner = mView.findViewById(R.id.privacy_settings);
- if (FeatureFlagUtils.isEnabled(mContext,
- com.android.settings.core.FeatureFlags.WIFI_MAC_RANDOMIZATION)) {
+ if (mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_wifi_p2p_mac_randomization_supported)) {
View privacySettingsLayout = mView.findViewById(R.id.privacy_settings_fields);
privacySettingsLayout.setVisibility(View.VISIBLE);
}
diff --git a/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java b/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
index b79f2d4..97ddc53 100644
--- a/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
@@ -58,8 +58,9 @@
@Override
public int getAvailabilityStatus() {
- return FeatureFlagUtils.isEnabled(mContext, FeatureFlags.WIFI_MAC_RANDOMIZATION)
- ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ return mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_wifi_p2p_mac_randomization_supported) ?
+ AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/wifi/slice/WifiSlice.java b/src/com/android/settings/wifi/slice/WifiSlice.java
index 8d20f7f..a2debb8 100644
--- a/src/com/android/settings/wifi/slice/WifiSlice.java
+++ b/src/com/android/settings/wifi/slice/WifiSlice.java
@@ -198,7 +198,7 @@
private IconCompat getEndIcon(AccessPoint accessPoint) {
if (accessPoint.isActive()) {
- return IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent);
+ return null;
} else if (accessPoint.getSecurity() != AccessPoint.SECURITY_NONE) {
return IconCompat.createWithResource(mContext, R.drawable.ic_friction_lock_closed);
} else if (accessPoint.isMetered()) {
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBaseTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBaseTest.java
index 7b9bc25..81d52d2 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBaseTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBaseTest.java
@@ -25,11 +25,11 @@
import static org.robolectric.Shadows.shadowOf;
import android.app.Activity;
+import android.app.role.RoleControllerManager;
import android.app.role.RoleManager;
import android.content.Context;
import android.content.Intent;
import android.os.UserManager;
-import android.permission.PermissionControllerManager;
import androidx.preference.Preference;
@@ -63,7 +63,7 @@
@Mock
private RoleManager mRoleManager;
@Mock
- private PermissionControllerManager mPermissionControllerManager;
+ private RoleControllerManager mRoleControllerManager;
@Mock
private Preference mPreference;
@@ -77,8 +77,7 @@
MockitoAnnotations.initMocks(this);
ShadowApplication shadowApplication = ShadowApplication.getInstance();
shadowApplication.setSystemService(Context.ROLE_SERVICE, mRoleManager);
- shadowApplication.setSystemService(Context.PERMISSION_CONTROLLER_SERVICE,
- mPermissionControllerManager);
+ shadowApplication.setSystemService(Context.ROLE_CONTROLLER_SERVICE, mRoleControllerManager);
mActivity = Robolectric.setupActivity(Activity.class);
mShadowUserManager = shadowOf(mActivity.getSystemService(UserManager.class));
mController = new TestRolePreferenceController(mActivity);
@@ -87,7 +86,7 @@
@Test
public void constructor_callsIsApplicationQualifiedForRole() {
- verify(mPermissionControllerManager).isApplicationQualifiedForRole(eq(TEST_ROLE_NAME), eq(
+ verify(mRoleControllerManager).isApplicationQualifiedForRole(eq(TEST_ROLE_NAME), eq(
TEST_PACKAGE_NAME), any(Executor.class), any(Consumer.class));
}
@@ -154,7 +153,7 @@
private void setRoleIsVisible(boolean visible) {
final ArgumentCaptor<Consumer<Boolean>> callbackCaptor = ArgumentCaptor.forClass(
Consumer.class);
- verify(mPermissionControllerManager).isRoleVisible(eq(TEST_ROLE_NAME), any(Executor.class),
+ verify(mRoleControllerManager).isRoleVisible(eq(TEST_ROLE_NAME), any(Executor.class),
callbackCaptor.capture());
final Consumer<Boolean> callback = callbackCaptor.getValue();
callback.accept(visible);
@@ -163,7 +162,7 @@
private void setApplicationIsQualifiedForRole(boolean qualified) {
final ArgumentCaptor<Consumer<Boolean>> callbackCaptor = ArgumentCaptor.forClass(
Consumer.class);
- verify(mPermissionControllerManager).isApplicationQualifiedForRole(eq(TEST_ROLE_NAME), eq(
+ verify(mRoleControllerManager).isApplicationQualifiedForRole(eq(TEST_ROLE_NAME), eq(
TEST_PACKAGE_NAME), any(Executor.class), callbackCaptor.capture());
final Consumer<Boolean> callback = callbackCaptor.getValue();
callback.accept(qualified);
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultBrowserShortcutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultBrowserShortcutPreferenceControllerTest.java
index c2a3b4a..5940d72 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultBrowserShortcutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultBrowserShortcutPreferenceControllerTest.java
@@ -18,8 +18,8 @@
import static com.google.common.truth.Truth.assertThat;
+import android.app.role.RoleControllerManager;
import android.content.Context;
-import android.permission.PermissionControllerManager;
import org.junit.Before;
import org.junit.Test;
@@ -34,15 +34,15 @@
public class DefaultBrowserShortcutPreferenceControllerTest {
@Mock
- private PermissionControllerManager mPermissionControllerManager;
+ private RoleControllerManager mRoleControllerManager;
private DefaultBrowserShortcutPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- ShadowApplication.getInstance().setSystemService(Context.PERMISSION_CONTROLLER_SERVICE,
- mPermissionControllerManager);
+ ShadowApplication.getInstance().setSystemService(Context.ROLE_CONTROLLER_SERVICE,
+ mRoleControllerManager);
mController = new DefaultBrowserShortcutPreferenceController(RuntimeEnvironment.application,
"Package1");
}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultEmergencyShortcutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultEmergencyShortcutPreferenceControllerTest.java
index 8466092..8dcf530 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultEmergencyShortcutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultEmergencyShortcutPreferenceControllerTest.java
@@ -18,8 +18,8 @@
import static com.google.common.truth.Truth.assertThat;
+import android.app.role.RoleControllerManager;
import android.content.Context;
-import android.permission.PermissionControllerManager;
import org.junit.Before;
import org.junit.Test;
@@ -34,15 +34,15 @@
public class DefaultEmergencyShortcutPreferenceControllerTest {
@Mock
- private PermissionControllerManager mPermissionControllerManager;
+ private RoleControllerManager mRoleControllerManager;
private DefaultEmergencyShortcutPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- ShadowApplication.getInstance().setSystemService(Context.PERMISSION_CONTROLLER_SERVICE,
- mPermissionControllerManager);
+ ShadowApplication.getInstance().setSystemService(Context.ROLE_CONTROLLER_SERVICE,
+ mRoleControllerManager);
mController = new DefaultEmergencyShortcutPreferenceController(
RuntimeEnvironment.application, "Package1");
}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultHomeShortcutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultHomeShortcutPreferenceControllerTest.java
index c5cae3a..7071fec 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultHomeShortcutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultHomeShortcutPreferenceControllerTest.java
@@ -18,8 +18,8 @@
import static com.google.common.truth.Truth.assertThat;
+import android.app.role.RoleControllerManager;
import android.content.Context;
-import android.permission.PermissionControllerManager;
import org.junit.Before;
import org.junit.Test;
@@ -34,15 +34,15 @@
public class DefaultHomeShortcutPreferenceControllerTest {
@Mock
- private PermissionControllerManager mPermissionControllerManager;
+ private RoleControllerManager mRoleControllerManager;
private DefaultHomeShortcutPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- ShadowApplication.getInstance().setSystemService(Context.PERMISSION_CONTROLLER_SERVICE,
- mPermissionControllerManager);
+ ShadowApplication.getInstance().setSystemService(Context.ROLE_CONTROLLER_SERVICE,
+ mRoleControllerManager);
mController = new DefaultHomeShortcutPreferenceController(RuntimeEnvironment.application,
"Package1");
}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceControllerTest.java
index 4e7a800..d1b6aeb 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultPhoneShortcutPreferenceControllerTest.java
@@ -18,8 +18,8 @@
import static com.google.common.truth.Truth.assertThat;
+import android.app.role.RoleControllerManager;
import android.content.Context;
-import android.permission.PermissionControllerManager;
import org.junit.Before;
import org.junit.Test;
@@ -37,15 +37,15 @@
private static final String PREFERENCE_KEY = "default_phone_app";
@Mock
- private PermissionControllerManager mPermissionControllerManager;
+ private RoleControllerManager mRoleControllerManager;
private DefaultPhoneShortcutPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- ShadowApplication.getInstance().setSystemService(Context.PERMISSION_CONTROLLER_SERVICE,
- mPermissionControllerManager);
+ ShadowApplication.getInstance().setSystemService(Context.ROLE_CONTROLLER_SERVICE,
+ mRoleControllerManager);
mController = new DefaultPhoneShortcutPreferenceController(RuntimeEnvironment.application,
TEST_PACKAGE_NAME);
}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultSmsShortcutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultSmsShortcutPreferenceControllerTest.java
index b31a10d..8626d2d 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/DefaultSmsShortcutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/DefaultSmsShortcutPreferenceControllerTest.java
@@ -18,8 +18,8 @@
import static com.google.common.truth.Truth.assertThat;
+import android.app.role.RoleControllerManager;
import android.content.Context;
-import android.permission.PermissionControllerManager;
import org.junit.Before;
import org.junit.Test;
@@ -37,15 +37,15 @@
private static final String PREFERENCE_KEY = "default_sms_app";
@Mock
- private PermissionControllerManager mPermissionControllerManager;
+ private RoleControllerManager mRoleControllerManager;
private DefaultSmsShortcutPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- ShadowApplication.getInstance().setSystemService(Context.PERMISSION_CONTROLLER_SERVICE,
- mPermissionControllerManager);
+ ShadowApplication.getInstance().setSystemService(Context.ROLE_CONTROLLER_SERVICE,
+ mRoleControllerManager);
mController = new DefaultSmsShortcutPreferenceController(RuntimeEnvironment.application,
TEST_PACKAGE_NAME);
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
index 0103031..d5e0ed8 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
@@ -65,7 +65,9 @@
private static final String STATUS_NOT_CHARGING = "Not charging";
private static final long REMAINING_TIME_NULL = -1;
private static final long REMAINING_TIME = 2;
+ // Strings are defined in frameworks/base/packages/SettingsLib/res/values/strings.xml
private static final String ENHANCED_STRING_SUFFIX = "based on your usage";
+ private static final String EXTEND_PREFIX = "Extend battery life past";
private static final long TEST_CHARGE_TIME_REMAINING = TimeUnit.MINUTES.toMicros(1);
private static final String TEST_CHARGE_TIME_REMAINING_STRINGIFIED =
"1 min left until fully charged";
@@ -148,8 +150,10 @@
// We only add special mention for the long string
assertThat(info.remainingLabel.toString()).contains(ENHANCED_STRING_SUFFIX);
+ assertThat(info.suggestionLabel).contains(EXTEND_PREFIX);
// shortened string should not have extra text
assertThat(info2.remainingLabel.toString()).doesNotContain(ENHANCED_STRING_SUFFIX);
+ assertThat(info2.suggestionLabel).contains(EXTEND_PREFIX);
}
@Test
@@ -169,6 +173,19 @@
mContext.getString(R.string.power_remaining_duration_only_shutdown_imminent));
assertThat(info2.remainingLabel.toString()).isEqualTo(
mContext.getString(R.string.power_remaining_duration_only_shutdown_imminent));
+ assertThat(info2.suggestionLabel).contains(EXTEND_PREFIX);
+ }
+
+ @Test
+ public void getBatteryInfo_MoreThanOneDay_suggestionLabelIsCorrectString() {
+ Estimate estimate = new Estimate(Duration.ofDays(3).toMillis(),
+ true /* isBasedOnUsage */,
+ 1000 /* averageDischargeTime */);
+ BatteryInfo info = BatteryInfo.getBatteryInfo(mContext, mDisChargingBatteryBroadcast,
+ mBatteryStats, estimate, SystemClock.elapsedRealtime() * 1000,
+ false /* shortString */);
+
+ assertThat(info.suggestionLabel).doesNotContain(EXTEND_PREFIX);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
new file mode 100644
index 0000000..a441864
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceControllerTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2016 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.fuelgauge.batterysaver;
+
+import static com.android.settings.fuelgauge.batterysaver.BatterySaverStickyPreferenceController.LOW_POWER_STICKY_AUTO_DISABLE_ENABLED;
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.Settings;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class BatterySaverStickyPreferenceControllerTest {
+
+ private static final String PREF_KEY = "battery_saver_sticky";
+
+ private Context mContext;
+ private BatterySaverStickyPreferenceController mController;
+
+ @Before
+ public void setup() {
+ mContext = RuntimeEnvironment.application;
+ mController = new BatterySaverStickyPreferenceController(mContext, PREF_KEY);
+ }
+
+ private int getAutoDisableSetting() {
+ return Settings.System.getInt(mContext.getContentResolver(),
+ LOW_POWER_STICKY_AUTO_DISABLE_ENABLED,
+ 1);
+ }
+
+ @Test
+ public void testOnPreferenceChange_turnOnKeepActive_autoDisableOff() {
+ mController.onPreferenceChange(null, true);
+ final int isOn = getAutoDisableSetting();
+ assertThat(isOn).isEqualTo(0);
+ }
+
+ @Test
+ public void testOnPreferenceChange_TurnOffKeepActive_autoDisableOff() {
+ mController.onPreferenceChange(null, false);
+ final int isOn = getAutoDisableSetting();
+ assertThat(isOn).isEqualTo(1);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
index 1a0539c..eb9a461 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
@@ -31,6 +31,7 @@
import android.content.Context;
import android.net.Uri;
+import android.provider.Settings;
import android.util.ArrayMap;
import com.android.settings.homepage.contextualcards.conditional.ConditionFooterContextualCard;
@@ -126,6 +127,24 @@
}
@Test
+ public void getCardLoaderTimeout_noConfiguredTimeout_shouldReturnDefaultTimeout() {
+ final long timeout = mManager.getCardLoaderTimeout(mContext);
+
+ assertThat(timeout).isEqualTo(ContextualCardManager.CARD_CONTENT_LOADER_TIMEOUT_MS);
+ }
+
+ @Test
+ public void getCardLoaderTimeout_hasConfiguredTimeout_shouldReturnConfiguredTimeout() {
+ final long configuredTimeout = 5000L;
+ Settings.Global.putLong(mContext.getContentResolver(),
+ ContextualCardManager.KEY_GLOBAL_CARD_LOADER_TIMEOUT, configuredTimeout);
+
+ final long timeout = mManager.getCardLoaderTimeout(mContext);
+
+ assertThat(timeout).isEqualTo(configuredTimeout);
+ }
+
+ @Test
public void onFinishCardLoading_fastLoad_shouldCallOnContextualCardUpdated() {
mManager.mStartTime = System.currentTimeMillis();
final ContextualCardManager manager = spy(mManager);
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
index 77fc5d9..4a23c33 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
@@ -23,6 +23,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -83,7 +84,7 @@
// Mock the icon and detail intent of Bluetooth.
mIcon = IconCompat.createWithResource(mContext,
- com.android.internal.R.drawable.ic_settings_bluetooth);
+ com.android.internal.R.drawable.ic_settings_bluetooth);
mDetailIntent = PendingIntent.getActivity(mContext, 0, new Intent("test action"), 0);
doReturn(mIcon).when(mBluetoothDevicesSlice).getBluetoothDeviceIcon(any());
doReturn(mDetailIntent).when(mBluetoothDevicesSlice).getBluetoothDetailIntent(any());
@@ -122,6 +123,27 @@
}
@Test
+ public void getSlice_hasMediaBluetoothDevice_shouldBuildMediaBluetoothAction() {
+ mockBluetoothDeviceList(1 /* deviceCount */);
+ doReturn(true).when(mBluetoothDeviceList.get(0)).isConnectedA2dpDevice();
+ doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
+
+ mBluetoothDevicesSlice.getSlice();
+
+ verify(mBluetoothDevicesSlice).buildMediaBluetoothAction(any());
+ }
+
+ @Test
+ public void getSlice_noMediaBluetoothDevice_shouldNotBuildMediaBluetoothAction() {
+ mockBluetoothDeviceList(1 /* deviceCount */);
+ doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
+
+ mBluetoothDevicesSlice.getSlice();
+
+ verify(mBluetoothDevicesSlice, never()).buildMediaBluetoothAction(any());
+ }
+
+ @Test
public void getSlice_noBluetoothDevices_shouldHaveNoBluetoothDevicesTitle() {
doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
@@ -175,7 +197,6 @@
doReturn(BLUETOOTH_MOCK_TITLE).when(mCachedBluetoothDevice).getName();
doReturn(BLUETOOTH_MOCK_SUMMARY).when(mCachedBluetoothDevice).getConnectionSummary();
doReturn(BLUETOOTH_MOCK_ADDRESS).when(mCachedBluetoothDevice).getAddress();
- doReturn(true).when(mCachedBluetoothDevice).isConnectedA2dpDevice();
for (int i = 0; i < deviceCount; i++) {
mBluetoothDeviceList.add(mCachedBluetoothDevice);
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java
index c497cf8..31daa37 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileDataSliceTest.java
@@ -24,6 +24,7 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
@@ -162,4 +163,27 @@
assertThat(isMobileDataEnabled).isEqualTo(seed);
}
+
+ @Test
+ public void airplaneModeEnabled_slicePrimaryActionIsEmpty() {
+ doReturn(true).when(mMobileDataSlice).isAirplaneModeEnabled();
+ doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(SUB_ID);
+ final Slice mobileData = mMobileDataSlice.getSlice();
+
+ final SliceMetadata metadata = SliceMetadata.from(mContext, mobileData);
+ assertThat(metadata.getTitle())
+ .isEqualTo(mContext.getString(R.string.mobile_data_settings_title));
+
+ assertThat(metadata.getSubtitle())
+ .isEqualTo(mContext.getString(R.string.mobile_data_ap_mode_disabled));
+
+ final List<SliceAction> toggles = metadata.getToggles();
+ assertThat(toggles).hasSize(0);
+
+ final SliceAction primaryAction = metadata.getPrimaryAction();
+ final PendingIntent pendingIntent = primaryAction.getAction();
+ final Intent actionIntent = pendingIntent.getIntent();
+
+ assertThat(actionIntent.getAction()).isNull();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/notification/AppNotificationSettingsTest.java b/tests/robotests/src/com/android/settings/notification/AppNotificationSettingsTest.java
new file mode 100644
index 0000000..9555a56
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/AppNotificationSettingsTest.java
@@ -0,0 +1,93 @@
+package com.android.settings.notification;
+
+import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.view.Window;
+import android.view.WindowManager;
+
+import androidx.fragment.app.FragmentActivity;
+import androidx.fragment.app.FragmentManager;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+@RunWith(RobolectricTestRunner.class)
+public class AppNotificationSettingsTest {
+
+ private WindowManager.LayoutParams mLayoutParams;
+ private AppNotificationSettings mFragment;
+ private FragmentActivity mActivity;
+ @Mock
+ private Window mWindow;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mLayoutParams = new WindowManager.LayoutParams();
+ mActivity = spy(Robolectric.setupActivity(FragmentActivity.class));
+ mFragment = spy(new AppNotificationSettings());
+ when(mFragment.getActivity()).thenReturn(mActivity);
+ when(mFragment.getFragmentManager()).thenReturn(mock(FragmentManager.class));
+ when(mActivity.getWindow()).thenReturn(mWindow);
+ when(mWindow.getAttributes()).thenReturn(mLayoutParams);
+ }
+
+ @Test
+ @Config(shadows = {ShadowNotificationSettingsBase.class})
+ public void onResume_shouldHideSystemOverlay() {
+ mFragment.onResume();
+
+ verify(mWindow).addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
+ }
+
+ @Test
+ @Config(shadows = {ShadowNotificationSettingsBase.class})
+ public void onPause_shouldRemoveHideSystemOverlay() {
+ mFragment.onResume();
+
+ verify(mWindow).addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
+
+ mFragment.onPause();
+
+ // There's no Window.clearPrivateFlags() method, so the Window.attributes are updated.
+ ArgumentCaptor<WindowManager.LayoutParams> paramCaptor = ArgumentCaptor.forClass(
+ WindowManager.LayoutParams.class);
+ verify(mWindow).setAttributes(paramCaptor.capture());
+ assertEquals(0,
+ paramCaptor.getValue().privateFlags
+ & SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
+ }
+
+ @Implements(NotificationSettingsBase.class)
+ public static class ShadowNotificationSettingsBase {
+
+ protected void __constructor__() {
+ // Do nothing
+ }
+
+ @Implementation
+ protected void onResume() {
+ // No-op.
+ }
+
+ @Implementation
+ protected void onPause() {
+ // No-op.
+ }
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/panel/NfcPanelTest.java b/tests/robotests/src/com/android/settings/panel/NfcPanelTest.java
index bf6662d..1de2c5a 100644
--- a/tests/robotests/src/com/android/settings/panel/NfcPanelTest.java
+++ b/tests/robotests/src/com/android/settings/panel/NfcPanelTest.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2019 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.panel;
import static com.google.common.truth.Truth.assertThat;
diff --git a/tests/robotests/src/com/android/settings/panel/WifiPanelTest.java b/tests/robotests/src/com/android/settings/panel/WifiPanelTest.java
new file mode 100644
index 0000000..08db23e
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/panel/WifiPanelTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2019 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.panel;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.net.Uri;
+
+import com.android.settings.slices.CustomSliceRegistry;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class WifiPanelTest {
+
+ private WifiPanel mPanel;
+
+ @Before
+ public void setUp() {
+ mPanel = WifiPanel.create(RuntimeEnvironment.application);
+ }
+
+ @Test
+ public void getSlices_containsNecessarySlices() {
+ final List<Uri> uris = mPanel.getSlices();
+
+ assertThat(uris).containsExactly(
+ CustomSliceRegistry.WIFI_SLICE_URI);
+ }
+
+ @Test
+ public void getSeeMoreIntent_notNull() {
+ assertThat(mPanel.getSeeMoreIntent()).isNotNull();
+ }
+}