Snap for 9618620 from 40a293fbdf
to tm-qpr3-release
Change-Id: If40d5b126b1a25bab9a0f04ff7d2fc10ff55c1a0
This commit is contained in:
@@ -8828,6 +8828,9 @@
|
|||||||
<!-- Sound: Title for the option managing notification volume. [CHAR LIMIT=30] -->
|
<!-- Sound: Title for the option managing notification volume. [CHAR LIMIT=30] -->
|
||||||
<string name="notification_volume_option_title">Notification volume</string>
|
<string name="notification_volume_option_title">Notification volume</string>
|
||||||
|
|
||||||
|
<!-- Sound: Summary for when notification volume is disabled. [CHAR LIMIT=100] -->
|
||||||
|
<string name="notification_volume_disabled_summary">Unavailable because ring is muted</string>
|
||||||
|
|
||||||
<!-- Sound: Title for the option defining the phone ringtone. [CHAR LIMIT=30] -->
|
<!-- Sound: Title for the option defining the phone ringtone. [CHAR LIMIT=30] -->
|
||||||
<string name="ringtone_title">Phone ringtone</string>
|
<string name="ringtone_title">Phone ringtone</string>
|
||||||
|
|
||||||
|
@@ -86,8 +86,8 @@
|
|||||||
android:icon="@drawable/ic_notifications"
|
android:icon="@drawable/ic_notifications"
|
||||||
android:title="@string/notification_volume_option_title"
|
android:title="@string/notification_volume_option_title"
|
||||||
android:order="-150"
|
android:order="-150"
|
||||||
settings:controller=
|
settings:controller="com.android.settings.notification.NotificationVolumePreferenceController"
|
||||||
"com.android.settings.notification.NotificationVolumePreferenceController"/>
|
settings:unavailableSliceSubtitle="@string/notification_volume_disabled_summary"/>
|
||||||
|
|
||||||
<!-- Alarm volume -->
|
<!-- Alarm volume -->
|
||||||
<com.android.settings.notification.VolumeSeekBarPreference
|
<com.android.settings.notification.VolumeSeekBarPreference
|
||||||
|
@@ -154,7 +154,7 @@ public class SettingsInitialize extends BroadcastReceiver {
|
|||||||
DeepLinkHomepageActivity.class);
|
DeepLinkHomepageActivity.class);
|
||||||
final ComponentName searchStateReceiver = new ComponentName(context,
|
final ComponentName searchStateReceiver = new ComponentName(context,
|
||||||
SearchStateReceiver.class);
|
SearchStateReceiver.class);
|
||||||
final int enableState = SplitController.getInstance().isSplitSupported()
|
final int enableState = SplitController.getInstance(context).isSplitSupported()
|
||||||
? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
|
? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
|
||||||
: PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
|
: PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
|
||||||
pm.setComponentEnabledSetting(deepLinkHome, enableState, PackageManager.DONT_KILL_APP);
|
pm.setComponentEnabledSetting(deepLinkHome, enableState, PackageManager.DONT_KILL_APP);
|
||||||
|
@@ -22,12 +22,12 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.util.FeatureFlagUtils;
|
import android.util.FeatureFlagUtils;
|
||||||
import android.util.LayoutDirection;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.window.embedding.ActivityFilter;
|
import androidx.window.embedding.ActivityFilter;
|
||||||
import androidx.window.embedding.ActivityRule;
|
import androidx.window.embedding.ActivityRule;
|
||||||
import androidx.window.embedding.SplitController;
|
import androidx.window.embedding.RuleController;
|
||||||
|
import androidx.window.embedding.SplitAttributes;
|
||||||
import androidx.window.embedding.SplitPairFilter;
|
import androidx.window.embedding.SplitPairFilter;
|
||||||
import androidx.window.embedding.SplitPairRule;
|
import androidx.window.embedding.SplitPairRule;
|
||||||
import androidx.window.embedding.SplitPlaceholderRule;
|
import androidx.window.embedding.SplitPlaceholderRule;
|
||||||
@@ -49,6 +49,7 @@ import com.android.settings.overlay.FeatureFactory;
|
|||||||
import com.android.settings.password.ChooseLockPattern;
|
import com.android.settings.password.ChooseLockPattern;
|
||||||
import com.android.settingslib.users.AvatarPickerActivity;
|
import com.android.settingslib.users.AvatarPickerActivity;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -59,11 +60,11 @@ public class ActivityEmbeddingRulesController {
|
|||||||
private static final ComponentName COMPONENT_NAME_WILDCARD = new ComponentName(
|
private static final ComponentName COMPONENT_NAME_WILDCARD = new ComponentName(
|
||||||
"*" /* pkg */, "*" /* cls */);
|
"*" /* pkg */, "*" /* cls */);
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final SplitController mSplitController;
|
private final RuleController mRuleController;
|
||||||
|
|
||||||
public ActivityEmbeddingRulesController(Context context) {
|
public ActivityEmbeddingRulesController(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mSplitController = SplitController.getInstance();
|
mRuleController = RuleController.getInstance(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,7 +76,7 @@ public class ActivityEmbeddingRulesController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mSplitController.clearRegisteredRules();
|
mRuleController.clearRules();
|
||||||
|
|
||||||
// Set a placeholder for home page.
|
// Set a placeholder for home page.
|
||||||
registerHomepagePlaceholderRule();
|
registerHomepagePlaceholderRule();
|
||||||
@@ -88,8 +89,8 @@ public class ActivityEmbeddingRulesController {
|
|||||||
ComponentName primaryComponent,
|
ComponentName primaryComponent,
|
||||||
ComponentName secondaryComponent,
|
ComponentName secondaryComponent,
|
||||||
String secondaryIntentAction,
|
String secondaryIntentAction,
|
||||||
int finishPrimaryWithSecondary,
|
SplitRule.FinishBehavior finishPrimaryWithSecondary,
|
||||||
int finishSecondaryWithPrimary,
|
SplitRule.FinishBehavior finishSecondaryWithPrimary,
|
||||||
boolean clearTop) {
|
boolean clearTop) {
|
||||||
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
|
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
|
||||||
return;
|
return;
|
||||||
@@ -98,14 +99,20 @@ public class ActivityEmbeddingRulesController {
|
|||||||
filters.add(new SplitPairFilter(primaryComponent, secondaryComponent,
|
filters.add(new SplitPairFilter(primaryComponent, secondaryComponent,
|
||||||
secondaryIntentAction));
|
secondaryIntentAction));
|
||||||
|
|
||||||
SplitController.getInstance().registerRule(new SplitPairRule(filters,
|
SplitAttributes attributes = new SplitAttributes.Builder()
|
||||||
finishPrimaryWithSecondary,
|
.setSplitType(SplitAttributes.SplitType.ratio(
|
||||||
finishSecondaryWithPrimary,
|
ActivityEmbeddingUtils.getSplitRatio(context)))
|
||||||
clearTop,
|
.setLayoutDirection(SplitAttributes.LayoutDirection.LOCALE)
|
||||||
ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthPx(context),
|
.build();
|
||||||
ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthPx(context),
|
SplitPairRule splitPairRule = new SplitPairRule.Builder(filters)
|
||||||
ActivityEmbeddingUtils.getSplitRatio(context),
|
.setFinishPrimaryWithSecondary(finishPrimaryWithSecondary)
|
||||||
LayoutDirection.LOCALE));
|
.setFinishSecondaryWithPrimary(finishSecondaryWithPrimary)
|
||||||
|
.setClearTop(clearTop)
|
||||||
|
.setMinWidthDp(ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthDp())
|
||||||
|
.setMinSmallestWidthDp(ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthDp())
|
||||||
|
.setDefaultSplitAttributes(attributes)
|
||||||
|
.build();
|
||||||
|
RuleController.getInstance(context).addRule(splitPairRule);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,8 +133,10 @@ public class ActivityEmbeddingRulesController {
|
|||||||
new ComponentName(context, Settings.class),
|
new ComponentName(context, Settings.class),
|
||||||
secondaryComponent,
|
secondaryComponent,
|
||||||
secondaryIntentAction,
|
secondaryIntentAction,
|
||||||
finishPrimaryWithSecondary ? SplitRule.FINISH_ADJACENT : SplitRule.FINISH_NEVER,
|
finishPrimaryWithSecondary ? SplitRule.FinishBehavior.ADJACENT
|
||||||
finishSecondaryWithPrimary ? SplitRule.FINISH_ADJACENT : SplitRule.FINISH_NEVER,
|
: SplitRule.FinishBehavior.NEVER,
|
||||||
|
finishSecondaryWithPrimary ? SplitRule.FinishBehavior.ADJACENT
|
||||||
|
: SplitRule.FinishBehavior.NEVER,
|
||||||
clearTop);
|
clearTop);
|
||||||
|
|
||||||
registerTwoPanePairRule(
|
registerTwoPanePairRule(
|
||||||
@@ -135,8 +144,10 @@ public class ActivityEmbeddingRulesController {
|
|||||||
new ComponentName(context, SettingsHomepageActivity.class),
|
new ComponentName(context, SettingsHomepageActivity.class),
|
||||||
secondaryComponent,
|
secondaryComponent,
|
||||||
secondaryIntentAction,
|
secondaryIntentAction,
|
||||||
finishPrimaryWithSecondary ? SplitRule.FINISH_ADJACENT : SplitRule.FINISH_NEVER,
|
finishPrimaryWithSecondary ? SplitRule.FinishBehavior.ADJACENT
|
||||||
finishSecondaryWithPrimary ? SplitRule.FINISH_ADJACENT : SplitRule.FINISH_NEVER,
|
: SplitRule.FinishBehavior.NEVER,
|
||||||
|
finishSecondaryWithPrimary ? SplitRule.FinishBehavior.ADJACENT
|
||||||
|
: SplitRule.FinishBehavior.NEVER,
|
||||||
clearTop);
|
clearTop);
|
||||||
|
|
||||||
// We should finish HomePageActivity altogether even if it shows in single pane for all deep
|
// We should finish HomePageActivity altogether even if it shows in single pane for all deep
|
||||||
@@ -146,8 +157,10 @@ public class ActivityEmbeddingRulesController {
|
|||||||
new ComponentName(context, DeepLinkHomepageActivity.class),
|
new ComponentName(context, DeepLinkHomepageActivity.class),
|
||||||
secondaryComponent,
|
secondaryComponent,
|
||||||
secondaryIntentAction,
|
secondaryIntentAction,
|
||||||
finishPrimaryWithSecondary ? SplitRule.FINISH_ALWAYS : SplitRule.FINISH_NEVER,
|
finishPrimaryWithSecondary ? SplitRule.FinishBehavior.ALWAYS
|
||||||
finishSecondaryWithPrimary ? SplitRule.FINISH_ALWAYS : SplitRule.FINISH_NEVER,
|
: SplitRule.FinishBehavior.NEVER,
|
||||||
|
finishSecondaryWithPrimary ? SplitRule.FinishBehavior.ALWAYS
|
||||||
|
: SplitRule.FinishBehavior.NEVER,
|
||||||
clearTop);
|
clearTop);
|
||||||
|
|
||||||
registerTwoPanePairRule(
|
registerTwoPanePairRule(
|
||||||
@@ -155,8 +168,10 @@ public class ActivityEmbeddingRulesController {
|
|||||||
new ComponentName(context, DeepLinkHomepageActivityInternal.class),
|
new ComponentName(context, DeepLinkHomepageActivityInternal.class),
|
||||||
secondaryComponent,
|
secondaryComponent,
|
||||||
secondaryIntentAction,
|
secondaryIntentAction,
|
||||||
finishPrimaryWithSecondary ? SplitRule.FINISH_ALWAYS : SplitRule.FINISH_NEVER,
|
finishPrimaryWithSecondary ? SplitRule.FinishBehavior.ALWAYS
|
||||||
finishSecondaryWithPrimary ? SplitRule.FINISH_ALWAYS : SplitRule.FINISH_NEVER,
|
: SplitRule.FinishBehavior.NEVER,
|
||||||
|
finishSecondaryWithPrimary ? SplitRule.FinishBehavior.ALWAYS
|
||||||
|
: SplitRule.FinishBehavior.NEVER,
|
||||||
clearTop);
|
clearTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,17 +222,20 @@ public class ActivityEmbeddingRulesController {
|
|||||||
|
|
||||||
final Intent intent = new Intent(mContext, Settings.NetworkDashboardActivity.class);
|
final Intent intent = new Intent(mContext, Settings.NetworkDashboardActivity.class);
|
||||||
intent.putExtra(SettingsActivity.EXTRA_IS_SECOND_LAYER_PAGE, true);
|
intent.putExtra(SettingsActivity.EXTRA_IS_SECOND_LAYER_PAGE, true);
|
||||||
final SplitPlaceholderRule placeholderRule = new SplitPlaceholderRule(
|
SplitAttributes attributes = new SplitAttributes.Builder()
|
||||||
activityFilters,
|
.setSplitType(SplitAttributes.SplitType.ratio(
|
||||||
intent,
|
ActivityEmbeddingUtils.getSplitRatio(mContext)))
|
||||||
false /* stickyPlaceholder */,
|
.build();
|
||||||
SplitRule.FINISH_ADJACENT,
|
final SplitPlaceholderRule placeholderRule = new SplitPlaceholderRule.Builder(
|
||||||
ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthPx(mContext),
|
activityFilters, intent)
|
||||||
ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthPx(mContext),
|
.setMinWidthDp(ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthDp())
|
||||||
ActivityEmbeddingUtils.getSplitRatio(mContext),
|
.setMinSmallestWidthDp(ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthDp())
|
||||||
LayoutDirection.LOCALE);
|
.setSticky(false)
|
||||||
|
.setFinishPrimaryWithPlaceholder(SplitRule.FinishBehavior.ADJACENT)
|
||||||
|
.setDefaultSplitAttributes(attributes)
|
||||||
|
.build();
|
||||||
|
|
||||||
mSplitController.registerRule(placeholderRule);
|
mRuleController.addRule(placeholderRule);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerAlwaysExpandRule() {
|
private void registerAlwaysExpandRule() {
|
||||||
@@ -235,14 +253,16 @@ public class ActivityEmbeddingRulesController {
|
|||||||
addActivityFilter(activityFilters, FaceEnrollIntroduction.class);
|
addActivityFilter(activityFilters, FaceEnrollIntroduction.class);
|
||||||
addActivityFilter(activityFilters, AvatarPickerActivity.class);
|
addActivityFilter(activityFilters, AvatarPickerActivity.class);
|
||||||
addActivityFilter(activityFilters, ChooseLockPattern.class);
|
addActivityFilter(activityFilters, ChooseLockPattern.class);
|
||||||
mSplitController.registerRule(new ActivityRule(activityFilters, true /* alwaysExpand */));
|
ActivityRule activityRule = new ActivityRule.Builder(activityFilters).setAlwaysExpand(true)
|
||||||
|
.build();
|
||||||
|
mRuleController.addRule(activityRule);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addActivityFilter(Set<ActivityFilter> activityFilters, Intent intent) {
|
private static void addActivityFilter(Set<ActivityFilter> activityFilters, Intent intent) {
|
||||||
activityFilters.add(new ActivityFilter(COMPONENT_NAME_WILDCARD, intent.getAction()));
|
activityFilters.add(new ActivityFilter(COMPONENT_NAME_WILDCARD, intent.getAction()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addActivityFilter(Set<ActivityFilter> activityFilters,
|
private void addActivityFilter(Collection<ActivityFilter> activityFilters,
|
||||||
Class<? extends Activity> activityClass) {
|
Class<? extends Activity> activityClass) {
|
||||||
activityFilters.add(new ActivityFilter(new ComponentName(mContext, activityClass),
|
activityFilters.add(new ActivityFilter(new ComponentName(mContext, activityClass),
|
||||||
null /* intentAction */));
|
null /* intentAction */));
|
||||||
|
@@ -30,29 +30,25 @@ import com.android.settings.R;
|
|||||||
/** An util class collecting all common methods for the embedding activity features. */
|
/** An util class collecting all common methods for the embedding activity features. */
|
||||||
public class ActivityEmbeddingUtils {
|
public class ActivityEmbeddingUtils {
|
||||||
// The smallest value of current width of the window when the split should be used.
|
// The smallest value of current width of the window when the split should be used.
|
||||||
private static final float MIN_CURRENT_SCREEN_SPLIT_WIDTH_DP = 720f;
|
private static final int MIN_CURRENT_SCREEN_SPLIT_WIDTH_DP = 720;
|
||||||
// The smallest value of the smallest-width (sw) of the window in any rotation when
|
// The smallest value of the smallest-width (sw) of the window in any rotation when
|
||||||
// the split should be used.
|
// the split should be used.
|
||||||
private static final float MIN_SMALLEST_SCREEN_SPLIT_WIDTH_DP = 600f;
|
private static final int MIN_SMALLEST_SCREEN_SPLIT_WIDTH_DP = 600;
|
||||||
// The minimum width of the activity to show the regular homepage layout.
|
// The minimum width of the activity to show the regular homepage layout.
|
||||||
private static final float MIN_REGULAR_HOMEPAGE_LAYOUT_WIDTH_DP = 380f;
|
private static final float MIN_REGULAR_HOMEPAGE_LAYOUT_WIDTH_DP = 380f;
|
||||||
private static final String TAG = "ActivityEmbeddingUtils";
|
private static final String TAG = "ActivityEmbeddingUtils";
|
||||||
|
|
||||||
/** Get the smallest pixel value of width of the window when the split should be used. */
|
/** Get the smallest width dp of the window when the split should be used. */
|
||||||
public static int getMinCurrentScreenSplitWidthPx(Context context) {
|
public static int getMinCurrentScreenSplitWidthDp() {
|
||||||
final DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
return MIN_CURRENT_SCREEN_SPLIT_WIDTH_DP;
|
||||||
return (int) TypedValue.applyDimension(
|
|
||||||
TypedValue.COMPLEX_UNIT_DIP, MIN_CURRENT_SCREEN_SPLIT_WIDTH_DP, dm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the smallest pixel value of the smallest-width (sw) of the window in any rotation when
|
* Get the smallest dp value of the smallest-width (sw) of the window in any rotation when
|
||||||
* the split should be used.
|
* the split should be used.
|
||||||
*/
|
*/
|
||||||
public static int getMinSmallestScreenSplitWidthPx(Context context) {
|
public static int getMinSmallestScreenSplitWidthDp() {
|
||||||
final DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
return MIN_SMALLEST_SCREEN_SPLIT_WIDTH_DP;
|
||||||
return (int) TypedValue.applyDimension(
|
|
||||||
TypedValue.COMPLEX_UNIT_DIP, MIN_SMALLEST_SCREEN_SPLIT_WIDTH_DP, dm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,7 +63,7 @@ public class ActivityEmbeddingUtils {
|
|||||||
public static boolean isEmbeddingActivityEnabled(Context context) {
|
public static boolean isEmbeddingActivityEnabled(Context context) {
|
||||||
final boolean isFlagEnabled = FeatureFlagUtils.isEnabled(context,
|
final boolean isFlagEnabled = FeatureFlagUtils.isEnabled(context,
|
||||||
FeatureFlagUtils.SETTINGS_SUPPORT_LARGE_SCREEN);
|
FeatureFlagUtils.SETTINGS_SUPPORT_LARGE_SCREEN);
|
||||||
final boolean isSplitSupported = SplitController.getInstance().isSplitSupported();
|
final boolean isSplitSupported = SplitController.getInstance(context).isSplitSupported();
|
||||||
|
|
||||||
Log.d(TAG, "isFlagEnabled = " + isFlagEnabled);
|
Log.d(TAG, "isFlagEnabled = " + isFlagEnabled);
|
||||||
Log.d(TAG, "isSplitSupported = " + isSplitSupported);
|
Log.d(TAG, "isSplitSupported = " + isSplitSupported);
|
||||||
|
@@ -56,6 +56,7 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
import androidx.window.embedding.ActivityEmbeddingController;
|
||||||
import androidx.window.embedding.SplitController;
|
import androidx.window.embedding.SplitController;
|
||||||
import androidx.window.embedding.SplitRule;
|
import androidx.window.embedding.SplitRule;
|
||||||
|
|
||||||
@@ -102,7 +103,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
|||||||
private View mTwoPaneSuggestionView;
|
private View mTwoPaneSuggestionView;
|
||||||
private CategoryMixin mCategoryMixin;
|
private CategoryMixin mCategoryMixin;
|
||||||
private Set<HomepageLoadedListener> mLoadedListeners;
|
private Set<HomepageLoadedListener> mLoadedListeners;
|
||||||
private SplitController mSplitController;
|
private ActivityEmbeddingController mActivityEmbeddingController;
|
||||||
private boolean mIsEmbeddingActivityEnabled;
|
private boolean mIsEmbeddingActivityEnabled;
|
||||||
private boolean mIsTwoPane;
|
private boolean mIsTwoPane;
|
||||||
// A regular layout shows icons on homepage, whereas a simplified layout doesn't.
|
// A regular layout shows icons on homepage, whereas a simplified layout doesn't.
|
||||||
@@ -190,8 +191,8 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
|||||||
setupEdgeToEdge();
|
setupEdgeToEdge();
|
||||||
setContentView(R.layout.settings_homepage_container);
|
setContentView(R.layout.settings_homepage_container);
|
||||||
|
|
||||||
mSplitController = SplitController.getInstance();
|
mActivityEmbeddingController = ActivityEmbeddingController.getInstance(this);
|
||||||
mIsTwoPane = mSplitController.isActivityEmbedded(this);
|
mIsTwoPane = mActivityEmbeddingController.isActivityEmbedded(this);
|
||||||
|
|
||||||
updateAppBarMinHeight();
|
updateAppBarMinHeight();
|
||||||
initHomepageContainer();
|
initHomepageContainer();
|
||||||
@@ -266,7 +267,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
|||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
final boolean newTwoPaneState = mSplitController.isActivityEmbedded(this);
|
final boolean newTwoPaneState = mActivityEmbeddingController.isActivityEmbedded(this);
|
||||||
if (mIsTwoPane != newTwoPaneState) {
|
if (mIsTwoPane != newTwoPaneState) {
|
||||||
mIsTwoPane = newTwoPaneState;
|
mIsTwoPane = newTwoPaneState;
|
||||||
updateHomepageAppBar();
|
updateHomepageAppBar();
|
||||||
@@ -518,15 +519,15 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
|||||||
new ComponentName(getApplicationContext(), getClass()),
|
new ComponentName(getApplicationContext(), getClass()),
|
||||||
targetComponentName,
|
targetComponentName,
|
||||||
targetIntent.getAction(),
|
targetIntent.getAction(),
|
||||||
SplitRule.FINISH_ALWAYS,
|
SplitRule.FinishBehavior.ALWAYS,
|
||||||
SplitRule.FINISH_ALWAYS,
|
SplitRule.FinishBehavior.ALWAYS,
|
||||||
true /* clearTop */);
|
true /* clearTop */);
|
||||||
ActivityEmbeddingRulesController.registerTwoPanePairRule(this,
|
ActivityEmbeddingRulesController.registerTwoPanePairRule(this,
|
||||||
new ComponentName(getApplicationContext(), Settings.class),
|
new ComponentName(getApplicationContext(), Settings.class),
|
||||||
targetComponentName,
|
targetComponentName,
|
||||||
targetIntent.getAction(),
|
targetIntent.getAction(),
|
||||||
SplitRule.FINISH_ALWAYS,
|
SplitRule.FinishBehavior.ALWAYS,
|
||||||
SplitRule.FINISH_ALWAYS,
|
SplitRule.FinishBehavior.ALWAYS,
|
||||||
true /* clearTop */);
|
true /* clearTop */);
|
||||||
|
|
||||||
final UserHandle user = intent.getParcelableExtra(EXTRA_USER_HANDLE, UserHandle.class);
|
final UserHandle user = intent.getParcelableExtra(EXTRA_USER_HANDLE, UserHandle.class);
|
||||||
|
@@ -35,7 +35,7 @@ import androidx.preference.Preference;
|
|||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.window.embedding.SplitController;
|
import androidx.window.embedding.ActivityEmbeddingController;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
@@ -65,6 +65,7 @@ public class TopLevelSettings extends DashboardFragment implements SplitLayoutLi
|
|||||||
private int mPaddingHorizontal;
|
private int mPaddingHorizontal;
|
||||||
private boolean mScrollNeeded = true;
|
private boolean mScrollNeeded = true;
|
||||||
private boolean mFirstStarted = true;
|
private boolean mFirstStarted = true;
|
||||||
|
private ActivityEmbeddingController mActivityEmbeddingController;
|
||||||
|
|
||||||
public TopLevelSettings() {
|
public TopLevelSettings() {
|
||||||
final Bundle args = new Bundle();
|
final Bundle args = new Bundle();
|
||||||
@@ -143,7 +144,7 @@ public class TopLevelSettings extends DashboardFragment implements SplitLayoutLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean activityEmbedded = SplitController.getInstance().isActivityEmbedded(getActivity());
|
boolean activityEmbedded = isActivityEmbedded();
|
||||||
if (icicle != null) {
|
if (icicle != null) {
|
||||||
mHighlightMixin = icicle.getParcelable(SAVED_HIGHLIGHT_MIXIN);
|
mHighlightMixin = icicle.getParcelable(SAVED_HIGHLIGHT_MIXIN);
|
||||||
mScrollNeeded = !mHighlightMixin.isActivityEmbedded() && activityEmbedded;
|
mScrollNeeded = !mHighlightMixin.isActivityEmbedded() && activityEmbedded;
|
||||||
@@ -154,6 +155,14 @@ public class TopLevelSettings extends DashboardFragment implements SplitLayoutLi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Wrap ActivityEmbeddingController#isActivityEmbedded for testing. */
|
||||||
|
public boolean isActivityEmbedded() {
|
||||||
|
if (mActivityEmbeddingController == null) {
|
||||||
|
mActivityEmbeddingController = ActivityEmbeddingController.getInstance(getActivity());
|
||||||
|
}
|
||||||
|
return mActivityEmbeddingController.isActivityEmbedded(getActivity());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
if (mFirstStarted) {
|
if (mFirstStarted) {
|
||||||
@@ -161,7 +170,7 @@ public class TopLevelSettings extends DashboardFragment implements SplitLayoutLi
|
|||||||
FeatureFactory.getFactory(getContext()).getSearchFeatureProvider().sendPreIndexIntent(
|
FeatureFactory.getFactory(getContext()).getSearchFeatureProvider().sendPreIndexIntent(
|
||||||
getContext());
|
getContext());
|
||||||
} else if (mIsEmbeddingActivityEnabled && isOnlyOneActivityInTask()
|
} else if (mIsEmbeddingActivityEnabled && isOnlyOneActivityInTask()
|
||||||
&& !SplitController.getInstance().isActivityEmbedded(getActivity())) {
|
&& !isActivityEmbedded()) {
|
||||||
// Set default highlight menu key for 1-pane homepage since it will show the placeholder
|
// Set default highlight menu key for 1-pane homepage since it will show the placeholder
|
||||||
// page once changing back to 2-pane.
|
// page once changing back to 2-pane.
|
||||||
Log.i(TAG, "Set default menu key");
|
Log.i(TAG, "Set default menu key");
|
||||||
@@ -286,7 +295,7 @@ public class TopLevelSettings extends DashboardFragment implements SplitLayoutLi
|
|||||||
* 3. the current activity is embedded */
|
* 3. the current activity is embedded */
|
||||||
return mHighlightMixin != null
|
return mHighlightMixin != null
|
||||||
&& TextUtils.equals(pref.getKey(), mHighlightMixin.getHighlightPreferenceKey())
|
&& TextUtils.equals(pref.getKey(), mHighlightMixin.getHighlightPreferenceKey())
|
||||||
&& SplitController.getInstance().isActivityEmbedded(getActivity());
|
&& isActivityEmbedded();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Show/hide the highlight on the menu entry for the search page presence */
|
/** Show/hide the highlight on the menu entry for the search page presence */
|
||||||
|
@@ -51,7 +51,6 @@ public class NotificationVolumePreferenceController extends
|
|||||||
private final RingReceiver mReceiver = new RingReceiver();
|
private final RingReceiver mReceiver = new RingReceiver();
|
||||||
private final H mHandler = new H();
|
private final H mHandler = new H();
|
||||||
|
|
||||||
|
|
||||||
public NotificationVolumePreferenceController(Context context) {
|
public NotificationVolumePreferenceController(Context context) {
|
||||||
this(context, KEY_NOTIFICATION_VOLUME);
|
this(context, KEY_NOTIFICATION_VOLUME);
|
||||||
}
|
}
|
||||||
@@ -63,7 +62,9 @@ public class NotificationVolumePreferenceController extends
|
|||||||
mVibrateIconId = R.drawable.ic_volume_ringer_vibrate;
|
mVibrateIconId = R.drawable.ic_volume_ringer_vibrate;
|
||||||
mSilentIconId = R.drawable.ic_notifications_off_24dp;
|
mSilentIconId = R.drawable.ic_notifications_off_24dp;
|
||||||
|
|
||||||
updateRingerMode();
|
if (updateRingerMode()) {
|
||||||
|
updateEnabledState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,12 +78,10 @@ public class NotificationVolumePreferenceController extends
|
|||||||
if (mPreference == null) {
|
if (mPreference == null) {
|
||||||
setupVolPreference(screen);
|
setupVolPreference(screen);
|
||||||
}
|
}
|
||||||
mSeparateNotification = isSeparateNotificationConfigEnabled();
|
|
||||||
if (mPreference != null) {
|
|
||||||
mPreference.setVisible(getAvailabilityStatus() == AVAILABLE);
|
|
||||||
}
|
|
||||||
updateEffectsSuppressor();
|
updateEffectsSuppressor();
|
||||||
selectPreferenceIconState();
|
selectPreferenceIconState();
|
||||||
|
updateEnabledState();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,15 +94,19 @@ public class NotificationVolumePreferenceController extends
|
|||||||
boolean newVal = isSeparateNotificationConfigEnabled();
|
boolean newVal = isSeparateNotificationConfigEnabled();
|
||||||
if (newVal != mSeparateNotification) {
|
if (newVal != mSeparateNotification) {
|
||||||
mSeparateNotification = newVal;
|
mSeparateNotification = newVal;
|
||||||
// manually hiding the preference because being unavailable does not do the job
|
// Update UI if config change happens when Sound Settings page is on the foreground
|
||||||
if (mPreference != null) {
|
if (mPreference != null) {
|
||||||
mPreference.setVisible(getAvailabilityStatus() == AVAILABLE);
|
int status = getAvailabilityStatus();
|
||||||
|
mPreference.setVisible(status == AVAILABLE
|
||||||
|
|| status == DISABLED_DEPENDENT_SETTING);
|
||||||
|
if (status == DISABLED_DEPENDENT_SETTING) {
|
||||||
|
mPreference.setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
@@ -126,10 +129,11 @@ public class NotificationVolumePreferenceController extends
|
|||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
boolean separateNotification = isSeparateNotificationConfigEnabled();
|
boolean separateNotification = isSeparateNotificationConfigEnabled();
|
||||||
|
|
||||||
return mContext.getResources().getBoolean(R.bool.config_show_notification_volume)
|
return mContext.getResources().getBoolean(R.bool.config_show_notification_volume)
|
||||||
&& !mHelper.isSingleVolume() && separateNotification
|
&& !mHelper.isSingleVolume() && separateNotification
|
||||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
? (mRingerMode == AudioManager.RINGER_MODE_NORMAL
|
||||||
|
? AVAILABLE : DISABLED_DEPENDENT_SETTING)
|
||||||
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -158,7 +162,6 @@ public class NotificationVolumePreferenceController extends
|
|||||||
if (mVibrator != null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
|
if (mVibrator != null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
|
||||||
mMuteIcon = mVibrateIconId;
|
mMuteIcon = mVibrateIconId;
|
||||||
mPreference.showIcon(mVibrateIconId);
|
mPreference.showIcon(mVibrateIconId);
|
||||||
|
|
||||||
} else if (mRingerMode == AudioManager.RINGER_MODE_SILENT
|
} else if (mRingerMode == AudioManager.RINGER_MODE_SILENT
|
||||||
|| mVibrator == null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
|
|| mVibrator == null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
|
||||||
mMuteIcon = mSilentIconId;
|
mMuteIcon = mSilentIconId;
|
||||||
@@ -175,6 +178,12 @@ public class NotificationVolumePreferenceController extends
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateEnabledState() {
|
||||||
|
if (mPreference != null) {
|
||||||
|
mPreference.setEnabled(mRingerMode == AudioManager.RINGER_MODE_NORMAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final class H extends Handler {
|
private final class H extends Handler {
|
||||||
private static final int UPDATE_EFFECTS_SUPPRESSOR = 1;
|
private static final int UPDATE_EFFECTS_SUPPRESSOR = 1;
|
||||||
private static final int UPDATE_RINGER_MODE = 2;
|
private static final int UPDATE_RINGER_MODE = 2;
|
||||||
@@ -191,10 +200,13 @@ public class NotificationVolumePreferenceController extends
|
|||||||
updateEffectsSuppressor();
|
updateEffectsSuppressor();
|
||||||
break;
|
break;
|
||||||
case UPDATE_RINGER_MODE:
|
case UPDATE_RINGER_MODE:
|
||||||
updateRingerMode();
|
if (updateRingerMode()) {
|
||||||
|
updateEnabledState();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NOTIFICATION_VOLUME_CHANGED:
|
case NOTIFICATION_VOLUME_CHANGED:
|
||||||
selectPreferenceIconState();
|
selectPreferenceIconState();
|
||||||
|
updateEnabledState();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,5 +251,4 @@ public class NotificationVolumePreferenceController extends
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -140,11 +140,18 @@ public abstract class RingerModeAffectedVolumePreferenceController extends
|
|||||||
return valueUpdated;
|
return valueUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateRingerMode() {
|
/**
|
||||||
|
* Updates UI Icon in response to ringer mode changes.
|
||||||
|
* @return whether the ringer mode has changed.
|
||||||
|
*/
|
||||||
|
protected boolean updateRingerMode() {
|
||||||
final int ringerMode = mHelper.getRingerModeInternal();
|
final int ringerMode = mHelper.getRingerModeInternal();
|
||||||
if (mRingerMode == ringerMode) return;
|
if (mRingerMode == ringerMode) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
mRingerMode = ringerMode;
|
mRingerMode = ringerMode;
|
||||||
selectPreferenceIconState();
|
selectPreferenceIconState();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -93,8 +93,9 @@ public class VolumeSliceHelper {
|
|||||||
|
|
||||||
if (AudioManager.VOLUME_CHANGED_ACTION.equals(action)) {
|
if (AudioManager.VOLUME_CHANGED_ACTION.equals(action)) {
|
||||||
handleVolumeChanged(context, intent);
|
handleVolumeChanged(context, intent);
|
||||||
} else if (AudioManager.STREAM_MUTE_CHANGED_ACTION.equals(action)
|
} else if (AudioManager.STREAM_MUTE_CHANGED_ACTION.equals(action)) {
|
||||||
|| AudioManager.STREAM_DEVICES_CHANGED_ACTION.equals(action)) {
|
handleMuteChanged(context, intent);
|
||||||
|
} else if (AudioManager.STREAM_DEVICES_CHANGED_ACTION.equals(action)) {
|
||||||
handleStreamChanged(context, intent);
|
handleStreamChanged(context, intent);
|
||||||
} else {
|
} else {
|
||||||
notifyAllStreamsChanged(context);
|
notifyAllStreamsChanged(context);
|
||||||
@@ -109,8 +110,29 @@ public class VolumeSliceHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When mute is changed, notifyChange on relevant Volume Slice ContentResolvers to mark them
|
||||||
|
* as needing update.
|
||||||
|
*
|
||||||
|
* In addition to the matching stream, we always notifyChange for the Notification stream
|
||||||
|
* when Ring events are issued. This is to make sure that Notification always gets updated
|
||||||
|
* for RingerMode changes, even if Notification's volume is zero and therefore it would not
|
||||||
|
* get its own AudioManager.VOLUME_CHANGED_ACTION.
|
||||||
|
*/
|
||||||
|
private static void handleMuteChanged(Context context, Intent intent) {
|
||||||
|
final int inputType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1);
|
||||||
|
handleStreamChanged(context, inputType);
|
||||||
|
if (inputType == AudioManager.STREAM_RING) {
|
||||||
|
handleStreamChanged(context, AudioManager.STREAM_NOTIFICATION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void handleStreamChanged(Context context, Intent intent) {
|
private static void handleStreamChanged(Context context, Intent intent) {
|
||||||
final int inputType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1);
|
final int inputType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1);
|
||||||
|
handleStreamChanged(context, inputType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleStreamChanged(Context context, int inputType) {
|
||||||
synchronized (sRegisteredUri) {
|
synchronized (sRegisteredUri) {
|
||||||
for (Map.Entry<Uri, Integer> entry : sRegisteredUri.entrySet()) {
|
for (Map.Entry<Uri, Integer> entry : sRegisteredUri.entrySet()) {
|
||||||
if (entry.getValue() == inputType) {
|
if (entry.getValue() == inputType) {
|
||||||
|
@@ -30,7 +30,7 @@ import androidx.preference.PreferenceGroup;
|
|||||||
import androidx.preference.PreferenceGroupAdapter;
|
import androidx.preference.PreferenceGroupAdapter;
|
||||||
import androidx.preference.PreferenceViewHolder;
|
import androidx.preference.PreferenceViewHolder;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.window.embedding.SplitController;
|
import androidx.window.embedding.ActivityEmbeddingController;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
@@ -250,6 +250,7 @@ public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapt
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isHighlightNeeded() {
|
private boolean isHighlightNeeded() {
|
||||||
return SplitController.getInstance().isActivityEmbedded(mHomepageActivity);
|
return ActivityEmbeddingController.getInstance(mHomepageActivity)
|
||||||
|
.isActivityEmbedded(mHomepageActivity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -198,6 +198,7 @@ public class NotificationVolumePreferenceControllerTest {
|
|||||||
com.android.settings.R.bool.config_show_notification_volume)).thenReturn(true);
|
com.android.settings.R.bool.config_show_notification_volume)).thenReturn(true);
|
||||||
// block the alternative condition to enable controller
|
// block the alternative condition to enable controller
|
||||||
when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
|
when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
|
||||||
|
|
||||||
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
|
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||||
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, "false", false);
|
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, "false", false);
|
||||||
@@ -217,8 +218,8 @@ public class NotificationVolumePreferenceControllerTest {
|
|||||||
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, Boolean.toString(true),
|
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, Boolean.toString(true),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
assertThat(controller.getAvailabilityStatus()
|
assertThat(controller.getAvailabilityStatus()).isEqualTo(
|
||||||
== BasePreferenceController.AVAILABLE).isTrue();
|
BasePreferenceController.AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -233,9 +234,10 @@ public class NotificationVolumePreferenceControllerTest {
|
|||||||
// block the alternative condition to enable controller
|
// block the alternative condition to enable controller
|
||||||
when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
|
when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
|
||||||
|
|
||||||
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
|
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||||
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, "true", false);
|
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, "true", false);
|
||||||
|
|
||||||
NotificationVolumePreferenceController controller =
|
NotificationVolumePreferenceController controller =
|
||||||
new NotificationVolumePreferenceController(mContext);
|
new NotificationVolumePreferenceController(mContext);
|
||||||
|
|
||||||
@@ -254,4 +256,19 @@ public class NotificationVolumePreferenceControllerTest {
|
|||||||
== BasePreferenceController.UNSUPPORTED_ON_DEVICE).isTrue();
|
== BasePreferenceController.UNSUPPORTED_ON_DEVICE).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void ringerModeSilent_unaliased_getAvailability_returnsDisabled() {
|
||||||
|
when(mResources.getBoolean(
|
||||||
|
com.android.settings.R.bool.config_show_notification_volume)).thenReturn(true);
|
||||||
|
when(mHelper.isSingleVolume()).thenReturn(false);
|
||||||
|
|
||||||
|
when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT);
|
||||||
|
|
||||||
|
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||||
|
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, "true", false);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus())
|
||||||
|
.isEqualTo(BasePreferenceController.DISABLED_DEPENDENT_SETTING);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,7 @@ import android.media.AudioManager;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
import com.android.settings.notification.MediaVolumePreferenceController;
|
import com.android.settings.notification.MediaVolumePreferenceController;
|
||||||
|
import com.android.settings.notification.NotificationVolumePreferenceController;
|
||||||
import com.android.settings.notification.RingVolumePreferenceController;
|
import com.android.settings.notification.RingVolumePreferenceController;
|
||||||
import com.android.settings.notification.SeparateRingVolumePreferenceController;
|
import com.android.settings.notification.SeparateRingVolumePreferenceController;
|
||||||
import com.android.settings.notification.VolumeSeekBarPreferenceController;
|
import com.android.settings.notification.VolumeSeekBarPreferenceController;
|
||||||
@@ -64,6 +65,7 @@ public class VolumeSliceHelperTest {
|
|||||||
private VolumeSeekBarPreferenceController mMediaController;
|
private VolumeSeekBarPreferenceController mMediaController;
|
||||||
private VolumeSeekBarPreferenceController mRingController;
|
private VolumeSeekBarPreferenceController mRingController;
|
||||||
private VolumeSeekBarPreferenceController mSeparateRingController;
|
private VolumeSeekBarPreferenceController mSeparateRingController;
|
||||||
|
private VolumeSeekBarPreferenceController mNotificationController;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@@ -72,8 +74,9 @@ public class VolumeSliceHelperTest {
|
|||||||
when(mContext.getContentResolver()).thenReturn(mResolver);
|
when(mContext.getContentResolver()).thenReturn(mResolver);
|
||||||
|
|
||||||
mMediaController = new MediaVolumePreferenceController(mContext);
|
mMediaController = new MediaVolumePreferenceController(mContext);
|
||||||
mSeparateRingController = new SeparateRingVolumePreferenceController(mContext);
|
|
||||||
mRingController = new RingVolumePreferenceController(mContext);
|
mRingController = new RingVolumePreferenceController(mContext);
|
||||||
|
mSeparateRingController = new SeparateRingVolumePreferenceController(mContext);
|
||||||
|
mNotificationController = new NotificationVolumePreferenceController(mContext);
|
||||||
|
|
||||||
mIntent = createIntent(AudioManager.VOLUME_CHANGED_ACTION)
|
mIntent = createIntent(AudioManager.VOLUME_CHANGED_ACTION)
|
||||||
.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, 1)
|
.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, 1)
|
||||||
@@ -238,6 +241,40 @@ public class VolumeSliceHelperTest {
|
|||||||
verify(mResolver).notifyChange(mMediaController.getSliceUri(), null);
|
verify(mResolver).notifyChange(mMediaController.getSliceUri(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Without this test passing, when notification is separated from ring and its value is already
|
||||||
|
* zero, setting ringermode to silent would not disable notification slider.
|
||||||
|
* Note: the above scenario happens only in volume panel where controllers do not get to
|
||||||
|
* register for events such as RINGER_MODE_CHANGE.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void onReceive_ringVolumeMuted_shouldNotifyChangeNotificationSlice() {
|
||||||
|
final Intent intent = createIntent(AudioManager.STREAM_MUTE_CHANGED_ACTION)
|
||||||
|
.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, mRingController.getAudioStream());
|
||||||
|
registerIntentToUri(mRingController);
|
||||||
|
registerIntentToUri(mNotificationController);
|
||||||
|
|
||||||
|
VolumeSliceHelper.onReceive(mContext, intent);
|
||||||
|
|
||||||
|
verify(mResolver).notifyChange(mNotificationController.getSliceUri(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifying notification slice on ring mute does not mean it should not notify ring slice.
|
||||||
|
* Rather, it should notify both slices.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void onReceive_ringVolumeMuted_shouldNotifyChangeRingSlice() {
|
||||||
|
final Intent intent = createIntent(AudioManager.STREAM_MUTE_CHANGED_ACTION)
|
||||||
|
.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, mRingController.getAudioStream());
|
||||||
|
registerIntentToUri(mRingController);
|
||||||
|
registerIntentToUri(mNotificationController);
|
||||||
|
|
||||||
|
VolumeSliceHelper.onReceive(mContext, intent);
|
||||||
|
|
||||||
|
verify(mResolver).notifyChange(mRingController.getSliceUri(), null);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onReceive_streamDevicesChanged_shouldNotifyChange() {
|
public void onReceive_streamDevicesChanged_shouldNotifyChange() {
|
||||||
final Intent intent = createIntent(AudioManager.STREAM_DEVICES_CHANGED_ACTION)
|
final Intent intent = createIntent(AudioManager.STREAM_DEVICES_CHANGED_ACTION)
|
||||||
|
Reference in New Issue
Block a user