Snap for 12551711 from a9e8225ba4 to 25Q1-release

Change-Id: I61d1533c2757f3e06400e454db1070cb1db0b336
This commit is contained in:
Android Build Coastguard Worker
2024-10-24 23:23:00 +00:00
22 changed files with 527 additions and 88 deletions

View File

@@ -14,3 +14,11 @@ flag {
description: "Flag for Screen Timeout settings"
bug: "323791114"
}
flag {
name: "catalyst_dark_ui_mode"
namespace: "android_settings"
description: "Flag for Dark theme"
bug: "323791114"
}

View File

@@ -21,3 +21,17 @@ flag {
description: "Flag for SIMs"
bug: "323791114"
}
flag {
name: "catalyst_adaptive_connectivity"
namespace: "android_settings"
description: "Flag for Adaptive connectivity"
bug: "323791114"
}
flag {
name: "catalyst_wifi_calling"
namespace: "android_settings"
description: "Flag for Wi-Fi calling screen"
bug: "323791114"
}

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2024 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.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/settingslib_materialColorSurfaceBright"/>
<stroke
android:width="1dp"
android:color="@color/settingslib_materialColorOutlineVariant"/>
</shape>

View File

@@ -0,0 +1,26 @@
<!--
Copyright (C) 2024 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportHeight="960"
android:viewportWidth="960"
android:autoMirrored="true">
<path
android:fillColor="@android:color/white"
android:pathData="M370,880L354,752Q341,747 329.5,740Q318,733 307,725L188,775L78,585L181,507Q180,500 180,493.5Q180,487 180,480Q180,473 180,466.5Q180,460 181,453L78,375L188,185L307,235Q318,227 330,220Q342,213 354,208L370,80L590,80L606,208Q619,213 630.5,220Q642,227 653,235L772,185L882,375L779,453Q780,460 780,466.5Q780,473 780,480Q780,487 780,493.5Q780,500 778,507L881,585L771,775L653,725Q642,733 630,740Q618,747 606,752L590,880L370,880ZM440,800L519,800L533,694Q564,686 590.5,670.5Q617,655 639,633L738,674L777,606L691,541Q696,527 698,511.5Q700,496 700,480Q700,464 698,448.5Q696,433 691,419L777,354L738,286L639,328Q617,305 590.5,289.5Q564,274 533,266L520,160L441,160L427,266Q396,274 369.5,289.5Q343,305 321,327L222,286L183,354L269,418Q264,433 262,448Q260,463 260,480Q260,496 262,511Q264,526 269,541L183,606L222,674L321,632Q343,655 369.5,670.5Q396,686 427,694L440,800ZM482,620Q540,620 581,579Q622,538 622,480Q622,422 581,381Q540,340 482,340Q423,340 382.5,381Q342,422 342,480Q342,538 382.5,579Q423,620 482,620ZM480,480L480,480Q480,480 480,480Q480,480 480,480L480,480L480,480L480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480L480,480L480,480L480,480Q480,480 480,480Q480,480 480,480L480,480L480,480L480,480Q480,480 480,480Q480,480 480,480L480,480L480,480L480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480L480,480L480,480L480,480Q480,480 480,480Q480,480 480,480L480,480Z" />
</vector>

View File

@@ -34,7 +34,7 @@
android:layout_height="72dp"
android:layout_gravity="center"
android:antialias="true"
android:background="@drawable/circle_outline"
android:background="@drawable/bt_header_circle_outline"
android:padding="8dp"
android:scaleType="fitCenter" />

View File

@@ -8149,11 +8149,13 @@
</string>
<!-- Modes: Summary for the modes segment, when no modes are active. [CHAR LIMIT=NONE]-->
<string name="zen_modes_summary_none_active">
<!-- Note: The "0" option should never actually occur. -->
<string name="zen_modes_summary">
{count, plural,
=0 {}
=1 {1 mode can turn on automatically}
other {# modes can turn on automatically}
=0 {Do Not Disturb}
=1 {{mode_1}}
=2 {{mode_1}, {mode_2}}
other {{mode_1}, {mode_2}, {mode_3}}
}
</string>

View File

@@ -16,7 +16,7 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="wifi_calling_settings"
android:key="wifi_calling"
android:title="@string/wifi_calling_settings_title">
<com.android.settings.widget.SettingsMainSwitchPreference

View File

@@ -34,6 +34,7 @@ import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
// LINT.IfChange
public class DarkUIPreferenceController extends TogglePreferenceController implements
LifecycleObserver, OnStart, OnStop {
@@ -123,3 +124,4 @@ public class DarkUIPreferenceController extends TogglePreferenceController imple
return AVAILABLE;
}
}
// LINT.ThenChange(darkmode/DarkModeScreen.kt)

