Merge "Keep consistency between sound and accessibility settings." into qt-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 1990ce0..f4ff282 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3241,6 +3241,17 @@
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.fuelgauge.batterysaver.BatterySaverScheduleSettings" />
</activity>
+
+ <activity android:name="Settings$GlobalActionsPanelSettingsActivity"
+ android:label="@string/global_actions_panel_title">
+ <intent-filter>
+ <action android:name="com.android.settings.GLOBAL_ACTIONS_PANEL_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.gestures.GlobalActionsPanelSettings" />
+ </activity>
+
<!-- This is the longest AndroidManifest.xml ever. -->
</application>
</manifest>
diff --git a/res/layout/profile_owner_add.xml b/res/layout/profile_owner_add.xml
index 84c51fd..2ee5dfc 100644
--- a/res/layout/profile_owner_add.xml
+++ b/res/layout/profile_owner_add.xml
@@ -27,12 +27,17 @@
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbars = "vertical"
- android:padding="?dialogPreferredPadding"
+ android:paddingStart="24dp"
+ android:paddingEnd="24dp"
+ android:paddingTop="12dp"
+ android:paddingBottom="6dp"
android:gravity="center_vertical"/>
<TextView android:id="@+id/admin_warning_simplified"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingStart="?dialogPreferredPadding"
- android:paddingEnd="?dialogPreferredPadding"/>
+ android:paddingStart="24dp"
+ android:paddingEnd="24dp"
+ android:paddingTop="6dp"
+ android:paddingBottom="12dp"/>
</LinearLayout>
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index f6fe0c2..b4ebc57 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -165,6 +165,7 @@
public static class BluetoothDeviceDetailActivity extends SettingsActivity { /* empty */ }
public static class WifiCallingDisclaimerActivity extends SettingsActivity { /* empty */ }
public static class MobileNetworkListActivity extends SettingsActivity {}
+ public static class GlobalActionsPanelSettingsActivity extends SettingsActivity {}
// Top level categories for new IA
public static class NetworkDashboardActivity extends SettingsActivity {}
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
index 0d0bd20..8b06975 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
@@ -312,7 +312,7 @@
addAndFinish();
}
})
- .setNeutralButton(R.string.cancel, null)
+ .setNegativeButton(R.string.cancel, null)
.setOnDismissListener(new DialogInterface.OnDismissListener() {
public void onDismiss(DialogInterface dialogInterface) {
finish();
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index d073dbc..b35a974 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -83,6 +83,7 @@
import com.android.settings.gestures.DoubleTapPowerSettings;
import com.android.settings.gestures.DoubleTapScreenSettings;
import com.android.settings.gestures.DoubleTwistGestureSettings;
+import com.android.settings.gestures.GlobalActionsPanelSettings;
import com.android.settings.gestures.PickupGestureSettings;
import com.android.settings.gestures.SwipeToNotificationSettings;
import com.android.settings.gestures.SystemNavigationGestureSettings;
@@ -279,7 +280,8 @@
ToggleBackupSettingFragment.class.getName(),
PreviouslyConnectedDeviceDashboardFragment.class.getName(),
BatterySaverScheduleSettings.class.getName(),
- MobileNetworkListFragment.class.getName()
+ MobileNetworkListFragment.class.getName(),
+ GlobalActionsPanelSettings.class.getName()
};
public static final String[] SETTINGS_FOR_RESTRICTED = {
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index 0c099ca..c0b4590 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -277,8 +277,7 @@
return true;
}
- if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA
- && !isTdscdmaSupported(context, telephonyManager)) {
+ if (shouldSpeciallyUpdateGsmCdma(context, subId)) {
return true;
}
}
@@ -296,16 +295,15 @@
if (isGsmBasicOptions(context, subId)) {
return true;
}
- final int settingsNetworkMode = android.provider.Settings.Global.getInt(
+ final int networkMode = android.provider.Settings.Global.getInt(
context.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
Phone.PREFERRED_NT_MODE);
if (isWorldMode(context, subId)) {
- if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO
- || settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
+ if (networkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
return true;
- } else if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA
- && !MobileNetworkUtils.isTdscdmaSupported(context, subId)) {
+ } else if (shouldSpeciallyUpdateGsmCdma(context, subId)) {
return true;
}
}
@@ -362,16 +360,24 @@
return false;
}
+ final int networkMode = android.provider.Settings.Global.getInt(
+ context.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
+ Phone.PREFERRED_NT_MODE);
+ if (networkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO
+ && isWorldMode(context, subId)) {
+ return false;
+ }
+ if (shouldSpeciallyUpdateGsmCdma(context, subId)) {
+ return false;
+ }
+
if (isGsmBasicOptions(context, subId)) {
return true;
}
- final int settingsNetworkMode = android.provider.Settings.Global.getInt(
- context.getContentResolver(),
- android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
- Phone.PREFERRED_NT_MODE);
if (isWorldMode(context, subId)) {
- if (settingsNetworkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
+ if (networkMode == TelephonyManager.NETWORK_MODE_LTE_GSM_WCDMA) {
return true;
}
}
@@ -414,7 +420,6 @@
return false;
}
-
/**
* Return subId that supported by search. If there are more than one, return first one,
* otherwise return {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID}
@@ -461,4 +466,33 @@
}
}
}
+
+ /**
+ * This method is migrated from {@link com.android.phone.MobileNetworkSettings} and we should
+ * use it carefully. This code snippet doesn't have very clear meaning however we should
+ * update GSM or CDMA differently based on what it returns.
+ *
+ * 1. For all CDMA settings, make them visible if it return {@code true}
+ * 2. For GSM settings, make them visible if it return {@code true} unless 3
+ * 3. For network select settings, make it invisible if it return {@code true}
+ */
+ @VisibleForTesting
+ static boolean shouldSpeciallyUpdateGsmCdma(Context context, int subId) {
+ final int networkMode = android.provider.Settings.Global.getInt(
+ context.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + subId,
+ Phone.PREFERRED_NT_MODE);
+ if (networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_WCDMA
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA
+ || networkMode == TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA) {
+ if (!isTdscdmaSupported(context, subId) && isWorldMode(context, subId)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
}
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index 32d8e91..fdd71e5 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -53,6 +53,7 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
+import com.android.settings.Utils;
import com.android.settings.applications.AppInfoBase;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
@@ -279,6 +280,12 @@
return null;
}
+ private Drawable getAlertingIcon() {
+ Drawable icon = getContext().getDrawable(R.drawable.ic_notifications);
+ icon.setTintList(Utils.getColorAccent(getContext()));
+ return icon;
+ }
+
protected Preference populateSingleChannelPrefs(PreferenceGroup parent,
final NotificationChannel channel, final boolean groupBlocked) {
MasterSwitchPreference channelPref = new MasterSwitchPreference(getPrefContext());
@@ -286,8 +293,10 @@
&& isChannelBlockable(channel)
&& isChannelConfigurable(channel)
&& !groupBlocked);
- channelPref.setIcon(channel.getImportance() > IMPORTANCE_LOW
- ? R.drawable.ic_notification_alert : R.drawable.ic_notification_silence);
+ channelPref.setIcon(null);
+ if (channel.getImportance() > IMPORTANCE_LOW) {
+ channelPref.setIcon(getAlertingIcon());
+ }
channelPref.setIconSize(MasterSwitchPreference.ICON_SIZE_SMALL);
channelPref.setKey(channel.getId());
channelPref.setTitle(channel.getName());
@@ -314,9 +323,10 @@
channel.lockFields(
NotificationChannel.USER_LOCKED_IMPORTANCE);
MasterSwitchPreference channelPref1 = (MasterSwitchPreference) preference;
- channelPref1.setIcon(channel.getImportance() > IMPORTANCE_LOW
- ? R.drawable.ic_notification_alert
- : R.drawable.ic_notification_silence);
+ channelPref1.setIcon(null);
+ if (channel.getImportance() > IMPORTANCE_LOW) {
+ channelPref1.setIcon(getAlertingIcon());
+ }
toggleBehaviorIconState(channelPref1.getIcon(),
importance != IMPORTANCE_NONE);
mBackend.updateChannel(mPkg, mUid, channel);
@@ -330,9 +340,14 @@
}
private void toggleBehaviorIconState(Drawable icon, boolean enabled) {
+ if (icon == null) return;
+
LayerDrawable layerDrawable = (LayerDrawable) icon;
GradientDrawable background =
(GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.back);
+
+ if (background == null) return;
+
if (enabled) {
background.clearColorFilter();
} else {
diff --git a/src/com/android/settings/widget/VideoPreference.java b/src/com/android/settings/widget/VideoPreference.java
index ca3e5cc..1af9065 100644
--- a/src/com/android/settings/widget/VideoPreference.java
+++ b/src/com/android/settings/widget/VideoPreference.java
@@ -24,10 +24,12 @@
import android.net.Uri;
import android.util.AttributeSet;
import android.util.Log;
+import android.util.TypedValue;
import android.view.Surface;
import android.view.TextureView;
import android.view.View;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
@@ -51,11 +53,12 @@
@VisibleForTesting
boolean mVideoReady;
private boolean mVideoPaused;
- private float mAspectRadio = 1.0f;
+ private float mAspectRatio = 1.0f;
private int mPreviewResource;
private boolean mViewVisible;
private Surface mSurface;
private int mAnimationId;
+ private int mHeight = LinearLayout.LayoutParams.MATCH_PARENT - 1; // video height in pixels
public VideoPreference(Context context) {
super(context);
@@ -121,7 +124,11 @@
R.id.video_container);
imageView.setImageResource(mPreviewResource);
- layout.setAspectRatio(mAspectRadio);
+ layout.setAspectRatio(mAspectRatio);
+ if (mHeight >= LinearLayout.LayoutParams.MATCH_PARENT) {
+ layout.setLayoutParams(new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.MATCH_PARENT, mHeight));
+ }
updateViewStates(imageView, playButton);
video.setOnClickListener(v -> updateViewStates(imageView, playButton));
@@ -247,8 +254,17 @@
return mVideoPaused;
}
+ /**
+ * sets the height of the video preference
+ * @param height in dp
+ */
+ public void setHeight(float height) {
+ mHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, height,
+ mContext.getResources().getDisplayMetrics());
+ }
+
@VisibleForTesting
void updateAspectRatio() {
- mAspectRadio = mMediaPlayer.getVideoWidth() / (float) mMediaPlayer.getVideoHeight();
+ mAspectRatio = mMediaPlayer.getVideoWidth() / (float) mMediaPlayer.getVideoHeight();
}
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
index 61599e6..2bfaeca 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
@@ -219,4 +219,86 @@
assertThat(MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, SUB_ID_1))
.isTrue();
}
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_notWorldMode_returnFalse() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, false);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isFalse();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_supportTdscdma_returnFalse() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, true);
+
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isFalse();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdmaGsm_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdmaGsmWcdma_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_GSM_WCDMA);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdma_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_TDSCDMA);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdmaWcdma_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_WCDMA);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteTdscdmaCdmaEvdoGsmWcdma_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
+
+ @Test
+ public void shouldSpeciallyUpdateGsmCdma_ModeLteCdmaEvdoGsmWcdma_returnTrue() {
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_WORLD_MODE_ENABLED_BOOL, true);
+ mCarrierConfig.putBoolean(CarrierConfigManager.KEY_SUPPORT_TDSCDMA_BOOL, false);
+
+ Settings.Global.putInt(mContext.getContentResolver(),
+ android.provider.Settings.Global.PREFERRED_NETWORK_MODE + SUB_ID_1,
+ TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA);
+ assertThat(MobileNetworkUtils.shouldSpeciallyUpdateGsmCdma(mContext, SUB_ID_1)).isTrue();
+ }
}