Snap for 5357520 from 4b01c8468c to qt-release
Change-Id: I2f300a2558ee5db2b4181695e1947c41896b5fe3
This commit is contained in:
@@ -100,6 +100,7 @@
|
||||
<uses-permission android:name="android.permission.USE_RESERVED_DISK" />
|
||||
<uses-permission android:name="android.permission.MANAGE_SCOPED_ACCESS_DIRECTORY_PERMISSIONS" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" />
|
||||
|
||||
<application android:label="@string/settings_label"
|
||||
android:icon="@drawable/ic_launcher_settings"
|
||||
|
||||
@@ -21,11 +21,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ViewFlipper
|
||||
android:id="@+id/view_flipper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
@@ -71,9 +66,4 @@
|
||||
android:text="@string/suggestion_button_text"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!--dismissal view-->
|
||||
<include layout="@layout/homepage_dismissal_view"/>
|
||||
|
||||
</ViewFlipper>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
@@ -27,6 +27,7 @@
|
||||
android:id="@+id/search_action_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/search_bar_height"
|
||||
android:layout_marginStart="-2dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:contentInsetStartWithNavigation="@dimen/search_bar_content_inset"
|
||||
android:navigationIcon="@drawable/ic_homepage_search">
|
||||
|
||||
@@ -1268,7 +1268,7 @@
|
||||
<item>NV</item>
|
||||
</string-array>
|
||||
<!-- Values for CDMA subscription-->
|
||||
<string-array name="cdma_subscription_values">
|
||||
<string-array name="cdma_subscription_values" translatable="false">
|
||||
<item>"0"</item>
|
||||
<item>"1"</item>
|
||||
</string-array>
|
||||
@@ -1351,7 +1351,7 @@
|
||||
<item>LTE / GSM / UMTS</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="preferred_network_mode_values_world_mode">
|
||||
<string-array name="preferred_network_mode_values_world_mode" translatable="false">
|
||||
<item>"10"</item>
|
||||
<item>"8"</item>
|
||||
<item>"9"</item>
|
||||
|
||||
@@ -2489,7 +2489,7 @@
|
||||
<item>Mobile</item>
|
||||
<item>Wi-Fi only</item>
|
||||
</string-array>
|
||||
<string-array name="wifi_calling_mode_values">
|
||||
<string-array name="wifi_calling_mode_values" translatable="false">
|
||||
<item>"2"</item>
|
||||
<item>"1"</item>
|
||||
<item>"0"</item>
|
||||
@@ -2502,7 +2502,7 @@
|
||||
<item>Wi-Fi</item>
|
||||
<item>Mobile</item>
|
||||
</string-array>
|
||||
<string-array name="wifi_calling_mode_values_without_wifi_only">
|
||||
<string-array name="wifi_calling_mode_values_without_wifi_only" translatable="false">
|
||||
<item>"2"</item>
|
||||
<item>"1"</item>
|
||||
</string-array>
|
||||
@@ -7001,7 +7001,7 @@
|
||||
<!-- Title for setting tile leading to Apps & Notification settings [CHAR LIMIT=40]-->
|
||||
<string name="app_and_notification_dashboard_title">Apps & notifications</string>
|
||||
<!-- Summary for Apps & Notification settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
|
||||
<string name="app_and_notification_dashboard_summary">Permissions, default apps</string>
|
||||
<string name="app_and_notification_dashboard_summary">Assistant, recent apps, default apps</string>
|
||||
<!-- Toast shown when an app in the work profile attempts to open notification settings. The apps in the work profile cannot access notification settings. [CHAR LIMIT=NONE] -->
|
||||
<string name="notification_settings_work_profile">Notification access is not available for apps in the work profile.</string>
|
||||
<!-- Title for setting tile leading to account settings [CHAR LIMIT=40]-->
|
||||
@@ -7193,6 +7193,9 @@
|
||||
<!-- Sound: Title for the option managing media volume. [CHAR LIMIT=30] -->
|
||||
<string name="media_volume_option_title">Media volume</string>
|
||||
|
||||
<!-- Sound: Title for the option managing remote media volume. [CHAR LIMIT=30] -->
|
||||
<string name="remote_media_volume_option_title">Cast volume</string>
|
||||
|
||||
<!-- Sound: Title for the option managing call volume. [CHAR LIMIT=30] -->
|
||||
<string name="call_volume_option_title">Call volume</string>
|
||||
|
||||
|
||||
@@ -303,6 +303,11 @@
|
||||
<item name="android:textSize">16sp</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.DialogMessage"
|
||||
parent="@*android:style/TextAppearance.DeviceDefault.Body1">
|
||||
<item name="android:textSize">16sp</item>
|
||||
</style>
|
||||
|
||||
<style name="SuggestionCardText">
|
||||
<item name="android:textAlignment">viewStart</item>
|
||||
</style>
|
||||
|
||||
@@ -128,8 +128,11 @@
|
||||
<!-- Redefine the ActionBar style for contentInsetStart -->
|
||||
<item name="android:actionBarStyle">@style/Widget.ActionBar</item>
|
||||
|
||||
<!-- copied from Theme.DeviceDefault.Light.Dialog.Alert -->
|
||||
<!-- copied from Theme.DeviceDefault.Dialog.Alert -->
|
||||
<item name="dialogCornerRadius">@*android:dimen/config_dialogCornerRadius</item>
|
||||
<item name="android:windowTitleStyle">@*android:style/DialogWindowTitle.DeviceDefault</item>
|
||||
<item name="android:textAppearanceMedium">@style/TextAppearance.DialogMessage</item>
|
||||
<item name="buttonBarButtonStyle">@*android:style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.ConfirmDeviceCredentials" parent="Theme.SubSettings">
|
||||
|
||||
@@ -22,6 +22,15 @@
|
||||
settings:keywords="@string/keywords_sounds"
|
||||
settings:initialExpandedChildrenCount="9">
|
||||
|
||||
<!-- Remote volume -->
|
||||
<com.android.settings.notification.RemoteVolumeSeekBarPreference
|
||||
android:key="remote_volume"
|
||||
android:icon="@drawable/ic_volume_remote"
|
||||
android:title="@string/remote_media_volume_option_title"
|
||||
android:order="-185"
|
||||
settings:allowDynamicSummaryInSlice="true"
|
||||
settings:controller="com.android.settings.notification.RemoteVolumePreferenceController"/>
|
||||
|
||||
<!-- Media volume -->
|
||||
<com.android.settings.notification.VolumeSeekBarPreference
|
||||
android:key="media_volume"
|
||||
|
||||
@@ -157,8 +157,8 @@ public class RestrictedListPreference extends CustomListPreference {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected ListAdapter createListAdapter() {
|
||||
return new RestrictedArrayAdapter(getContext(), getEntries(),
|
||||
protected ListAdapter createListAdapter(Context context) {
|
||||
return new RestrictedArrayAdapter(context, getEntries(),
|
||||
getSelectedValuePos());
|
||||
}
|
||||
|
||||
@@ -172,10 +172,9 @@ public class RestrictedListPreference extends CustomListPreference {
|
||||
@Override
|
||||
protected void onPrepareDialogBuilder(Builder builder,
|
||||
DialogInterface.OnClickListener listener) {
|
||||
builder.setAdapter(createListAdapter(), listener);
|
||||
builder.setAdapter(createListAdapter(builder.getContext()), listener);
|
||||
}
|
||||
|
||||
|
||||
public class RestrictedArrayAdapter extends ArrayAdapter<CharSequence> {
|
||||
private final int mSelectedIndex;
|
||||
public RestrictedArrayAdapter(Context context, CharSequence[] objects, int selectedIndex) {
|
||||
|
||||
@@ -139,6 +139,8 @@ public class SliceContextualCardRenderer implements ContextualCardRenderer, Life
|
||||
|
||||
switch (holder.getItemViewType()) {
|
||||
case VIEW_TYPE_DEFERRED_SETUP:
|
||||
// Deferred setup is never dismissible.
|
||||
break;
|
||||
case VIEW_TYPE_HALF_WIDTH:
|
||||
initDismissalActions(holder, card, R.id.content);
|
||||
break;
|
||||
|
||||
@@ -20,12 +20,15 @@ import android.app.settings.SettingsEnums;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageItemInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
import android.service.notification.NotificationAssistantService;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.R;
|
||||
@@ -114,9 +117,13 @@ public class NotificationAssistantPicker extends DefaultAppPickerFragment implem
|
||||
List<CandidateInfo> list = new ArrayList<>();
|
||||
services.sort(new PackageItemInfo.DisplayNameComparator(mPm));
|
||||
for (ServiceInfo service : services) {
|
||||
if (mContext.getPackageManager().checkPermission(
|
||||
android.Manifest.permission.REQUEST_NOTIFICATION_ASSISTANT_SERVICE,
|
||||
service.packageName) == PackageManager.PERMISSION_GRANTED) {
|
||||
final ComponentName cn = new ComponentName(service.packageName, service.name);
|
||||
list.add(new DefaultAppInfo(mContext, mPm, mUserId, cn));
|
||||
}
|
||||
}
|
||||
list.add(new CandidateNone(mContext));
|
||||
mCandidateInfos = list;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
@@ -78,7 +77,8 @@ public class NotificationLockscreenPreference extends RestrictedListPreference {
|
||||
DialogInterface.OnClickListener innerListener) {
|
||||
|
||||
mListener = new Listener(innerListener);
|
||||
builder.setSingleChoiceItems(createListAdapter(), getSelectedValuePos(), mListener);
|
||||
builder.setSingleChoiceItems(createListAdapter(builder.getContext()), getSelectedValuePos(),
|
||||
mListener);
|
||||
mShowRemoteInput = getEntryValues().length == 3;
|
||||
mAllowRemoteInput = Settings.Secure.getInt(getContext().getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT, 0) != 0;
|
||||
@@ -116,11 +116,6 @@ public class NotificationLockscreenPreference extends RestrictedListPreference {
|
||||
mListener.setView(panel);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ListAdapter createListAdapter() {
|
||||
return new RestrictedArrayAdapter(getContext(), getEntries(), -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogClosed(boolean positiveResult) {
|
||||
super.onDialogClosed(positiveResult);
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.session.MediaController;
|
||||
import android.media.session.MediaSession;
|
||||
import android.media.session.MediaSessionManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.slices.SliceBackgroundWorker;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.volume.MediaSessions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class RemoteVolumePreferenceController extends
|
||||
VolumeSeekBarPreferenceController {
|
||||
|
||||
private static final String KEY_REMOTE_VOLUME = "remote_volume";
|
||||
@VisibleForTesting
|
||||
static final int REMOTE_VOLUME = 100;
|
||||
|
||||
private MediaSessionManager mMediaSessionManager;
|
||||
private MediaSessions mMediaSessions;
|
||||
@VisibleForTesting
|
||||
MediaSession.Token mActiveToken;
|
||||
@VisibleForTesting
|
||||
MediaController mMediaController;
|
||||
|
||||
@VisibleForTesting
|
||||
MediaSessions.Callbacks mCallbacks = new MediaSessions.Callbacks() {
|
||||
@Override
|
||||
public void onRemoteUpdate(MediaSession.Token token, String name,
|
||||
MediaController.PlaybackInfo pi) {
|
||||
if (mActiveToken == null) {
|
||||
updateToken(token);
|
||||
}
|
||||
if (mActiveToken == token) {
|
||||
updatePreference(mPreference, mActiveToken, pi);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteRemoved(MediaSession.Token t) {
|
||||
if (mActiveToken == t) {
|
||||
updateToken(null);
|
||||
if (mPreference != null) {
|
||||
mPreference.setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteVolumeChanged(MediaSession.Token token, int flags) {
|
||||
if (mActiveToken == token) {
|
||||
final MediaController.PlaybackInfo pi = mMediaController.getPlaybackInfo();
|
||||
if (pi != null) {
|
||||
setSliderPosition(pi.getCurrentVolume());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public RemoteVolumePreferenceController(Context context) {
|
||||
super(context, KEY_REMOTE_VOLUME);
|
||||
mMediaSessionManager = context.getSystemService(MediaSessionManager.class);
|
||||
mMediaSessions = new MediaSessions(context, Looper.getMainLooper(), mCallbacks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
final List<MediaController> controllers = mMediaSessionManager.getActiveSessions(null);
|
||||
for (MediaController mediaController : controllers) {
|
||||
final MediaController.PlaybackInfo pi = mediaController.getPlaybackInfo();
|
||||
if (isRemote(pi)) {
|
||||
updateToken(mediaController.getSessionToken());
|
||||
return AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
// No active remote media at this point
|
||||
return CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
if (mMediaController != null) {
|
||||
updatePreference(mPreference, mActiveToken, mMediaController.getPlaybackInfo());
|
||||
}
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
//TODO(b/126199571): register callback once b/126890783 is fixed
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
//TODO(b/126199571): unregister callback once b/126890783 is fixed
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliderPosition() {
|
||||
if (mPreference != null) {
|
||||
return mPreference.getProgress();
|
||||
}
|
||||
if (mMediaController == null) {
|
||||
return 0;
|
||||
}
|
||||
final MediaController.PlaybackInfo playbackInfo = mMediaController.getPlaybackInfo();
|
||||
return playbackInfo != null ? playbackInfo.getCurrentVolume() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setSliderPosition(int position) {
|
||||
if (mPreference != null) {
|
||||
mPreference.setProgress(position);
|
||||
}
|
||||
if (mMediaController == null) {
|
||||
return false;
|
||||
}
|
||||
mMediaController.setVolumeTo(position, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSteps() {
|
||||
if (mPreference != null) {
|
||||
return mPreference.getMax();
|
||||
}
|
||||
if (mMediaController == null) {
|
||||
return 0;
|
||||
}
|
||||
final MediaController.PlaybackInfo playbackInfo = mMediaController.getPlaybackInfo();
|
||||
return playbackInfo != null ? playbackInfo.getMaxVolume() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSliceable() {
|
||||
return TextUtils.equals(getPreferenceKey(), KEY_REMOTE_VOLUME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_REMOTE_VOLUME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAudioStream() {
|
||||
// This can be anything because remote volume controller doesn't rely on it.
|
||||
return REMOTE_VOLUME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMuteIcon() {
|
||||
return R.drawable.ic_volume_remote_mute;
|
||||
}
|
||||
|
||||
public static boolean isRemote(MediaController.PlaybackInfo pi) {
|
||||
return pi != null
|
||||
&& pi.getPlaybackType() == MediaController.PlaybackInfo.PLAYBACK_TYPE_REMOTE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends SliceBackgroundWorker> getBackgroundWorkerClass() {
|
||||
//TODO(b/126199571): return RemoteVolumeSliceWorker once b/126890783 is fixed
|
||||
return null;
|
||||
}
|
||||
|
||||
private void updatePreference(VolumeSeekBarPreference seekBarPreference,
|
||||
MediaSession.Token token, MediaController.PlaybackInfo playbackInfo) {
|
||||
if (seekBarPreference == null || token == null || playbackInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
seekBarPreference.setMax(playbackInfo.getMaxVolume());
|
||||
seekBarPreference.setVisible(true);
|
||||
setSliderPosition(playbackInfo.getCurrentVolume());
|
||||
}
|
||||
|
||||
private void updateToken(MediaSession.Token token) {
|
||||
mActiveToken = token;
|
||||
if (token != null) {
|
||||
mMediaController = new MediaController(mContext, mActiveToken);
|
||||
} else {
|
||||
mMediaController = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener for background change to remote volume, which listens callback
|
||||
* from {@code MediaSessions}
|
||||
*/
|
||||
public static class RemoteVolumeSliceWorker extends SliceBackgroundWorker<Void> implements
|
||||
MediaSessions.Callbacks {
|
||||
|
||||
private MediaSessions mMediaSessions;
|
||||
|
||||
public RemoteVolumeSliceWorker(Context context, Uri uri) {
|
||||
super(context, uri);
|
||||
mMediaSessions = new MediaSessions(context, Looper.getMainLooper(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSlicePinned() {
|
||||
mMediaSessions.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSliceUnpinned() {
|
||||
mMediaSessions.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
mMediaSessions = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteUpdate(MediaSession.Token token, String name,
|
||||
MediaController.PlaybackInfo pi) {
|
||||
notifySliceChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteRemoved(MediaSession.Token t) {
|
||||
notifySliceChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteVolumeChanged(MediaSession.Token token, int flags) {
|
||||
notifySliceChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
/**
|
||||
* A slider preference that controls remote volume, which doesn't go through
|
||||
* {@link android.media.AudioManager}
|
||||
**/
|
||||
public class RemoteVolumeSeekBarPreference extends VolumeSeekBarPreference {
|
||||
|
||||
public RemoteVolumeSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
|
||||
int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public RemoteVolumeSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public RemoteVolumeSeekBarPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public RemoteVolumeSeekBarPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStream(int stream) {
|
||||
// Do nothing here, volume is not controlled by AudioManager
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
if (mSeekBar == null) return;
|
||||
updateIconView();
|
||||
updateSuppressionText();
|
||||
}
|
||||
}
|
||||
@@ -184,6 +184,7 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult
|
||||
volumeControllers.add(use(RingVolumePreferenceController.class));
|
||||
volumeControllers.add(use(NotificationVolumePreferenceController.class));
|
||||
volumeControllers.add(use(CallVolumePreferenceController.class));
|
||||
volumeControllers.add(use(RemoteVolumePreferenceController.class));
|
||||
|
||||
use(MediaOutputPreferenceController.class).setCallback(listPreference ->
|
||||
onPreferenceDataChanged(listPreference));
|
||||
|
||||
@@ -40,8 +40,8 @@ import java.util.Objects;
|
||||
public class VolumeSeekBarPreference extends SeekBarPreference {
|
||||
private static final String TAG = "VolumeSeekBarPreference";
|
||||
|
||||
protected SeekBar mSeekBar;
|
||||
private int mStream;
|
||||
private SeekBar mSeekBar;
|
||||
private SeekBarVolumizer mVolumizer;
|
||||
private Callback mCallback;
|
||||
private ImageView mIconView;
|
||||
@@ -121,7 +121,7 @@ public class VolumeSeekBarPreference extends SeekBarPreference {
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
protected void init() {
|
||||
if (mSeekBar == null) return;
|
||||
final SeekBarVolumizer.Callback sbvc = new SeekBarVolumizer.Callback() {
|
||||
@Override
|
||||
@@ -158,7 +158,7 @@ public class VolumeSeekBarPreference extends SeekBarPreference {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateIconView() {
|
||||
protected void updateIconView() {
|
||||
if (mIconView == null) return;
|
||||
if (mIconResId != 0) {
|
||||
mIconView.setImageResource(mIconResId);
|
||||
@@ -195,7 +195,7 @@ public class VolumeSeekBarPreference extends SeekBarPreference {
|
||||
updateSuppressionText();
|
||||
}
|
||||
|
||||
private void updateSuppressionText() {
|
||||
protected void updateSuppressionText() {
|
||||
if (mSuppressionTextView != null && mSeekBar != null) {
|
||||
mSuppressionTextView.setText(mSuppressionText);
|
||||
final boolean showSuppression = !TextUtils.isEmpty(mSuppressionText);
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.settings.panel;
|
||||
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_ALARM_URI;
|
||||
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_CALL_URI;
|
||||
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_MEDIA_URI;
|
||||
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_REMOTE_MEDIA_URI;
|
||||
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_RINGER_URI;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
@@ -52,6 +53,7 @@ public class VolumePanel implements PanelContent {
|
||||
@Override
|
||||
public List<Uri> getSlices() {
|
||||
final List<Uri> uris = new ArrayList<>();
|
||||
uris.add(VOLUME_REMOTE_MEDIA_URI);
|
||||
uris.add(VOLUME_MEDIA_URI);
|
||||
uris.add(VOLUME_CALL_URI);
|
||||
uris.add(VOLUME_RINGER_URI);
|
||||
|
||||
@@ -167,7 +167,8 @@ public class PermissionBarChartPreferenceController extends BasePreferenceContro
|
||||
barViewInfos[index] = new BarViewInfo(
|
||||
getPermissionGroupIcon(permissionGroupInfo.getName()),
|
||||
permissionGroupInfo.getAppAccessCount(),
|
||||
R.string.storage_detail_apps);
|
||||
R.string.storage_detail_apps,
|
||||
getPermissionGroupLabel(permissionGroupInfo.getName()));
|
||||
|
||||
// Set the click listener for each bar view.
|
||||
// The listener will navigate user to permission usage app.
|
||||
@@ -194,6 +195,18 @@ public class PermissionBarChartPreferenceController extends BasePreferenceContro
|
||||
return icon;
|
||||
}
|
||||
|
||||
private CharSequence getPermissionGroupLabel(CharSequence permissionGroup) {
|
||||
CharSequence label = null;
|
||||
try {
|
||||
label = mPackageManager.getPermissionGroupInfo(permissionGroup.toString(), 0)
|
||||
.loadLabel(mPackageManager);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.w(TAG, "Cannot find group label for " + permissionGroup, e);
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
private boolean areSamePermissionGroups(List<RuntimePermissionUsageInfo> newUsageInfos) {
|
||||
if (newUsageInfos.size() != mOldUsageInfos.size()) {
|
||||
return false;
|
||||
|
||||
@@ -219,6 +219,17 @@ public class CustomSliceRegistry {
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath("media_volume")
|
||||
.build();
|
||||
|
||||
/**
|
||||
* Full {@link Uri} for the Remote Media Volume Slice.
|
||||
*/
|
||||
public static final Uri VOLUME_REMOTE_MEDIA_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath("remote_volume")
|
||||
.build();
|
||||
|
||||
/**
|
||||
* Full {@link Uri} for the Ringer volume Slice.
|
||||
*/
|
||||
|
||||
@@ -90,6 +90,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
||||
private boolean mValidListener = false;
|
||||
private boolean mEditableWfcMode = true;
|
||||
private boolean mEditableWfcRoamingMode = true;
|
||||
private boolean mUseWfcHomeModeForRoaming = false;
|
||||
|
||||
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
private ImsManager mImsManager;
|
||||
@@ -317,6 +318,9 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
||||
CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL);
|
||||
mEditableWfcRoamingMode = b.getBoolean(
|
||||
CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL);
|
||||
mUseWfcHomeModeForRoaming = b.getBoolean(
|
||||
CarrierConfigManager.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL,
|
||||
false);
|
||||
isWifiOnlySupported = b.getBoolean(
|
||||
CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, true);
|
||||
}
|
||||
@@ -499,7 +503,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
||||
// Don't show WFC (home) preference if it's not editable.
|
||||
preferenceScreen.removePreference(mButtonWfcMode);
|
||||
}
|
||||
if (mEditableWfcRoamingMode) {
|
||||
if (mEditableWfcRoamingMode && !mUseWfcHomeModeForRoaming) {
|
||||
preferenceScreen.addPreference(mButtonWfcRoamingMode);
|
||||
} else {
|
||||
// Don't show WFC roaming preference if it's not editable.
|
||||
@@ -528,10 +532,8 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
|
||||
mImsManager.setWfcMode(buttonMode, false);
|
||||
mButtonWfcMode.setSummary(getWfcModeSummary(buttonMode));
|
||||
mMetricsFeatureProvider.action(getActivity(), getMetricsCategory(), buttonMode);
|
||||
}
|
||||
if (!mEditableWfcRoamingMode) {
|
||||
int currentWfcRoamingMode = mImsManager.getWfcMode(true);
|
||||
if (buttonMode != currentWfcRoamingMode) {
|
||||
|
||||
if (mUseWfcHomeModeForRoaming) {
|
||||
mImsManager.setWfcMode(buttonMode, true);
|
||||
// mButtonWfcRoamingMode.setSummary is not needed; summary is selected value
|
||||
}
|
||||
|
||||
@@ -16,11 +16,13 @@
|
||||
|
||||
package com.android.settings.homepage.contextualcards.slices;
|
||||
|
||||
import static com.android.settings.homepage.contextualcards.slices.SliceContextualCardRenderer.VIEW_TYPE_DEFERRED_SETUP;
|
||||
import static com.android.settings.homepage.contextualcards.slices.SliceContextualCardRenderer.VIEW_TYPE_FULL_WIDTH;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.app.Activity;
|
||||
@@ -128,6 +130,15 @@ public class SliceContextualCardRendererTest {
|
||||
assertThat(viewFlipper.getCurrentView()).isEqualTo(dismissalView);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void longClick_deferredSetupCard_shouldNotBeClickable() {
|
||||
final RecyclerView.ViewHolder viewHolder = getDeferredSetupViewHolder();
|
||||
final View contentView = viewHolder.itemView.findViewById(R.id.content);
|
||||
mRenderer.bindView(viewHolder, buildContextualCard(TEST_SLICE_URI));
|
||||
|
||||
assertThat(contentView.isLongClickable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void longClick_shouldAddViewHolderToSet() {
|
||||
final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
|
||||
@@ -221,6 +232,18 @@ public class SliceContextualCardRendererTest {
|
||||
return mRenderer.createViewHolder(view, VIEW_TYPE_FULL_WIDTH);
|
||||
}
|
||||
|
||||
private RecyclerView.ViewHolder getDeferredSetupViewHolder() {
|
||||
final RecyclerView recyclerView = new RecyclerView(mActivity);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
|
||||
final View view = LayoutInflater.from(mActivity).inflate(VIEW_TYPE_DEFERRED_SETUP,
|
||||
recyclerView, false);
|
||||
final RecyclerView.ViewHolder viewHolder = spy(
|
||||
mRenderer.createViewHolder(view, VIEW_TYPE_DEFERRED_SETUP));
|
||||
doReturn(VIEW_TYPE_DEFERRED_SETUP).when(viewHolder).getItemViewType();
|
||||
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
private ContextualCard buildContextualCard(Uri sliceUri) {
|
||||
return new ContextualCard.Builder()
|
||||
.setName("test_name")
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.session.ControllerLink;
|
||||
import android.media.session.MediaController;
|
||||
import android.media.session.MediaSession;
|
||||
import android.media.session.MediaSessionManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class RemoteVolumePreferenceControllerTest {
|
||||
private static final int CURRENT_POS = 5;
|
||||
private static final int MAX_POS = 10;
|
||||
|
||||
@Mock
|
||||
private MediaSessionManager mMediaSessionManager;
|
||||
@Mock
|
||||
private MediaController mMediaController;
|
||||
@Mock
|
||||
private ControllerLink.ControllerStub mStub;
|
||||
@Mock
|
||||
private ControllerLink.ControllerStub mStub2;
|
||||
private MediaSession.Token mToken;
|
||||
private MediaSession.Token mToken2;
|
||||
private RemoteVolumePreferenceController mController;
|
||||
private Context mContext;
|
||||
private List<MediaController> mActiveSessions;
|
||||
private MediaController.PlaybackInfo mPlaybackInfo;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
when(mContext.getSystemService(MediaSessionManager.class)).thenReturn(mMediaSessionManager);
|
||||
mActiveSessions = new ArrayList<>();
|
||||
mActiveSessions.add(mMediaController);
|
||||
when(mMediaSessionManager.getActiveSessions(null)).thenReturn(
|
||||
mActiveSessions);
|
||||
mToken = new MediaSession.Token(new ControllerLink(mStub));
|
||||
mToken2 = new MediaSession.Token(new ControllerLink(mStub2));
|
||||
|
||||
mController = new RemoteVolumePreferenceController(mContext);
|
||||
mPlaybackInfo = new MediaController.PlaybackInfo(
|
||||
MediaController.PlaybackInfo.PLAYBACK_TYPE_REMOTE, 0, MAX_POS, CURRENT_POS, null);
|
||||
when(mMediaController.getPlaybackInfo()).thenReturn(mPlaybackInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_containRemoteMedia_returnTrue() {
|
||||
when(mMediaController.getPlaybackInfo()).thenReturn(
|
||||
new MediaController.PlaybackInfo(MediaController.PlaybackInfo.PLAYBACK_TYPE_REMOTE,
|
||||
0, 0, 0, null));
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_noRemoteMedia_returnFalse() {
|
||||
when(mMediaController.getPlaybackInfo()).thenReturn(
|
||||
new MediaController.PlaybackInfo(MediaController.PlaybackInfo.PLAYBACK_TYPE_LOCAL,
|
||||
0, 0, 0, null));
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMuteIcon_returnMuteIcon() {
|
||||
assertThat(mController.getMuteIcon()).isEqualTo(R.drawable.ic_volume_remote_mute);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAudioStream_returnRemoteVolume() {
|
||||
assertThat(mController.getAudioStream()).isEqualTo(
|
||||
RemoteVolumePreferenceController.REMOTE_VOLUME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSliderPosition_controllerNull_returnZero() {
|
||||
mController.mMediaController = null;
|
||||
|
||||
assertThat(mController.getSliderPosition()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSliderPosition_controllerExists_returnValue() {
|
||||
mController.mMediaController = mMediaController;
|
||||
|
||||
assertThat(mController.getSliderPosition()).isEqualTo(CURRENT_POS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMaxSteps_controllerNull_returnZero() {
|
||||
mController.mMediaController = null;
|
||||
|
||||
assertThat(mController.getMaxSteps()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMaxSteps_controllerExists_returnValue() {
|
||||
mController.mMediaController = mMediaController;
|
||||
|
||||
assertThat(mController.getMaxSteps()).isEqualTo(MAX_POS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSliderPosition_controllerNull_returnFalse() {
|
||||
mController.mMediaController = null;
|
||||
|
||||
assertThat(mController.setSliderPosition(CURRENT_POS)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSliderPosition_controllerExists_returnTrue() {
|
||||
mController.mMediaController = mMediaController;
|
||||
|
||||
assertThat(mController.setSliderPosition(CURRENT_POS)).isTrue();
|
||||
verify(mMediaController).setVolumeTo(CURRENT_POS, 0 /* flags */);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onRemoteUpdate_firstToken_updateTokenAndPreference() {
|
||||
mController.mPreference = new VolumeSeekBarPreference(mContext);
|
||||
mController.mActiveToken = null;
|
||||
|
||||
mController.mCallbacks.onRemoteUpdate(mToken, "token", mPlaybackInfo);
|
||||
|
||||
assertThat(mController.mActiveToken).isEqualTo(mToken);
|
||||
assertThat(mController.mPreference.isVisible()).isTrue();
|
||||
assertThat(mController.mPreference.getMax()).isEqualTo(MAX_POS);
|
||||
assertThat(mController.mPreference.getProgress()).isEqualTo(CURRENT_POS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onRemoteUpdate_differentToken_doNothing() {
|
||||
mController.mActiveToken = mToken;
|
||||
|
||||
mController.mCallbacks.onRemoteUpdate(mToken2, "token2", mPlaybackInfo);
|
||||
|
||||
assertThat(mController.mActiveToken).isEqualTo(mToken);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onRemoteRemoved_tokenRemoved_setInvisible() {
|
||||
mController.mPreference = new VolumeSeekBarPreference(mContext);
|
||||
mController.mActiveToken = mToken;
|
||||
|
||||
mController.mCallbacks.onRemoteRemoved(mToken);
|
||||
|
||||
assertThat(mController.mActiveToken).isNull();
|
||||
assertThat(mController.mPreference.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onRemoteVolumeChanged_volumeChanged_updateIt() {
|
||||
mController.mPreference = new VolumeSeekBarPreference(mContext);
|
||||
mController.mPreference.setMax(MAX_POS);
|
||||
mController.mActiveToken = mToken;
|
||||
mController.mMediaController = mMediaController;
|
||||
|
||||
mController.mCallbacks.onRemoteVolumeChanged(mToken, 0 /* flags */);
|
||||
|
||||
assertThat(mController.mPreference.getProgress()).isEqualTo(CURRENT_POS);
|
||||
}
|
||||
}
|
||||
@@ -19,18 +19,23 @@ package com.android.settings.wifi.calling;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.ims.ProvisioningManager;
|
||||
import android.view.View;
|
||||
@@ -58,10 +63,15 @@ import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class WifiCallingSettingsForSubTest {
|
||||
private static final String BUTTON_WFC_MODE = "wifi_calling_mode";
|
||||
private static final String BUTTON_WFC_ROAMING_MODE = "wifi_calling_roaming_mode";
|
||||
|
||||
private TestFragment mFragment;
|
||||
private Context mContext;
|
||||
private TextView mEmptyView;
|
||||
private final PersistableBundle mBundle = new PersistableBundle();
|
||||
|
||||
@Mock private static CarrierConfigManager sCarrierConfigManager;
|
||||
@Mock private ImsManager mImsManager;
|
||||
@Mock private TelephonyManager mTelephonyManager;
|
||||
@Mock private PreferenceScreen mPreferenceScreen;
|
||||
@@ -70,6 +80,8 @@ public class WifiCallingSettingsForSubTest {
|
||||
@Mock private ToggleSwitch mToggleSwitch;
|
||||
@Mock private View mView;
|
||||
@Mock private ImsConfig mImsConfig;
|
||||
@Mock private ListPreference mButtonWfcMode;
|
||||
@Mock private ListPreference mButtonWfcRoamingMode;
|
||||
|
||||
@Before
|
||||
public void setUp() throws NoSuchFieldException, ImsException {
|
||||
@@ -89,6 +101,8 @@ public class WifiCallingSettingsForSubTest {
|
||||
when(mFragment.getArguments()).thenReturn(bundle);
|
||||
doNothing().when(mFragment).addPreferencesFromResource(anyInt());
|
||||
doReturn(mock(ListPreference.class)).when(mFragment).findPreference(any());
|
||||
doReturn(mButtonWfcMode).when(mFragment).findPreference(BUTTON_WFC_MODE);
|
||||
doReturn(mButtonWfcRoamingMode).when(mFragment).findPreference(BUTTON_WFC_ROAMING_MODE);
|
||||
doNothing().when(mFragment).finish();
|
||||
doReturn(mView).when(mFragment).getView();
|
||||
|
||||
@@ -101,12 +115,26 @@ public class WifiCallingSettingsForSubTest {
|
||||
doReturn(mImsManager).when(mFragment).getImsManager();
|
||||
doReturn(mImsConfig).when(mImsManager).getConfigInterface();
|
||||
doReturn(true).when(mImsManager).isWfcProvisionedOnDevice();
|
||||
doReturn(true).when(mImsManager).isWfcEnabledByUser();
|
||||
doReturn(true).when(mImsManager).isNonTtyOrTtyOnVolteEnabled();
|
||||
doReturn(ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED)
|
||||
.when(mImsManager).getWfcMode(anyBoolean());
|
||||
|
||||
doReturn(mBundle).when(sCarrierConfigManager).getConfigForSubId(anyInt());
|
||||
setDefaultCarrierConfigValues();
|
||||
|
||||
mFragment.onAttach(mContext);
|
||||
mFragment.onCreate(null);
|
||||
mFragment.onActivityCreated(null);
|
||||
}
|
||||
|
||||
private void setDefaultCarrierConfigValues() {
|
||||
mBundle.putBoolean(
|
||||
CarrierConfigManager.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL, false);
|
||||
mBundle.putBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL, true);
|
||||
mBundle.putBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHelpResource_shouldReturn0() {
|
||||
assertThat(mFragment.getHelpResource()).isEqualTo(0);
|
||||
@@ -142,13 +170,108 @@ public class WifiCallingSettingsForSubTest {
|
||||
verify(mImsConfig).removeConfigCallback(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onResume_useWfcHomeModeConfigFalseAndEditable_shouldShowWfcRoaming() {
|
||||
// Call onResume to update the WFC roaming preference.
|
||||
mFragment.onResume();
|
||||
|
||||
// Check that WFC roaming preference is shown.
|
||||
verify(mPreferenceScreen, times(1)).addPreference(mButtonWfcRoamingMode);
|
||||
verify(mPreferenceScreen, never()).removePreference(mButtonWfcRoamingMode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onResume_useWfcHomeModeConfigTrueAndEditable_shouldHideWfcRoaming() {
|
||||
mBundle.putBoolean(
|
||||
CarrierConfigManager.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL, true);
|
||||
mBundle.putBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL, true);
|
||||
|
||||
// Call onResume to update the WFC roaming preference.
|
||||
mFragment.onResume();
|
||||
|
||||
// Check that WFC roaming preference is hidden.
|
||||
verify(mPreferenceScreen, never()).addPreference(mButtonWfcRoamingMode);
|
||||
verify(mPreferenceScreen, times(1)).removePreference(mButtonWfcRoamingMode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onResume_useWfcHomeModeConfigFalseAndNotEditable_shouldHideWfcRoaming() {
|
||||
mBundle.putBoolean(
|
||||
CarrierConfigManager.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL, false);
|
||||
mBundle.putBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL, false);
|
||||
|
||||
// Call onResume to update the WFC roaming preference.
|
||||
mFragment.onResume();
|
||||
|
||||
// Check that WFC roaming preference is hidden.
|
||||
verify(mPreferenceScreen, never()).addPreference(mButtonWfcRoamingMode);
|
||||
verify(mPreferenceScreen, times(1)).removePreference(mButtonWfcRoamingMode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onResume_useWfcHomeModeConfigTrueAndNotEditable_shouldHideWfcRoaming() {
|
||||
mBundle.putBoolean(
|
||||
CarrierConfigManager.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL, true);
|
||||
mBundle.putBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL, false);
|
||||
|
||||
// Call onResume to update the WFC roaming preference.
|
||||
mFragment.onResume();
|
||||
|
||||
// Check that WFC roaming preference is hidden.
|
||||
verify(mPreferenceScreen, never()).addPreference(mButtonWfcRoamingMode);
|
||||
verify(mPreferenceScreen, times(1)).removePreference(mButtonWfcRoamingMode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_useWfcHomeModeConfigFalse_shouldNotSetWfcRoaming() {
|
||||
// Call onResume to update carrier config values.
|
||||
mFragment.onResume();
|
||||
|
||||
// Set the WFC home mode.
|
||||
mFragment.onPreferenceChange(mButtonWfcMode,
|
||||
String.valueOf(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED));
|
||||
|
||||
// Check that only WFC home mode is set.
|
||||
verify(mImsManager, times(1)).setWfcMode(
|
||||
eq(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED),
|
||||
eq(false));
|
||||
verify(mImsManager, never()).setWfcMode(
|
||||
eq(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED),
|
||||
eq(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_useWfcHomeModeConfigTrue_shouldSetWfcRoaming() {
|
||||
mBundle.putBoolean(
|
||||
CarrierConfigManager.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL, true);
|
||||
|
||||
// Call onResume to update carrier config values.
|
||||
mFragment.onResume();
|
||||
|
||||
// Set the WFC home mode.
|
||||
mFragment.onPreferenceChange(mButtonWfcMode,
|
||||
String.valueOf(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED));
|
||||
|
||||
// Check that both WFC home mode and roaming mode are set.
|
||||
verify(mImsManager, times(1)).setWfcMode(
|
||||
eq(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED),
|
||||
eq(false));
|
||||
verify(mImsManager, times(1)).setWfcMode(
|
||||
eq(ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED),
|
||||
eq(true));
|
||||
}
|
||||
|
||||
protected class TestFragment extends WifiCallingSettingsForSub {
|
||||
@Override
|
||||
protected Object getSystemService(final String name) {
|
||||
if (Context.TELEPHONY_SERVICE.equals(name)) {
|
||||
switch (name) {
|
||||
case Context.TELEPHONY_SERVICE:
|
||||
return mTelephonyManager;
|
||||
}
|
||||
case Context.CARRIER_CONFIG_SERVICE:
|
||||
return sCarrierConfigManager;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user