View File

@@ -18,6 +18,7 @@ package com.android.settings.display
import android.content.Context
import com.android.settings.DisplaySettings
import com.android.settings.R
import com.android.settings.display.darkmode.DarkModeScreen
import com.android.settings.flags.Flags
import com.android.settingslib.metadata.PreferenceAvailabilityProvider
import com.android.settingslib.metadata.PreferenceIconProvider
@@ -46,7 +47,9 @@ class DisplayScreen :
override fun fragmentClass() = DisplaySettings::class.java
override fun getPreferenceHierarchy(context: Context) = preferenceHierarchy(this) {}
override fun getPreferenceHierarchy(context: Context) = preferenceHierarchy(this) {
+DarkModeScreen.KEY
}
override fun isAvailable(context: Context) =
context.resources.getBoolean(R.bool.config_show_top_level_display)

View File

@@ -14,7 +14,6 @@
package com.android.settings.display.darkmode;
import android.app.UiModeManager;
import android.content.Context;
import android.content.res.Configuration;
import android.os.PowerManager;
@@ -28,39 +27,44 @@ import com.android.settingslib.PrimarySwitchPreference;
*/
public class DarkModePreference extends PrimarySwitchPreference {
private UiModeManager mUiModeManager;
private DarkModeObserver mDarkModeObserver;
private PowerManager mPowerManager;
private Runnable mCallback;
private TimeFormatter mFormat;
private boolean isCatalystEnabled;
public DarkModePreference(Context context, AttributeSet attrs) {
super(context, attrs);
mDarkModeObserver = new DarkModeObserver(context);
mUiModeManager = context.getSystemService(UiModeManager.class);
mPowerManager = context.getSystemService(PowerManager.class);
mFormat = new TimeFormatter(context);
mCallback = () -> {
final boolean batterySaver = mPowerManager.isPowerSaveMode();
final boolean active = (getContext().getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_YES) != 0;
setSwitchEnabled(!batterySaver);
updateSummary(batterySaver, active);
};
mDarkModeObserver.subscribe(mCallback);
}
/**
* Sets if catalyst is enabled on the preference.
*/
public void setCatalystEnabled(boolean catalystEnabled) {
isCatalystEnabled = catalystEnabled;
}
@Override
public void onAttached() {
super.onAttached();
mDarkModeObserver.subscribe(mCallback);
if (!isCatalystEnabled) {
Context context = getContext();
mDarkModeObserver = new DarkModeObserver(context);
Runnable callback = () -> {
PowerManager powerManager = context.getSystemService(PowerManager.class);
final boolean batterySaver = powerManager.isPowerSaveMode();
final boolean active = (context.getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_YES) != 0;
setSwitchEnabled(!batterySaver);
updateSummary(batterySaver, active);
};
mDarkModeObserver.subscribe(callback);
}
}
@Override
public void onDetached() {
super.onDetached();
mDarkModeObserver.unsubscribe();
if (!isCatalystEnabled) {
mDarkModeObserver.unsubscribe();
}
}
private void updateSummary(boolean batterySaver, boolean active) {

View File

@@ -0,0 +1,171 @@
/*
* Copyright (C) 2024 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.display.darkmode
import android.app.UiModeManager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.res.Configuration
import android.os.PowerManager
import androidx.preference.Preference
import com.android.settings.R
import com.android.settings.flags.Flags
import com.android.settingslib.PrimarySwitchPreference
import com.android.settingslib.datastore.KeyValueStore
import com.android.settingslib.datastore.NoOpKeyedObservable
import com.android.settingslib.metadata.BooleanValue
import com.android.settingslib.metadata.PersistentPreference
import com.android.settingslib.metadata.PreferenceLifecycleContext
import com.android.settingslib.metadata.PreferenceLifecycleProvider
import com.android.settingslib.metadata.PreferenceMetadata
import com.android.settingslib.metadata.PreferenceSummaryProvider
import com.android.settingslib.metadata.ProvidePreferenceScreen
import com.android.settingslib.metadata.preferenceHierarchy
import com.android.settingslib.preference.PreferenceScreenBinding
import com.android.settingslib.preference.PreferenceScreenCreator
import java.util.WeakHashMap
// LINT.IfChange
@ProvidePreferenceScreen
class DarkModeScreen :
PreferenceScreenCreator,
PreferenceScreenBinding,
PersistentPreference<Boolean>,
BooleanValue,
PreferenceSummaryProvider,
PreferenceLifecycleProvider {
/**
* States for different screens.
*
* The "Dark mode" appears in several screens. And in Android split-screen mode, more than one
* "Dark mode" settings could be displayed at the same time. As [PreferenceScreenCreator] works
* like singleton, we need to register different broadcast receivers for different screens.
*/
private val fragmentStates = WeakHashMap<PreferenceLifecycleContext, FragmentState>()
override val key: String
get() = KEY
override val title: Int
get() = R.string.dark_ui_mode
override val keywords: Int
get() = R.string.keywords_dark_ui_mode
override fun isFlagEnabled(context: Context) = Flags.catalystDarkUiMode()
override fun fragmentClass() = DarkModeSettingsFragment::class.java
override fun hasCompleteHierarchy() = false
override fun getPreferenceHierarchy(context: Context) = preferenceHierarchy(this) {}
override fun storage(context: Context): KeyValueStore = DarkModeStorage(context)
override fun createWidget(context: Context) = PrimarySwitchPreference(context)
override fun bind(preference: Preference, metadata: PreferenceMetadata) {
super.bind(preference, metadata)
if (preference is DarkModePreference) preference.setCatalystEnabled(true)
val context = preference.context
val primarySwitchPreference = preference as PrimarySwitchPreference
primarySwitchPreference.isSwitchEnabled = !context.isPowerSaveMode()
primarySwitchPreference.isChecked = context.isDarkMode()
}
override fun isEnabled(context: Context) = !context.isPowerSaveMode()
override fun getSummary(context: Context): CharSequence? {
val active = context.isDarkMode()
return when {
!context.isPowerSaveMode() -> AutoDarkTheme.getStatus(context, active)
active -> context.getString(R.string.dark_ui_mode_disabled_summary_dark_theme_on)
else -> context.getString(R.string.dark_ui_mode_disabled_summary_dark_theme_off)
}
}
override fun onStart(context: PreferenceLifecycleContext) {
val broadcastReceiver =
object : BroadcastReceiver() {
override fun onReceive(receiverContext: Context, intent: Intent) {
context.notifyPreferenceChange(this@DarkModeScreen)
}
}
context.registerReceiver(
broadcastReceiver,
IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED),
)
val darkModeObserver = DarkModeObserver(context)
darkModeObserver.subscribe { context.notifyPreferenceChange(this@DarkModeScreen) }
fragmentStates[context] = FragmentState(broadcastReceiver, darkModeObserver)
}
override fun onStop(context: PreferenceLifecycleContext) {
fragmentStates.remove(context)?.run {
context.unregisterReceiver(broadcastReceiver)
darkModeObserver.unsubscribe()
}
}
private class FragmentState(
val broadcastReceiver: BroadcastReceiver,
val darkModeObserver: DarkModeObserver,
)
/**
* Abstract storage for dark mode settings.
*
* The underlying storage is manipulated by [UiModeManager] but we do not need to worry about
* the details. Additionally, the observer is for UI purpose only right now, so use
* [NoOpKeyedObservable].
*/
@Suppress("UNCHECKED_CAST")
private class DarkModeStorage(private val context: Context) :
NoOpKeyedObservable<String>(), KeyValueStore {
override fun contains(key: String) = key == KEY
override fun <T : Any> getValue(key: String, valueType: Class<T>) =
when {
key == KEY && valueType == Boolean::class.javaObjectType ->
context.isDarkMode() as T
else -> null
}
override fun <T : Any> setValue(key: String, valueType: Class<T>, value: T?) {
if (key == KEY && value is Boolean) {
context.getSystemService(UiModeManager::class.java)?.setNightModeActivated(value)
}
}
}
companion object {
const val KEY = "dark_ui_mode"
private fun Context.isPowerSaveMode() =
getSystemService(PowerManager::class.java)?.isPowerSaveMode == true
private fun Context.isDarkMode() =
(resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_YES) != 0
}
}
// LINT.ThenChange(../DarkUIPreferenceController.java)

