Merge tag 'android-16.0.0_r1' of https://android.googlesource.com/platform/packages/apps/Settings into HEAD
Android 16.0.0 release 1
Change-Id: Ic78040624e22096851aac16482cb2915ec64c0ed
diff --git a/Android.bp b/Android.bp
index c0a4c7c..0c7cf49 100644
--- a/Android.bp
+++ b/Android.bp
@@ -113,6 +113,8 @@
"statslog-settings",
"setupdesign-lottie-loading-layout",
"device_policy_aconfig_flags_lib",
+ "OmniLib",
+ "OmniPreference",
"keyboard_flags_lib",
"com_android_systemui_flags_lib",
"settings_connectivity_flags_lib",
diff --git a/res/drawable/settings_panel_rounded_top_corner_background.xml b/res/drawable/settings_panel_rounded_top_corner_background.xml
index 1c234cc..5e44b11 100644
--- a/res/drawable/settings_panel_rounded_top_corner_background.xml
+++ b/res/drawable/settings_panel_rounded_top_corner_background.xml
@@ -21,6 +21,6 @@
android:topRightRadius="@dimen/settings_panel_corner_radius"
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"/>
- <solid android:color="?android:attr/colorBackground" />
+ <solid android:color="@color/panel_background_color" />
</shape>
-</inset>
\ No newline at end of file
+</inset>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 9dfc715..15fe19d 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -115,8 +115,10 @@
<color name="homepage_purple_fg">@color/m3_ref_palette_purple30</color>
<color name="homepage_purple_bg">@color/m3_ref_palette_purple90</color>
- <color name="contextual_card_dismissal_background">@*android:color/material_grey_100</color>
+ <color name="contextual_card_dismissal_background">@*android:color/background_device_default_light</color>
<color name="contextual_card_background">@*android:color/background_device_default_light</color>
+ <color name="panel_background_color">@*android:color/background_device_default_light</color>
+
<!-- End of dashboard/homepage icon background colors -->
<color name="battery_good_color_light">#43a047</color> <!-- Material Green 600 -->
diff --git a/res/values/custom_config.xml b/res/values/custom_config.xml
new file mode 100755
index 0000000..a825ba2
--- /dev/null
+++ b/res/values/custom_config.xml
@@ -0,0 +1,5 @@
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <bool name="config_show_brightness">true</bool>
+</resources>
\ No newline at end of file
diff --git a/res/values/custom_strings.xml b/res/values/custom_strings.xml
new file mode 100644
index 0000000..7f9eb14
--- /dev/null
+++ b/res/values/custom_strings.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2017-2018 The OmniROM 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.
+*/
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="selinux_status">SELinux status</string>
+ <string name="selinux_status_disabled">Disabled</string>
+ <string name="selinux_status_permissive">Permissive</string>
+ <string name="selinux_status_enforcing">Enforcing</string>
+
+ <string name="mod_version">Omni version</string>
+ <string name="mod_version_default">Unknown</string>
+
+ <string name="battery_image">Show battery image</string>
+ <string name="battery_image_description">Show battery image in status bar</string>
+
+ <!-- Back gesture height -->
+ <string name="back_height_low_label">Full</string>
+ <string name="back_height_high_label">Bottom</string>
+ <string name="back_options_dialog_title">Options</string>
+ <string name="back_height_message">Amount of screen height used as touchable region for back gesture.</string>
+
+ <string name="navbar_gesture_handle_category">Gesture handle</string>
+ <string name="navbar_gesture_handle_hide_title">Hide gesture handle</string>
+ <string name="navbar_gesture_handle_hide_summary">Hide horizontal line</string>
+
+ <string name="navbar_gesture_handle_small_title">Small size</string>
+ <string name="navbar_gesture_handle_small_summary">Use small gesture handle</string>
+
+ <!-- Sound: Title for the option defining the phone ringtone for slot1 on Muilti SIM device. [CHAR LIMIT=50] -->
+ <string name="ringtone1_title">Phone ringtone - SIM 1</string>
+ <!-- Sound: Title for the option defining the phone ringtone for slot2 on Muilti SIM device. [CHAR LIMIT=50] -->
+ <string name="ringtone2_title">Phone ringtone - SIM 2</string>
+
+</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 9f1df7d..ec96648 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -530,7 +530,7 @@
<style name="Widget.SliceView.Panel">
<item name="titleSize">16sp</item>
<item name="rowStyle">@style/SliceRow</item>
- <item name="android:background">?android:attr/colorBackgroundFloating</item>
+ <item name="android:background">@color/panel_background_color</item>
</style>
<style name="Widget.SliceView.Panel.Slider">
@@ -607,11 +607,13 @@
<style name="PanelOptionRoundedOutlinedButton" parent="@android:style/Widget.Material.Button">
<item name="android:background">@drawable/volume_dialog_button_background_outline</item>
+ <item name="android:textAllCaps">false</item>
</style>
<style name="PanelOptionRoundedSolidButton" parent="@android:style/Widget.Material.Button">
<item name="android:textColor">@android:color/system_neutral1_900</item>
<item name="android:background">@drawable/volume_dialog_button_background_solid</item>
+ <item name="android:textAllCaps">false</item>
</style>
<style name="SetupWizardPartnerResource">
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index f839a47..e195770 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -22,6 +22,7 @@
settings:keywords="@string/keywords_display">
<PreferenceCategory
+ android:key="category_brightness"
android:title="@string/category_name_brightness"
android:order="-200">
diff --git a/res/xml/gesture_navigation_settings.xml b/res/xml/gesture_navigation_settings.xml
index 60cb189..0899039 100644
--- a/res/xml/gesture_navigation_settings.xml
+++ b/res/xml/gesture_navigation_settings.xml
@@ -66,6 +66,35 @@
android:max="2"
settings:textStart="@string/low_label"
settings:textEnd="@string/high_label"/>
+
+ <com.android.settings.widget.LabeledSeekBarPreference
+ android:key="gesture_back_height"
+ android:title="@string/back_height_message"
+ android:max="3"
+ android:selectable="true"
+ settings:textStart="@string/back_height_low_label"
+ settings:textEnd="@string/back_height_high_label"/>
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="navbar_gesture_handle_category"
+ android:persistent="false"
+ android:title="@string/navbar_gesture_handle_category">
+
+ <omnirom.preference.SystemSettingSwitchPreference
+ android:key="navbar_gesture_handle_hide"
+ android:title="@string/navbar_gesture_handle_hide_title"
+ android:summary="@string/navbar_gesture_handle_hide_summary"
+ android:defaultValue="false"
+ settings:controller="com.android.settings.gestures.GestureHandlePreferenceController"/>
+
+ <omnirom.preference.SystemSettingSwitchPreference
+ android:key="navbar_gesture_handle_small"
+ android:title="@string/navbar_gesture_handle_small_title"
+ android:summary="@string/navbar_gesture_handle_small_summary"
+ android:defaultValue="false"
+ settings:controller="com.android.settings.gestures.GestureSmallPreferenceController"/>
+
</PreferenceCategory>
<com.android.settingslib.widget.FooterPreference
diff --git a/res/xml/my_device_info.xml b/res/xml/my_device_info.xml
index abcb485..9bf5c0a 100644
--- a/res/xml/my_device_info.xml
+++ b/res/xml/my_device_info.xml
@@ -52,7 +52,7 @@
settings:controller="com.android.settings.deviceinfo.BrandedAccountPreferenceController"/>
<!-- Phone number -->
- <Preference
+ <com.android.settings.deviceinfo.PhoneNumberSummaryPreference
android:key="phone_number"
android:order="3"
android:title="@string/status_number"
@@ -120,6 +120,7 @@
android:key="eid_info"
android:order="31"
android:title="@string/status_eid"
+ android:summary="@string/device_info_protected_single_press"
android:positiveButtonText="@string/dlg_ok"
android:dialogLayout="@layout/dialog_eid_status"
settings:isPreferenceVisible="@bool/config_show_sim_info"
@@ -127,7 +128,7 @@
settings:controller="com.android.settings.deviceinfo.simstatus.SimEidPreferenceController"/>
<!-- IMEI -->
- <Preference
+ <com.android.settings.deviceinfo.PhoneNumberSummaryPreference
android:key="imei_info"
android:order="32"
android:title="@string/status_imei"
@@ -237,4 +238,18 @@
settings:controller="com.android.settings.deviceinfo.BuildNumberPreferenceController"/>
</PreferenceCategory>
+ <!-- omni version -->
+ <Preference
+ android:key="omni_version"
+ android:order="54"
+ android:title="@string/mod_version"
+ android:summary="@string/mod_version_default"/>
+
+ <!-- SELinux status information -->
+ <Preference
+ android:key="selinux_status"
+ android:order="55"
+ android:title="@string/selinux_status"
+ android:summary="@string/selinux_status_enforcing"/>
+
</PreferenceScreen>
diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml
index 065baae..f98a3a1 100644
--- a/res/xml/power_usage_summary.xml
+++ b/res/xml/power_usage_summary.xml
@@ -74,6 +74,12 @@
android:summary="@string/battery_percentage_description"
settings:controller="com.android.settings.display.BatteryPercentagePreferenceController" />
+ <SwitchPreferenceCompat
+ android:key="battery_image"
+ android:title="@string/battery_image"
+ android:summary="@string/battery_image_description"
+ settings:controller="com.android.settings.display.BatteryImagePreferenceController" />
+
<com.android.settingslib.widget.FooterPreference
android:key="power_usage_footer"
android:title="@string/battery_footer_summary"
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index cab3b20..cbeaaf5 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -115,6 +115,16 @@
android:order="-120"
settings:keywords="@string/sound_settings"/>
+ <!-- Phone ringtone for Slot2 -->
+ <com.android.settings.DefaultRingtonePreference
+ android:key="ringtone2"
+ android:title="@string/ringtone2_title"
+ android:dialogTitle="@string/ringtone_title"
+ android:summary="@string/summary_placeholder"
+ android:ringtoneType="ringtone"
+ settings:allowDividerAbove="false"
+ android:order="-110"/>
+
<!-- Live Caption -110 and Now Playing -105-->
<!-- Spatial audio -->
diff --git a/src/com/android/settings/DefaultRingtonePreference.java b/src/com/android/settings/DefaultRingtonePreference.java
index 4c65488..e6d5ced 100644
--- a/src/com/android/settings/DefaultRingtonePreference.java
+++ b/src/com/android/settings/DefaultRingtonePreference.java
@@ -62,12 +62,14 @@
@VisibleForTesting
void setActualDefaultRingtoneUri(Uri ringtoneUri) {
- RingtoneManager.setActualDefaultRingtoneUri(mUserContext, getRingtoneType(), ringtoneUri);
+ RingtoneManager.setActualDefaultRingtoneUriBySlot(mUserContext, getRingtoneType(),
+ ringtoneUri, getSlotId());
}
@Override
protected Uri onRestoreRingtone() {
- return RingtoneManager.getActualDefaultRingtoneUri(mUserContext, getRingtoneType());
+ return RingtoneManager.getActualDefaultRingtoneUriBySlot(mUserContext, getRingtoneType(),
+ getSlotId());
}
}
diff --git a/src/com/android/settings/RingtonePreference.java b/src/com/android/settings/RingtonePreference.java
index 6b9dad7..43600c2 100644
--- a/src/com/android/settings/RingtonePreference.java
+++ b/src/com/android/settings/RingtonePreference.java
@@ -40,6 +40,7 @@
* <p>
* If the user chooses the "Default" item, the saved string will be one of
* {@link System#DEFAULT_RINGTONE_URI},
+ * {@link System#DEFAULT_RINGTONE2_URI},
* {@link System#DEFAULT_NOTIFICATION_URI}, or
* {@link System#DEFAULT_ALARM_ALERT_URI}. If the user chooses the "Silent"
* item, the saved string will be an empty string.
@@ -55,6 +56,9 @@
private static final String TAG = "RingtonePreference";
+ // Default is slot0
+ private int mSlotId = 0;
+
private int mRingtoneType;
private boolean mShowDefault;
private boolean mShowSilent;
@@ -90,6 +94,25 @@
}
/**
+ * Sets the slot id that this preference belongs to.
+ *
+ * @param slotId The slot id that this preference belongs to.
+ */
+ public void setSlotId(int slotId) {
+ mSlotId = slotId;
+ }
+
+ /**
+ * Returns the slot id that this preference belongs to.
+ *
+ * @return The slot id that this preference belongs to.
+ * @see #setSlotId(int)
+ */
+ public int getSlotId() {
+ return mSlotId;
+ }
+
+ /**
* Returns the sound type(s) that are shown in the picker.
*
* @return The sound type(s) that are shown in the picker.
@@ -167,7 +190,7 @@
ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, mShowDefault);
if (mShowDefault) {
ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
- RingtoneManager.getDefaultUri(getRingtoneType()));
+ RingtoneManager.getDefaultUriBySlot(getRingtoneType(), getSlotId()));
}
ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, mShowSilent);
diff --git a/src/com/android/settings/applications/ProcStatsData.java b/src/com/android/settings/applications/ProcStatsData.java
index aedb066..fd17898 100644
--- a/src/com/android/settings/applications/ProcStatsData.java
+++ b/src/com/android/settings/applications/ProcStatsData.java
@@ -274,7 +274,7 @@
final ProcessState proc = mStats.mProcesses.get(pkgProc.getName(),
pkgProc.getUid());
if (proc == null) {
- Log.w(TAG, "No process found for pkg " + st.mPackageName
+ if (DEBUG) Log.w(TAG, "No process found for pkg " + st.mPackageName
+ "/" + st.mUid + " proc name " + pkgProc.getName());
continue;
}
diff --git a/src/com/android/settings/deviceinfo/OmniVersionPreferenceController.java b/src/com/android/settings/deviceinfo/OmniVersionPreferenceController.java
new file mode 100644
index 0000000..778c4f9
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/OmniVersionPreferenceController.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2017 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.deviceinfo;
+
+import android.content.Context;
+import android.os.SystemProperties;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+import android.text.TextUtils;
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+public class OmniVersionPreferenceController extends AbstractPreferenceController implements
+ PreferenceControllerMixin {
+
+ private static final String PROPERTY_OMNI_VERSION = "ro.omni.version";
+ private static final String KEY_OMNI_VERSION = "omni_version";
+
+ public OmniVersionPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return !TextUtils.isEmpty(SystemProperties.get(PROPERTY_OMNI_VERSION));
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_OMNI_VERSION;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ final Preference pref = screen.findPreference(KEY_OMNI_VERSION);
+ if (pref == null) {
+ return;
+ }
+ pref.setSummary(SystemProperties.get(PROPERTY_OMNI_VERSION));
+ }
+}
+
diff --git a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
index bb39d88..a5c9b2d 100644
--- a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
@@ -63,6 +63,27 @@
}
@Override
+ public CharSequence getSummary() {
+ return mContext.getString(R.string.device_info_protected_single_press);
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ String prefKey = preference.getKey();
+ if (prefKey.startsWith(KEY_PHONE_NUMBER)) {
+ int simSlotNumber = 0;
+ if (!TextUtils.equals(prefKey, KEY_PHONE_NUMBER)) {
+ // Get multisim slot number from preference key.
+ // Multisim preference key is KEY_PHONE_NUMBER + simSlotNumber
+ simSlotNumber = Integer.parseInt(
+ prefKey.replaceAll("[^0-9]", ""));
+ }
+ setPhoneNumber(simSlotNumber);
+ }
+ return super.handlePreferenceTreeClick(preference);
+ }
+
+ @Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
if (!isAvailable()) {
@@ -92,7 +113,7 @@
for (int simSlotNumber = 0; simSlotNumber < mPreferenceList.size(); simSlotNumber++) {
final Preference simStatusPreference = mPreferenceList.get(simSlotNumber);
simStatusPreference.setTitle(getPreferenceTitle(simSlotNumber));
- setPhoneNumber(simSlotNumber);
+ simStatusPreference.setSummary(getSummary());
}
}
@@ -133,7 +154,7 @@
}
@VisibleForTesting
- protected String getFormattedPhoneNumber(SubscriptionInfo subscriptionInfo) {
+ protected CharSequence getFormattedPhoneNumber(SubscriptionInfo subscriptionInfo) {
final String phoneNumber = SubscriptionUtil.getBidiFormattedPhoneNumber(mContext,
subscriptionInfo);
return TextUtils.isEmpty(phoneNumber) ? mContext.getString(R.string.device_info_default)
@@ -142,6 +163,6 @@
@VisibleForTesting
protected Preference createNewPreference(Context context) {
- return new Preference(context);
+ return new PhoneNumberSummaryPreference(context);
}
}
diff --git a/src/com/android/settings/deviceinfo/SELinuxStatusPreferenceController.java b/src/com/android/settings/deviceinfo/SELinuxStatusPreferenceController.java
new file mode 100644
index 0000000..d0bf806
--- /dev/null
+++ b/src/com/android/settings/deviceinfo/SELinuxStatusPreferenceController.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2017 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.deviceinfo;
+
+import android.content.Context;
+import android.os.SELinux;
+import android.os.SystemProperties;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+import android.text.TextUtils;
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+public class SELinuxStatusPreferenceController extends AbstractPreferenceController implements
+ PreferenceControllerMixin {
+
+ private static final String PROPERTY_SELINUX_STATUS = "ro.build.selinux";
+ private static final String KEY_SELINUX_STATUS = "selinux_status";
+
+ public SELinuxStatusPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return !TextUtils.isEmpty(SystemProperties.get(PROPERTY_SELINUX_STATUS));
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_SELINUX_STATUS;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ final Preference pref = screen.findPreference(KEY_SELINUX_STATUS);
+ if (pref == null) {
+ return;
+ }
+ if (!SELinux.isSELinuxEnabled()) {
+ String status = mContext.getResources().getString(R.string.selinux_status_disabled);
+ pref.setSummary(status);
+ } else if (!SELinux.isSELinuxEnforced()) {
+ String status = mContext.getResources().getString(R.string.selinux_status_permissive);
+ pref.setSummary(status);
+ }
+ }
+}
+
diff --git a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
index e209d85..ab56513 100644
--- a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
+++ b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
@@ -38,8 +38,10 @@
import com.android.settings.deviceinfo.FeedbackPreferenceController;
import com.android.settings.deviceinfo.IpAddressPreferenceController;
import com.android.settings.deviceinfo.ManualPreferenceController;
+import com.android.settings.deviceinfo.OmniVersionPreferenceController;
import com.android.settings.deviceinfo.RegulatoryInfoPreferenceController;
import com.android.settings.deviceinfo.SafetyInfoPreferenceController;
+import com.android.settings.deviceinfo.SELinuxStatusPreferenceController;
import com.android.settings.deviceinfo.UptimePreferenceController;
import com.android.settings.deviceinfo.WifiMacAddressPreferenceController;
import com.android.settings.deviceinfo.imei.ImeiInfoPreferenceController;
@@ -128,6 +130,8 @@
controllers.add(new FeedbackPreferenceController(fragment, context));
controllers.add(new FccEquipmentIdPreferenceController(context));
controllers.add(new UptimePreferenceController(context, lifecycle));
+ controllers.add(new SELinuxStatusPreferenceController(context));
+ controllers.add(new OmniVersionPreferenceController(context));
Consumer<String> imeiInfoList = imeiKey -> {
ImeiInfoPreferenceController imeiRecord =
@@ -160,6 +164,7 @@
if (executor != null) {
executor.shutdown();
}
+
return controllers;
}
diff --git a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
index 13e26cc..128b39d 100644
--- a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
@@ -33,6 +33,7 @@
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.deviceinfo.PhoneNumberSummaryPreference;
import com.android.settings.deviceinfo.simstatus.SlotSimStatus;
import com.android.settings.network.SubscriptionUtil;
import com.android.settingslib.Utils;
@@ -102,7 +103,6 @@
multiImeiPreference.setKey(DEFAULT_KEY + (1 + simSlotNumber));
multiImeiPreference.setEnabled(true);
multiImeiPreference.setCopyingEnabled(true);
-
category.addPreference(multiImeiPreference);
}
}
@@ -112,6 +112,11 @@
updatePreference(preference, keyToSlotIndex(preference.getKey()));
}
+ @Override
+ public CharSequence getSummary() {
+ return mContext.getString(R.string.device_info_protected_single_press);
+ }
+
private CharSequence getSummary(int simSlot) {
final int phoneType = getPhoneType(simSlot);
return phoneType == PHONE_TYPE_CDMA ? mTelephonyManager.getMeid(simSlot)
@@ -148,12 +153,8 @@
@VisibleForTesting
protected void updatePreference(Preference preference, int simSlot) {
- if (simSlot < 0) {
- preference.setVisible(false);
- return;
- }
preference.setTitle(getTitle(simSlot));
- preference.setSummary(getSummary(simSlot));
+ preference.setSummary(getSummary());
}
private CharSequence getTitleForGsmPhone(int simSlot, boolean isPrimaryImei) {
@@ -197,6 +198,6 @@
@VisibleForTesting
Preference createNewPreference(Context context) {
- return new Preference(context);
+ return new PhoneNumberSummaryPreference(context);
}
}
diff --git a/src/com/android/settings/deviceinfo/simstatus/SimEidPreferenceController.kt b/src/com/android/settings/deviceinfo/simstatus/SimEidPreferenceController.kt
index 54331aa..8316e52 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SimEidPreferenceController.kt
+++ b/src/com/android/settings/deviceinfo/simstatus/SimEidPreferenceController.kt
@@ -96,7 +96,6 @@
}
preference.title = title
preference.dialogTitle = title
- preference.summary = eid
updateDialog()
}
}
@@ -134,6 +133,9 @@
val qrCodeView = dialog.requireViewById<ImageView>(R.id.esim_id_qrcode)
qrCodeView.setImageBitmap(getEidQrCode(eid))
+
+ // After "Tap to show", eid is displayed on preference.
+ preference.summary = textView.text
}
override fun handlePreferenceTreeClick(preference: Preference): Boolean {
diff --git a/src/com/android/settings/display/BatteryImagePreferenceController.java b/src/com/android/settings/display/BatteryImagePreferenceController.java
new file mode 100644
index 0000000..d0ed9ad
--- /dev/null
+++ b/src/com/android/settings/display/BatteryImagePreferenceController.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.display;
+
+import static org.omnirom.omnilib.utils.OmniSettings.OMNI_SHOW_BATTERY_IMAGE;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.Preference;
+import androidx.preference.TwoStatePreference;
+
+import com.android.internal.R;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.PreferenceControllerMixin;
+
+/**
+ * A controller to manage the switch for showing battery image in the status bar.
+ */
+
+public class BatteryImagePreferenceController extends BasePreferenceController implements
+ PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
+
+ public BatteryImagePreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ int setting = Settings.System.getInt(mContext.getContentResolver(),
+ OMNI_SHOW_BATTERY_IMAGE, 1);
+
+ ((TwoStatePreference) preference).setChecked(setting == 1);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ boolean showImage = (Boolean) newValue;
+ Settings.System.putInt(mContext.getContentResolver(), OMNI_SHOW_BATTERY_IMAGE,
+ showImage ? 1 : 0);
+ return true;
+ }
+}
diff --git a/src/com/android/settings/display/BrightnessLevelPreferenceController.java b/src/com/android/settings/display/BrightnessLevelPreferenceController.java
index 2b6e5f6..951af63 100644
--- a/src/com/android/settings/display/BrightnessLevelPreferenceController.java
+++ b/src/com/android/settings/display/BrightnessLevelPreferenceController.java
@@ -39,6 +39,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
@@ -61,11 +62,14 @@
public class BrightnessLevelPreferenceController extends BasePreferenceController implements
PreferenceControllerMixin, LifecycleObserver, OnStart, OnStop {
private static final Uri BRIGHTNESS_ADJ_URI;
+ private static final String KEY_CATEGORY_BRIGHTNESS = "category_brightness";
private final ContentResolver mContentResolver;
private final Handler mHandler = new Handler(Looper.getMainLooper());
private final DisplayManager mDisplayManager;
@Nullable
private Preference mPreference;
+ private PreferenceCategory mBrightnessCategory;
+ private boolean mHideBrightnessCategory;
static {
BRIGHTNESS_ADJ_URI = System.getUriFor(System.SCREEN_AUTO_BRIGHTNESS_ADJ);
@@ -108,6 +112,7 @@
lifecycle.addObserver(this);
}
mContentResolver = mContext.getContentResolver();
+ mHideBrightnessCategory = !mContext.getResources().getBoolean(R.bool.config_show_brightness);
}
@Override
@@ -119,6 +124,8 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
+ mBrightnessCategory = (PreferenceCategory) screen.findPreference(KEY_CATEGORY_BRIGHTNESS);
+ mBrightnessCategory.setVisible(!mHideBrightnessCategory);
}
@Override
diff --git a/src/com/android/settings/display/ControlsPrivacyPreferenceController.java b/src/com/android/settings/display/ControlsPrivacyPreferenceController.java
index b9a2bfa..1345bf9 100644
--- a/src/com/android/settings/display/ControlsPrivacyPreferenceController.java
+++ b/src/com/android/settings/display/ControlsPrivacyPreferenceController.java
@@ -92,7 +92,7 @@
.getSecurityFeatureProvider()
.getLockPatternUtils(mContext);
final int userId = UserHandle.myUserId();
- return utils.isSecure(userId);
+ return !utils.isLockScreenDisabled(userId);
}
private boolean isControlsAvailable() {
diff --git a/src/com/android/settings/display/CustomizableLockScreenUtils.java b/src/com/android/settings/display/CustomizableLockScreenUtils.java
index 2344436..6d52f8f 100644
--- a/src/com/android/settings/display/CustomizableLockScreenUtils.java
+++ b/src/com/android/settings/display/CustomizableLockScreenUtils.java
@@ -75,7 +75,9 @@
* <p>This is a slow, blocking call that shouldn't be made on the main thread.
*/
public static boolean isFeatureEnabled(Context context) {
- if (!isWallpaperPickerInstalled(context)) {
+ // TODO omni we need to enable custom_lockscreen_shortcuts_enabled=true
+ // but still want to use old settings so we have this here for now
+ if (!isWallpaperPickerInstalled(context) || true) {
return false;
}
diff --git a/src/com/android/settings/display/QRCodeScannerPreferenceController.java b/src/com/android/settings/display/QRCodeScannerPreferenceController.java
index cb022a7..e15860e 100644
--- a/src/com/android/settings/display/QRCodeScannerPreferenceController.java
+++ b/src/com/android/settings/display/QRCodeScannerPreferenceController.java
@@ -64,7 +64,7 @@
@OnLifecycleEvent(ON_START)
public void onStart() {
mContentResolver.registerContentObserver(
- Settings.Global.getUriFor(SHOW_QR_CODE_SCANNER_SETTING), false,
+ Settings.Secure.getUriFor(SHOW_QR_CODE_SCANNER_SETTING), false,
mSettingsObserver);
}
diff --git a/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
index 44fb0c4..e609981 100644
--- a/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
@@ -67,6 +67,8 @@
setSummaryAsync(info);
},
true /* shortString */);
+ // mIsBatteryPresent could change
+ mPreference.setVisible(getAvailabilityStatus() == AVAILABLE);
});
mBatteryStatusFeatureProvider =
@@ -75,7 +77,7 @@
@Override
public int getAvailabilityStatus() {
- return mContext.getResources().getBoolean(R.bool.config_show_top_level_battery)
+ return mContext.getResources().getBoolean(R.bool.config_show_top_level_battery) && mIsBatteryPresent
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
diff --git a/src/com/android/settings/gestures/BackGestureIndicatorView.java b/src/com/android/settings/gestures/BackGestureIndicatorView.java
index c60afd0..3bf40ec 100644
--- a/src/com/android/settings/gestures/BackGestureIndicatorView.java
+++ b/src/com/android/settings/gestures/BackGestureIndicatorView.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.PixelFormat;
+import android.graphics.Point;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -37,6 +38,7 @@
private ImageView mRightIndicator;
private BackGestureIndicatorDrawable mLeftDrawable;
private BackGestureIndicatorDrawable mRightDrawable;
+ private int mHeightScale;
public BackGestureIndicatorView(Context context) {
super(context);
@@ -87,6 +89,10 @@
indicator.setWidth(width);
}
+ public void setIndicatorHeightScale(int heightScale) {
+ mHeightScale = heightScale;
+ }
+
public WindowManager.LayoutParams getLayoutParams(
WindowManager.LayoutParams parentWindowAttributes) {
int copiedFlags = (parentWindowAttributes.flags
@@ -99,8 +105,33 @@
| copiedFlags,
PixelFormat.TRANSLUCENT);
+ setCurrentGestureHeight(lp);
lp.setTitle("BackGestureIndicatorView");
lp.token = getContext().getActivityToken();
return lp;
}
+
+ private void setCurrentGestureHeight(WindowManager.LayoutParams lp) {
+ Point displaySize = new Point();
+ getContext().getDisplay().getRealSize(displaySize);
+
+ // mHeightScale cant be range 0 - 3
+ // 0 means full height
+ // 1 measns half of the screen
+ // 2 means lower third of the screen
+ // 3 means lower sicth of the screen
+ if (mHeightScale == 0) {
+ lp.height = displaySize.y;
+ lp.y = 0;
+ } else if (mHeightScale == 1) {
+ lp.height = displaySize.y / 2;
+ lp.y = displaySize.y - lp.height;
+ } else if (mHeightScale == 2) {
+ lp.height = displaySize.y / 3;
+ lp.y = displaySize.y - lp.height;
+ } else {
+ lp.height = displaySize.y / 6;
+ lp.y = displaySize.y - lp.height;
+ }
+ }
}
diff --git a/src/com/android/settings/gestures/GestureHandlePreferenceController.java b/src/com/android/settings/gestures/GestureHandlePreferenceController.java
new file mode 100644
index 0000000..2eddb46
--- /dev/null
+++ b/src/com/android/settings/gestures/GestureHandlePreferenceController.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2016 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.gestures;
+
+import android.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+public class GestureHandlePreferenceController extends BasePreferenceController {
+
+ public GestureHandlePreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+}
diff --git a/src/com/android/settings/gestures/GestureNavigationSettingsFragment.java b/src/com/android/settings/gestures/GestureNavigationSettingsFragment.java
index 9a6b653..35ff454 100644
--- a/src/com/android/settings/gestures/GestureNavigationSettingsFragment.java
+++ b/src/com/android/settings/gestures/GestureNavigationSettingsFragment.java
@@ -33,6 +33,8 @@
import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.widget.ButtonPreference;
+import org.omnirom.omnilib.utils.OmniSettings;
+
/**
* A fragment to include all the settings related to Gesture Navigation mode.
*/
@@ -47,6 +49,7 @@
private static final String LEFT_EDGE_SEEKBAR_KEY = "gesture_left_back_sensitivity";
private static final String RIGHT_EDGE_SEEKBAR_KEY = "gesture_right_back_sensitivity";
+ private static final String KEY_BACK_HEIGHT = "gesture_back_height";
private static final String GESTURE_TUTORIAL_KEY = "assistant_gesture_navigation_tutorial";
final Intent mLaunchTutorialIntent = new Intent(ACTION_GESTURE_SANDBOX)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
@@ -57,6 +60,9 @@
private float[] mBackGestureInsetScales;
private float mDefaultBackGestureInset;
+ private float[] mBackGestureHeightScales = { 0f, 1f, 2f, 3f };
+ private int mCurrentRightWidth;
+ private int mCurrentLefttWidth;
public GestureNavigationSettingsFragment() {
super();
@@ -82,6 +88,7 @@
initSeekBarPreference(LEFT_EDGE_SEEKBAR_KEY);
initSeekBarPreference(RIGHT_EDGE_SEEKBAR_KEY);
+ initSeekBarPreference(KEY_BACK_HEIGHT);
initTutorialButton();
}
@@ -146,12 +153,30 @@
pref.setContinuousUpdates(true);
pref.setHapticFeedbackMode(SeekBarPreference.HAPTIC_FEEDBACK_MODE_ON_TICKS);
- final String settingsKey = key == LEFT_EDGE_SEEKBAR_KEY
- ? Settings.Secure.BACK_GESTURE_INSET_SCALE_LEFT
- : Settings.Secure.BACK_GESTURE_INSET_SCALE_RIGHT;
- final float initScale = Settings.Secure.getFloat(
+ final String settingsKey = key == LEFT_EDGE_SEEKBAR_KEY ?
+ Settings.Secure.BACK_GESTURE_INSET_SCALE_LEFT
+ : key == RIGHT_EDGE_SEEKBAR_KEY ?
+ Settings.Secure.BACK_GESTURE_INSET_SCALE_RIGHT
+ : OmniSettings.OMNI_BACK_GESTURE_HEIGHT;
+
+
+ float initScale = Settings.Secure.getFloat(
getContext().getContentResolver(), settingsKey, 1.0f);
+ // needed if we just change the height
+ float currentWidthScale = Settings.Secure.getFloat(
+ getContext().getContentResolver(), Settings.Secure.BACK_GESTURE_INSET_SCALE_RIGHT, 1.0f);
+ mCurrentRightWidth = (int) (mDefaultBackGestureInset * currentWidthScale);
+ currentWidthScale = Settings.Secure.getFloat(
+ getContext().getContentResolver(), Settings.Secure.BACK_GESTURE_INSET_SCALE_LEFT, 1.0f);
+ mCurrentLefttWidth = (int) (mDefaultBackGestureInset * currentWidthScale);
+
+ if (key == KEY_BACK_HEIGHT) {
+ mBackGestureInsetScales = mBackGestureHeightScales;
+ initScale = Settings.System.getInt(
+ getContext().getContentResolver(), settingsKey, 0);
+ }
+
// Find the closest value to initScale
float minDistance = Float.MAX_VALUE;
int minDistanceIndex = -1;
@@ -165,15 +190,38 @@
pref.setProgress(minDistanceIndex);
pref.setOnPreferenceChangeListener((p, v) -> {
- final int width = (int) (mDefaultBackGestureInset * mBackGestureInsetScales[(int) v]);
- mIndicatorView.setIndicatorWidth(width, key == LEFT_EDGE_SEEKBAR_KEY);
+ if (key != KEY_BACK_HEIGHT) {
+ final int width = (int) (mDefaultBackGestureInset * mBackGestureInsetScales[(int) v]);
+ mIndicatorView.setIndicatorWidth(width, key == LEFT_EDGE_SEEKBAR_KEY);
+ if (key == LEFT_EDGE_SEEKBAR_KEY) {
+ mCurrentLefttWidth = width;
+ } else {
+ mCurrentRightWidth = width;
+ }
+ } else {
+ final int heightScale = (int) (mBackGestureInsetScales[(int) v]);
+ mIndicatorView.setIndicatorHeightScale(heightScale);
+ // dont use updateViewLayout else it will animate
+ mWindowManager.removeView(mIndicatorView);
+ mWindowManager.addView(mIndicatorView, mIndicatorView.getLayoutParams(
+ getActivity().getWindow().getAttributes()));
+ // peek the indicators
+ mIndicatorView.setIndicatorWidth(mCurrentRightWidth, false);
+ mIndicatorView.setIndicatorWidth(mCurrentLefttWidth, true);
+ }
return true;
});
pref.setOnPreferenceChangeStopListener((p, v) -> {
- mIndicatorView.setIndicatorWidth(0, key == LEFT_EDGE_SEEKBAR_KEY);
final float scale = mBackGestureInsetScales[(int) v];
- Settings.Secure.putFloat(getContext().getContentResolver(), settingsKey, scale);
+ if (key == KEY_BACK_HEIGHT) {
+ mIndicatorView.setIndicatorWidth(0, false);
+ mIndicatorView.setIndicatorWidth(0, true);
+ Settings.System.putInt(getContext().getContentResolver(), settingsKey, (int) scale);
+ } else {
+ mIndicatorView.setIndicatorWidth(0, key == LEFT_EDGE_SEEKBAR_KEY);
+ Settings.Secure.putFloat(getContext().getContentResolver(), settingsKey, scale);
+ }
return true;
});
}
diff --git a/src/com/android/settings/gestures/GestureSmallPreferenceController.java b/src/com/android/settings/gestures/GestureSmallPreferenceController.java
new file mode 100644
index 0000000..09b42a6
--- /dev/null
+++ b/src/com/android/settings/gestures/GestureSmallPreferenceController.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2016 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.gestures;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.database.ContentObserver;
+import android.os.Handler;
+import android.os.Looper;
+import android.provider.Settings;
+import android.util.Log;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnPause;
+import com.android.settingslib.core.lifecycle.events.OnResume;
+
+import org.omnirom.omnilib.utils.OmniSettings;
+
+public class GestureSmallPreferenceController extends BasePreferenceController implements
+ LifecycleObserver, OnResume, OnPause {
+
+ private ContentObserver mObserver =
+ new ContentObserver(new Handler(Looper.getMainLooper())) {
+ @Override
+ public void onChange(boolean selfChange) {
+ updateState(mPreference);
+ }
+ };
+ private Preference mPreference;
+
+ public GestureSmallPreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
+ }
+
+ private boolean hideGestureHandle() {
+ return Settings.System.getInt(mContext.getContentResolver(),
+ OmniSettings.OMNI_GESTURE_HANDLE_HIDE, 0) != 0;
+ }
+
+ @Override
+ public void onResume() {
+ mContext.getContentResolver().registerContentObserver(
+ Settings.System.getUriFor(OmniSettings.OMNI_GESTURE_HANDLE_HIDE),
+ false, mObserver);
+ }
+
+ @Override
+ public void onPause() {
+ mContext.getContentResolver().unregisterContentObserver(mObserver);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return hideGestureHandle() ? DISABLED_DEPENDENT_SETTING : AVAILABLE;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ preference.setEnabled(getAvailabilityStatus() != DISABLED_DEPENDENT_SETTING);
+ refreshSummary(preference);
+ }
+}
diff --git a/src/com/android/settings/gestures/GesturesSettingPreferenceController.java b/src/com/android/settings/gestures/GesturesSettingPreferenceController.java
index e8c4b93..d117862 100644
--- a/src/com/android/settings/gestures/GesturesSettingPreferenceController.java
+++ b/src/com/android/settings/gestures/GesturesSettingPreferenceController.java
@@ -68,6 +68,9 @@
controllers.add(new DoubleTapScreenPreferenceController(context, FAKE_PREF_KEY)
.setConfig(ambientDisplayConfiguration));
controllers.add(new PreventRingingParentPreferenceController(context, FAKE_PREF_KEY));
+ controllers.add(new PowerMenuPreferenceController(context, FAKE_PREF_KEY));
+ controllers.add(new OneHandedPreferenceCategoryController(context, FAKE_PREF_KEY));
+ controllers.add(new SystemNavigationPreferenceController(context, FAKE_PREF_KEY));
return controllers;
}
}
diff --git a/src/com/android/settings/notification/PhoneRingtone2PreferenceController.java b/src/com/android/settings/notification/PhoneRingtone2PreferenceController.java
new file mode 100644
index 0000000..2acda01
--- /dev/null
+++ b/src/com/android/settings/notification/PhoneRingtone2PreferenceController.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2018 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.RingtoneManager;
+import android.telephony.TelephonyManager;
+
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.DefaultRingtonePreference;
+import com.android.settings.Utils;
+
+public class PhoneRingtone2PreferenceController extends RingtonePreferenceControllerBase {
+
+ private static final int SLOT_ID = 1;
+ private static final String KEY_PHONE_RINGTONE2 = "ringtone2";
+
+ public PhoneRingtone2PreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+
+ DefaultRingtonePreference ringtonePreference =
+ (DefaultRingtonePreference) screen.findPreference(KEY_PHONE_RINGTONE2);
+ ringtonePreference.setSlotId(SLOT_ID);
+ ringtonePreference.setEnabled(hasCard());
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_PHONE_RINGTONE2;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ TelephonyManager telephonyManager =
+ (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ return Utils.isVoiceCapable(mContext) && telephonyManager.isMultiSimEnabled();
+ }
+
+ @Override
+ public int getRingtoneType() {
+ return RingtoneManager.TYPE_RINGTONE;
+ }
+
+ private boolean hasCard() {
+ TelephonyManager telephonyManager =
+ (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ return telephonyManager.hasIccCard(SLOT_ID);
+ }
+}
diff --git a/src/com/android/settings/notification/PhoneRingtonePreferenceController.java b/src/com/android/settings/notification/PhoneRingtonePreferenceController.java
index 2944b7d..c89dfcc 100644
--- a/src/com/android/settings/notification/PhoneRingtonePreferenceController.java
+++ b/src/com/android/settings/notification/PhoneRingtonePreferenceController.java
@@ -20,10 +20,18 @@
import android.media.RingtoneManager;
import android.media.audio.Flags;
+import android.telephony.TelephonyManager;
+
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.DefaultRingtonePreference;
+import com.android.settings.R;
+
import com.android.settings.Utils;
public class PhoneRingtonePreferenceController extends RingtonePreferenceControllerBase {
+ private static final int SLOT_ID = 0;
private static final String KEY_PHONE_RINGTONE = "phone_ringtone";
public PhoneRingtonePreferenceController(Context context) {
@@ -31,6 +39,21 @@
}
@Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+
+ TelephonyManager telephonyManager =
+ (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ if (telephonyManager.isMultiSimEnabled()) {
+ // For Multi SIM device, shoud show "Phone ringtone - SIM 1" for slot1 ringtone setting.
+ DefaultRingtonePreference ringtonePreference =
+ (DefaultRingtonePreference) screen.findPreference(KEY_PHONE_RINGTONE);
+ ringtonePreference.setTitle(mContext.getString(R.string.ringtone1_title));
+ ringtonePreference.setEnabled(hasCard());
+ }
+ }
+
+ @Override
public String getPreferenceKey() {
return KEY_PHONE_RINGTONE;
}
@@ -48,6 +71,12 @@
return RingtoneManager.TYPE_RINGTONE;
}
+ private boolean hasCard() {
+ TelephonyManager telephonyManager =
+ (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ return telephonyManager.hasIccCard(SLOT_ID);
+ }
+
private boolean isRingtoneVibrationEnabled() {
return Flags.enableRingtoneHapticsCustomization() && mContext.getResources().getBoolean(
com.android.internal.R.bool.config_ringtoneVibrationSettingsSupported);
diff --git a/src/com/android/settings/notification/RingtonePreferenceControllerBase.java b/src/com/android/settings/notification/RingtonePreferenceControllerBase.java
index 29b9266..359ea71 100644
--- a/src/com/android/settings/notification/RingtonePreferenceControllerBase.java
+++ b/src/com/android/settings/notification/RingtonePreferenceControllerBase.java
@@ -24,6 +24,7 @@
import androidx.preference.Preference;
+import com.android.settings.RingtonePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.utils.ThreadUtils;
@@ -51,8 +52,8 @@
}
private void updateSummary(Preference preference) {
- final Uri ringtoneUri = RingtoneManager.getActualDefaultRingtoneUri(
- mContext, getRingtoneType());
+ final Uri ringtoneUri = RingtoneManager.getActualDefaultRingtoneUriBySlot(mContext,
+ getRingtoneType(), ((RingtonePreference)preference).getSlotId());
final CharSequence summary;
try {
diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java
index 0b23e07..c667900 100644
--- a/src/com/android/settings/notification/SoundSettings.java
+++ b/src/com/android/settings/notification/SoundSettings.java
@@ -254,6 +254,7 @@
// === Phone & notification ringtone ===
controllers.add(new PhoneRingtonePreferenceController(context));
+ controllers.add(new PhoneRingtone2PreferenceController(context));
controllers.add(new AlarmRingtonePreferenceController(context));
controllers.add(new NotificationRingtonePreferenceController(context));
diff --git a/src/com/android/settings/slices/SlicesDatabaseHelper.java b/src/com/android/settings/slices/SlicesDatabaseHelper.java
index cad045e..1aa5c65 100644
--- a/src/com/android/settings/slices/SlicesDatabaseHelper.java
+++ b/src/com/android/settings/slices/SlicesDatabaseHelper.java
@@ -246,6 +246,6 @@
@VisibleForTesting
String getBuildTag() {
- return Build.FINGERPRINT;
+ return String.valueOf(Build.TIME);
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/wifi/p2p/WifiP2pPreferenceController.java b/src/com/android/settings/wifi/p2p/WifiP2pPreferenceController.java
index 5d73fa4..2a5e8c6 100644
--- a/src/com/android/settings/wifi/p2p/WifiP2pPreferenceController.java
+++ b/src/com/android/settings/wifi/p2p/WifiP2pPreferenceController.java
@@ -15,6 +15,8 @@
*/
package com.android.settings.wifi.p2p;
+import static android.content.pm.PackageManager.FEATURE_WIFI_DIRECT;
+
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -92,8 +94,7 @@
@Override
public boolean isAvailable() {
- // Always show preference.
- return true;
+ return mContext.getPackageManager().hasSystemFeature(FEATURE_WIFI_DIRECT);
}
@Override
public String getPreferenceKey() {
diff --git a/tests/robotests/src/com/android/settings/notification/PhoneRingtone2PreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/PhoneRingtone2PreferenceControllerTest.java
new file mode 100644
index 0000000..87fa6a5
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/PhoneRingtone2PreferenceControllerTest.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2018 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.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.media.RingtoneManager;
+import android.telephony.TelephonyManager;
+
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.DefaultRingtonePreference;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class PhoneRingtone2PreferenceControllerTest {
+
+ @Mock
+ private TelephonyManager mTelephonyManager;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ @Mock
+ private DefaultRingtonePreference mPreference;
+
+ private Context mContext;
+ private PhoneRingtone2PreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowContext = ShadowApplication.getInstance();
+ shadowContext.setSystemService(Context.TELEPHONY_SERVICE, mTelephonyManager);
+ mContext = RuntimeEnvironment.application;
+ mController = new PhoneRingtone2PreferenceController(mContext);
+ }
+
+ @Test
+ public void displayPreference_shouldSetSlotId() {
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
+ .thenReturn(mPreference);
+ mController.displayPreference(mPreferenceScreen);
+
+ verify(mPreference).setSlotId(1);
+ }
+
+ @Test
+ public void isAvailable_notVoiceCapable_shouldReturnFalse() {
+ when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
+
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void isAvailable_notMultiSimEnabled_shouldReturnFalse() {
+ when(mTelephonyManager.isMultiSimEnabled()).thenReturn(false);
+
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void isAvailable_VoiceCapable_and_MultiSimEnabled_shouldReturnTrue() {
+ when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
+ when(mTelephonyManager.isMultiSimEnabled()).thenReturn(true);
+
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void getRingtoneType_shouldReturnRingtone() {
+ assertThat(mController.getRingtoneType()).isEqualTo(RingtoneManager.TYPE_RINGTONE);
+ }
+}
diff --git a/tests/uitests/src/com/android/settings/ui/SoundSettingsTest.java b/tests/uitests/src/com/android/settings/ui/SoundSettingsTest.java
index f981f7f..72d4a11 100644
--- a/tests/uitests/src/com/android/settings/ui/SoundSettingsTest.java
+++ b/tests/uitests/src/com/android/settings/ui/SoundSettingsTest.java
@@ -21,6 +21,7 @@
import android.provider.Settings;
import android.system.helpers.SettingsHelper;
import android.system.helpers.SettingsHelper.SettingsType;
+import android.telephony.TelephonyManager;
import android.test.InstrumentationTestCase;
import androidx.test.filters.MediumTest;
@@ -42,6 +43,7 @@
private UiDevice mDevice;
private ContentResolver mResolver;
private SettingsHelper mHelper;
+ private TelephonyManager mTelephonyManager;
private final Map<String, String> ringtoneSounds = Map.of(
@@ -100,6 +102,8 @@
mDevice.setOrientationNatural();
mResolver = getInstrumentation().getContext().getContentResolver();
mHelper = new SettingsHelper();
+ mTelephonyManager = (TelephonyManager) getInstrumentation().getContext()
+ .getSystemService(Context.TELEPHONY_SERVICE);
}
@Override
@@ -174,26 +178,49 @@
public void testPhoneRingtoneNone() throws Exception {
launchSoundSettings();
mHelper.clickSetting("Phone ringtone");
- verifyRingtone(new RingtoneSetting("None", "null"),
- Settings.System.RINGTONE);
+ if (mTelephonyManager.isMultiSimEnabled()) {
+ mHelper.clickSetting("Phone ringtone - SIM 1");
+ verifyRingtone(new RingtoneSetting("None", "null"), Settings.System.RINGTONE);
+ mHelper.clickSetting("Phone ringtone - SIM 2");
+ verifyRingtone(new RingtoneSetting("None", "null"), Settings.System.RINGTONE2);
+ } else {
+ mHelper.clickSetting("Phone ringtone");
+ verifyRingtone(new RingtoneSetting("None", "null"), Settings.System.RINGTONE);
+ }
}
@MediumTest
@Suppress
public void testPhoneRingtoneHangouts() throws Exception {
launchSoundSettings();
- mHelper.clickSetting("Phone ringtone");
- verifyRingtone(new RingtoneSetting("Hangouts Call", "31"), Settings.System.RINGTONE);
+ if (mTelephonyManager.isMultiSimEnabled()) {
+ mHelper.clickSetting("Phone ringtone - SIM 1");
+ verifyRingtone(new RingtoneSetting("Hangouts Call", "31"), Settings.System.RINGTONE);
+ mHelper.clickSetting("Phone ringtone - SIM 2");
+ verifyRingtone(new RingtoneSetting("Hangouts Call", "31"), Settings.System.RINGTONE2);
+ } else {
+ mHelper.clickSetting("Phone ringtone");
+ verifyRingtone(new RingtoneSetting("Hangouts Call", "31"), Settings.System.RINGTONE);
+ }
}
@MediumTest
public void testPhoneRingtone() throws Exception {
launchSoundSettings();
- mHelper.clickSetting("Phone ringtone");
String ringtone = ringtoneSounds.get(mDevice.getProductName()).toString();
String ringtoneSettingValue = ringtoneCodes.get(mDevice.getProductName()).toString();
- verifyRingtone(new RingtoneSetting(ringtone, ringtoneSettingValue),
- Settings.System.RINGTONE);
+ if (mTelephonyManager.isMultiSimEnabled()) {
+ mHelper.clickSetting("Phone ringtone - SIM 1");
+ verifyRingtone(new RingtoneSetting(ringtone, ringtoneSettingValue),
+ Settings.System.RINGTONE);
+ mHelper.clickSetting("Phone ringtone - SIM 2");
+ verifyRingtone(new RingtoneSetting(ringtone, ringtoneSettingValue),
+ Settings.System.RINGTONE2);
+ } else {
+ mHelper.clickSetting("Phone ringtone");
+ verifyRingtone(new RingtoneSetting(ringtone, ringtoneSettingValue),
+ Settings.System.RINGTONE);
+ }
}
@MediumTest