diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 44f5b64803e..e0e4d739cc9 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -376,6 +376,17 @@
android:value="true" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 949b6758d94..1d4b0992e44 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -9392,10 +9392,17 @@
listener, displayed as a dialog message. [CHAR LIMIT=NONE] -->
%1$s will be able to read all notifications,
- including personal information such as contact names and the text of messages you receive.
+ including personal information such as contact names, photos, and the text of messages you receive.
This app will also be able to snooze or dismiss notifications or take action on buttons in notifications, including answering phone calls.
\n\nThis will also give the app the ability to turn Do Not Disturb on or off and change related settings.
+ %1$s will be able to:
+ Read your notifications
+ It can read your notifications, including personal information such as contacts, messages, and photos.
+ Reply to messages
+ It can reply to messages and take action on buttons in notifications, including snoozing or dismissing notifications and answering calls.
+ Change settings
+ It can turn Do Not Disturb on or off and change related settings.
If you turn off notification access for %1$s, Do Not Disturb access may also be turned off.
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 4de795c41b5..a297b9d52a8 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -324,4 +324,6 @@ public class Settings extends SettingsActivity {
* Activity for AppDashboard.
*/
public static class AppDashboardActivity extends SettingsActivity {}
+
+ public static class AdaptiveBrightnessActivity extends SettingsActivity { /* empty */ }
}
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index edd4088a27f..c1f45746599 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -768,7 +768,7 @@ public class ManageApplications extends InstrumentedFragment
int i = item.getItemId();
if (i == R.id.sort_order_alpha || i == R.id.sort_order_size) {
if (mApplications != null) {
- mApplications.rebuild(menuId);
+ mApplications.rebuild(menuId, false);
}
} else if (i == R.id.show_system || i == R.id.hide_system) {
mShowSystem = !mShowSystem;
@@ -1097,13 +1097,13 @@ public class ManageApplications extends InstrumentedFragment
// Notification filters require resorting the list
if (mManageApplications.mListType == LIST_TYPE_NOTIFICATION) {
if (FILTER_APPS_FREQUENT == appFilter.getFilterType()) {
- rebuild(R.id.sort_order_frequent_notification);
+ rebuild(R.id.sort_order_frequent_notification, false);
} else if (FILTER_APPS_RECENT == appFilter.getFilterType()) {
- rebuild(R.id.sort_order_recent_notification);
+ rebuild(R.id.sort_order_recent_notification, false);
} else if (FILTER_APPS_BLOCKED == appFilter.getFilterType()) {
- rebuild(R.id.sort_order_alpha);
+ rebuild(R.id.sort_order_alpha, true);
} else {
- rebuild(R.id.sort_order_alpha);
+ rebuild(R.id.sort_order_alpha, true);
}
} else {
rebuild();
@@ -1121,7 +1121,7 @@ public class ManageApplications extends InstrumentedFragment
}
rebuild();
} else {
- rebuild(sort);
+ rebuild(sort, false);
}
}
@@ -1149,8 +1149,8 @@ public class ManageApplications extends InstrumentedFragment
}
}
- public void rebuild(int sort) {
- if (sort == mLastSortMode) {
+ public void rebuild(int sort, boolean force) {
+ if (sort == mLastSortMode && !force) {
return;
}
mManageApplications.mSortOrder = sort;
diff --git a/src/com/android/settings/applications/specialaccess/notificationaccess/ScaryWarningDialogFragment.java b/src/com/android/settings/applications/specialaccess/notificationaccess/ScaryWarningDialogFragment.java
index 6613f96e7fb..b9ad2c3cb69 100644
--- a/src/com/android/settings/applications/specialaccess/notificationaccess/ScaryWarningDialogFragment.java
+++ b/src/com/android/settings/applications/specialaccess/notificationaccess/ScaryWarningDialogFragment.java
@@ -18,8 +18,15 @@ package com.android.settings.applications.specialaccess.notificationaccess;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
-import android.content.DialogInterface;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
@@ -55,25 +62,49 @@ public class ScaryWarningDialogFragment extends InstrumentedDialogFragment {
.getString(KEY_COMPONENT));
NotificationAccessDetails parent = (NotificationAccessDetails) getTargetFragment();
- final String title = getResources().getString(
- R.string.notification_listener_security_warning_title, label);
- final String summary = getResources().getString(
- R.string.notification_listener_security_warning_summary, label);
return new AlertDialog.Builder(getContext())
- .setMessage(summary)
- .setTitle(title)
+ .setView(getDialogView(getContext(), label, parent, cn))
.setCancelable(true)
- .setPositiveButton(R.string.allow,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- parent.enable(cn);
- }
- })
- .setNegativeButton(R.string.deny,
- (dialog, id) -> {
- // pass
- })
.create();
}
+
+ private View getDialogView(Context context, CharSequence label,
+ NotificationAccessDetails parent, ComponentName cn) {
+ LayoutInflater inflater = (LayoutInflater) context.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+
+ View content = inflater.inflate(R.layout.enable_nls_dialog_content, null);
+
+ Drawable icon = null;
+ try {
+ icon = context.getPackageManager().getApplicationIcon(cn.getPackageName());
+ } catch (PackageManager.NameNotFoundException e) {
+ }
+
+ ImageView appIcon = content.findViewById(R.id.app_icon);
+ if (icon != null) {
+ appIcon.setImageDrawable(icon);
+ } else {
+ appIcon.setVisibility(View.GONE);
+ }
+
+ final String title = context.getResources().getString(
+ R.string.notification_listener_security_warning_title, label);
+ ((TextView) content.findViewById(R.id.title)).setText(title);
+
+ final String prompt = context.getResources().getString(
+ R.string.nls_warning_prompt, label);
+ ((TextView) content.findViewById(R.id.prompt)).setText(prompt);
+
+ Button allowButton = content.findViewById(R.id.allow_button);
+ allowButton.setOnClickListener((view) -> {
+ parent.enable(cn);
+ dismiss();
+ });
+ Button denyButton = content.findViewById(R.id.deny_button);
+ denyButton.setOnClickListener((view) -> {
+ dismiss();
+ });
+ return content;
+ }
}
\ No newline at end of file
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 3c594a714c0..6897a094816 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -84,6 +84,7 @@ import com.android.settings.deviceinfo.StorageDashboardFragment;
import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
import com.android.settings.deviceinfo.firmwareversion.FirmwareVersionSettings;
import com.android.settings.deviceinfo.legal.ModuleLicensesDashboard;
+import com.android.settings.display.AutoBrightnessSettings;
import com.android.settings.display.NightDisplaySettings;
import com.android.settings.display.SmartAutoRotatePreferenceFragment;
import com.android.settings.display.darkmode.DarkModeSettingsFragment;
@@ -319,7 +320,8 @@ public class SettingsGateway {
MediaControlsSettings.class.getName(),
NetworkProviderSettings.class.getName(),
AlarmsAndRemindersDetails.class.getName(),
- MediaManagementAppsDetails.class.getName()
+ MediaManagementAppsDetails.class.getName(),
+ AutoBrightnessSettings.class.getName()
};
public static final String[] SETTINGS_FOR_RESTRICTED = {
@@ -350,6 +352,8 @@ public class SettingsGateway {
Settings.ConfigureNotificationSettingsActivity.class.getName(),
Settings.ManageApplicationsActivity.class.getName(),
Settings.PaymentSettingsActivity.class.getName(),
+ // Home page > Display
+ Settings.AdaptiveBrightnessActivity.class.getName(),
// Home page > Security & screen lock
Settings.LocationSettingsActivity.class.getName(),
// Home page > System
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSettings.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSettings.java
index 64114463246..0c596bbc951 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSettings.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSettings.java
@@ -29,7 +29,6 @@ import android.os.Handler;
import android.provider.Settings;
import android.text.TextUtils;
import android.view.View;
-import android.util.Pair;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -184,35 +183,18 @@ public class BatterySaverScheduleSettings extends RadioButtonPickerFragment {
}
private void logPowerSaver() {
- int currentSaverPercentage = getSaverPercentage();
- String currentSaverScheduleKey = mRadioButtonController.getDefaultKey();
+ final int currentSaverPercentage = getSaverPercentage();
+ final String currentSaverScheduleKey = mRadioButtonController.getDefaultKey();
if (mSaverScheduleKey.equals(currentSaverScheduleKey)
&& mSaverPercentage == currentSaverPercentage) {
return;
}
- int scheduleType = -1;
- int schedulePercentage = -1;
- switch (currentSaverScheduleKey) {
- case BatterySaverScheduleRadioButtonsController.KEY_NO_SCHEDULE:
- scheduleType = SettingsEnums.BATTERY_SAVER_SCHEDULE_TYPE_NO_SCHEDULE;
- break;
- case BatterySaverScheduleRadioButtonsController.KEY_ROUTINE:
- scheduleType = SettingsEnums.BATTERY_SAVER_SCHEDULE_TYPE_BASED_ON_ROUTINE;
- break;
- case BatterySaverScheduleRadioButtonsController.KEY_PERCENTAGE:
- scheduleType = SettingsEnums.BATTERY_SAVER_SCHEDULE_TYPE_BASED_ON_PERCENTAGE;
- schedulePercentage = currentSaverPercentage;
- break;
- // Unknown schedule type.
- default:
- return;
- }
FeatureFactory.getFactory(mContext).getMetricsFeatureProvider()
- .action(mContext, SettingsEnums.FUELGAUGE_BATTERY_SAVER,
- Pair.create(SettingsEnums.FIELD_BATTERY_SAVER_SCHEDULE_TYPE,
- scheduleType),
- Pair.create(SettingsEnums.FIELD_BATTERY_SAVER_PERCENTAGE_VALUE,
- schedulePercentage));
+ .action(SettingsEnums.FUELGAUGE_BATTERY_SAVER,
+ SettingsEnums.FIELD_BATTERY_SAVER_SCHEDULE_TYPE,
+ SettingsEnums.FIELD_BATTERY_SAVER_PERCENTAGE_VALUE,
+ currentSaverScheduleKey,
+ currentSaverPercentage);
}
private int getSaverPercentage() {
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
index 25eca7adb22..da17f1143bb 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
@@ -455,10 +455,13 @@ public class ManageApplicationsTest {
ManageApplications.ApplicationsAdapter adapter = new ManageApplications.ApplicationsAdapter(
mState, mFragment, mock(AppFilterItem.class), mock(Bundle.class));
- adapter.rebuild(mSortRecent.getItemId());
+ adapter.rebuild(mSortRecent.getItemId(), false);
assertThat(mFragment.mSortOrder).isEqualTo(mSortRecent.getItemId());
- adapter.rebuild(mSortFrequent.getItemId());
+ adapter.rebuild(mSortFrequent.getItemId(), false);
+ assertThat(mFragment.mSortOrder).isEqualTo(mSortFrequent.getItemId());
+
+ adapter.rebuild(mSortFrequent.getItemId(), true);
assertThat(mFragment.mSortOrder).isEqualTo(mSortFrequent.getItemId());
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSettingsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSettingsTest.java
index afd7f66d56b..5c24da9aedb 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleSettingsTest.java
@@ -43,22 +43,22 @@ public final class BatterySaverScheduleSettingsTest {
@Test
public void onPause_withNoScheduleType_logExpectedData() {
- setSchedule(PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE, 0);
+ int expectedPercentage = 0;
+ setSchedule(PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE, expectedPercentage);
mBatterySaverScheduleSettings.onPause();
- verifySchedule(SettingsEnums.BATTERY_SAVER_SCHEDULE_TYPE_NO_SCHEDULE,
- /* schedulePercentage= */ -1);
+ verifySchedule("key_battery_saver_no_schedule", expectedPercentage);
}
@Test
public void onPause_withRoutineScheduleType_logExpectedData() {
- setSchedule(PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC, 0);
+ int expectedPercentage = 0;
+ setSchedule(PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC, expectedPercentage);
mBatterySaverScheduleSettings.onPause();
- verifySchedule(SettingsEnums.BATTERY_SAVER_SCHEDULE_TYPE_BASED_ON_ROUTINE,
- /* schedulePercentage= */ -1);
+ verifySchedule("key_battery_saver_routine", expectedPercentage);
}
@Test
@@ -68,8 +68,7 @@ public final class BatterySaverScheduleSettingsTest {
mBatterySaverScheduleSettings.onPause();
- verifySchedule(SettingsEnums.BATTERY_SAVER_SCHEDULE_TYPE_BASED_ON_PERCENTAGE,
- expectedPercentage);
+ verifySchedule("key_battery_saver_percentage", expectedPercentage);
}
@Test
@@ -90,8 +89,7 @@ public final class BatterySaverScheduleSettingsTest {
mBatterySaverScheduleSettings.onPause();
- verifySchedule(SettingsEnums.BATTERY_SAVER_SCHEDULE_TYPE_BASED_ON_PERCENTAGE,
- expectedPercentage);
+ verifySchedule("key_battery_saver_percentage", expectedPercentage);
}
private void setSchedule(int scheduleType, int schedulePercentage) {
@@ -101,13 +99,12 @@ public final class BatterySaverScheduleSettingsTest {
Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, schedulePercentage);
}
- private void verifySchedule(int scheduleType, int schedulePercentage) {
+ private void verifySchedule(String scheduleTypeKey, int schedulePercentage) {
waitAWhile();
- verify(mMetricsFeatureProvider).action(mContext, SettingsEnums.FUELGAUGE_BATTERY_SAVER,
- Pair.create(SettingsEnums.FIELD_BATTERY_SAVER_SCHEDULE_TYPE,
- scheduleType),
- Pair.create(SettingsEnums.FIELD_BATTERY_SAVER_PERCENTAGE_VALUE,
- schedulePercentage));
+ verify(mMetricsFeatureProvider).action(SettingsEnums.FUELGAUGE_BATTERY_SAVER,
+ SettingsEnums.FIELD_BATTERY_SAVER_SCHEDULE_TYPE,
+ SettingsEnums.FIELD_BATTERY_SAVER_PERCENTAGE_VALUE,
+ scheduleTypeKey, schedulePercentage);
}
private void waitAWhile() {