View File

@@ -0,0 +1,45 @@
/*
* Copyright (C) 2024 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.network
import android.content.Context
import com.android.settings.R
import com.android.settings.flags.Flags
import com.android.settingslib.metadata.ProvidePreferenceScreen
import com.android.settingslib.metadata.preferenceHierarchy
import com.android.settingslib.preference.PreferenceScreenCreator
@ProvidePreferenceScreen
class AdaptiveConnectivityScreen : PreferenceScreenCreator {
override val key
get() = KEY
override val title
get() = R.string.adaptive_connectivity_title
override fun isFlagEnabled(context: Context) = Flags.catalystAdaptiveConnectivity()
override fun fragmentClass() = AdaptiveConnectivitySettings::class.java
override fun getPreferenceHierarchy(context: Context) = preferenceHierarchy(this) {}
override fun hasCompleteHierarchy() = false
companion object {
const val KEY = "adaptive_connectivity"
}
}

View File

@@ -16,6 +16,10 @@
package com.android.settings.network;
import android.app.settings.SettingsEnums;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
@@ -30,8 +34,6 @@ public class AdaptiveConnectivitySettings extends DashboardFragment {
private static final String TAG = "AdaptiveConnectivitySettings";
private static final String KEY_ADAPTIVE_CONNECTIVITY_PREFERENCE = "adaptive_connectivity";
@Override
public int getMetricsCategory() {
return SettingsEnums.ADAPTIVE_CONNECTIVITY_CATEGORY;
@@ -49,4 +51,9 @@ public class AdaptiveConnectivitySettings extends DashboardFragment {
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.adaptive_connectivity_settings);
@Override
public @Nullable String getPreferenceScreenBindingKey(@NonNull Context context) {
return AdaptiveConnectivityScreen.KEY;
}
}

View File

@@ -16,7 +16,6 @@
package com.android.settings.network;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -27,13 +26,14 @@ import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.system.ResetDashboardFragment;
import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settings.system.ResetDashboardFragment;
public class EraseEuiccDataDialogFragment extends InstrumentedDialogFragment implements
DialogInterface.OnClickListener {

View File

@@ -498,29 +498,27 @@ class ZenModeSummaryHelper {
MessageFormat msgFormat = new MessageFormat(
mContext.getString(R.string.zen_modes_summary_some_active),
Locale.getDefault());
Map<String, Object> args = new HashMap<>();
args.put("count", activeModes.size());
args.put("mode_1", activeModes.get(0).getName());
if (activeModes.size() >= 2) {
args.put("mode_2", activeModes.get(1).getName());
if (activeModes.size() == 3) {
args.put("mode_3", activeModes.get(2).getName());
}
}
return msgFormat.format(args);
return buildModesSummary(msgFormat, activeModes);
} else {
int automaticModeCount = (int) modes.stream()
.filter(m -> m.isEnabled() && !m.isManualDnd() && !m.isCustomManual())
.count();
MessageFormat msgFormat = new MessageFormat(
mContext.getString(R.string.zen_modes_summary_none_active),
mContext.getString(R.string.zen_modes_summary),
Locale.getDefault());
Map<String, Object> msgArgs = Map.of("count", automaticModeCount);
return msgFormat.format(msgArgs);
return buildModesSummary(msgFormat, modes);
}
}
private static String buildModesSummary(MessageFormat msgFormat, List<ZenMode> modes) {
Map<String, Object> args = new HashMap<>();
args.put("count", modes.size());
if (modes.size() >= 1) {
args.put("mode_1", modes.get(0).getName());
if (modes.size() >= 2) {
args.put("mode_2", modes.get(1).getName());
if (modes.size() >= 3) {
args.put("mode_3", modes.get(2).getName());
}
}
}
return msgFormat.format(args);
}
}

View File

@@ -174,8 +174,8 @@ class ZenModeTriggerUpdatePreferenceController extends AbstractZenModePreference
@DrawableRes int icon;
if (mode.getType() == TYPE_BEDTIME) {
icon = com.android.internal.R.drawable.ic_zen_mode_type_schedule_time; // Clock
} else if (mode.getType() == TYPE_DRIVING) {
icon = com.android.internal.R.drawable.ic_zen_mode_type_driving; // Car
} else if (mode.getType() == TYPE_DRIVING && configurationIntent != null) {
icon = R.drawable.ic_zen_mode_trigger_with_settings; // Gear
} else {
icon = configurationIntent != null ? R.drawable.ic_zen_mode_trigger_with_activity
: R.drawable.ic_zen_mode_trigger_without_activity;

View File

@@ -0,0 +1,45 @@
/*
* Copyright (C) 2024 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.wifi.calling
import android.content.Context
import com.android.settings.R
import com.android.settings.flags.Flags
import com.android.settingslib.metadata.ProvidePreferenceScreen
import com.android.settingslib.metadata.preferenceHierarchy
import com.android.settingslib.preference.PreferenceScreenCreator
@ProvidePreferenceScreen
class WifiCallingScreen : PreferenceScreenCreator {
override val key: String
get() = KEY
override val title: Int
get() = R.string.wifi_calling_settings_title
override val summary: Int
get() = R.string.wifi_calling_summary
override fun isFlagEnabled(context: Context) = Flags.catalystWifiCalling()
override fun fragmentClass() = WifiCallingSettingsForSub::class.java
override fun getPreferenceHierarchy(context: Context) = preferenceHierarchy(this) {}
companion object {
const val KEY = "wifi_calling"
}
}

View File

@@ -724,4 +724,9 @@ public class WifiCallingSettingsForSub extends DashboardFragment
return mOverrideWfcRoamingModeWhileUsingNtn;
}
@Override
public @Nullable String getPreferenceScreenBindingKey(@NonNull Context context) {
return WifiCallingScreen.KEY;
}
}

View File

@@ -57,7 +57,7 @@ import java.util.Collections;
public final class AppWithAdminGrantedPermissionsCounterTest {
@Rule
MockitoRule mMockitoRule = MockitoJUnit.rule();
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
private final String APP_1 = "app1";
private final String APP_2 = "app2";

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2024 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.network
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.settings.flags.Flags
import com.android.settingslib.preference.CatalystScreenTestCase
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class AdaptiveConnectivityScreenTest : CatalystScreenTestCase() {
override val preferenceScreenCreator = AdaptiveConnectivityScreen()
override val flagName
get() = Flags.FLAG_CATALYST_ADAPTIVE_CONNECTIVITY
override fun migration() {}
@Test
fun key() {
assertThat(preferenceScreenCreator.key).isEqualTo(AdaptiveConnectivityScreen.KEY)
}
}

View File

@@ -29,7 +29,6 @@ import static com.google.common.truth.Truth.assertThat;
import static org.robolectric.Shadows.shadowOf;
import android.app.AutomaticZenRule;
import android.app.Flags;
import android.content.Context;
import android.content.pm.ApplicationInfo;
@@ -38,9 +37,7 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.service.notification.SystemZenRules;
import android.service.notification.ZenDeviceEffects;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenPolicy;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
@@ -476,46 +473,61 @@ public class ZenModeSummaryHelperTest {
}
@Test
public void getModesSummary_noRules_noSummary() {
public void getModesSummary_noModesWtf_fallbackSummary() {
String summary = mSummaryHelper.getModesSummary(ImmutableList.of());
assertThat(summary).isEmpty();
assertThat(summary).isEqualTo("Do Not Disturb");
}
@Test
public void getModesSummary_onlyDndAndNotActive_noSummary() {
ImmutableList<ZenMode> modes = ImmutableList.of(TestModeBuilder.MANUAL_DND_INACTIVE);
String summary = mSummaryHelper.getModesSummary(modes);
assertThat(summary).isEmpty();
}
@Test
public void getModesSummary_noRulesActive_countsOnlyEnabledAutomaticModes() {
public void getModesSummary_oneMode_listsMode() {
ImmutableList<ZenMode> modes = ImmutableList.of(
TestModeBuilder.MANUAL_DND_INACTIVE, // Not automatic
new TestModeBuilder().setName("Auto 1").build(), // App provided automatic
new TestModeBuilder()
.setName("Custom manual 1")
.setPackage(SystemZenRules.PACKAGE_ANDROID)
.setType(AutomaticZenRule.TYPE_OTHER)
.setConditionId(ZenModeConfig.toCustomManualConditionId())
.build(), // Custom manual, not automatic
new TestModeBuilder()
.setName("Disabled 1")
.setEnabled(false)
.build(), // Would be automatic, but it's disabled.
new TestModeBuilder()
.setName("Sleep")
.setPackage(SystemZenRules.PACKAGE_ANDROID)
.setType(AutomaticZenRule.TYPE_SCHEDULE_TIME)
.build() // Time based, automatic.
new TestModeBuilder().setName("Surfing").build()
);
String summary = mSummaryHelper.getModesSummary(modes);
assertThat(summary).isEqualTo("2 modes can turn on automatically");
assertThat(summary).isEqualTo("Surfing");
}
@Test
public void getModesSummary_oneModeActive_listsMode() {
public void getModesSummary_twoModes_listsModes() {
ImmutableList<ZenMode> modes = ImmutableList.of(
new TestModeBuilder().setName("Cartwheeling").build(),
new TestModeBuilder().setName("Hula-hooping").build()
);
String summary = mSummaryHelper.getModesSummary(modes);
assertThat(summary).isEqualTo("Cartwheeling, Hula-hooping");
}
@Test
public void getModesSummary_threeModes_listsModes() {
ImmutableList<ZenMode> modes = ImmutableList.of(
new TestModeBuilder().setName("Prancing").build(),
new TestModeBuilder().setName("Hopping").build(),
new TestModeBuilder().setName("Skipping").build()
);
String summary = mSummaryHelper.getModesSummary(modes);
assertThat(summary).isEqualTo("Prancing, Hopping, Skipping");
}
@Test
public void getModesSummary_manyModes_listsThreeModes() {
ImmutableList<ZenMode> modes = ImmutableList.of(
new TestModeBuilder().setName("Juggling").build(),
new TestModeBuilder().setName("Rhyming").build(),
new TestModeBuilder().setName("Meandering").build(),
new TestModeBuilder().setName("Doodling").build(),
new TestModeBuilder().setName("Whistling").build(),
new TestModeBuilder().setName("Lounging").build()
);
String summary = mSummaryHelper.getModesSummary(modes);
assertThat(summary).isEqualTo("Juggling, Rhyming, Meandering");
}
@Test
public void getModesSummary_oneModeActive_listsActiveMode() {
ImmutableList<ZenMode> modes = ImmutableList.of(
TestModeBuilder.MANUAL_DND_ACTIVE,
new TestModeBuilder().setName("Inactive").setActive(false).build());
@@ -525,7 +537,7 @@ public class ZenModeSummaryHelperTest {
}
@Test
public void getModesSummary_twoModesActive_listsModes() {
public void getModesSummary_twoModesActive_listsActiveModes() {
ImmutableList<ZenMode> modes = ImmutableList.of(
TestModeBuilder.MANUAL_DND_ACTIVE,
new TestModeBuilder().setName("Inactive").setActive(false).build(),
@@ -536,7 +548,7 @@ public class ZenModeSummaryHelperTest {
}
@Test
public void getModesSummary_threeModesActive_listsModes() {
public void getModesSummary_threeModesActive_listsActiveModes() {
ImmutableList<ZenMode> modes = ImmutableList.of(
TestModeBuilder.MANUAL_DND_INACTIVE,
new TestModeBuilder().setName("Inactive #1").setActive(false).build(),
@@ -550,7 +562,7 @@ public class ZenModeSummaryHelperTest {
}
@Test
public void getModesSummary_manyModesActive_listsACouple() {
public void getModesSummary_manyModesActive_listsSomeActiveModes() {
ImmutableList<ZenMode> modes = ImmutableList.of(
TestModeBuilder.MANUAL_DND_ACTIVE,
new TestModeBuilder().setName("Inactive #1").setActive(false).build(),

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2024 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.wifi.calling
import com.android.settings.flags.Flags
import com.android.settingslib.preference.CatalystScreenTestCase
import com.google.common.truth.Truth.assertThat
import org.junit.Test
class WifiCallingScreenTest : CatalystScreenTestCase() {
override val preferenceScreenCreator = WifiCallingScreen()
override val flagName: String
get() = Flags.FLAG_CATALYST_WIFI_CALLING
@Test
fun key() {
assertThat(preferenceScreenCreator.key).isEqualTo(WifiCallingScreen.KEY)
}
override fun migration() {}
}