Snap for 13010426 from 883070758b to 25Q2-release
Change-Id: Iae8883a58834464a01d44176e85f039d7d6a1f27
This commit is contained in:
@@ -513,14 +513,19 @@
|
||||
<string name="main_clear_button_text" product="default">Erase all data</string>
|
||||
<string name="usb_tethering_subtext" product="default">Share phone\u2019s internet connection via USB</string>
|
||||
<string name="usb_tethering_subtext" product="tablet">Share tablet\u2019s internet connection via USB</string>
|
||||
<!-- Bluetooth Tethering subtext [CHAR LIMIT=70]-->
|
||||
<string name="bluetooth_tethering_subtext" product="tablet">Share tablet\u2019s internet connection via Bluetooth</string>
|
||||
<string name="usb_tethering_subtext" product="device">Share device\u2019s internet connection via USB</string>
|
||||
<!-- Bluetooth Tethering subtext [CHAR LIMIT=70]-->
|
||||
<string name="bluetooth_tethering_subtext" product="default">Share phone\u2019s internet connection via Bluetooth</string>
|
||||
<!-- Bluetooth Tethering subtext for tablet [CHAR LIMIT=70]-->
|
||||
<string name="bluetooth_tethering_subtext" product="tablet">Share tablet\u2019s internet connection via Bluetooth</string>
|
||||
<!-- Bluetooth Tethering subtext for generic device [CHAR LIMIT=70]-->
|
||||
<string name="bluetooth_tethering_subtext" product="device">Share device\u2019s internet connection via Bluetooth</string>
|
||||
<!-- Ethernet Tethering subtext [CHAR LIMIT=NONE]-->
|
||||
<string name="ethernet_tethering_subtext" product="default">Share phone\u2019s internet connection via Ethernet</string>
|
||||
<!-- Ethernet Tethering subtext for tablet [CHAR LIMIT=NONE]-->
|
||||
<string name="ethernet_tethering_subtext" product="tablet">Share tablet\u2019s internet connection via Ethernet</string>
|
||||
<!-- Ethernet Tethering subtext for generic device [CHAR LIMIT=NONE]-->
|
||||
<string name="ethernet_tethering_subtext" product="device">Share device\u2019s internet connection via Ethernet</string>
|
||||
<!-- Main settings screen, setting title for the user to go into the About phone screen -->
|
||||
<string name="about_settings" product="tablet">About tablet</string>
|
||||
<!-- Main settings screen, setting title for the user to go into the About phone screen -->
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingTop="@dimen/search_bar_container_top_padding"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||
|
||||
@@ -87,6 +87,7 @@
|
||||
<dimen name="search_bar_padding_end_two_pane">24dp</dimen>
|
||||
<dimen name="search_bar_title_padding_start">-4dp</dimen>
|
||||
<dimen name="search_bar_title_padding_start_regular_two_pane">8dp</dimen>
|
||||
<dimen name="search_bar_container_top_padding">8dp</dimen>
|
||||
|
||||
<!-- Avatar -->
|
||||
<dimen name="avatar_length">48dp</dimen>
|
||||
|
||||
@@ -14079,7 +14079,7 @@
|
||||
<!-- Text for displaying when default account is set as local only [CHAR LIMIT=50] -->
|
||||
<string name="contacts_storage_local_account_summary">Device only</string>
|
||||
<!-- Text for displaying eligible account preference title [CHAR LIMIT=50] -->
|
||||
<string name="contacts_storage_account_title">Device and %1$s</string>
|
||||
<string name="contacts_storage_account_title">Device & %1$s</string>
|
||||
<!-- Text for add account selection message when no account has been added [CHAR LIMIT=100] -->
|
||||
<string name="contacts_storage_first_time_add_account_message">Add an account to get started</string>
|
||||
<!-- Text for account preference category title for contacts storage settings page [CHAR LIMIT=100] -->
|
||||
|
||||
@@ -190,9 +190,6 @@
|
||||
|
||||
<!-- Define this color for material design -->
|
||||
<item name="colorPrimaryVariant">@android:color/white</item>
|
||||
<!-- Workaround for E2E modification. -->
|
||||
<!-- TODO (b/328622648) waiting for new method instead of this attribute. -->
|
||||
<item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Settings.Home" parent="Theme.Settings.HomeBase">
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.search.SearchIndexableRaw;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Preference controller for accessibility button preference.
|
||||
@@ -67,7 +68,8 @@ public class AccessibilityButtonPreferenceController extends BasePreferenceContr
|
||||
} else {
|
||||
return mContext.getString(
|
||||
R.string.accessibility_shortcut_unassigned_setting_unavailable_summary,
|
||||
AccessibilityUtil.getShortcutSummaryList(mContext, SOFTWARE));
|
||||
AccessibilityUtil.getShortcutSummaryList(mContext, SOFTWARE)
|
||||
.toString().toLowerCase(Locale.getDefault()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ import androidx.preference.Preference;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Setting to allow the hardware shortcut to turn on from the lock screen
|
||||
*/
|
||||
@@ -87,7 +89,8 @@ public class HardwareShortcutFromLockscreenPreferenceController
|
||||
} else {
|
||||
return mContext.getString(
|
||||
R.string.accessibility_shortcut_unassigned_setting_unavailable_summary,
|
||||
AccessibilityUtil.getShortcutSummaryList(mContext, HARDWARE));
|
||||
AccessibilityUtil.getShortcutSummaryList(mContext, HARDWARE)
|
||||
.toString().toLowerCase(Locale.getDefault()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ public class HighContrastTextMigrationReceiver extends BroadcastReceiver {
|
||||
@VisibleForTesting
|
||||
static final String ACTION_OPEN_SETTINGS =
|
||||
"com.android.settings.accessibility.ACTION_OPEN_HIGH_CONTRAST_TEXT_SETTINGS";
|
||||
private static final String ACTION_NOTIFICATION_DISMISSED =
|
||||
"com.android.settings.accessibility.ACTION_HIGH_CONTRAST_TEXT_NOTIFICATION_DISMISSED";
|
||||
@VisibleForTesting
|
||||
static final int NOTIFICATION_ID = R.string.accessibility_notification_high_contrast_text_title;
|
||||
|
||||
@@ -87,6 +89,8 @@ public class HighContrastTextMigrationReceiver extends BroadcastReceiver {
|
||||
context.startActivity(settingsIntent);
|
||||
|
||||
context.getSystemService(NotificationManager.class).cancel(NOTIFICATION_ID);
|
||||
} else if (ACTION_NOTIFICATION_DISMISSED.equals(intent.getAction())) {
|
||||
Counter.logIncrement("accessibility.value_hct_notification_dismissed");
|
||||
} else if (ACTION_RESTORED.equals(intent.getAction())) {
|
||||
Log.i(TAG, "HCT attempted to be restored from backup; showing notification for userId: "
|
||||
+ context.getUserId());
|
||||
@@ -159,6 +163,13 @@ public class HighContrastTextMigrationReceiver extends BroadcastReceiver {
|
||||
.addAction(settingsAction)
|
||||
.setAutoCancel(true);
|
||||
}
|
||||
|
||||
Intent deleteIntent = new Intent(context, HighContrastTextMigrationReceiver.class);
|
||||
deleteIntent.setAction(ACTION_NOTIFICATION_DISMISSED);
|
||||
PendingIntent deletePendingIntent = PendingIntent.getBroadcast(context, 0,
|
||||
deleteIntent, PendingIntent.FLAG_IMMUTABLE);
|
||||
notificationBuilder.setDeleteIntent(deletePendingIntent);
|
||||
|
||||
NotificationManager notificationManager =
|
||||
context.getSystemService(NotificationManager.class);
|
||||
NotificationChannel notificationChannel = new NotificationChannel(
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2025 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.biometrics;
|
||||
|
||||
import android.safetycenter.SafetySourceIssue;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public interface BiometricsFeatureProvider {
|
||||
|
||||
/** Returns a SafetySourceIssue for biometrics. */
|
||||
@Nullable
|
||||
SafetySourceIssue getSafetySourceIssue(@NonNull String sourceId);
|
||||
|
||||
/** Notifies that the action of an issue is launched */
|
||||
void notifySafetyIssueActionLaunched();
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2025 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.biometrics;
|
||||
|
||||
import android.safetycenter.SafetySourceIssue;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class BiometricsFeatureProviderImpl implements BiometricsFeatureProvider {
|
||||
@Nullable
|
||||
@Override
|
||||
public SafetySourceIssue getSafetySourceIssue(@NonNull String sourceId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifySafetyIssueActionLaunched() {}
|
||||
}
|
||||
@@ -25,7 +25,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.Uri;
|
||||
import android.provider.SettingsSlicesContract;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.graphics.drawable.IconCompat;
|
||||
@@ -37,6 +36,7 @@ import androidx.slice.builders.SliceAction;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SubSettings;
|
||||
import com.android.settings.connecteddevice.BluetoothDashboardFragment;
|
||||
import com.android.settings.contract.SettingsContractKt;
|
||||
import com.android.settings.network.SatelliteRepository;
|
||||
import com.android.settings.slices.CustomSliceRegistry;
|
||||
import com.android.settings.slices.SliceBroadcastReceiver;
|
||||
@@ -118,7 +118,7 @@ public class BluetoothSliceBuilder {
|
||||
public static Intent getIntent(Context context) {
|
||||
final String screenTitle = context.getText(R.string.bluetooth_settings_title).toString();
|
||||
final Uri contentUri = new Uri.Builder().appendPath(
|
||||
SettingsSlicesContract.KEY_BLUETOOTH).build();
|
||||
SettingsContractKt.KEY_BLUETOOTH).build();
|
||||
return SliceBuilderUtils.buildSearchResultPageIntent(context,
|
||||
BluetoothDashboardFragment.class.getName(), null /* key */, screenTitle,
|
||||
SettingsEnums.SETTINGS_CONNECTED_DEVICE_CATEGORY,
|
||||
|
||||
@@ -452,17 +452,38 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen
|
||||
var pref = getDisplayPreference(context, display, groupCleanable);
|
||||
pref.setSummary(display.getMode().getPhysicalWidth() + " x "
|
||||
+ display.getMode().getPhysicalHeight());
|
||||
pref.setTitle(display.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Preference getDisplayPreference(@NonNull Context context,
|
||||
@NonNull Display display, @NonNull PrefRefresh groupCleanable) {
|
||||
var pref = groupCleanable.findUnusedPreference(DisplayPreference.generateKey(display));
|
||||
pref = pref != null ? pref : new DisplayPreference(context, display);
|
||||
groupCleanable.addPreference(pref);
|
||||
return pref;
|
||||
var itemKey = "display_id_" + display.getDisplayId();
|
||||
var categoryKey = itemKey + "_category";
|
||||
var category = (PreferenceCategory) groupCleanable.findUnusedPreference(categoryKey);
|
||||
|
||||
if (category != null) {
|
||||
groupCleanable.addPreference(category);
|
||||
return category.findPreference(itemKey);
|
||||
} else {
|
||||
category = new PreferenceCategory(context);
|
||||
category.setPersistent(false);
|
||||
category.setKey(categoryKey);
|
||||
// Must add the category to the hierarchy before adding its descendants. Otherwise
|
||||
// the category will not have a preference manager, which causes an exception when a
|
||||
// child is added to it.
|
||||
groupCleanable.addPreference(category);
|
||||
|
||||
var prefItem = new DisplayPreference(context, display);
|
||||
prefItem.setTitle(context.getString(EXTERNAL_DISPLAY_RESOLUTION_TITLE_RESOURCE)
|
||||
+ " | " + context.getString(EXTERNAL_DISPLAY_ROTATION_TITLE_RESOURCE));
|
||||
prefItem.setKey(itemKey);
|
||||
|
||||
category.addPreference(prefItem);
|
||||
category.setTitle(display.getName());
|
||||
|
||||
return prefItem;
|
||||
}
|
||||
}
|
||||
|
||||
private List<Display> externalDisplaysToShow(int displayIdToShow) {
|
||||
@@ -621,16 +642,11 @@ public class ExternalDisplayPreferenceFragment extends SettingsPreferenceFragmen
|
||||
implements Preference.OnPreferenceClickListener {
|
||||
private final int mDisplayId;
|
||||
|
||||
static String generateKey(final Display display) {
|
||||
return "display_id_" + display.getDisplayId();
|
||||
}
|
||||
|
||||
DisplayPreference(@NonNull final Context context, @NonNull final Display display) {
|
||||
super(context);
|
||||
mDisplayId = display.getDisplayId();
|
||||
|
||||
setPersistent(false);
|
||||
setKey(generateKey(display));
|
||||
setOnPreferenceClickListener(this);
|
||||
}
|
||||
|
||||
|
||||
37
src/com/android/settings/contract/SettingsContract.kt
Normal file
37
src/com/android/settings/contract/SettingsContract.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2025 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.contract
|
||||
|
||||
import android.provider.SettingsSlicesContract
|
||||
|
||||
/** Contract key for the "Airplane Mode" setting. */
|
||||
const val KEY_AIRPLANE_MODE = SettingsSlicesContract.KEY_AIRPLANE_MODE
|
||||
|
||||
/** Contract key for the "Battery Saver" setting. */
|
||||
const val KEY_BATTERY_SAVER = SettingsSlicesContract.KEY_BATTERY_SAVER
|
||||
|
||||
/** Contract key for the "Bluetooth" setting. */
|
||||
const val KEY_BLUETOOTH = SettingsSlicesContract.KEY_BLUETOOTH
|
||||
|
||||
/** Contract key for the "Location" setting. */
|
||||
const val KEY_LOCATION = SettingsSlicesContract.KEY_LOCATION
|
||||
|
||||
/** Contract key for the "Wi-fi" setting. */
|
||||
const val KEY_WIFI = SettingsSlicesContract.KEY_WIFI
|
||||
|
||||
/** Contract key for the "Use Data Saver" setting. */
|
||||
const val KEY_DATA_SAVER = "data_saver"
|
||||
@@ -17,8 +17,11 @@
|
||||
package com.android.settings.datausage
|
||||
|
||||
import android.Manifest
|
||||
import android.app.settings.SettingsEnums.ACTION_DATA_SAVER_MODE
|
||||
import android.content.Context
|
||||
import com.android.settings.PreferenceActionMetricsProvider
|
||||
import com.android.settings.R
|
||||
import com.android.settings.contract.KEY_DATA_SAVER
|
||||
import com.android.settings.widget.MainSwitchBarMetadata
|
||||
import com.android.settingslib.datastore.AbstractKeyedDataObservable
|
||||
import com.android.settingslib.datastore.KeyValueStore
|
||||
@@ -28,7 +31,8 @@ import com.android.settingslib.metadata.PreferenceLifecycleProvider
|
||||
import com.android.settingslib.metadata.ReadWritePermit
|
||||
import com.android.settingslib.metadata.SensitivityLevel
|
||||
|
||||
class DataSaverMainSwitchPreference : MainSwitchBarMetadata, PreferenceLifecycleProvider {
|
||||
class DataSaverMainSwitchPreference :
|
||||
MainSwitchBarMetadata, PreferenceActionMetricsProvider, PreferenceLifecycleProvider {
|
||||
|
||||
override val key
|
||||
get() = KEY
|
||||
@@ -39,6 +43,11 @@ class DataSaverMainSwitchPreference : MainSwitchBarMetadata, PreferenceLifecycle
|
||||
override val disableWidgetOnCheckedChanged: Boolean
|
||||
get() = false
|
||||
|
||||
override val preferenceActionMetrics: Int
|
||||
get() = ACTION_DATA_SAVER_MODE
|
||||
|
||||
override fun tags(context: Context) = arrayOf(KEY_DATA_SAVER)
|
||||
|
||||
override fun storage(context: Context) = createDataStore(context)
|
||||
|
||||
override fun getReadPermissions(context: Context) =
|
||||
|
||||
@@ -80,13 +80,14 @@ public class BatteryHeaderTextPreferenceController extends BasePreferenceControl
|
||||
}
|
||||
if (BatteryUtils.isBatteryDefenderOn(info)
|
||||
|| FeatureFactory.getFeatureFactory()
|
||||
.getPowerUsageFeatureProvider()
|
||||
.isExtraDefend()) {
|
||||
.getPowerUsageFeatureProvider()
|
||||
.isExtraDefend()) {
|
||||
return mContext.getString(
|
||||
com.android.settingslib.R.string.battery_info_status_charging_on_hold);
|
||||
}
|
||||
if (info.remainingLabel != null
|
||||
&& mBatterySettingsFeatureProvider.isChargingOptimizationMode(mContext)) {
|
||||
&& mBatterySettingsFeatureProvider.isChargingOptimizationMode(
|
||||
mContext, info.isLongLife)) {
|
||||
return info.remainingLabel;
|
||||
}
|
||||
if (info.batteryStatus == BatteryManager.BATTERY_STATUS_NOT_CHARGING) {
|
||||
@@ -97,8 +98,8 @@ public class BatteryHeaderTextPreferenceController extends BasePreferenceControl
|
||||
mBatterySettingsFeatureProvider.getWirelessChargingLabel(mContext, info);
|
||||
if (mBatteryHeaderTextPreference != null && wirelessChargingLabel != null) {
|
||||
mBatteryHeaderTextPreference.setContentDescription(
|
||||
mBatterySettingsFeatureProvider
|
||||
.getWirelessChargingContentDescription(mContext, info));
|
||||
mBatterySettingsFeatureProvider.getWirelessChargingContentDescription(
|
||||
mContext, info));
|
||||
return wirelessChargingLabel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ public class BatteryInfo {
|
||||
}
|
||||
final BatterySettingsFeatureProvider featureProvider =
|
||||
FeatureFactory.getFeatureFactory().getBatterySettingsFeatureProvider();
|
||||
if (featureProvider.isChargingOptimizationMode(context)) {
|
||||
if (featureProvider.isChargingOptimizationMode(context, info.isLongLife)) {
|
||||
final CharSequence chargeLabel =
|
||||
featureProvider.getChargingOptimizationChargeLabel(
|
||||
context,
|
||||
@@ -567,10 +567,11 @@ public class BatteryInfo {
|
||||
|
||||
private static boolean isPluggedIn(Context context, boolean isCharging, int chargingPolicy) {
|
||||
return isCharging
|
||||
|| (chargingPolicy == BatteryManager.CHARGING_POLICY_ADAPTIVE_LONGLIFE
|
||||
&& FeatureFactory.getFeatureFactory()
|
||||
.getBatterySettingsFeatureProvider()
|
||||
.isChargingOptimizationMode(context));
|
||||
|| FeatureFactory.getFeatureFactory()
|
||||
.getBatterySettingsFeatureProvider()
|
||||
.isChargingOptimizationMode(
|
||||
context,
|
||||
chargingPolicy == BatteryManager.CHARGING_POLICY_ADAPTIVE_LONGLIFE);
|
||||
}
|
||||
|
||||
public interface BatteryDataParser {
|
||||
|
||||
@@ -60,7 +60,7 @@ public interface BatterySettingsFeatureProvider {
|
||||
@NonNull Context context, long remainingTimeMs, long currentTimeMs);
|
||||
|
||||
/** Return true if it's in the charging optimization mode. */
|
||||
boolean isChargingOptimizationMode(@NonNull Context context);
|
||||
boolean isChargingOptimizationMode(@NonNull Context context, boolean isLongLife);
|
||||
|
||||
/** Return a charging remaining time label for charging optimization mode. */
|
||||
@Nullable
|
||||
|
||||
@@ -76,7 +76,7 @@ public class BatterySettingsFeatureProviderImpl implements BatterySettingsFeatur
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChargingOptimizationMode(@NonNull Context context) {
|
||||
public boolean isChargingOptimizationMode(@NonNull Context context, boolean isLongLife) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -161,7 +161,8 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle
|
||||
}
|
||||
final BatterySettingsFeatureProvider featureProvider =
|
||||
FeatureFactory.getFeatureFactory().getBatterySettingsFeatureProvider();
|
||||
if (info.chargeLabel != null && featureProvider.isChargingOptimizationMode(mContext)) {
|
||||
if (info.chargeLabel != null
|
||||
&& featureProvider.isChargingOptimizationMode(mContext, info.isLongLife)) {
|
||||
return info.chargeLabel;
|
||||
}
|
||||
if (info.batteryStatus == BatteryManager.BATTERY_STATUS_NOT_CHARGING) {
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.provider.SettingsSlicesContract;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.contract.SettingsContractKt;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settings.fuelgauge.BatterySaverReceiver;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
@@ -73,7 +74,7 @@ public class BatterySaverButtonPreferenceController extends TogglePreferenceCont
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSlicesContract.AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(SettingsSlicesContract.KEY_BATTERY_SAVER)
|
||||
.appendPath(SettingsContractKt.KEY_BATTERY_SAVER)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -395,9 +395,18 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(android.R.id.content),
|
||||
(v, windowInsets) -> {
|
||||
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()
|
||||
| WindowInsetsCompat.Type.displayCutout());
|
||||
// Apply the insets paddings to the view.
|
||||
v.setPadding(insets.left, insets.top, insets.right, insets.bottom);
|
||||
v.setPadding(insets.left, 0, insets.right, insets.bottom);
|
||||
|
||||
// reset the top padding of search bar container to original top padding
|
||||
// plus insets top.
|
||||
View container = findViewById(R.id.app_bar_container);
|
||||
final int top_padding = getResources().getDimensionPixelSize(
|
||||
R.dimen.search_bar_container_top_padding);
|
||||
container.setPadding(container.getPaddingLeft(), top_padding + insets.top,
|
||||
container.getPaddingRight(), container.getPaddingBottom());
|
||||
|
||||
// Return CONSUMED if you don't want the window insets to keep being
|
||||
// passed down to descendant views.
|
||||
@@ -466,8 +475,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
||||
: Utils.getColorAttrDefaultColor(this, android.R.attr.colorBackground);
|
||||
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
// Update status bar color
|
||||
window.setStatusBarColor(color);
|
||||
|
||||
// Update content background.
|
||||
findViewById(android.R.id.content).setBackgroundColor(color);
|
||||
if (Flags.homepageRevamp()) {
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
package com.android.settings.location;
|
||||
|
||||
import static android.provider.SettingsSlicesContract.KEY_LOCATION;
|
||||
|
||||
import static androidx.slice.builders.ListBuilder.ICON_IMAGE;
|
||||
|
||||
import static com.android.settings.contract.SettingsContractKt.KEY_LOCATION;
|
||||
|
||||
import android.annotation.ColorInt;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.settings.SettingsEnums;
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.android.settings.PreferenceActionMetricsProvider
|
||||
import com.android.settings.PreferenceRestrictionMixin
|
||||
import com.android.settings.R
|
||||
import com.android.settings.Utils
|
||||
import com.android.settings.contract.KEY_AIRPLANE_MODE
|
||||
import com.android.settings.network.SatelliteRepository.Companion.isSatelliteOn
|
||||
import com.android.settingslib.RestrictedSwitchPreference
|
||||
import com.android.settingslib.datastore.AbstractKeyedDataObservable
|
||||
@@ -59,6 +60,8 @@ class AirplaneModePreference :
|
||||
override val icon: Int
|
||||
@DrawableRes get() = R.drawable.ic_airplanemode_active
|
||||
|
||||
override fun tags(context: Context) = arrayOf(KEY_AIRPLANE_MODE)
|
||||
|
||||
override fun isAvailable(context: Context) =
|
||||
(context.resources.getBoolean(R.bool.config_show_toggle_airplane) &&
|
||||
!context.packageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK))
|
||||
|
||||
@@ -37,6 +37,7 @@ import androidx.preference.TwoStatePreference;
|
||||
import com.android.settings.AirplaneModeEnabler;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.contract.SettingsContractKt;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnDestroy;
|
||||
@@ -64,7 +65,7 @@ public class AirplaneModePreferenceController extends TogglePreferenceController
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSlicesContract.AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(SettingsSlicesContract.KEY_AIRPLANE_MODE)
|
||||
.appendPath(SettingsContractKt.KEY_AIRPLANE_MODE)
|
||||
.build();
|
||||
|
||||
private Fragment mFragment;
|
||||
|
||||
@@ -72,8 +72,7 @@ public class CellularSecurityPreferenceController extends BasePreferenceControll
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)
|
||||
|| !Flags.enableModemCipherTransparencyUnsolEvents()
|
||||
|| !Flags.enableModemCipherTransparency()) {
|
||||
|| !Flags.enableModemCipherTransparencyUnsolEvents()) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
if (mTelephonyManager == null) {
|
||||
|
||||
@@ -924,6 +924,9 @@ public class NetworkProviderSettings extends RestrictedDashboardFragment
|
||||
|
||||
@Override
|
||||
public void onWifiEntriesChanged(@WifiPickerTracker.WifiEntriesChangedReason int reason) {
|
||||
if (isFinishingOrDestroyed()) {
|
||||
return;
|
||||
}
|
||||
updateWifiEntryPreferences();
|
||||
if (reason == WifiPickerTracker.WIFI_ENTRIES_CHANGED_REASON_SCAN_RESULTS) {
|
||||
setProgressBarVisible(false);
|
||||
|
||||
@@ -60,8 +60,7 @@ public class CellularSecurityNotificationsDividerController extends
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (!Flags.enableModemCipherTransparencyUnsolEvents()
|
||||
|| !Flags.enableModemCipherTransparency()) {
|
||||
if (!Flags.enableModemCipherTransparencyUnsolEvents()) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
if (!isSafetyCenterSupported()) {
|
||||
|
||||
@@ -178,8 +178,7 @@ public class CellularSecurityNotificationsPreferenceController extends
|
||||
}
|
||||
|
||||
private boolean areFlagsEnabled() {
|
||||
if (!Flags.enableModemCipherTransparencyUnsolEvents()
|
||||
|| !Flags.enableModemCipherTransparency()) {
|
||||
if (!Flags.enableModemCipherTransparencyUnsolEvents()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -28,17 +28,18 @@ import android.os.Message;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.DefaultLifecycleObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
/**
|
||||
* Update notification volume icon in Settings in response to user adjusting volume.
|
||||
*/
|
||||
public class NotificationVolumePreferenceController extends
|
||||
RingerModeAffectedVolumePreferenceController {
|
||||
RingerModeAffectedVolumePreferenceController implements DefaultLifecycleObserver {
|
||||
|
||||
private static final String KEY_NOTIFICATION_VOLUME = "notification_volume";
|
||||
private static final String TAG = "NotificationVolumePreferenceController";
|
||||
@@ -80,17 +81,13 @@ public class NotificationVolumePreferenceController extends
|
||||
updateEnabledState();
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
public void onResume(@NonNull LifecycleOwner owner) {
|
||||
mReceiver.register(true);
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
public void onPause(@NonNull LifecycleOwner owner) {
|
||||
mReceiver.register(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,7 @@ public class RemoteVolumeSeekBarPreference extends VolumeSeekBarPreference {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
if (mSeekBar == null) return;
|
||||
protected void onBindViewHolder() {
|
||||
setContinuousUpdates(true);
|
||||
updateIconView();
|
||||
updateSuppressionText();
|
||||
|
||||
@@ -27,16 +27,17 @@ import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.DefaultLifecycleObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
/**
|
||||
* This slider represents both ring and notification
|
||||
*/
|
||||
public class RingVolumePreferenceController extends
|
||||
RingerModeAffectedVolumePreferenceController {
|
||||
RingerModeAffectedVolumePreferenceController implements DefaultLifecycleObserver {
|
||||
|
||||
private static final String KEY_RING_VOLUME = "ring_volume";
|
||||
private static final String TAG = "RingVolumePreferenceController";
|
||||
@@ -58,10 +59,8 @@ public class RingVolumePreferenceController extends
|
||||
updateRingerMode();
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
public void onResume(@NonNull LifecycleOwner owner) {
|
||||
mReceiver.register(true);
|
||||
updateEffectsSuppressor();
|
||||
selectPreferenceIconState();
|
||||
@@ -71,10 +70,8 @@ public class RingVolumePreferenceController extends
|
||||
}
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
public void onPause(@NonNull LifecycleOwner owner) {
|
||||
mReceiver.register(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,17 +27,18 @@ import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.DefaultLifecycleObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
/**
|
||||
* This slider is used to represent ring volume when ring is separated from notification
|
||||
*/
|
||||
// LINT.IfChange
|
||||
public class SeparateRingVolumePreferenceController extends
|
||||
RingerModeAffectedVolumePreferenceController {
|
||||
RingerModeAffectedVolumePreferenceController implements DefaultLifecycleObserver {
|
||||
|
||||
private static final String KEY_SEPARATE_RING_VOLUME = "separate_ring_volume";
|
||||
private static final String TAG = "SeparateRingVolumePreferenceController";
|
||||
@@ -59,10 +60,8 @@ public class SeparateRingVolumePreferenceController extends
|
||||
updateRingerMode();
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
public void onResume(@NonNull LifecycleOwner owner) {
|
||||
mReceiver.register(true);
|
||||
updateEffectsSuppressor();
|
||||
selectPreferenceIconState();
|
||||
@@ -73,10 +72,8 @@ public class SeparateRingVolumePreferenceController extends
|
||||
}
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
public void onPause(@NonNull LifecycleOwner owner) {
|
||||
mReceiver.register(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ import com.android.settings.widget.UpdatableListPreferenceDialogFragment;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.instrumentation.Instrumentable;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.preference.UtilsKt;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -113,14 +114,12 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult
|
||||
if (phoneRingTonePreference != null && openPhoneRingtonePicker) {
|
||||
onPreferenceTreeClick(phoneRingTonePreference);
|
||||
}
|
||||
if (isCatalystEnabled()) {
|
||||
for (String key : getPreferenceKeysInHierarchy()) {
|
||||
Preference preference = findPreference(key);
|
||||
if (preference instanceof VolumeSeekBarPreference) {
|
||||
((VolumeSeekBarPreference) preference).setCallback(mVolumeCallback);
|
||||
}
|
||||
UtilsKt.forEachRecursively(getPreferenceScreen(), preference -> {
|
||||
if (preference instanceof VolumeSeekBarPreference) {
|
||||
((VolumeSeekBarPreference) preference).setCallback(mVolumeCallback);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,22 +202,11 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
ArrayList<VolumeSeekBarPreferenceController> volumeControllers = new ArrayList<>();
|
||||
volumeControllers.add(use(AlarmVolumePreferenceController.class));
|
||||
volumeControllers.add(use(MediaVolumePreferenceController.class));
|
||||
volumeControllers.add(use(SeparateRingVolumePreferenceController.class));
|
||||
volumeControllers.add(use(NotificationVolumePreferenceController.class));
|
||||
volumeControllers.add(use(CallVolumePreferenceController.class));
|
||||
|
||||
use(HandsFreeProfileOutputPreferenceController.class).setCallback(listPreference ->
|
||||
onPreferenceDataChanged(listPreference));
|
||||
mHfpOutputControllerKey =
|
||||
use(HandsFreeProfileOutputPreferenceController.class).getPreferenceKey();
|
||||
|
||||
for (VolumeSeekBarPreferenceController controller : volumeControllers) {
|
||||
controller.setCallback(mVolumeCallback);
|
||||
getSettingsLifecycle().addObserver(controller);
|
||||
}
|
||||
}
|
||||
|
||||
// === Volumes ===
|
||||
|
||||
@@ -62,7 +62,6 @@ public class VolumeSeekBarPreference extends SeekBarPreference {
|
||||
private boolean mZenMuted;
|
||||
private int mIconResId;
|
||||
private int mMuteIconResId;
|
||||
private boolean mStopped;
|
||||
@VisibleForTesting
|
||||
AudioManager mAudioManager;
|
||||
private Locale mLocale;
|
||||
@@ -114,18 +113,13 @@ public class VolumeSeekBarPreference extends SeekBarPreference {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
public void onActivityResume() {
|
||||
if (mStopped) {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
public void onActivityPause() {
|
||||
mStopped = true;
|
||||
@Override
|
||||
public void onDetached() {
|
||||
if (mVolumizer != null) {
|
||||
mVolumizer.stop();
|
||||
mVolumizer = null;
|
||||
}
|
||||
super.onDetached();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,16 +129,25 @@ public class VolumeSeekBarPreference extends SeekBarPreference {
|
||||
mIconView = (ImageView) view.findViewById(com.android.internal.R.id.icon);
|
||||
mSuppressionTextView = (TextView) view.findViewById(R.id.suppression_text);
|
||||
mTitle = (TextView) view.findViewById(com.android.internal.R.id.title);
|
||||
init();
|
||||
onBindViewHolder();
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
if (mSeekBar == null) return;
|
||||
// It's unnecessary to set up relevant volumizer configuration if preference is disabled.
|
||||
if (!isEnabled()) {
|
||||
mSeekBar.setEnabled(false);
|
||||
return;
|
||||
protected void onBindViewHolder() {
|
||||
boolean isEnabled = isEnabled();
|
||||
mSeekBar.setEnabled(isEnabled);
|
||||
if (mVolumizer == null) {
|
||||
createSeekBarVolumizer();
|
||||
}
|
||||
mVolumizer.setSeekBar(mSeekBar);
|
||||
updateIconView();
|
||||
updateSuppressionText();
|
||||
if (isEnabled && mListener != null) {
|
||||
mListener.onUpdateMuteState();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullAway")
|
||||
protected void createSeekBarVolumizer() {
|
||||
final SeekBarVolumizer.Callback sbvc = new SeekBarVolumizer.Callback() {
|
||||
@Override
|
||||
public void onSampleStarting(SeekBarVolumizer sbv) {
|
||||
@@ -184,16 +187,8 @@ public class VolumeSeekBarPreference extends SeekBarPreference {
|
||||
}
|
||||
};
|
||||
final Uri sampleUri = mStream == AudioManager.STREAM_MUSIC ? getMediaVolumeUri() : null;
|
||||
if (mVolumizer == null) {
|
||||
mVolumizer = mSeekBarVolumizerFactory.create(mStream, sampleUri, sbvc);
|
||||
}
|
||||
mVolumizer = mSeekBarVolumizerFactory.create(mStream, sampleUri, sbvc);
|
||||
mVolumizer.start();
|
||||
mVolumizer.setSeekBar(mSeekBar);
|
||||
updateIconView();
|
||||
updateSuppressionText();
|
||||
if (mListener != null) {
|
||||
mListener.onUpdateMuteState();
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateIconView() {
|
||||
|
||||
@@ -19,22 +19,17 @@ package com.android.settings.notification;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.notification.VolumeSeekBarPreference.Callback;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
/**
|
||||
* Base class for preference controller that handles VolumeSeekBarPreference
|
||||
*/
|
||||
public abstract class VolumeSeekBarPreferenceController extends
|
||||
AdjustVolumeRestrictedPreferenceController implements LifecycleObserver {
|
||||
AdjustVolumeRestrictedPreferenceController {
|
||||
|
||||
protected VolumeSeekBarPreference mPreference;
|
||||
protected VolumeSeekBarPreference.Callback mVolumePreferenceCallback;
|
||||
protected AudioHelper mHelper;
|
||||
protected VolumeSeekBarPreference.Listener mVolumePreferenceListener;
|
||||
|
||||
@@ -48,10 +43,6 @@ public abstract class VolumeSeekBarPreferenceController extends
|
||||
mHelper = helper;
|
||||
}
|
||||
|
||||
public void setCallback(Callback callback) {
|
||||
mVolumePreferenceCallback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
@@ -62,26 +53,11 @@ public abstract class VolumeSeekBarPreferenceController extends
|
||||
|
||||
protected void setupVolPreference(PreferenceScreen screen) {
|
||||
mPreference = screen.findPreference(getPreferenceKey());
|
||||
mPreference.setCallback(mVolumePreferenceCallback);
|
||||
mPreference.setListener(mVolumePreferenceListener);
|
||||
mPreference.setStream(getAudioStream());
|
||||
mPreference.setMuteIcon(getMuteIcon());
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
||||
public void onResume() {
|
||||
if (mPreference != null) {
|
||||
mPreference.onActivityResume();
|
||||
}
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
||||
public void onPause() {
|
||||
if (mPreference != null) {
|
||||
mPreference.onActivityPause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliceHighlightMenuRes() {
|
||||
return R.string.menu_key_sound;
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider
|
||||
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider
|
||||
import com.android.settings.accounts.AccountFeatureProvider
|
||||
import com.android.settings.applications.ApplicationFeatureProvider
|
||||
import com.android.settings.biometrics.BiometricsFeatureProvider
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider
|
||||
@@ -107,6 +108,11 @@ abstract class FeatureFactory {
|
||||
*/
|
||||
abstract val bluetoothFeatureProvider: BluetoothFeatureProvider
|
||||
|
||||
/**
|
||||
* Retrieves implementation for Biometrics feature.
|
||||
*/
|
||||
abstract val biometricsFeatureProvider: BiometricsFeatureProvider
|
||||
|
||||
/**
|
||||
* Retrieves implementation for Face feature.
|
||||
*/
|
||||
|
||||
@@ -27,6 +27,8 @@ import com.android.settings.accessibility.AccessibilitySearchFeatureProviderImpl
|
||||
import com.android.settings.accounts.AccountFeatureProvider
|
||||
import com.android.settings.accounts.AccountFeatureProviderImpl
|
||||
import com.android.settings.applications.ApplicationFeatureProviderImpl
|
||||
import com.android.settings.biometrics.BiometricsFeatureProvider
|
||||
import com.android.settings.biometrics.BiometricsFeatureProviderImpl
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider
|
||||
import com.android.settings.biometrics.face.FaceFeatureProviderImpl
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider
|
||||
@@ -145,6 +147,10 @@ open class FeatureFactoryImpl : FeatureFactory() {
|
||||
BluetoothFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override val biometricsFeatureProvider: BiometricsFeatureProvider by lazy {
|
||||
BiometricsFeatureProviderImpl()
|
||||
}
|
||||
|
||||
override val faceFeatureProvider: FaceFeatureProvider by lazy { FaceFeatureProviderImpl() }
|
||||
|
||||
override val fingerprintFeatureProvider: FingerprintFeatureProvider by lazy {
|
||||
|
||||
@@ -154,7 +154,7 @@ public abstract class RegionPickerBaseListPreferenceController extends BasePrefe
|
||||
|
||||
private List<LocaleStore.LocaleInfo> getSortedLocaleList(
|
||||
List<LocaleStore.LocaleInfo> localeInfos) {
|
||||
final Locale sortingLocale = Locale.getDefault();
|
||||
final Locale sortingLocale = LocaleList.getDefault().get(0);
|
||||
final LocaleHelper.LocaleInfoComparator comp =
|
||||
new LocaleHelper.LocaleInfoComparator(sortingLocale, true);
|
||||
Collections.sort(localeInfos, comp);
|
||||
@@ -162,7 +162,7 @@ public abstract class RegionPickerBaseListPreferenceController extends BasePrefe
|
||||
}
|
||||
|
||||
private void switchRegion(LocaleStore.LocaleInfo localeInfo) {
|
||||
if (localeInfo.getLocale().equals(Locale.getDefault())) {
|
||||
if (localeInfo.getLocale().equals(LocaleList.getDefault().get(0))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.safetycenter.SafetyEvent;
|
||||
import android.safetycenter.SafetySourceData;
|
||||
import android.safetycenter.SafetySourceIssue;
|
||||
import android.safetycenter.SafetySourceStatus;
|
||||
|
||||
/** Static helpers for setting SafetyCenter data for biometric safety sources. */
|
||||
@@ -42,6 +43,30 @@ public final class BiometricSourcesUtils {
|
||||
boolean enabled,
|
||||
boolean hasEnrolled,
|
||||
SafetyEvent safetyEvent) {
|
||||
setBiometricSafetySourceData(
|
||||
safetySourceId,
|
||||
context,
|
||||
title,
|
||||
summary,
|
||||
pendingIntent,
|
||||
enabled,
|
||||
hasEnrolled,
|
||||
safetyEvent,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/** Sets data for one of the biometrics sources */
|
||||
public static void setBiometricSafetySourceData(
|
||||
String safetySourceId,
|
||||
Context context,
|
||||
String title,
|
||||
String summary,
|
||||
PendingIntent pendingIntent,
|
||||
boolean enabled,
|
||||
boolean hasEnrolled,
|
||||
SafetyEvent safetyEvent,
|
||||
SafetySourceIssue safetySourceIssue) {
|
||||
int severityLevel =
|
||||
enabled && hasEnrolled
|
||||
? SafetySourceData.SEVERITY_LEVEL_INFORMATION
|
||||
@@ -52,8 +77,13 @@ public final class BiometricSourcesUtils {
|
||||
.setPendingIntent(pendingIntent)
|
||||
.setEnabled(enabled)
|
||||
.build();
|
||||
SafetySourceData safetySourceData =
|
||||
new SafetySourceData.Builder().setStatus(status).build();
|
||||
|
||||
SafetySourceData.Builder builder = new SafetySourceData.Builder().setStatus(status);
|
||||
if (safetySourceIssue != null) {
|
||||
builder.addIssue(safetySourceIssue);
|
||||
}
|
||||
SafetySourceData safetySourceData = builder.build();
|
||||
|
||||
|
||||
SafetyCenterManagerWrapper.get()
|
||||
.setSafetySourceData(context, safetySourceId, safetySourceData, safetyEvent);
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.safetycenter.SafetyEvent;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricNavigationUtils;
|
||||
import com.android.settings.biometrics.face.FaceStatusUtils;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
|
||||
/** Face biometrics Safety Source for Safety Center. */
|
||||
@@ -87,7 +88,9 @@ public final class FaceSafetySource {
|
||||
REQUEST_CODE_FACE_SETTING),
|
||||
disablingAdmin == null /* enabled */,
|
||||
faceStatusUtils.hasEnrolled(),
|
||||
safetyEvent);
|
||||
safetyEvent,
|
||||
FeatureFactory.getFeatureFactory().getBiometricsFeatureProvider()
|
||||
.getSafetySourceIssue(SAFETY_SOURCE_ID));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.safetycenter.SafetyEvent;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricNavigationUtils;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintStatusUtils;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
|
||||
/** Fingerprint biometrics Safety Source for Safety Center. */
|
||||
@@ -89,7 +90,9 @@ public final class FingerprintSafetySource {
|
||||
REQUEST_CODE_FINGERPRINT_SETTING),
|
||||
disablingAdmin == null /* enabled */,
|
||||
fingerprintStatusUtils.hasEnrolled(),
|
||||
safetyEvent);
|
||||
safetyEvent,
|
||||
FeatureFactory.getFeatureFactory().getBiometricsFeatureProvider()
|
||||
.getSafetySourceIssue(SAFETY_SOURCE_ID));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
package com.android.settings.slices;
|
||||
|
||||
import static android.provider.SettingsSlicesContract.KEY_LOCATION;
|
||||
import static android.provider.SettingsSlicesContract.KEY_WIFI;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.net.Uri;
|
||||
import android.provider.SettingsSlicesContract;
|
||||
@@ -26,6 +23,7 @@ import android.util.ArrayMap;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.contract.SettingsContractKt;
|
||||
import com.android.settings.display.AlwaysOnDisplaySlice;
|
||||
import com.android.settings.display.ScreenTimeoutPreferenceController;
|
||||
import com.android.settings.flashlight.FlashlightSlice;
|
||||
@@ -68,7 +66,7 @@ public class CustomSliceRegistry {
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSlicesContract.AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(SettingsSlicesContract.KEY_BLUETOOTH)
|
||||
.appendPath(SettingsContractKt.KEY_BLUETOOTH)
|
||||
.build();
|
||||
|
||||
/**
|
||||
@@ -115,7 +113,7 @@ public class CustomSliceRegistry {
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSlicesContract.AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(KEY_LOCATION)
|
||||
.appendPath(SettingsContractKt.KEY_LOCATION)
|
||||
.build();
|
||||
/**
|
||||
* Backing Uri for Low storage Slice.
|
||||
@@ -240,7 +238,7 @@ public class CustomSliceRegistry {
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSlicesContract.AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(KEY_WIFI)
|
||||
.appendPath(SettingsContractKt.KEY_WIFI)
|
||||
.build();
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package com.android.settings.wifi.slice;
|
||||
|
||||
import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
|
||||
import static android.provider.SettingsSlicesContract.KEY_WIFI;
|
||||
|
||||
import static com.android.settings.contract.SettingsContractKt.KEY_WIFI;
|
||||
import static com.android.settings.slices.CustomSliceRegistry.WIFI_SLICE_URI;
|
||||
import static com.android.settingslib.wifi.WifiUtils.getHotspotIconResource;
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.ContactsContract;
|
||||
import android.provider.ContactsContract.RawContacts.DefaultAccount.DefaultAccountAndState;
|
||||
import android.provider.SearchIndexableResource;
|
||||
@@ -250,13 +249,13 @@ public class ContactsStorageSettingsTest {
|
||||
|
||||
SelectorWithWidgetPreference account1Preference = accountCategory.findPreference(
|
||||
String.valueOf(TEST_ACCOUNT1.hashCode()));
|
||||
assertThat(account1Preference.getTitle()).isEqualTo("Device and Google");
|
||||
assertThat(account1Preference.getTitle()).isEqualTo("Device & Google");
|
||||
assertThat(account1Preference.getSummary()).isEqualTo("test@gmail.com");
|
||||
assertThat(account1Preference.getIcon()).isNotNull();
|
||||
|
||||
SelectorWithWidgetPreference account2Preference = accountCategory.findPreference(
|
||||
String.valueOf(TEST_ACCOUNT2.hashCode()));
|
||||
assertThat(account2Preference.getTitle()).isEqualTo("Device and Samsung");
|
||||
assertThat(account2Preference.getTitle()).isEqualTo("Device & Samsung");
|
||||
assertThat(account2Preference.getSummary()).isEqualTo("test@samsung.com");
|
||||
assertThat(account2Preference.getIcon()).isNotNull();
|
||||
|
||||
@@ -304,19 +303,19 @@ public class ContactsStorageSettingsTest {
|
||||
|
||||
SelectorWithWidgetPreference account1Preference = accountCategory.findPreference(
|
||||
String.valueOf(TEST_ACCOUNT1.hashCode()));
|
||||
assertThat(account1Preference.getTitle()).isEqualTo("Device and Google");
|
||||
assertThat(account1Preference.getTitle()).isEqualTo("Device & Google");
|
||||
assertThat(account1Preference.getSummary()).isEqualTo("test@gmail.com");
|
||||
assertThat(account1Preference.getIcon()).isNotNull();
|
||||
|
||||
SelectorWithWidgetPreference account2Preference = accountCategory.findPreference(
|
||||
String.valueOf(TEST_ACCOUNT2.hashCode()));
|
||||
assertThat(account2Preference.getTitle()).isEqualTo("Device and Samsung");
|
||||
assertThat(account2Preference.getTitle()).isEqualTo("Device & Samsung");
|
||||
assertThat(account2Preference.getSummary()).isEqualTo("test@samsung.com");
|
||||
assertThat(account2Preference.getIcon()).isNotNull();
|
||||
|
||||
SelectorWithWidgetPreference account3Preference = accountCategory.findPreference(
|
||||
String.valueOf(TEST_ACCOUNT3.hashCode()));
|
||||
assertThat(account3Preference.getTitle()).isEqualTo("Device and Outlook");
|
||||
assertThat(account3Preference.getTitle()).isEqualTo("Device & Outlook");
|
||||
assertThat(account3Preference.getSummary()).isEqualTo("test@outlook.com");
|
||||
assertThat(account3Preference.getIcon()).isNotNull();
|
||||
|
||||
@@ -374,13 +373,13 @@ public class ContactsStorageSettingsTest {
|
||||
// onAccountsUpdate should refresh the icon and layouts.
|
||||
SelectorWithWidgetPreference account1Preference = accountCategory.findPreference(
|
||||
String.valueOf(TEST_ACCOUNT1.hashCode()));
|
||||
assertThat(account1Preference.getTitle()).isEqualTo("Device and Google");
|
||||
assertThat(account1Preference.getTitle()).isEqualTo("Device & Google");
|
||||
assertThat(account1Preference.getSummary()).isEqualTo("test@gmail.com");
|
||||
assertThat(account1Preference.getIcon()).isNotNull();
|
||||
|
||||
SelectorWithWidgetPreference account2Preference = accountCategory.findPreference(
|
||||
String.valueOf(TEST_ACCOUNT2.hashCode()));
|
||||
assertThat(account2Preference.getTitle()).isEqualTo("Device and Samsung");
|
||||
assertThat(account2Preference.getTitle()).isEqualTo("Device & Samsung");
|
||||
assertThat(account2Preference.getSummary()).isEqualTo("test@samsung.com");
|
||||
assertThat(account2Preference.getIcon()).isNotNull();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.settings.fuelgauge;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -98,9 +99,7 @@ public class BatteryHeaderTextPreferenceControllerTest {
|
||||
mBatteryIntent.putExtra(BatteryManager.EXTRA_PLUGGED, 1);
|
||||
doReturn(mBatteryIntent).when(mContext).registerReceiver(any(), any());
|
||||
|
||||
doReturn(mBatteryHeaderTextPreference)
|
||||
.when(mPreferenceScreen)
|
||||
.findPreference(PREF_KEY);
|
||||
doReturn(mBatteryHeaderTextPreference).when(mPreferenceScreen).findPreference(PREF_KEY);
|
||||
|
||||
mBatteryInfo.batteryLevel = BATTERY_LEVEL;
|
||||
|
||||
@@ -322,7 +321,8 @@ public class BatteryHeaderTextPreferenceControllerTest {
|
||||
/* isFastCharging= */ true,
|
||||
/* isChargingStringV2= */ true);
|
||||
var expectedChargingString = batteryInfo.remainingLabel;
|
||||
when(mFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||
when(mFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(
|
||||
eq(mContext), anyBoolean()))
|
||||
.thenReturn(true);
|
||||
|
||||
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
||||
@@ -339,7 +339,8 @@ public class BatteryHeaderTextPreferenceControllerTest {
|
||||
/* isFastCharging= */ true,
|
||||
/* isChargingStringV2= */ true);
|
||||
var expectedChargingString = batteryInfo.statusLabel;
|
||||
when(mFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||
when(mFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(
|
||||
eq(mContext), anyBoolean()))
|
||||
.thenReturn(true);
|
||||
|
||||
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
||||
@@ -356,7 +357,8 @@ public class BatteryHeaderTextPreferenceControllerTest {
|
||||
/* isFastCharging= */ true,
|
||||
/* isChargingStringV2= */ true);
|
||||
var expectedChargingString = batteryInfo.statusLabel + " • " + batteryInfo.remainingLabel;
|
||||
when(mFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||
when(mFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(
|
||||
eq(mContext), anyBoolean()))
|
||||
.thenReturn(false);
|
||||
|
||||
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
||||
@@ -448,7 +450,9 @@ public class BatteryHeaderTextPreferenceControllerTest {
|
||||
|
||||
mController.updateHeaderPreference(mBatteryInfo);
|
||||
|
||||
verify(mBatteryHeaderTextPreference).setText(mContext.getString(
|
||||
verify(mBatteryHeaderTextPreference)
|
||||
.setText(
|
||||
mContext.getString(
|
||||
com.android.settingslib.R.string
|
||||
.battery_info_status_charging_on_hold));
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.settings.fuelgauge;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
@@ -729,7 +730,8 @@ public class BatteryInfoTest {
|
||||
ChargingType.WIRED, ChargingSpeed.REGULAR, /* batteryLevel= */ 65);
|
||||
var expectedRemainingLabel = "Expected remaining label";
|
||||
var expectedChargeLabel = "65% - " + expectedRemainingLabel;
|
||||
when(mFeatureFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||
when(mFeatureFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(
|
||||
eq(mContext), anyBoolean()))
|
||||
.thenReturn(true);
|
||||
when(mFeatureFactory.batterySettingsFeatureProvider.getChargingOptimizationRemainingLabel(
|
||||
eq(mContext), anyInt(), anyInt(), anyLong(), anyLong()))
|
||||
@@ -755,7 +757,8 @@ public class BatteryInfoTest {
|
||||
Intent batteryIntent =
|
||||
createIntentForGetBatteryInfoTest(
|
||||
ChargingType.WIRED, ChargingSpeed.REGULAR, /* batteryLevel= */ 65);
|
||||
when(mFeatureFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||
when(mFeatureFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(
|
||||
eq(mContext), anyBoolean()))
|
||||
.thenReturn(false);
|
||||
var expectedStatusLabel = "Charging";
|
||||
var expectedRemainingLabel = "2 hr, 10 min left until full";
|
||||
@@ -777,7 +780,8 @@ public class BatteryInfoTest {
|
||||
Intent batteryIntent =
|
||||
createIntentForGetBatteryInfoTest(
|
||||
ChargingType.WIRED, ChargingSpeed.REGULAR, /* batteryLevel= */ 65);
|
||||
when(mFeatureFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||
when(mFeatureFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(
|
||||
eq(mContext), anyBoolean()))
|
||||
.thenReturn(false);
|
||||
var expectedStatusLabel = "Charging";
|
||||
var expectedRemainingLabel = "Fully charged by";
|
||||
@@ -827,7 +831,7 @@ public class BatteryInfoTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBatteryInfo_plugTypeNoneWithLonglifeAndChargeOptimization_chargingString() {
|
||||
public void getBatteryInfo_plugTypeNoneIsChargeOptimization_chargingString() {
|
||||
prepareTestGetBatteryInfoEnvironment(
|
||||
/* remainingTimeMs= */ Duration.ofMinutes(130).toMillis(),
|
||||
/* chargingStringV2Enabled= */ false);
|
||||
@@ -840,7 +844,8 @@ public class BatteryInfoTest {
|
||||
/* isLonglife= */ true);
|
||||
var expectedRemainingLabel = "Expected remaining label";
|
||||
var expectedChargeLabel = "85% - " + expectedRemainingLabel;
|
||||
when(mFeatureFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||
when(mFeatureFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(
|
||||
eq(mContext), anyBoolean()))
|
||||
.thenReturn(true);
|
||||
when(mFeatureFactory.batterySettingsFeatureProvider.getChargingOptimizationRemainingLabel(
|
||||
eq(mContext), anyInt(), anyInt(), anyLong(), anyLong()))
|
||||
@@ -859,34 +864,7 @@ public class BatteryInfoTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBatteryInfo_plugTypeNoneNotChargeOptimizationLonglife_dischargingString() {
|
||||
prepareTestGetBatteryInfoEnvironment(
|
||||
/* remainingTimeMs= */ Duration.ofMinutes(130).toMillis(),
|
||||
/* chargingStringV2Enabled= */ false);
|
||||
Intent batteryIntent =
|
||||
createIntentForGetBatteryInfoTest(
|
||||
ChargingType.NONE,
|
||||
ChargingSpeed.REGULAR,
|
||||
/* batteryLevel= */ 85,
|
||||
BatteryManager.BATTERY_STATUS_DISCHARGING,
|
||||
/* isLonglife= */ true);
|
||||
var expectedRemainingLabel =
|
||||
PowerUtil.getBatteryRemainingShortStringFormatted(
|
||||
mContext, PowerUtil.convertUsToMs(1000L));
|
||||
when(mFeatureFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||
.thenReturn(false);
|
||||
var expectedStatusLabel = "Not charging";
|
||||
|
||||
assertGetBatteryInfo(
|
||||
batteryIntent,
|
||||
/* currentTimeMillis= */ UNUSED_TIME_MS,
|
||||
expectedStatusLabel,
|
||||
expectedRemainingLabel,
|
||||
expectedRemainingLabel);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBatteryInfo_plugTypeNoneChargeOptimizationNotLonglife_dischargingString() {
|
||||
public void getBatteryInfo_plugTypeNoneNotChargeOptimization_dischargingString() {
|
||||
prepareTestGetBatteryInfoEnvironment(
|
||||
/* remainingTimeMs= */ Duration.ofMinutes(130).toMillis(),
|
||||
/* chargingStringV2Enabled= */ false);
|
||||
@@ -900,8 +878,9 @@ public class BatteryInfoTest {
|
||||
var expectedRemainingLabel =
|
||||
PowerUtil.getBatteryRemainingShortStringFormatted(
|
||||
mContext, PowerUtil.convertUsToMs(1000L));
|
||||
when(mFeatureFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||
.thenReturn(true);
|
||||
when(mFeatureFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(
|
||||
eq(mContext), anyBoolean()))
|
||||
.thenReturn(false);
|
||||
var expectedStatusLabel = "Not charging";
|
||||
|
||||
assertGetBatteryInfo(
|
||||
|
||||
@@ -89,7 +89,7 @@ public class BatterySettingsFeatureProviderImplTest {
|
||||
|
||||
@Test
|
||||
public void isChargingOptimizationMode_default_returnFalse() {
|
||||
assertThat(mImpl.isChargingOptimizationMode(mContext)).isFalse();
|
||||
assertThat(mImpl.isChargingOptimizationMode(mContext, true)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -118,6 +118,8 @@ public class NetworkProviderSettingsTest {
|
||||
@Spy
|
||||
Context mContext = ApplicationProvider.getApplicationContext();
|
||||
@Mock
|
||||
private FragmentActivity mFragmentActivity;
|
||||
@Mock
|
||||
private PowerManager mPowerManager;
|
||||
@Mock
|
||||
private WifiManager mWifiManager;
|
||||
@@ -129,7 +131,6 @@ public class NetworkProviderSettingsTest {
|
||||
private AirplaneModeEnabler mAirplaneModeEnabler;
|
||||
@Mock
|
||||
private DataUsagePreference mDataUsagePreference;
|
||||
private NetworkProviderSettings mNetworkProviderSettings;
|
||||
@Mock
|
||||
private WifiPickerTracker mMockWifiPickerTracker;
|
||||
@Mock
|
||||
@@ -157,8 +158,11 @@ public class NetworkProviderSettingsTest {
|
||||
@Mock
|
||||
NetworkProviderSettings.WifiRestriction mWifiRestriction;
|
||||
|
||||
private NetworkProviderSettings mNetworkProviderSettings;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
when(mFragmentActivity.getApplicationContext()).thenReturn(mContext);
|
||||
when(mMenu.add(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(mMenuItem);
|
||||
|
||||
mNetworkProviderSettings = spy(new NetworkProviderSettings() {
|
||||
@@ -166,6 +170,8 @@ public class NetworkProviderSettingsTest {
|
||||
boolean showAnySubscriptionInfo(Context context) { return true; }
|
||||
});
|
||||
doReturn(mContext).when(mNetworkProviderSettings).getContext();
|
||||
doReturn(mFragmentActivity).when(mNetworkProviderSettings).getActivity();
|
||||
doReturn(mFragmentActivity).when(mNetworkProviderSettings).requireActivity();
|
||||
doReturn(mPreferenceManager).when(mNetworkProviderSettings).getPreferenceManager();
|
||||
doReturn(null).when(mNetworkProviderSettings).getPreferenceScreenBindingKey(mContext);
|
||||
doReturn(mPowerManager).when(mContext).getSystemService(PowerManager.class);
|
||||
@@ -294,13 +300,10 @@ public class NetworkProviderSettingsTest {
|
||||
}
|
||||
|
||||
private void setUpForOnCreate() {
|
||||
final FragmentActivity activity = mock(FragmentActivity.class);
|
||||
doReturn(activity).when(mNetworkProviderSettings).requireActivity();
|
||||
doReturn(activity).when(mNetworkProviderSettings).getActivity();
|
||||
final Resources.Theme theme = mContext.getTheme();
|
||||
when(activity.getTheme()).thenReturn(theme);
|
||||
when(mFragmentActivity.getTheme()).thenReturn(theme);
|
||||
UserManager userManager = mock(UserManager.class);
|
||||
when(activity.getSystemService(Context.USER_SERVICE))
|
||||
when(mFragmentActivity.getSystemService(Context.USER_SERVICE))
|
||||
.thenReturn(userManager);
|
||||
|
||||
when(mNetworkProviderSettings.findPreference(NetworkProviderSettings.PREF_KEY_DATA_USAGE))
|
||||
@@ -343,10 +346,6 @@ public class NetworkProviderSettingsTest {
|
||||
|
||||
@Test
|
||||
public void onCreateContextMenu_shouldHaveForgetAndDisconnectMenuForConnectedWifiEntry() {
|
||||
final FragmentActivity activity = mock(FragmentActivity.class);
|
||||
when(activity.getApplicationContext()).thenReturn(mContext);
|
||||
when(mNetworkProviderSettings.getActivity()).thenReturn(activity);
|
||||
|
||||
when(mWifiEntry.canDisconnect()).thenReturn(true);
|
||||
when(mWifiEntry.canForget()).thenReturn(true);
|
||||
when(mWifiEntry.isSaved()).thenReturn(true);
|
||||
@@ -365,10 +364,6 @@ public class NetworkProviderSettingsTest {
|
||||
|
||||
@Test
|
||||
public void onCreateContextMenu_canShare_shouldHaveShareMenuForConnectedWifiEntry() {
|
||||
final FragmentActivity activity = mock(FragmentActivity.class);
|
||||
when(activity.getApplicationContext()).thenReturn(mContext);
|
||||
when(mNetworkProviderSettings.getActivity()).thenReturn(activity);
|
||||
|
||||
when(mWifiEntry.canDisconnect()).thenReturn(true);
|
||||
when(mWifiEntry.canShare()).thenReturn(true);
|
||||
when(mWifiEntry.canForget()).thenReturn(true);
|
||||
@@ -387,10 +382,6 @@ public class NetworkProviderSettingsTest {
|
||||
|
||||
@Test
|
||||
public void onCreateContextMenu_canNotShare_shouldDisappearShareMenuForConnectedWifiEntry() {
|
||||
final FragmentActivity activity = mock(FragmentActivity.class);
|
||||
when(activity.getApplicationContext()).thenReturn(mContext);
|
||||
when(mNetworkProviderSettings.getActivity()).thenReturn(activity);
|
||||
|
||||
when(mWifiEntry.canDisconnect()).thenReturn(true);
|
||||
when(mWifiEntry.canShare()).thenReturn(false);
|
||||
when(mWifiEntry.canForget()).thenReturn(true);
|
||||
@@ -414,6 +405,13 @@ public class NetworkProviderSettingsTest {
|
||||
verify(mNetworkProviderSettings).changeNextButtonState(anyBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onWifiEntriesChanged_activityIsNull_shouldNotCrash() {
|
||||
doReturn(null).when(mNetworkProviderSettings).getActivity();
|
||||
|
||||
mNetworkProviderSettings.onWifiEntriesChanged(WIFI_ENTRIES_CHANGED_REASON_GENERAL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void openSubscriptionHelpPage_shouldCallStartActivityForResult() {
|
||||
doReturn(new Intent()).when(mNetworkProviderSettings).getHelpIntent(mContext,
|
||||
@@ -428,20 +426,16 @@ public class NetworkProviderSettingsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onNumSavedNetworksChanged_isFinishing_ShouldNotCrash() {
|
||||
final FragmentActivity activity = mock(FragmentActivity.class);
|
||||
when(activity.isFinishing()).thenReturn(true);
|
||||
when(mNetworkProviderSettings.getActivity()).thenReturn(activity);
|
||||
public void onNumSavedNetworksChanged_isFinishing_shouldNotCrash() {
|
||||
when(mFragmentActivity.isFinishing()).thenReturn(true);
|
||||
when(mNetworkProviderSettings.getContext()).thenReturn(null);
|
||||
|
||||
mNetworkProviderSettings.onNumSavedNetworksChanged();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onNumSavedSubscriptionsChanged_isFinishing_ShouldNotCrash() {
|
||||
final FragmentActivity activity = mock(FragmentActivity.class);
|
||||
when(activity.isFinishing()).thenReturn(true);
|
||||
when(mNetworkProviderSettings.getActivity()).thenReturn(activity);
|
||||
public void onNumSavedSubscriptionsChanged_isFinishing_shouldNotCrash() {
|
||||
when(mFragmentActivity.isFinishing()).thenReturn(true);
|
||||
when(mNetworkProviderSettings.getContext()).thenReturn(null);
|
||||
|
||||
mNetworkProviderSettings.onNumSavedSubscriptionsChanged();
|
||||
@@ -634,7 +628,7 @@ public class NetworkProviderSettingsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateWifiEntryPreferences_activityIsNull_ShouldNotCrash() {
|
||||
public void updateWifiEntryPreferences_activityIsNull_shouldNotCrash() {
|
||||
when(mNetworkProviderSettings.getActivity()).thenReturn(null);
|
||||
|
||||
// should not crash
|
||||
@@ -642,9 +636,7 @@ public class NetworkProviderSettingsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateWifiEntryPreferences_viewIsNull_ShouldNotCrash() {
|
||||
final FragmentActivity activity = mock(FragmentActivity.class);
|
||||
when(mNetworkProviderSettings.getActivity()).thenReturn(activity);
|
||||
public void updateWifiEntryPreferences_viewIsNull_shouldNotCrash() {
|
||||
when(mNetworkProviderSettings.getView()).thenReturn(null);
|
||||
|
||||
// should not crash
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
package com.android.settings.notification;
|
||||
|
||||
import static android.provider.Settings.Secure.LOCK_SCREEN_NOTIFICATION_MINIMALISM;
|
||||
import static android.provider.Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -34,6 +38,8 @@ import android.provider.Settings;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.server.notification.Flags;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -44,9 +50,15 @@ import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
/**
|
||||
* Disable FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS because this toggle will be replaced by the new
|
||||
* settings page.
|
||||
*/
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@DisableFlags(Flags.FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS)
|
||||
public class LockscreenNotificationMinimalismPreferenceControllerTest {
|
||||
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
@@ -56,8 +68,6 @@ public class LockscreenNotificationMinimalismPreferenceControllerTest {
|
||||
private Preference mPreference;
|
||||
static final int ON = 1;
|
||||
static final int OFF = 0;
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -72,17 +82,33 @@ public class LockscreenNotificationMinimalismPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_MINIMALISM)
|
||||
@DisableFlags(Flags.FLAG_NOTIFICATION_MINIMALISM)
|
||||
public void display_featureFlagOff_shouldNotDisplay() {
|
||||
// Given: lockscreen show notifications, FLAG_NOTIFICATION_MINIMALISM is disabled
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
LOCK_SCREEN_SHOW_NOTIFICATIONS, ON);
|
||||
|
||||
// When: displayPreference
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
// Then: The controller is CONDITIONALLY_UNAVAILABLE, preference is not visible
|
||||
assertThat(mPreference.isVisible()).isFalse();
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_MINIMALISM)
|
||||
public void display_featureFlagOn_shouldDisplay() {
|
||||
// Given: lockscreen show notifications, FLAG_NOTIFICATION_MINIMALISM is enabled
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
LOCK_SCREEN_SHOW_NOTIFICATIONS, ON);
|
||||
|
||||
// When: displayPreference
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
// Then: The controller is AVAILABLE, preference is visible
|
||||
assertThat(mPreference.isVisible()).isTrue();
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -37,11 +37,14 @@ import android.content.Context;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.server.notification.Flags;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.ShadowRestrictedLockUtilsInternal;
|
||||
import com.android.settings.testutils.shadow.ShadowUtils;
|
||||
@@ -49,6 +52,7 @@ import com.android.settingslib.RestrictedSwitchPreference;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -59,13 +63,19 @@ import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Disable FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS because this toggle will be replaced by the new
|
||||
* settings page.
|
||||
*/
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {
|
||||
ShadowUtils.class,
|
||||
ShadowRestrictedLockUtilsInternal.class,
|
||||
})
|
||||
@DisableFlags(Flags.FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS)
|
||||
public class RedactNotificationPreferenceControllerTest {
|
||||
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
@Mock
|
||||
private DevicePolicyManager mDpm;
|
||||
@Mock
|
||||
|
||||
@@ -37,6 +37,8 @@ import android.provider.Settings;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.server.notification.Flags;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -47,9 +49,15 @@ import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
/**
|
||||
* Disable FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS because this toggle will be replaced by the new
|
||||
* settings page.
|
||||
*/
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@DisableFlags(Flags.FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS)
|
||||
public class ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest {
|
||||
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
@@ -57,8 +65,6 @@ public class ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest {
|
||||
|
||||
private ShowOnlyUnseenNotificationsOnLockscreenPreferenceController mController;
|
||||
private Preference mPreference;
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
@@ -31,14 +31,18 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class VolumeSeekBarPreferenceControllerTest {
|
||||
@Rule
|
||||
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||
|
||||
@Mock
|
||||
private Context mContext;
|
||||
@@ -47,8 +51,6 @@ public class VolumeSeekBarPreferenceControllerTest {
|
||||
@Mock
|
||||
private VolumeSeekBarPreference mPreference;
|
||||
@Mock
|
||||
private VolumeSeekBarPreference.Callback mCallback;
|
||||
@Mock
|
||||
private VolumeSeekBarPreference.Listener mListener;
|
||||
@Mock
|
||||
private AudioHelper mHelper;
|
||||
@@ -57,10 +59,9 @@ public class VolumeSeekBarPreferenceControllerTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mScreen.findPreference(nullable(String.class))).thenReturn(mPreference);
|
||||
when(mPreference.getKey()).thenReturn("key");
|
||||
mController = new VolumeSeekBarPreferenceControllerTestable(mContext, mCallback, true,
|
||||
mController = new VolumeSeekBarPreferenceControllerTestable(mContext, true,
|
||||
mPreference.getKey(), mListener);
|
||||
mController.setAudioHelper(mHelper);
|
||||
}
|
||||
@@ -69,7 +70,6 @@ public class VolumeSeekBarPreferenceControllerTest {
|
||||
public void displayPreference_available_shouldUpdatePreference() {
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
verify(mPreference).setCallback(mCallback);
|
||||
verify(mPreference).setStream(VolumeSeekBarPreferenceControllerTestable.AUDIO_STREAM);
|
||||
verify(mPreference).setMuteIcon(VolumeSeekBarPreferenceControllerTestable.MUTE_ICON);
|
||||
verify(mPreference).setListener(mListener);
|
||||
@@ -77,7 +77,7 @@ public class VolumeSeekBarPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void displayPreference_notAvailable_shouldNotUpdatePreference() {
|
||||
mController = new VolumeSeekBarPreferenceControllerTestable(mContext, mCallback, false,
|
||||
mController = new VolumeSeekBarPreferenceControllerTestable(mContext, false,
|
||||
mPreference.getKey(), mListener);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
@@ -88,24 +88,6 @@ public class VolumeSeekBarPreferenceControllerTest {
|
||||
verify(mPreference, never()).setListener(mListener);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onResume_shouldResumePreference() {
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.onResume();
|
||||
|
||||
verify(mPreference).onActivityResume();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPause_shouldPausePreference() {
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
mController.onPause();
|
||||
|
||||
verify(mPreference).onActivityPause();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sliderMethods_handleNullPreference() {
|
||||
when(mHelper.getStreamVolume(mController.getAudioStream())).thenReturn(4);
|
||||
@@ -152,19 +134,17 @@ public class VolumeSeekBarPreferenceControllerTest {
|
||||
assertThat(mController.getSliderPosition()).isEqualTo(7);
|
||||
}
|
||||
|
||||
private class VolumeSeekBarPreferenceControllerTestable
|
||||
extends VolumeSeekBarPreferenceController {
|
||||
private static class VolumeSeekBarPreferenceControllerTestable extends
|
||||
VolumeSeekBarPreferenceController {
|
||||
|
||||
private final static int AUDIO_STREAM = 1;
|
||||
private final static int MUTE_ICON = 2;
|
||||
private static final int AUDIO_STREAM = 1;
|
||||
private static final int MUTE_ICON = 2;
|
||||
|
||||
private boolean mAvailable;
|
||||
private final boolean mAvailable;
|
||||
|
||||
VolumeSeekBarPreferenceControllerTestable(Context context,
|
||||
VolumeSeekBarPreference.Callback callback, boolean available, String key,
|
||||
VolumeSeekBarPreferenceControllerTestable(Context context, boolean available, String key,
|
||||
VolumeSeekBarPreference.Listener listener) {
|
||||
super(context, key);
|
||||
setCallback(callback);
|
||||
mAvailable = available;
|
||||
mVolumePreferenceListener = listener;
|
||||
}
|
||||
|
||||
@@ -32,12 +32,14 @@ import android.preference.SeekBarVolumizer;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -47,6 +49,10 @@ public class VolumeSeekBarPreferenceTest {
|
||||
|
||||
private static final CharSequence CONTENT_DESCRIPTION = "TEST";
|
||||
private static final int STREAM = 5;
|
||||
|
||||
@Rule
|
||||
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||
|
||||
@Mock
|
||||
private AudioManager mAudioManager;
|
||||
@Mock
|
||||
@@ -70,10 +76,10 @@ public class VolumeSeekBarPreferenceTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
|
||||
when(mSeekBarVolumizerFactory.create(eq(STREAM), eq(null), mSbvc.capture()))
|
||||
.thenReturn(mVolumizer);
|
||||
doCallRealMethod().when(mPreference).createSeekBarVolumizer();
|
||||
doCallRealMethod().when(mPreference).setStream(anyInt());
|
||||
doCallRealMethod().when(mPreference).updateContentDescription(CONTENT_DESCRIPTION);
|
||||
mPreference.mSeekBar = mSeekBar;
|
||||
@@ -99,50 +105,50 @@ public class VolumeSeekBarPreferenceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void init_listenerIsCalled() {
|
||||
public void onBindViewHolder_listenerIsCalled() {
|
||||
when(mPreference.isEnabled()).thenReturn(true);
|
||||
doCallRealMethod().when(mPreference).setListener(mListener);
|
||||
doCallRealMethod().when(mPreference).init();
|
||||
doCallRealMethod().when(mPreference).onBindViewHolder();
|
||||
|
||||
mPreference.setStream(STREAM);
|
||||
mPreference.setListener(mListener);
|
||||
mPreference.init();
|
||||
mPreference.onBindViewHolder();
|
||||
|
||||
verify(mPreference).updateContentDescription(CONTENT_DESCRIPTION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void init_listenerNotSet_noException() {
|
||||
public void onBindViewHolder_listenerNotSet_noException() {
|
||||
when(mPreference.isEnabled()).thenReturn(true);
|
||||
doCallRealMethod().when(mPreference).init();
|
||||
doCallRealMethod().when(mPreference).onBindViewHolder();
|
||||
|
||||
mPreference.setStream(STREAM);
|
||||
mPreference.init();
|
||||
mPreference.onBindViewHolder();
|
||||
|
||||
verify(mPreference, never()).updateContentDescription(CONTENT_DESCRIPTION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void init_preferenceIsDisabled_shouldNotInvokeListener() {
|
||||
public void onBindViewHolder_preferenceIsDisabled_shouldNotInvokeListener() {
|
||||
when(mPreference.isEnabled()).thenReturn(false);
|
||||
doCallRealMethod().when(mPreference).setListener(mListener);
|
||||
doCallRealMethod().when(mPreference).init();
|
||||
doCallRealMethod().when(mPreference).onBindViewHolder();
|
||||
|
||||
mPreference.setStream(STREAM);
|
||||
mPreference.init();
|
||||
mPreference.onBindViewHolder();
|
||||
|
||||
verify(mPreference, never()).updateContentDescription(CONTENT_DESCRIPTION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void init_changeProgress_overrideStateDescriptionCalled() {
|
||||
public void onBindViewHolder_changeProgress_overrideStateDescriptionCalled() {
|
||||
final int progress = 4;
|
||||
when(mPreference.isEnabled()).thenReturn(true);
|
||||
when(mPreference.formatStateDescription(progress)).thenReturn(CONTENT_DESCRIPTION);
|
||||
doCallRealMethod().when(mPreference).init();
|
||||
doCallRealMethod().when(mPreference).onBindViewHolder();
|
||||
|
||||
mPreference.setStream(STREAM);
|
||||
mPreference.init();
|
||||
mPreference.onBindViewHolder();
|
||||
|
||||
verify(mSeekBarVolumizerFactory).create(eq(STREAM), eq(null), mSbvc.capture());
|
||||
|
||||
@@ -166,10 +172,10 @@ public class VolumeSeekBarPreferenceTest {
|
||||
when(mContext.getResources()).thenReturn(mRes);
|
||||
when(mRes.getConfiguration()).thenReturn(mConfig);
|
||||
when(mConfig.getLocales()).thenReturn(new LocaleList(Locale.US));
|
||||
doCallRealMethod().when(mPreference).init();
|
||||
doCallRealMethod().when(mPreference).onBindViewHolder();
|
||||
|
||||
mPreference.setStream(STREAM);
|
||||
mPreference.init();
|
||||
mPreference.onBindViewHolder();
|
||||
|
||||
verify(mSeekBarVolumizerFactory).create(eq(STREAM), eq(null), mSbvc.capture());
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ import androidx.slice.SliceProvider;
|
||||
import androidx.slice.widget.SliceLiveData;
|
||||
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.contract.SettingsContractKt;
|
||||
import com.android.settings.testutils.DatabaseTestUtils;
|
||||
import com.android.settings.testutils.FakeToggleController;
|
||||
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
||||
@@ -626,7 +627,7 @@ public class SettingsSliceProviderTest {
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSlicesContract.AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(SettingsSlicesContract.KEY_LOCATION)
|
||||
.appendPath(SettingsContractKt.KEY_LOCATION)
|
||||
.build();
|
||||
|
||||
mProvider.onSlicePinned(uri);
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider;
|
||||
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider;
|
||||
import com.android.settings.accounts.AccountFeatureProvider;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.biometrics.BiometricsFeatureProvider;
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider;
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
||||
@@ -80,6 +81,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public final UserFeatureProvider userFeatureProvider;
|
||||
public final AccountFeatureProvider mAccountFeatureProvider;
|
||||
public final BluetoothFeatureProvider mBluetoothFeatureProvider;
|
||||
public final BiometricsFeatureProvider mBiometricsFeatureProvider;
|
||||
public final FaceFeatureProvider mFaceFeatureProvider;
|
||||
public final FingerprintFeatureProvider mFingerprintFeatureProvider;
|
||||
|
||||
@@ -135,6 +137,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
mContextualCardFeatureProvider = mock(ContextualCardFeatureProvider.class);
|
||||
panelFeatureProvider = mock(PanelFeatureProvider.class);
|
||||
mBluetoothFeatureProvider = mock(BluetoothFeatureProvider.class);
|
||||
mBiometricsFeatureProvider = mock(BiometricsFeatureProvider.class);
|
||||
mFaceFeatureProvider = mock(FaceFeatureProvider.class);
|
||||
mFingerprintFeatureProvider = mock(FingerprintFeatureProvider.class);
|
||||
wifiTrackerLibProvider = mock(WifiTrackerLibProvider.class);
|
||||
@@ -258,6 +261,11 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
return mBluetoothFeatureProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiometricsFeatureProvider getBiometricsFeatureProvider() {
|
||||
return mBiometricsFeatureProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaceFeatureProvider getFaceFeatureProvider() {
|
||||
return mFaceFeatureProvider;
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider
|
||||
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider
|
||||
import com.android.settings.accounts.AccountFeatureProvider
|
||||
import com.android.settings.applications.ApplicationFeatureProvider
|
||||
import com.android.settings.biometrics.BiometricsFeatureProvider
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider
|
||||
@@ -114,6 +115,8 @@ class FakeFeatureFactory : FeatureFactory() {
|
||||
|
||||
override val bluetoothFeatureProvider: BluetoothFeatureProvider
|
||||
get() = TODO("Not yet implemented")
|
||||
override val biometricsFeatureProvider: BiometricsFeatureProvider
|
||||
get() = TODO("Not yet implemented")
|
||||
override val faceFeatureProvider: FaceFeatureProvider
|
||||
get() = TODO("Not yet implemented")
|
||||
override val fingerprintFeatureProvider: FingerprintFeatureProvider
|
||||
|
||||
@@ -173,16 +173,18 @@ public class ExternalDisplayPreferenceFragmentTest extends ExternalDisplayTestBa
|
||||
mHandler.flush();
|
||||
PreferenceCategory pref = mPreferenceScreen.findPreference(DISPLAYS_LIST_PREFERENCE_KEY);
|
||||
assertThat(pref).isNotNull();
|
||||
DisplayPreference display1Pref = (DisplayPreference) pref.getPreference(0);
|
||||
DisplayPreference display2Pref = (DisplayPreference) pref.getPreference(1);
|
||||
var display1Category = (PreferenceCategory) pref.getPreference(0);
|
||||
var display1Pref = (DisplayPreference) display1Category.getPreference(0);
|
||||
var display2Category = (PreferenceCategory) pref.getPreference(1);
|
||||
var display2Pref = (DisplayPreference) display2Category.getPreference(0);
|
||||
assertThat(display1Pref.getKey()).isEqualTo("display_id_" + 1);
|
||||
assertThat("" + display1Pref.getTitle()).isEqualTo("HDMI");
|
||||
assertThat("" + display1Category.getTitle()).isEqualTo("HDMI");
|
||||
assertThat("" + display1Pref.getSummary()).isEqualTo("1920 x 1080");
|
||||
display1Pref.onPreferenceClick(display1Pref);
|
||||
assertThat(mDisplayIdArg).isEqualTo(1);
|
||||
verify(mMockedMetricsLogger).writePreferenceClickMetric(display1Pref);
|
||||
assertThat(display2Pref.getKey()).isEqualTo("display_id_" + 2);
|
||||
assertThat("" + display2Pref.getTitle()).isEqualTo("Overlay #1");
|
||||
assertThat("" + display2Category.getTitle()).isEqualTo("Overlay #1");
|
||||
assertThat("" + display2Pref.getSummary()).isEqualTo("1240 x 780");
|
||||
display2Pref.onPreferenceClick(display2Pref);
|
||||
assertThat(mDisplayIdArg).isEqualTo(2);
|
||||
|
||||
@@ -136,10 +136,8 @@ public final class CellularSecurityPreferenceControllerTest {
|
||||
|
||||
private void enableFlags(boolean enabled) {
|
||||
if (enabled) {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_MODEM_CIPHER_TRANSPARENCY);
|
||||
} else {
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_MODEM_CIPHER_TRANSPARENCY_UNSOL_EVENTS);
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_MODEM_CIPHER_TRANSPARENCY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,10 +114,8 @@ public class CellularSecurityNotificationsDividerControllerTest {
|
||||
private void enableFlags(boolean enabled) {
|
||||
if (enabled) {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_MODEM_CIPHER_TRANSPARENCY_UNSOL_EVENTS);
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_MODEM_CIPHER_TRANSPARENCY);
|
||||
} else {
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_MODEM_CIPHER_TRANSPARENCY_UNSOL_EVENTS);
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_MODEM_CIPHER_TRANSPARENCY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,10 +217,8 @@ public class CellularSecurityNotificationsPreferenceControllerTest {
|
||||
private void enableFlags(boolean enabled) {
|
||||
if (enabled) {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_MODEM_CIPHER_TRANSPARENCY_UNSOL_EVENTS);
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_MODEM_CIPHER_TRANSPARENCY);
|
||||
} else {
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_MODEM_CIPHER_TRANSPARENCY_UNSOL_EVENTS);
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_MODEM_CIPHER_TRANSPARENCY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider;
|
||||
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider;
|
||||
import com.android.settings.accounts.AccountFeatureProvider;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.biometrics.BiometricsFeatureProvider;
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider;
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
||||
@@ -79,6 +80,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public final UserFeatureProvider userFeatureProvider;
|
||||
public final AccountFeatureProvider mAccountFeatureProvider;
|
||||
public final BluetoothFeatureProvider mBluetoothFeatureProvider;
|
||||
public final BiometricsFeatureProvider mBiometricsFeatureProvider;
|
||||
public final FaceFeatureProvider mFaceFeatureProvider;
|
||||
public final FingerprintFeatureProvider mFingerprintFeatureProvider;
|
||||
|
||||
@@ -136,6 +138,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
mContextualCardFeatureProvider = mock(ContextualCardFeatureProvider.class);
|
||||
panelFeatureProvider = mock(PanelFeatureProvider.class);
|
||||
mBluetoothFeatureProvider = mock(BluetoothFeatureProvider.class);
|
||||
mBiometricsFeatureProvider = mock(BiometricsFeatureProvider.class);
|
||||
mFaceFeatureProvider = mock(FaceFeatureProvider.class);
|
||||
mFingerprintFeatureProvider = mock(FingerprintFeatureProvider.class);
|
||||
wifiTrackerLibProvider = mock(WifiTrackerLibProvider.class);
|
||||
@@ -259,6 +262,11 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
return mBluetoothFeatureProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiometricsFeatureProvider getBiometricsFeatureProvider() {
|
||||
return mBiometricsFeatureProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaceFeatureProvider getFaceFeatureProvider() {
|
||||
return mFaceFeatureProvider;
|
||||
|
||||
Reference in New Issue
Block a user