Snap for 4733905 from 13365e83c0 to qt-release

Change-Id: Idbb467a45772fc212f60d68865ef2178697cfd1e
This commit is contained in:
android-build-team Robot
2018-04-20 09:38:35 +00:00
183 changed files with 5746 additions and 1645 deletions

View File

@@ -1390,7 +1390,7 @@
<category android:name="android.intent.category.VOICE_LAUNCH" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.PrivacySettings" />
android:value="com.android.settings.backup.PrivacySettings" />
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
android:value="true" />
</activity>

View File

@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="96dp"
android:height="96dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?android:attr/colorControlNormal">
<path
android:fillColor="#000000"
android:pathData="M15.5,14h-0.79l-0.28-0.27c1.2-1.4,1.82-3.31,1.48-5.34c-0.47-2.78-2.79-5-5.59-5.34c-4.23-0.52-7.79,3.04-7.27,7.27
c0.34,2.8,2.56,5.12,5.34,5.59c2.03,0.34,3.94-0.28,5.34-1.48L14,14.71v0.79l5.2,5.19c0.41,0.41,1.07,0.41,1.48,0l0.01-0.01
c0.41-0.41,0.41-1.07,0-1.48L15.5,14z M9.5,14C7.01,14,5,11.99,5,9.5S7.01,5,9.5,5S14,7.01,14,9.5S11.99,14,9.5,14z" />
</vector>

View File

@@ -20,8 +20,6 @@
android:viewportHeight="24">
<path
android:pathData="M 0 0 H 24 V 24 H 0 V 0 Z" />
<path
android:fillColor="#F09300"
android:pathData="M14,10.5v9.06C12.87,21,12,22,12,22S5,14.25,5,9A7,7,0,0,1,18.93,8H14.29A2.5,2.5,0,1,0,14,10.5ZM16,22h2V20H16Zm0-4h2V10H16Z" />
android:fillColor="#FF000000"
android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13C19,5.13 15.87,2 12,2zM7,9c0,-2.76 2.24,-5 5,-5s5,2.24 5,5c0,2.88 -2.88,7.19 -5,9.88C9.92,16.21 7,11.85 7,9zM11,13h2v2h-2V13zM13,6h-2v5h2V6z"/>
</vector>

View File

@@ -20,10 +20,6 @@
android:viewportHeight="24">
<path
android:pathData="M 0 0 H 24 V 24 H 0 V 0 Z" />
<path
android:fillColor="#4285F4"
android:pathData="M12,2 C8.13400675,2 5,5.13400675 5,9 C5,14.25 12,22 12,22 C12,22 19,14.25 19,9
C19,5.13400675 15.8659932,2 12,2 L12,2 Z M8.2,9.66 L9.61,8.24 L11,9.66
L15.24,5.42 L16.65,6.83 L11,12.49 L8.2,9.66 Z" />
android:fillColor="#FF000000"
android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13C19,5.13 15.87,2 12,2zM7,9c0,-2.76 2.24,-5 5,-5s5,2.24 5,5c0,2.88 -2.88,7.19 -5,9.88C9.92,16.21 7,11.85 7,9zM14.5,9c0,1.38 -1.12,2.5 -2.5,2.5S9.5,10.38 9.5,9s1.12,-2.5 2.5,-2.5S14.5,7.62 14.5,9z"/>
</vector>

View File

@@ -20,8 +20,6 @@
android:viewportHeight="24">
<path
android:pathData="M 0 0 H 24 V 24 H 0 V 0 Z" />
<path
android:fillColor="#F09300"
android:pathData="M17,1H7A2,2,0,0,0,5,3V21a2,2,0,0,0,2,2H17a2,2,0,0,0,2-2V3A2,2,0,0,0,17,1Zm0,18H7V5H17Zm-1-6H13V8H11v5H8l4,4Z" />
android:fillColor="#FF000000"
android:pathData="M17,1.01L7,1C5.9,1 5,1.9 5,3v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3C19,1.9 18.1,1.01 17,1.01zM17,21H7l0,-1h10V21zM17,18H7V6h10V18zM7,4V3h10v1H7zM16,12.5l-4,4l-4,-4l1.41,-1.41L11,12.67V8.5V8h2v0.5v4.17l1.59,-1.59L16,12.5z"/>
</vector>

View File

@@ -20,8 +20,6 @@
android:viewportHeight="24">
<path
android:pathData="M 0 0 H 24 V 24 H 0 V 0 Z" />
<path
android:fillColor="#4285F4"
android:pathData="M17,1H7A2,2,0,0,0,5,3V21a2,2,0,0,0,2,2H17a2,2,0,0,0,2-2V3A2,2,0,0,0,17,1ZM9.11,14.06h0l1.41,1.41,5.66-5.66-1.42-1.4-4.24,4.24L9.11,11.24,7.7,12.66ZM17,19H7V5H17Z" />
android:fillColor="#FF000000"
android:pathData="M17,1.01L7,1C5.9,1 5,1.9 5,3v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3C19,1.9 18.1,1.01 17,1.01zM17,21H7l0,-1h10V21zM17,18H7V6h10V18zM7,4V3h10v1H7zM11.14,16l-3.84,-3.84l1.41,-1.42l2.43,2.42l4.16,-4.16l1.42,1.41L11.14,16z"/>
</vector>

View File

@@ -20,8 +20,6 @@
android:viewportHeight="24">
<path
android:pathData="M 0 0 H 24 V 24 H 0 V 0 Z" />
<path
android:fillColor="#F09300"
android:pathData="M17,1a2,2,0,0,1,2,2V21a2,2,0,0,1-2,2H7a2,2,0,0,1-2-2V3A2,2,0,0,1,7,1Zm0,18V5H7V19ZM11,6.5h2v7H11Zm0,9h2v2H11Z" />
android:fillColor="#FF000000"
android:pathData="M17,1.01L7,1C5.9,1 5,1.9 5,3v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3C19,1.9 18.1,1.01 17,1.01zM17,21H7l0,-1h10V21zM17,18H7V6h10V18zM7,4V3h10v1H7zM11,15h2v2h-2V15zM13,8h-2v5h2V8z"/>
</vector>

View File

@@ -14,20 +14,12 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="22dp"
android:height="22dp"
android:viewportWidth="22"
android:viewportHeight="22">
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#F5A623"
android:fillType="evenOdd"
android:pathData="M20.5515334,2.919 C15.9049774,0.613 11,0 11,0 C11,0 6.09502262,0.613
1.44846657,2.919 C1.15485168,4.149 1,5.432 1,6.752 C1,8.109 1.16490699,9.429
1.47561589,10.693 C2.13624937,13.382 3.45852187,15.813 5.26143791,17.807
C6.84313725,19.559 8.79788839,20.973 11,21.926 C13.2021116,20.973
15.1568627,19.559 16.7395676,17.807 C18.5414781,15.813 19.8637506,13.382
20.5253896,10.693 C20.835093,9.429 21,8.109 21,6.752 C21,5.432 20.8461538,4.149
20.5515334,2.919 M12,15.5 L10,15.5 L10,13.5 L12,13.5 L12,15.5 L12,15.5 Z M12,12
L10,12 L10,6 L12,6 L12,12 L12,12 Z" />
android:fillColor="#FF000000"
android:pathData="M12,4.24l6,3v4.1c0,3.9 -2.55,7.5 -6,8.59c-3.45,-1.09 -6,-4.7 -6,-8.59v-4.1L12,4.24M12,2L4,6v5.33c0,4.93 3.41,9.55 8,10.67c4.59,-1.12 8,-5.73 8,-10.67V6L12,2L12,2zM11,15h2v2h-2V15zM13,8h-2v5h2V8z"/>
</vector>

View File

@@ -14,22 +14,12 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="22dp"
android:height="22dp"
android:viewportWidth="22"
android:viewportHeight="22">
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#4285F4"
android:fillType="evenOdd"
android:pathData="M20.5515334,2.92885159 C20.8461538,4.16300283 21,5.45033294 21,6.77478792
C21,8.13636778 20.835093,9.46082277 20.5253896,10.7290888 C19.8637506,13.4271641
18.5414781,15.8663687 16.7395676,17.8670984 C15.1568627,19.6250114
13.2021116,21.0437836 11,22 C8.79788839,21.0437836 6.84313725,19.6250114
5.26143791,17.8670984 C3.45852187,15.8663687 2.13624937,13.4271641
1.47561589,10.7290888 C1.16490699,9.46082277 1,8.13636778 1,6.77478792
C1,5.45033294 1.15485168,4.16300283 1.44846657,2.92885159
C6.09502262,0.615068868 11,0 11,0 C11,0 15.9049774,0.615068868
20.5515334,2.92885159 Z M15.6984615,6 L9.61538462,12.2961783 L7,10
L5.69846154,11.3471338 L9.61538462,15 L17,7.3566879 L15.6984615,6 Z" />
android:fillColor="#FF000000"
android:pathData="M11.14,16l-3.84,-3.84l1.41,-1.42l2.43,2.42l4.16,-4.16l1.42,1.41L11.14,16zM12,4.24l6,3v4.1c0,3.9 -2.55,7.5 -6,8.59c-3.45,-1.09 -6,-4.7 -6,-8.59v-4.1L12,4.24M12,2L4,6v5.33c0,4.93 3.41,9.55 8,10.67c4.59,-1.12 8,-5.73 8,-10.67V6L12,2L12,2z"/>
</vector>

View File

@@ -14,30 +14,11 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="22dp"
android:height="22dp"
android:viewportWidth="22"
android:viewportHeight="22">
<group
android:translateX="-1"
android:translateY="-1">
<path
android:fillType="evenOdd"
android:pathData="M 0 0 H 24 V 24 H 0 V 0 Z" />
<path
android:fillColor="#D84336"
android:fillType="evenOdd"
android:pathData="M21.5515334,3.92885159 C21.8461538,5.16300283 22,6.45033294 22,7.77478792
C22,9.13636778 21.835093,10.4608228 21.5253896,11.7290888 C20.8637506,14.4271641
19.5414781,16.8663687 17.7395676,18.8670984 C16.1568627,20.6250114
14.2021116,22.0437836 12,23 C9.79788839,22.0437836 7.84313725,20.6250114
6.26143791,18.8670984 C4.45852187,16.8663687 3.13624937,14.4271641
2.47561589,11.7290888 C2.16490699,10.4608228 2,9.13636778 2,7.77478792
C2,6.45033294 2.15485168,5.16300283 2.44846657,3.92885159 C7.09502262,1.61506887
12,1 12,1 C12,1 16.9049774,1.61506887 21.5515334,3.92885159 Z M14.6469246,7
L11.9600359,9.71972847 L9.272253,7 L8.00878156,8.28072408 L10.6956703,11.0004526
L8,13.720181 L9.26347144,15 L11.9600359,12.2802715 L14.7347402,15 L16,13.720181
L13.2252957,11.0004526 L15.9121844,8.28072408 L14.6469246,7 Z" />
</group>
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M15.5,9.91L14.09,8.5L12,10.59L9.91,8.5L8.5,9.91L10.59,12L8.5,14.09l1.41,1.41L12,13.42l2.09,2.08l1.41,-1.41L13.42,12L15.5,9.91zM12,4.24l6,3v4.1c0,3.9 -2.55,7.5 -6,8.59c-3.45,-1.09 -6,-4.7 -6,-8.59v-4.1L12,4.24M12,2L4,6v5.33c0,4.93 3.41,9.55 8,10.67c4.59,-1.12 8,-5.73 8,-10.67V6L12,2L12,2z"/>
</vector>

View File

@@ -62,35 +62,22 @@
<TextView
android:id="@+id/install_type"
style="@style/TextAppearance.EntityHeaderSummary"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:singleLine="true"
android:ellipsize="marquee"
android:textAppearance="@android:style/TextAppearance.Material.Body1"
android:textColor="?android:attr/textColorSecondary" />
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/entity_header_summary"
style="@style/TextAppearance.EntityHeaderSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:singleLine="true"
android:ellipsize="marquee"
android:textAppearance="@android:style/TextAppearance.Material.Body1"
android:textColor="?android:attr/textColorSecondary" />
android:layout_height="wrap_content" />
<TextView
android:id="@+id/entity_header_second_summary"
style="@style/TextAppearance.EntityHeaderSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:singleLine="true"
android:ellipsize="marquee"
android:textAlignment="viewStart"
android:textAppearance="@android:style/TextAppearance.Material.Body1"
android:textColor="?android:attr/textColorSecondary" />
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>

View File

@@ -23,4 +23,5 @@
android:paddingStart="4dp"
android:paddingEnd="4dp"
android:paddingTop="8dp"
android:paddingBottom="8dp" />
android:paddingBottom="8dp"
android:textAlignment="viewStart"/>

View File

@@ -20,6 +20,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:icon="@drawable/ic_lock"
android:importantForAutofill="noExcludeDescendants"
settings:suwFooter="@layout/choose_lock_password_footer"
settings:suwHeaderText="@string/lockpassword_choose_your_screen_lock_header">

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp"
android:paddingStart="@dimen/wifi_ap_band_checkbox_padding">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="8dp"
android:text="@string/wifi_ap_band_select_one"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<CheckBox
android:id="@+id/box_2g"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/wifi_ap_band_checkbox_padding"
android:layout_marginTop="@dimen/wifi_ap_band_checkbox_padding"
android:paddingStart="@dimen/wifi_ap_band_checkbox_padding"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<CheckBox
android:id="@+id/box_5g"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/wifi_ap_band_checkbox_padding"
android:textAppearance="?android:attr/textAppearanceMedium"/>
</LinearLayout>

View File

@@ -72,9 +72,10 @@
android:orientation="vertical"/>
</LinearLayout>
<FrameLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="6dp">
<SeekBar
@@ -93,10 +94,11 @@
android:textAlignment="viewStart"
android:singleLine="true"
android:ellipsize="end"
android:visibility="gone"
android:textAppearance="@android:style/TextAppearance.Material.Body1"
android:textColor="?android:attr/textColorSecondary"/>
</FrameLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@@ -55,36 +55,22 @@
<TextView
android:id="@+id/install_type"
style="@style/TextAppearance.EntityHeaderSummary"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:singleLine="true"
android:ellipsize="marquee"
android:textAppearance="@android:style/TextAppearance.Material.Body1"
android:textColor="?android:attr/textColorSecondary" />
android:layout_height="wrap_content" />
<TextView
android:id="@+id/entity_header_summary"
style="@style/TextAppearance.EntityHeaderSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:singleLine="true"
android:ellipsize="marquee"
android:textAlignment="viewStart"
android:textAppearance="@android:style/TextAppearance.Material.Body1"
android:textColor="?android:attr/textColorSecondary" />
android:layout_height="wrap_content" />
<TextView
android:id="@+id/entity_header_second_summary"
style="@style/TextAppearance.EntityHeaderSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:singleLine="true"
android:ellipsize="marquee"
android:textAlignment="viewStart"
android:textAppearance="@android:style/TextAppearance.Material.Body1"
android:textColor="?android:attr/textColorSecondary" />
android:layout_height="wrap_content" />
</LinearLayout>

View File

@@ -215,12 +215,9 @@
<string-array name="wifi_security">
<!-- The Wi-Fi network does not have any security. -->
<item>@string/wifi_security_none</item>
<!-- Do not translate. -->
<item>@string/wifi_security_wep</item>
<!-- Do not translate. -->
<item>@string/wifi_security_psk_generic</item>
<!-- Do not translate. -->
<item>@string/wifi_security_eap</item>
<item translatable="false">@string/wifi_security_wep</item>
<item translatable="false">@string/wifi_security_psk_generic</item>
<item translatable="false">@string/wifi_security_eap</item>
</string-array>
@@ -229,47 +226,33 @@
<string-array name="wifi_security_no_eap">
<!-- The Wi-Fi network does not have any security. -->
<item>@string/wifi_security_none</item>
<!-- Do not translate. -->
<item>@string/wifi_security_wep</item>
<!-- Do not translate. -->
<item>@string/wifi_security_psk_generic</item>
<item translatable="false">@string/wifi_security_wep</item>
<item translatable="false">@string/wifi_security_psk_generic</item>
</string-array>
<!-- Match this with the constants in WifiDialog. --> <skip />
<!-- Wi-Fi settings. The type of EAP method a Wi-Fi network has. -->
<string-array name="wifi_eap_method">
<!-- Do not translate. -->
<string-array name="wifi_eap_method" translatable="false">
<item>PEAP</item>
<!-- Do not translate. -->
<item>TLS</item>
<!-- Do not translate. -->
<item>TTLS</item>
<!-- Do not translate. -->
<item>PWD</item>
<!-- Do not translate. -->
<item>SIM</item>
<!-- Do not translate. -->
<item>AKA</item>
<!-- Do not translate. -->
<item>AKA\'</item>
</string-array>
<!-- Type of EAP method when EAP SIM, AKA, AKA' are not supported -->
<string-array name="eap_method_without_sim_auth">
<!-- Do not translate. -->
<string-array name="eap_method_without_sim_auth" translatable="false">
<item>PEAP</item>
<!-- Do not translate. -->
<item>TLS</item>
<!-- Do not translate. -->
<item>TTLS</item>
<!-- Do not translate. -->
<item>PWD</item>
</string-array>
<!-- Wi-Fi AP band settings. Either Auto, 2.4GHz or 5GHz. -->
<!-- Note that adding/removing/moving the items will need wifi settings code change. -->
<string-array name="wifi_ap_band_config_full">
<item>@string/wifi_ap_choose_auto</item>
<item>@string/wifi_ap_choose_2G</item>
<item>@string/wifi_ap_choose_5G</item>
</string-array>
@@ -379,16 +362,11 @@
<!-- Type of EAP method when EAP SIM, AKA, AKA' are supported -->
<string-array name="wifi_peap_phase2_entries_with_sim_auth">
<item>None</item>
<!-- Do not translate. -->
<item>MSCHAPV2</item>
<!-- Do not translate. -->
<item>GTC</item>
<!-- Do not translate. -->
<item>SIM</item>
<!-- Do not translate. -->
<item>AKA</item>
<!-- Do not translate. -->
<item>AKA\'</item>
<item translatable="false">MSCHAPV2</item>
<item translatable="false">GTC</item>
<item translatable="false">SIM</item>
<item translatable="false">AKA</item>
<item translatable="false">AKA\'</item>
</string-array>
<!-- Phase 2 options for rest of EAP methods -->
@@ -513,12 +491,9 @@
<!-- MVNO Info used in APN editor -->
<string-array name="mvno_type_entries">
<item>None</item>
<!-- Do not translate. -->
<item>SPN</item>
<!-- Do not translate. -->
<item>IMSI</item>
<!-- Do not translate. -->
<item>GID</item>
<item translatable="false">SPN</item>
<item translatable="false">IMSI</item>
<item translatable="false">GID</item>
</string-array>
<string-array translatable="false" name="mvno_type_values">

View File

@@ -128,4 +128,7 @@
doesn't interact well with scroll view -->
<bool name="config_lock_pattern_minimal_ui">true</bool>
<!-- List of a11y components on the device allowed to be enabled by Settings Slices -->
<string-array name="config_settings_slices_accessibility_components" translatable="false"/>
</resources>

View File

@@ -191,6 +191,7 @@
<!-- WiFi Preferences -->
<dimen name="wifi_divider_height">1px</dimen>
<dimen name="wifi_ap_band_checkbox_padding">16dp</dimen>
<!-- Color picker -->
<dimen name="color_swatch_size">16dp</dimen>

View File

@@ -664,6 +664,8 @@
<string name="save">Save</string>
<!-- Button label for generic done action [CHAR LIMIT=20] -->
<string name="done">Done</string>
<!-- Button label for generic apply action [CHAR LIMIT=20] -->
<string name="apply">Apply</string>
<!-- Title of the Settings activity shown within the application itself. -->
<string name="settings_label">Settings</string>
@@ -9070,13 +9072,13 @@
<!-- Data usage remaining string [CHAR LIMIT=30] -->
<string name="data_used"><xliff:g name="bytes" example="2 GB">^1</xliff:g> used</string>
<!-- Data usage remaining string [CHAR LIMIT=30] -->
<!-- Data usage remaining string [CHAR LIMIT=13] -->
<string name="data_used_formatted"><xliff:g name="value" example="500">^1</xliff:g> <xliff:g name="units" example="GB">^2</xliff:g> used</string>
<!-- Data usage over limit string [CHAR LIMIT=30] -->
<!-- Shows the amount of data the user has used over their data limit [CHAR LIMIT=13] -->
<string name="data_overusage"><xliff:g name="bytes" example="2 GB">^1</xliff:g> over</string>
<!-- Optional part of data usage showing the remaining amount [CHAR LIMIT=30] -->
<!-- Optional part of data usage showing the remaining amount [CHAR LIMIT=13] -->
<string name="data_remaining"><xliff:g name="bytes" example="2 GB">^1</xliff:g> left</string>
<!-- Informational text about time left in billing cycle [CHAR LIMIT=60] -->
@@ -9257,6 +9259,9 @@
<!-- [CHAR_LIMIT=NONE] Developer Settings: Title of the setting which turns on emulation of a display cutout. -->
<string name="display_cutout_emulation">Simulate a display with a cutout</string>
<!-- [CHAR_LIMIT=NONE] Developer Settings: Search keywords for the setting which turns on emulation of a display cutout. -->
<string name="display_cutout_emulation_keywords">display cutout, notch</string>
<!-- [CHAR_LIMIT=NONE] Developer Settings: Label for the option that turns off display cutout emulation. -->
<string name="display_cutout_emulation_none">None</string>

View File

@@ -425,6 +425,15 @@
<item name="android:textSize">16sp</item>
</style>
<style name="TextAppearance.EntityHeaderSummary"
parent="@android:style/TextAppearance.Material.Body1">
<item name="android:textAlignment">viewStart</item>
<item name="android:textColor">?android:attr/textColorSecondary</item>
<item name="android:gravity">start</item>
<item name="android:singleLine">true</item>
<item name="android:ellipsize">marquee</item>
</style>
<style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button.Colored"/>
<style name="ActionSecondaryButton" parent="android:Widget.DeviceDefault.Button"/>

View File

@@ -15,6 +15,7 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/legal_information"
android:key="legal_screen">
@@ -26,35 +27,32 @@
<!-- Copyright information -->
<Preference
android:key="copyright"
android:title="@string/copyright_title">
<intent android:action="android.settings.COPYRIGHT"/>
</Preference>
android:title="@string/copyright_title"
settings:controller="com.android.settings.deviceinfo.legal.CopyrightPreferenceController" />
<!-- License information -->
<Preference
android:key="license"
android:title="@string/license_title">
<intent android:action="android.settings.LICENSE"/>
</Preference>
android:title="@string/license_title"
settings:controller="com.android.settings.deviceinfo.legal.LicensePreferenceController" />
<!-- Terms and conditions -->
<Preference
android:key="terms"
android:title="@string/terms_title">
<intent android:action="android.settings.TERMS"/>
</Preference>
android:title="@string/terms_title"
settings:controller="com.android.settings.deviceinfo.legal.TermsPreferenceController" />
<!-- System WebView License information -->
<Preference
android:key="webview_license"
android:title="@string/webview_license_title">
<intent android:action="android.settings.WEBVIEW_LICENSE"/>
</Preference>
android:title="@string/webview_license_title"
settings:controller="com.android.settings.deviceinfo.legal.WebViewLicensePreferenceController" />
<Preference
android:key="wallpaper_attributions"
android:title="@string/wallpaper_attributions"
android:summary="@string/wallpaper_attributions_values"/>
android:summary="@string/wallpaper_attributions_values"
settings:controller="com.android.settings.deviceinfo.legal.WallpaperAttributionsPreferenceController" />
</PreferenceScreen>

View File

@@ -33,7 +33,8 @@
<!-- Pulse notification light -->
<SwitchPreference
android:key="notification_pulse"
android:title="@string/notification_pulse_title"/>
android:title="@string/notification_pulse_title"
settings:controller="com.android.settings.notification.PulseNotificationPreferenceController" />
<!-- Default notification ringtone -->
<com.android.settings.DefaultRingtonePreference

View File

@@ -52,8 +52,7 @@
android:fragment="com.android.settings.connecteddevice.BluetoothDashboardFragment"
android:key="bluetooth_settings"
android:title="@string/bluetooth_settings_title"
android:icon="@drawable/ic_settings_bluetooth"
settings:allowDividerAbove="true"/>
android:icon="@drawable/ic_settings_bluetooth"/>
<PreferenceCategory
android:key="dashboard_tile_placeholder" />

View File

@@ -382,7 +382,8 @@
<ListPreference
android:key="display_cutout_emulation"
android:title="@string/display_cutout_emulation" />
android:title="@string/display_cutout_emulation"
settings:keywords="@string/display_cutout_emulation_keywords" />
</PreferenceCategory>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="keyboard_layout_picker"
android:title="@string/keyboard_layout_picker_title"
settings:controller="com.android.settings.inputmethod.KeyboardLayoutPickerController">
</PreferenceScreen>

View File

@@ -14,8 +14,10 @@
limitations under the License.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="privacy_settings_screen"
android:title="@string/privacy_settings_title">
<!-- Backup settings -->
@@ -23,31 +25,36 @@
android:key="backup_data"
android:title="@string/backup_data_title"
android:persistent="false"
android:fragment="com.android.settings.backup.ToggleBackupSettingFragment"/>
android:fragment="com.android.settings.backup.ToggleBackupSettingFragment"
settings:controller="com.android.settings.backup.BackupDataPreferenceController" />
<Preference
android:key="configure_account"
android:title="@string/backup_configure_account_title"
android:persistent="false">
android:persistent="false"
settings:controller="com.android.settings.backup.ConfigureAccountPreferenceController">
<!-- the Intent declared here is always overwritten by a real one -->
<intent android:action="dummy" />
</Preference>
<Preference
android:key="data_management"
android:persistent="false">
android:persistent="false"
settings:controller="com.android.settings.backup.DataManagementPreferenceController">
</Preference>
<SwitchPreference
android:key="auto_restore"
android:title="@string/auto_restore_title"
android:summary="@string/auto_restore_summary" />
android:summary="@string/auto_restore_summary"
settings:controller="com.android.settings.backup.AutoRestorePreferenceController" />
<Preference
android:key="backup_inactive"
android:title="@string/backup_inactive_title"
android:persistent="false"
android:enabled="false"
android:selectable="false" />
android:selectable="false"
settings:controller="com.android.settings.backup.BackupInactivePreferenceController" />
</PreferenceScreen>

View File

@@ -41,7 +41,7 @@
<com.android.settings.widget.GearPreference
android:key="unlock_set_or_change"
android:title="@string/unlock_set_unlock_launch_picker_title"
android:summary="@string/unlock_set_unlock_mode_none"
android:summary="@string/summary_placeholder"
settings:keywords="@string/keywords_lockscreen" />
<Preference

View File

@@ -20,7 +20,7 @@
android:title="@string/sound_settings"
android:key="sound_settings"
settings:keywords="@string/keywords_sounds"
settings:initialExpandedChildrenCount="8">
settings:initialExpandedChildrenCount="9">
<!-- Media volume -->
<com.android.settings.notification.VolumeSeekBarPreference
@@ -141,11 +141,6 @@
android:key="screen_locking_sounds"
android:title="@string/screen_locking_sounds_title" />
<!-- Charging sounds -->
<SwitchPreference
android:key="charging_sounds"
android:title="@string/charging_sounds_title" />
<!-- Docking sounds -->
<SwitchPreference
android:key="docking_sounds"

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="user_dict_list"
android:title="@string/user_dict_settings_title"
settings:controller="com.android.settings.inputmethod.UserDictionaryListPreferenceController">
</PreferenceScreen>

View File

@@ -14,7 +14,10 @@
limitations under the License.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/wallpaper_settings_fragment_title">
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="wallpaper_type"
android:title="@string/wallpaper_settings_fragment_title"
settings:controller="com.android.settings.wallpaper.WallpaperTypePreferenceController">
</PreferenceScreen>

View File

@@ -35,8 +35,11 @@
android:title="@string/wifi_hotspot_auto_off_title"
android:summary="@string/wifi_hotspot_auto_off_summary"/>
<ListPreference
<com.android.settings.widget.HotspotApBandSelectionPreference
android:key="wifi_tether_network_ap_band"
android:title="@string/wifi_hotspot_ap_band_title"
android:summary="@string/summary_placeholder" />
android:dialogLayout="@layout/hotspot_ap_band_selection_dialog"
android:dialogTitle="@string/wifi_hotspot_ap_band_title"
android:negativeButtonText="@string/cancel"
android:positiveButtonText="@string/apply"/>
</PreferenceScreen>

View File

@@ -24,15 +24,15 @@
android:title="@string/zen_mode_block_effects_screen_off"
android:key="zen_mode_block_screen_off">
<CheckBoxPreference
<com.android.settings.widget.DisabledCheckBoxPreference
android:key="zen_effect_intent"
android:title="@string/zen_mode_block_effect_intent" />
<CheckBoxPreference
<com.android.settings.widget.DisabledCheckBoxPreference
android:key="zen_effect_light"
android:title="@string/zen_mode_block_effect_light" />
<CheckBoxPreference
<com.android.settings.widget.DisabledCheckBoxPreference
android:key="zen_effect_ambient"
android:title="@string/zen_mode_block_effect_ambient" />
@@ -40,19 +40,19 @@
<PreferenceCategory
android:title="@string/zen_mode_block_effects_screen_on"
android:key="zen_mode_block_screen_on">
<CheckBoxPreference
<com.android.settings.widget.DisabledCheckBoxPreference
android:key="zen_effect_badge"
android:title="@string/zen_mode_block_effect_badge" />
<CheckBoxPreference
<com.android.settings.widget.DisabledCheckBoxPreference
android:key="zen_effect_status"
android:title="@string/zen_mode_block_effect_status" />
<CheckBoxPreference
<com.android.settings.widget.DisabledCheckBoxPreference
android:key="zen_effect_peek"
android:title="@string/zen_mode_block_effect_peek" />
<CheckBoxPreference
<com.android.settings.widget.DisabledCheckBoxPreference
android:key="zen_effect_list"
android:title="@string/zen_mode_block_effect_list" />
</PreferenceCategory>

View File

@@ -25,7 +25,8 @@
<!-- sound vibration -->
<com.android.settings.widget.DisabledCheckBoxPreference
android:key="zen_effect_sound"
android:title="@string/zen_mode_block_effect_sound" />
android:title="@string/zen_mode_block_effect_sound"
android:enabled="false"/>
<!-- What to block (effects) -->
<Preference

View File

@@ -57,6 +57,7 @@ class EditPinPreference extends CustomEditTextPreference {
if (editText != null) {
editText.setInputType(InputType.TYPE_CLASS_NUMBER |
InputType.TYPE_NUMBER_VARIATION_PASSWORD);
editText.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
}
}

View File

@@ -16,19 +16,11 @@
package com.android.settings;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.provider.SearchIndexableResource;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.PreferenceGroup;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settingslib.search.SearchIndexable;
@@ -37,94 +29,34 @@ import java.util.Arrays;
import java.util.List;
@SearchIndexable
public class LegalSettings extends SettingsPreferenceFragment implements Indexable {
public class LegalSettings extends DashboardFragment {
private static final String KEY_TERMS = "terms";
private static final String KEY_LICENSE = "license";
private static final String KEY_COPYRIGHT = "copyright";
private static final String KEY_WEBVIEW_LICENSE = "webview_license";
@VisibleForTesting static final String KEY_WALLPAPER_ATTRIBUTIONS = "wallpaper_attributions";
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.about_legal);
final Activity act = getActivity();
// These are contained in the "container" preference group
PreferenceGroup parentPreference = getPreferenceScreen();
Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_TERMS,
Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_LICENSE,
Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_COPYRIGHT,
Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_WEBVIEW_LICENSE,
Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
checkWallpaperAttributionAvailability(act);
}
private static final String TAG = "LegalSettings";
@Override
public int getMetricsCategory() {
return MetricsEvent.ABOUT_LEGAL_SETTINGS;
}
@VisibleForTesting
void checkWallpaperAttributionAvailability(Context context) {
if (!context.getResources().getBoolean(
R.bool.config_show_wallpaper_attribution)) {
removePreference(KEY_WALLPAPER_ATTRIBUTIONS);
}
@Override
protected String getLogTag() {
return TAG;
}
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
protected int getPreferenceScreenResId() {
return R.xml.about_legal;
}
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(
Context context, boolean enabled) {
final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.about_legal;
return Arrays.asList(sir);
}
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
public List<String> getNonIndexableKeys(Context context) {
final List<String> keys = super.getNonIndexableKeys(context);
if (!checkIntentAction(context, "android.settings.TERMS")) {
keys.add(KEY_TERMS);
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(
Context context, boolean enabled) {
final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.about_legal;
return Arrays.asList(sir);
}
if (!checkIntentAction(context, "android.settings.LICENSE")) {
keys.add(KEY_LICENSE);
}
if (!checkIntentAction(context, "android.settings.COPYRIGHT")) {
keys.add(KEY_COPYRIGHT);
}
if (!checkIntentAction(context, "android.settings.WEBVIEW_LICENSE")) {
keys.add(KEY_WEBVIEW_LICENSE);
}
keys.add(KEY_WALLPAPER_ATTRIBUTIONS);
return keys;
}
private boolean checkIntentAction(Context context, String action) {
final Intent intent = new Intent(action);
// Find the activity that is in the system image
final PackageManager pm = context.getPackageManager();
final List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
final int listSize = list.size();
for (int i = 0; i < listSize; i++) {
ResolveInfo resolveInfo = list.get(i);
if ((resolveInfo.activityInfo.applicationInfo.flags &
ApplicationInfo.FLAG_SYSTEM) != 0) {
return true;
}
}
return false;
}
};
};
}

View File

@@ -1,248 +0,0 @@
/*
* Copyright (C) 2009 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;
import android.app.backup.IBackupManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
import android.support.v7.preference.PreferenceScreen;
import android.util.Log;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settingslib.RestrictedLockUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Gesture lock pattern settings.
*/
public class PrivacySettings extends SettingsPreferenceFragment {
// Vendor specific
private static final String GSETTINGS_PROVIDER = "com.google.settings";
@VisibleForTesting
static final String BACKUP_DATA = "backup_data";
@VisibleForTesting
static final String AUTO_RESTORE = "auto_restore";
@VisibleForTesting
static final String CONFIGURE_ACCOUNT = "configure_account";
@VisibleForTesting
static final String DATA_MANAGEMENT = "data_management";
private static final String BACKUP_INACTIVE = "backup_inactive";
private static final String TAG = "PrivacySettings";
private IBackupManager mBackupManager;
private Preference mBackup;
private SwitchPreference mAutoRestore;
private Preference mConfigure;
private Preference mManageData;
private boolean mEnabled;
@Override
public int getMetricsCategory() {
return MetricsEvent.PRIVACY;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Don't allow any access if this is not an admin user.
// TODO: backup/restore currently only works with owner user b/22760572
mEnabled = UserManager.get(getActivity()).isAdminUser();
if (!mEnabled) {
return;
}
addPreferencesFromResource(R.xml.privacy_settings);
final PreferenceScreen screen = getPreferenceScreen();
mBackupManager = IBackupManager.Stub.asInterface(
ServiceManager.getService(Context.BACKUP_SERVICE));
setPreferenceReferences(screen);
Set<String> keysToRemove = new HashSet<>();
getNonVisibleKeys(getActivity(), keysToRemove);
final int screenPreferenceCount = screen.getPreferenceCount();
for (int i = screenPreferenceCount - 1; i >= 0; --i) {
Preference preference = screen.getPreference(i);
if (keysToRemove.contains(preference.getKey())) {
screen.removePreference(preference);
}
}
updateToggles();
}
@Override
public void onResume() {
super.onResume();
// Refresh UI
if (mEnabled) {
updateToggles();
}
}
@VisibleForTesting
void setPreferenceReferences(PreferenceScreen screen) {
mBackup = screen.findPreference(BACKUP_DATA);
mAutoRestore = (SwitchPreference) screen.findPreference(AUTO_RESTORE);
mAutoRestore.setOnPreferenceChangeListener(preferenceChangeListener);
mConfigure = screen.findPreference(CONFIGURE_ACCOUNT);
mManageData = screen.findPreference(DATA_MANAGEMENT);
}
private OnPreferenceChangeListener preferenceChangeListener = new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (!(preference instanceof SwitchPreference)) {
return true;
}
boolean nextValue = (Boolean) newValue;
boolean result = false;
if (preference == mAutoRestore) {
try {
mBackupManager.setAutoRestore(nextValue);
result = true;
} catch (RemoteException e) {
mAutoRestore.setChecked(!nextValue);
}
}
return result;
}
};
/*
* Creates toggles for each backup/reset preference.
*/
private void updateToggles() {
ContentResolver res = getContentResolver();
boolean backupEnabled = false;
Intent configIntent = null;
String configSummary = null;
Intent manageIntent = null;
String manageLabel = null;
try {
backupEnabled = mBackupManager.isBackupEnabled();
String transport = mBackupManager.getCurrentTransport();
configIntent = validatedActivityIntent(
mBackupManager.getConfigurationIntent(transport), "config");
configSummary = mBackupManager.getDestinationString(transport);
manageIntent = validatedActivityIntent(
mBackupManager.getDataManagementIntent(transport), "management");
manageLabel = mBackupManager.getDataManagementLabel(transport);
mBackup.setSummary(backupEnabled
? R.string.accessibility_feature_state_on
: R.string.accessibility_feature_state_off);
} catch (RemoteException e) {
// leave it 'false' and disable the UI; there's no backup manager
mBackup.setEnabled(false);
}
mAutoRestore.setChecked(Settings.Secure.getInt(res,
Settings.Secure.BACKUP_AUTO_RESTORE, 1) == 1);
mAutoRestore.setEnabled(backupEnabled);
final boolean configureEnabled = (configIntent != null) && backupEnabled;
mConfigure.setEnabled(configureEnabled);
mConfigure.setIntent(configIntent);
setConfigureSummary(configSummary);
final boolean manageEnabled = (manageIntent != null) && backupEnabled;
if (manageEnabled) {
mManageData.setIntent(manageIntent);
if (manageLabel != null) {
mManageData.setTitle(manageLabel);
}
} else {
// Hide the item if data management intent is not supported by transport.
getPreferenceScreen().removePreference(mManageData);
}
}
private Intent validatedActivityIntent(Intent intent, String logLabel) {
if (intent != null) {
PackageManager pm = getPackageManager();
List<ResolveInfo> resolved = pm.queryIntentActivities(intent, 0);
if (resolved == null || resolved.isEmpty()) {
intent = null;
Log.e(TAG, "Backup " + logLabel + " intent " + intent
+ " fails to resolve; ignoring");
}
}
return intent;
}
private void setConfigureSummary(String summary) {
if (summary != null) {
mConfigure.setSummary(summary);
} else {
mConfigure.setSummary(R.string.backup_configure_account_default_summary);
}
}
@Override
public int getHelpResource() {
return R.string.help_url_backup_reset;
}
private static void getNonVisibleKeys(Context context, Collection<String> nonVisibleKeys) {
final IBackupManager backupManager = IBackupManager.Stub.asInterface(
ServiceManager.getService(Context.BACKUP_SERVICE));
boolean isServiceActive = false;
try {
isServiceActive = backupManager.isBackupServiceActive(UserHandle.myUserId());
} catch (RemoteException e) {
Log.w(TAG, "Failed querying backup manager service activity status. " +
"Assuming it is inactive.");
}
boolean vendorSpecific = context.getPackageManager().
resolveContentProvider(GSETTINGS_PROVIDER, 0) == null;
if (vendorSpecific || isServiceActive) {
nonVisibleKeys.add(BACKUP_INACTIVE);
}
if (vendorSpecific || !isServiceActive) {
nonVisibleKeys.add(BACKUP_DATA);
nonVisibleKeys.add(AUTO_RESTORE);
nonVisibleKeys.add(CONFIGURE_ACCOUNT);
}
}
}

View File

@@ -32,9 +32,11 @@ import android.os.Bundle;
import android.os.RecoverySystem;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Telephony;
import android.support.annotation.VisibleForTesting;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -151,9 +153,20 @@ public class ResetNetworkConfirm extends InstrumentedFragment {
ImsManager.factoryReset(context);
restoreDefaultApn(context);
esimFactoryReset(context, context.getPackageName());
// There has been issues when Sms raw table somehow stores orphan
// fragments. They lead to garbled message when new fragments come
// in and combied with those stale ones. In case this happens again,
// user can reset all network settings which will clean up this table.
cleanUpSmsRawTable(context);
}
};
private void cleanUpSmsRawTable(Context context) {
ContentResolver resolver = context.getContentResolver();
Uri uri = Uri.withAppendedPath(Telephony.Sms.CONTENT_URI, "raw/permanentDelete");
resolver.delete(uri, null, null);
}
@VisibleForTesting
void esimFactoryReset(Context context, String packageName) {
if (mEraseEsim) {

View File

@@ -27,6 +27,7 @@ import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.UserHandle;
import android.os.UserManager;
import android.support.annotation.VisibleForTesting;
import android.view.View;
import android.widget.TextView;
@@ -56,7 +57,7 @@ public abstract class RestrictedSettingsFragment extends SettingsPreferenceFragm
protected static final String RESTRICT_IF_OVERRIDABLE = "restrict_if_overridable";
// No RestrictedSettingsFragment screens should use this number in startActivityForResult.
private static final int REQUEST_PIN_CHALLENGE = 12309;
@VisibleForTesting static final int REQUEST_PIN_CHALLENGE = 12309;
private static final String KEY_CHALLENGE_SUCCEEDED = "chsc";
private static final String KEY_CHALLENGE_REQUESTED = "chrq";
@@ -86,7 +87,8 @@ public abstract class RestrictedSettingsFragment extends SettingsPreferenceFragm
}
};
private AlertDialog mActionDisabledDialog;
@VisibleForTesting
AlertDialog mActionDisabledDialog;
/**
* @param restrictionKey The restriction key to check before pin protecting
@@ -153,6 +155,10 @@ public abstract class RestrictedSettingsFragment extends SettingsPreferenceFragm
if (resultCode == Activity.RESULT_OK) {
mChallengeSucceeded = true;
mChallengeRequested = false;
if (mActionDisabledDialog != null && mActionDisabledDialog.isShowing()) {
mActionDisabledDialog.setOnDismissListener(null);
mActionDisabledDialog.dismiss();
}
} else {
mChallengeSucceeded = false;
}

View File

@@ -344,6 +344,21 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
return super.onPreferenceTreeClick(preference);
}
public static CharSequence getServiceSummary(Context context, AccessibilityServiceInfo info,
boolean serviceEnabled) {
final String serviceState = serviceEnabled
? context.getString(R.string.accessibility_summary_state_enabled)
: context.getString(R.string.accessibility_summary_state_disabled);
final CharSequence serviceSummary = info.loadSummary(context.getPackageManager());
final String stateSummaryCombo = context.getString(
R.string.preference_summary_default_combination,
serviceState, serviceSummary);
return (TextUtils.isEmpty(serviceSummary))
? serviceState
: stateSummaryCombo;
}
private void handleToggleTextContrastPreferenceClick() {
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
@@ -545,15 +560,9 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
preference.setSummary(R.string.accessibility_summary_state_stopped);
description = getString(R.string.accessibility_description_state_stopped);
} else {
final String serviceState = serviceEnabled ?
getString(R.string.accessibility_summary_state_enabled) :
getString(R.string.accessibility_summary_state_disabled);
final CharSequence serviceSummary = info.loadSummary(getPackageManager());
final String stateSummaryCombo = getString(
R.string.preference_summary_default_combination,
serviceState, serviceSummary);
preference.setSummary((TextUtils.isEmpty(serviceSummary)) ? serviceState
: stateSummaryCombo);
final CharSequence serviceSummary = getServiceSummary(getContext(), info,
serviceEnabled);
preference.setSummary(serviceSummary);
}
// Disable all accessibility services that are not permitted.

View File

@@ -0,0 +1,108 @@
/*
* 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.accessibility;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.provider.Settings;
import android.view.accessibility.AccessibilityManager;
import com.android.settings.accessibility.AccessibilitySettings;
import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.accessibility.AccessibilityUtils;
import java.util.List;
import java.util.Set;
/**
* PreferenceController for accessibility services to be used by Slices.
* Wraps the common logic which enables accessibility services and checks their availability.
* <p>
* Should not be used in a {@link com.android.settings.dashboard.DashboardFragment}.
*/
public class AccessibilitySlicePreferenceController extends TogglePreferenceController {
private final ComponentName mComponentName;
private final int ON = 1;
private final int OFF = 0;
public AccessibilitySlicePreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
mComponentName = ComponentName.unflattenFromString(getPreferenceKey());
if (mComponentName == null) {
throw new IllegalArgumentException(
"Illegal Component Name from: " + preferenceKey);
}
}
@Override
public CharSequence getSummary() {
final AccessibilityServiceInfo serviceInfo = getAccessibilityServiceInfo();
return serviceInfo == null
? "" : AccessibilitySettings.getServiceSummary(mContext, serviceInfo, isChecked());
}
@Override
public boolean isChecked() {
final ContentResolver contentResolver = mContext.getContentResolver();
final boolean accessibilityEnabled = Settings.Secure.getInt(contentResolver,
Settings.Secure.ACCESSIBILITY_ENABLED, OFF) == ON;
if (!accessibilityEnabled) {
return false;
}
final Set<ComponentName> componentNames =
AccessibilityUtils.getEnabledServicesFromSettings(mContext);
return componentNames.contains(mComponentName);
}
@Override
public boolean setChecked(boolean isChecked) {
if (getAccessibilityServiceInfo() == null) {
return false;
}
AccessibilityUtils.setAccessibilityServiceState(mContext, mComponentName, isChecked);
return isChecked == isChecked(); // Verify that it was probably changed.
}
@Override
public int getAvailabilityStatus() {
// Return unsupported when the service is disabled or not installed.
return getAccessibilityServiceInfo() == null ? DISABLED_UNSUPPORTED : AVAILABLE;
}
private AccessibilityServiceInfo getAccessibilityServiceInfo() {
final AccessibilityManager accessibilityManager = mContext.getSystemService(
AccessibilityManager.class);
final List<AccessibilityServiceInfo> serviceList =
accessibilityManager.getInstalledAccessibilityServiceList();
for (AccessibilityServiceInfo serviceInfo : serviceList) {
if (mComponentName.equals(serviceInfo.getComponentName())) {
return serviceInfo;
}
}
return null;
}
}

View File

@@ -40,6 +40,7 @@ import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen;
import android.text.BidiFormatter;
import android.util.ArrayMap;
import android.util.Log;
import android.util.SparseArray;
@@ -313,7 +314,7 @@ public class AccountPreferenceController extends AbstractPreferenceController
preferenceGroup.setOrder(mAccountProfileOrder++);
if (isSingleProfile()) {
preferenceGroup.setTitle(context.getString(R.string.account_for_section_header,
userInfo.name));
BidiFormatter.getInstance().unicodeWrap(userInfo.name)));
preferenceGroup.setContentDescription(
mContext.getString(R.string.account_settings));
} else if (userInfo.isManagedProfile()) {

View File

@@ -0,0 +1,89 @@
/*
* 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.backup;
import android.app.backup.IBackupManager;
import android.content.ContentResolver;
import android.content.Context;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.util.Log;
import com.android.settings.core.TogglePreferenceController;
public class AutoRestorePreferenceController extends TogglePreferenceController {
private static final String TAG = "AutoRestorePrefCtrler";
private PrivacySettingsConfigData mPSCD;
private Preference mPreference;
public AutoRestorePreferenceController(Context context, String key) {
super(context, key);
}
public void setPrivacySettingsConfigData(final PrivacySettingsConfigData pData) {
mPSCD = pData;
}
@Override
public int getAvailabilityStatus() {
if (!PrivacySettingsUtils.isAdminUser(mContext)) {
return DISABLED_FOR_USER;
}
if (PrivacySettingsUtils.isInvisibleKey(mContext, PrivacySettingsUtils.AUTO_RESTORE)) {
return DISABLED_UNSUPPORTED;
}
return AVAILABLE;
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
mPreference = preference;
preference.setEnabled(mPSCD.isBackupEnabled());
}
@Override
public boolean isChecked() {
final ContentResolver res = mContext.getContentResolver();
return Settings.Secure.getInt(res,
Settings.Secure.BACKUP_AUTO_RESTORE, 1) == 1;
}
@Override
public boolean setChecked(boolean isChecked) {
final boolean nextValue = isChecked;
boolean result = false;
final IBackupManager backupManager = IBackupManager.Stub.asInterface(
ServiceManager.getService(Context.BACKUP_SERVICE));
try {
backupManager.setAutoRestore(nextValue);
result = true;
} catch (RemoteException e) {
((SwitchPreference) mPreference).setChecked(!nextValue);
Log.e(TAG, "Error can't set setAutoRestore", e);
}
return result;
}
}

View File

@@ -0,0 +1,64 @@
/*
* 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.backup;
import android.content.Context;
import android.support.v7.preference.Preference;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.R;
public class BackupDataPreferenceController extends BasePreferenceController {
private PrivacySettingsConfigData mPSCD;
public BackupDataPreferenceController(Context context, String key) {
super(context, key);
}
public void setPrivacySettingsConfigData(final PrivacySettingsConfigData pData) {
mPSCD = pData;
}
@Override
public int getAvailabilityStatus() {
if (!PrivacySettingsUtils.isAdminUser(mContext)) {
return DISABLED_FOR_USER;
}
if (PrivacySettingsUtils.isInvisibleKey(mContext, PrivacySettingsUtils.BACKUP_DATA)) {
return DISABLED_UNSUPPORTED;
}
return AVAILABLE;
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
if (mPSCD.isBackupGray()) {
preference.setEnabled(false);
}
}
@Override
public CharSequence getSummary() {
if (!mPSCD.isBackupGray()) {
return mPSCD.isBackupEnabled()
? mContext.getText(R.string.accessibility_feature_state_on)
: mContext.getText(R.string.accessibility_feature_state_off);
}
return null;
}
}

View File

@@ -0,0 +1,39 @@
/*
* 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.backup;
import android.content.Context;
import com.android.settings.core.BasePreferenceController;
public class BackupInactivePreferenceController extends BasePreferenceController {
public BackupInactivePreferenceController(Context context, String key) {
super(context, key);
}
@Override
public int getAvailabilityStatus() {
if (!PrivacySettingsUtils.isAdminUser(mContext)) {
return DISABLED_FOR_USER;
}
if (PrivacySettingsUtils.isInvisibleKey(mContext, PrivacySettingsUtils.BACKUP_INACTIVE)) {
return DISABLED_UNSUPPORTED;
}
return AVAILABLE;
}
}

View File

@@ -0,0 +1,64 @@
/*
* 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.backup;
import android.content.Context;
import android.content.Intent;
import android.support.v7.preference.Preference;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.R;
public class ConfigureAccountPreferenceController extends BasePreferenceController {
private PrivacySettingsConfigData mPSCD;
public ConfigureAccountPreferenceController(Context context, String key) {
super(context, key);
}
public void setPrivacySettingsConfigData(final PrivacySettingsConfigData pData) {
mPSCD = pData;
}
@Override
public int getAvailabilityStatus() {
if (!PrivacySettingsUtils.isAdminUser(mContext)) {
return DISABLED_FOR_USER;
}
if (PrivacySettingsUtils.isInvisibleKey(mContext, PrivacySettingsUtils.CONFIGURE_ACCOUNT)) {
return DISABLED_UNSUPPORTED;
}
return AVAILABLE;
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
final Intent configIntent = mPSCD.getConfigIntent();
final boolean configureEnabled = (configIntent != null) && mPSCD.isBackupEnabled();
preference.setEnabled(configureEnabled);
preference.setIntent(configIntent);
}
@Override
public CharSequence getSummary() {
final String configSummary = mPSCD.getConfigSummary();
return configSummary != null
? configSummary
: mContext.getText(R.string.backup_configure_account_default_summary);
}
}

View File

@@ -0,0 +1,58 @@
/*
* 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.backup;
import android.content.Context;
import android.support.v7.preference.Preference;
import com.android.settings.core.BasePreferenceController;
public class DataManagementPreferenceController extends BasePreferenceController {
private PrivacySettingsConfigData mPSCD;
private boolean mManageEnabled;
public DataManagementPreferenceController(Context context, String key) {
super(context, key);
}
public void setPrivacySettingsConfigData(final PrivacySettingsConfigData pData) {
mPSCD = pData;
mManageEnabled = (mPSCD.getManageIntent() != null) && mPSCD.isBackupEnabled();
}
@Override
public int getAvailabilityStatus() {
if (!PrivacySettingsUtils.isAdminUser(mContext)) {
return DISABLED_FOR_USER;
}
if (!mManageEnabled) {
return DISABLED_UNSUPPORTED;
}
return AVAILABLE;
}
@Override
public void updateState(Preference preference) {
if (mManageEnabled) {
preference.setIntent(mPSCD.getManageIntent());
final String manageLabel = mPSCD.getManageLabel();
if (manageLabel != null) {
preference.setTitle(manageLabel);
}
}
}
}

View File

@@ -0,0 +1,96 @@
/*
* Copyright (C) 2009 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.backup;
import android.content.Context;
import android.provider.SearchIndexableResource;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;
import java.util.Arrays;
import java.util.List;
@SearchIndexable
public class PrivacySettings extends DashboardFragment {
private static final String TAG = "PrivacySettings";
@Override
public int getMetricsCategory() {
return MetricsEvent.PRIVACY;
}
@Override
protected String getLogTag() {
return TAG;
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.privacy_settings;
}
@Override
public int getHelpResource() {
return R.string.help_url_backup_reset;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
updatePrivacySettingsConfigData(context);
}
@Override
protected void updatePreferenceStates() {
updatePrivacySettingsConfigData(getContext());
super.updatePreferenceStates();
}
private void updatePrivacySettingsConfigData(final Context context) {
final PrivacySettingsConfigData pData = new PrivacySettingsConfigData();
if (PrivacySettingsUtils.isAdminUser(context)) {
PrivacySettingsUtils.updatePrivacyBuffer(context, pData);
}
use(BackupDataPreferenceController.class).setPrivacySettingsConfigData(pData);
use(ConfigureAccountPreferenceController.class).setPrivacySettingsConfigData(pData);
use(DataManagementPreferenceController.class).setPrivacySettingsConfigData(pData);
use(AutoRestorePreferenceController.class).setPrivacySettingsConfigData(pData);
}
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
boolean enabled) {
final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.privacy_settings;
return Arrays.asList(sir);
}
@Override
protected boolean isPageSearchEnabled(Context context) {
final BackupSettingsHelper backupHelper = new BackupSettingsHelper(context);
return !backupHelper.isBackupProvidedByManufacturer() &&
!backupHelper.isIntentProvidedByTransport();
}
};
}

View File

@@ -0,0 +1,85 @@
/*
* 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.backup;
import android.content.Intent;
public class PrivacySettingsConfigData {
private boolean mBackupEnabled;
private boolean mBackupGray;
private Intent mConfigIntent;
private String mConfigSummary;
private Intent mManageIntent;
private String mManageLabel;
public PrivacySettingsConfigData() {
mBackupEnabled = false;
mBackupGray = false;
mConfigIntent = null;
mConfigSummary = null;
mManageIntent = null;
mManageLabel = null;
}
public boolean isBackupEnabled() {
return mBackupEnabled;
}
public void setBackupEnabled(final boolean backupEnabled) {
mBackupEnabled = backupEnabled;
}
public boolean isBackupGray() {
return mBackupGray;
}
public void setBackupGray(final boolean backupGray) {
mBackupGray = backupGray;
}
public Intent getConfigIntent() {
return mConfigIntent;
}
public void setConfigIntent(final Intent configIntent) {
mConfigIntent = configIntent;
}
public String getConfigSummary() {
return mConfigSummary;
}
public void setConfigSummary(final String configSummary) {
mConfigSummary = configSummary;
}
public Intent getManageIntent() {
return mManageIntent;
}
public void setManageIntent(final Intent manageIntent) {
mManageIntent = manageIntent;
}
public String getManageLabel() {
return mManageLabel;
}
public void setManageLabel(final String manageLabel) {
mManageLabel = manageLabel;
}
}

View File

@@ -0,0 +1,122 @@
/*
* 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.backup;
import android.app.backup.IBackupManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
public class PrivacySettingsUtils {
private static final String TAG = "PrivacySettingsUtils";
private static final String GSETTINGS_PROVIDER = "com.google.settings";
static final String BACKUP_DATA = "backup_data";
static final String AUTO_RESTORE = "auto_restore";
static final String CONFIGURE_ACCOUNT = "configure_account";
static final String BACKUP_INACTIVE = "backup_inactive";
// Don't allow any access if this is not an admin user.
// TODO: backup/restore currently only works with owner user b/22760572
static boolean isAdminUser(final Context context) {
return UserManager.get(context).isAdminUser();
}
/**
* Send a {@param key} to check its preference will display in PrivacySettings or not.
*/
static boolean isInvisibleKey(final Context context, final String key) {
final Set<String> keysToRemove = getInvisibleKey(context);
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG,
"keysToRemove size=" + keysToRemove.size() + " keysToRemove=" + keysToRemove);
}
if (keysToRemove.contains(key)) {
return true;
}
return false;
}
private static Set<String> getInvisibleKey(final Context context) {
final IBackupManager backupManager = IBackupManager.Stub.asInterface(
ServiceManager.getService(Context.BACKUP_SERVICE));
boolean isServiceActive = false;
try {
isServiceActive = backupManager.isBackupServiceActive(UserHandle.myUserId());
} catch (RemoteException e) {
Log.w(TAG, "Failed querying backup manager service activity status. " +
"Assuming it is inactive.");
}
boolean vendorSpecific = context.getPackageManager().
resolveContentProvider(GSETTINGS_PROVIDER, 0) == null;
final Set<String> inVisibleKeys = new TreeSet<>();
if (vendorSpecific || isServiceActive) {
inVisibleKeys.add(BACKUP_INACTIVE);
}
if (vendorSpecific || !isServiceActive) {
inVisibleKeys.add(BACKUP_DATA);
inVisibleKeys.add(AUTO_RESTORE);
inVisibleKeys.add(CONFIGURE_ACCOUNT);
}
return inVisibleKeys;
}
public static void updatePrivacyBuffer(final Context context, PrivacySettingsConfigData data) {
final IBackupManager backupManager = IBackupManager.Stub.asInterface(
ServiceManager.getService(Context.BACKUP_SERVICE));
try {
data.setBackupEnabled(backupManager.isBackupEnabled());
String transport = backupManager.getCurrentTransport();
data.setConfigIntent(validatedActivityIntent(context,
backupManager.getConfigurationIntent(transport), "config"));
data.setConfigSummary(backupManager.getDestinationString(transport));
data.setManageIntent(validatedActivityIntent(context,
backupManager.getDataManagementIntent(transport), "management"));
data.setManageLabel(backupManager.getDataManagementLabel(transport));
data.setBackupGray(false);
} catch (RemoteException e) {
// leave it 'false' and disable the UI; there's no backup manager
// mBackup.setEnabled(false);
data.setBackupGray(true);
}
}
private static Intent validatedActivityIntent(final Context context, Intent intent,
String logLabel) {
if (intent != null) {
PackageManager pm = context.getPackageManager();
List<ResolveInfo> resolved = pm.queryIntentActivities(intent, 0);
if (resolved == null || resolved.isEmpty()) {
intent = null;
Log.e(TAG, "Backup " + logLabel + " intent " + intent
+ " fails to resolve; ignoring");
}
}
return intent;
}
}

View File

@@ -73,6 +73,16 @@ public class BluetoothDetailsHeaderController extends BluetoothDetailsController
mHeaderController.setIcon(pair.first);
mHeaderController.setIconContentDescription(pair.second);
mHeaderController.setSummary(summaryText);
mHeaderController.setEditListener(v -> showEditDeviceNameDialog());
mHeaderController.setButtonActions(
EntityHeaderController.ActionType.ACTION_EDIT_PREFERENCE,
EntityHeaderController.ActionType.ACTION_NONE);
}
@VisibleForTesting
void showEditDeviceNameDialog() {
RemoteDeviceNameDialogFragment.newInstance(mCachedDevice).show(
mFragment.getFragmentManager(), RemoteDeviceNameDialogFragment.TAG);
}
@Override

View File

@@ -22,9 +22,6 @@ import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.VisibleForTesting;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
@@ -41,9 +38,6 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
public static final String KEY_DEVICE_ADDRESS = "device_address";
private static final String TAG = "BTDeviceDetailsFrg";
@VisibleForTesting
static int EDIT_DEVICE_NAME_ITEM_ID = Menu.FIRST;
/**
* An interface to let tests override the normal mechanism for looking up the
* CachedBluetoothDevice and LocalBluetoothManager, and substitute their own mocks instead.
@@ -60,9 +54,12 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
@VisibleForTesting
static TestDataFactory sTestDataFactory;
private String mDeviceAddress;
private LocalBluetoothManager mManager;
private CachedBluetoothDevice mCachedDevice;
@VisibleForTesting
String mDeviceAddress;
@VisibleForTesting
LocalBluetoothManager mManager;
@VisibleForTesting
CachedBluetoothDevice mCachedDevice;
public BluetoothDeviceDetailsFragment() {
super(DISALLOW_CONFIG_BLUETOOTH);
@@ -117,24 +114,6 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
return R.xml.bluetooth_device_details_fragment;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
MenuItem item = menu.add(0, EDIT_DEVICE_NAME_ITEM_ID, 0, R.string.bluetooth_rename_button);
item.setIcon(R.drawable.ic_mode_edit);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == EDIT_DEVICE_NAME_ITEM_ID) {
RemoteDeviceNameDialogFragment.newInstance(mCachedDevice).show(
getFragmentManager(), RemoteDeviceNameDialogFragment.TAG);
return true;
}
return super.onOptionsItemSelected(menuItem);
}
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
ArrayList<AbstractPreferenceController> controllers = new ArrayList<>();

View File

@@ -54,7 +54,8 @@ public class PreferenceControllerListHelper {
List<Bundle> preferenceMetadata;
try {
preferenceMetadata = PreferenceXmlParserUtils.extractMetadata(context, xmlResId,
MetadataFlag.FLAG_NEED_KEY | MetadataFlag.FLAG_NEED_PREF_CONTROLLER);
MetadataFlag.FLAG_NEED_KEY | MetadataFlag.FLAG_NEED_PREF_CONTROLLER
| MetadataFlag.FLAG_INCLUDE_PREF_SCREEN);
} catch (IOException | XmlPullParserException e) {
Log.e(TAG, "Failed to parse preference xml for getting controllers", e);
return controllers;

View File

@@ -21,7 +21,6 @@ import com.android.settings.DeviceAdminSettings;
import com.android.settings.DisplaySettings;
import com.android.settings.IccLockSettings;
import com.android.settings.MasterClear;
import com.android.settings.PrivacySettings;
import com.android.settings.Settings;
import com.android.settings.TestingSettings;
import com.android.settings.TetherSettings;
@@ -51,6 +50,7 @@ import com.android.settings.applications.appinfo.WriteSettingsDetails;
import com.android.settings.applications.appops.BackgroundCheckSummary;
import com.android.settings.applications.assist.ManageAssist;
import com.android.settings.applications.manageapplications.ManageApplications;
import com.android.settings.backup.PrivacySettings;
import com.android.settings.backup.ToggleBackupSettingFragment;
import com.android.settings.bluetooth.BluetoothDeviceDetailsFragment;
import com.android.settings.connecteddevice.AdvancedConnectedDeviceDashboardFragment;

View File

@@ -259,8 +259,10 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
return;
}
tile.icon = Icon.createWithResource(iconInfo.first, iconInfo.second);
ThreadUtils.postOnMainThread(() ->
preference.setIcon(tile.icon.loadDrawable(preference.getContext()))
ThreadUtils.postOnMainThread(() -> {
preference.setIcon(tile.icon.loadDrawable(preference.getContext()));
tile.icon = null;
}
);
});
}

View File

@@ -402,7 +402,6 @@ public class BillingCycleSettings extends DataUsageBase implements
*/
public static class ConfirmLimitFragment extends InstrumentedDialogFragment implements
DialogInterface.OnClickListener {
private static final String EXTRA_MESSAGE = "message";
@VisibleForTesting static final String EXTRA_LIMIT_BYTES = "limitBytes";
public static final float FLOAT = 1.2f;
@@ -414,16 +413,13 @@ public class BillingCycleSettings extends DataUsageBase implements
if (policy == null) return;
final Resources res = parent.getResources();
final CharSequence message;
final long minLimitBytes = (long) (policy.warningBytes * FLOAT);
final long limitBytes;
// TODO: customize default limits based on network template
message = res.getString(R.string.data_usage_limit_dialog_mobile);
limitBytes = Math.max(5 * GIB_IN_BYTES, minLimitBytes);
final Bundle args = new Bundle();
args.putCharSequence(EXTRA_MESSAGE, message);
args.putLong(EXTRA_LIMIT_BYTES, limitBytes);
final ConfirmLimitFragment dialog = new ConfirmLimitFragment();
@@ -441,11 +437,9 @@ public class BillingCycleSettings extends DataUsageBase implements
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
final CharSequence message = getArguments().getCharSequence(EXTRA_MESSAGE);
return new AlertDialog.Builder(context)
.setTitle(R.string.data_usage_limit_dialog_title)
.setMessage(message)
.setMessage(R.string.data_usage_limit_dialog_mobile)
.setPositiveButton(android.R.string.ok, this)
.setNegativeButton(android.R.string.cancel, null)
.create();

View File

@@ -56,7 +56,7 @@ public class DataUsagePreference extends Preference implements TemplatePreferenc
DataUsageController.DataUsageInfo usageInfo = controller.getDataUsageInfo(mTemplate);
if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.DATA_USAGE_SETTINGS_V2)) {
if (mTemplate.isMatchRuleMobile()) {
setTitle(getContext().getString(R.string.app_cellular_data_usage));
setTitle(R.string.app_cellular_data_usage);
} else {
setTitle(mTitleRes);
setSummary(getContext().getString(R.string.data_usage_template,
@@ -83,7 +83,7 @@ public class DataUsagePreference extends Preference implements TemplatePreferenc
.setSourceMetricsCategory(MetricsProto.MetricsEvent.VIEW_UNKNOWN);
if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.DATA_USAGE_SETTINGS_V2)) {
if (mTemplate.isMatchRuleMobile()) {
launcher.setTitle(getContext().getString(R.string.app_cellular_data_usage));
launcher.setTitle(R.string.app_cellular_data_usage);
} else {
launcher.setTitle(mTitleRes);
}

View File

@@ -187,7 +187,7 @@ public class DataUsageSummaryPreference extends Preference {
updateCarrierInfo(carrierInfo);
if (mLaunchIntent != null) {
launchButton.setOnClickListener((view) -> {
getContext().sendBroadcast(mLaunchIntent);
getContext().startActivity(mLaunchIntent);
});
launchButton.setVisibility(View.VISIBLE);
} else {

View File

@@ -18,13 +18,13 @@ package com.android.settings.deviceinfo;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.Fragment;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.storage.StorageManager;
import android.os.storage.VolumeRecord;
import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
@@ -35,11 +35,13 @@ import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.search.actionbar.SearchMenuController;
public class PrivateVolumeForget extends SettingsPreferenceFragment {
private static final String TAG_FORGET_CONFIRM = "forget_confirm";
public class PrivateVolumeForget extends InstrumentedFragment {
@VisibleForTesting
static final String TAG_FORGET_CONFIRM = "forget_confirm";
private VolumeRecord mRecord;
@@ -48,6 +50,13 @@ public class PrivateVolumeForget extends SettingsPreferenceFragment {
return MetricsEvent.DEVICEINFO_STORAGE;
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setHasOptionsMenu(true);
SearchMenuController.init(this /* host */);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@@ -116,12 +125,12 @@ public class PrivateVolumeForget extends SettingsPreferenceFragment {
builder.setPositiveButton(R.string.storage_menu_forget,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
storage.forgetVolume(fsUuid);
getActivity().finish();
}
});
@Override
public void onClick(DialogInterface dialog, int which) {
storage.forgetVolume(fsUuid);
getActivity().finish();
}
});
builder.setNegativeButton(R.string.cancel, null);
return builder.create();

View File

@@ -17,7 +17,6 @@
package com.android.settings.deviceinfo;
import static android.os.storage.DiskInfo.EXTRA_DISK_ID;
import static com.android.settings.deviceinfo.StorageWizardBase.EXTRA_FORMAT_FORGET_UUID;
import static com.android.settings.deviceinfo.StorageWizardBase.EXTRA_FORMAT_PRIVATE;
@@ -36,9 +35,9 @@ import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.core.InstrumentedFragment;
public class PrivateVolumeFormat extends InstrumentedPreferenceFragment {
public class PrivateVolumeFormat extends InstrumentedFragment {
private VolumeInfo mVolume;
private DiskInfo mDisk;

View File

@@ -30,10 +30,11 @@ import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.deviceinfo.StorageSettings.UnmountTask;
import com.android.settings.search.actionbar.SearchMenuController;
public class PrivateVolumeUnmount extends SettingsPreferenceFragment {
public class PrivateVolumeUnmount extends InstrumentedFragment {
private VolumeInfo mVolume;
private DiskInfo mDisk;
@@ -42,6 +43,13 @@ public class PrivateVolumeUnmount extends SettingsPreferenceFragment {
return MetricsEvent.DEVICEINFO_STORAGE;
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setHasOptionsMenu(true);
SearchMenuController.init(this /* host */);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

View File

@@ -22,6 +22,7 @@ import static android.os.storage.VolumeInfo.EXTRA_VOLUME_ID;
import static com.android.settings.deviceinfo.StorageSettings.TAG;
import android.annotation.LayoutRes;
import android.annotation.NonNull;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
@@ -145,7 +146,7 @@ public abstract class StorageWizardBase extends Activity {
((TextView) aux.requireViewById(R.id.storage_wizard_migrate_v2_checklist_media))
.setText(TextUtils.expandTemplate(
getText(R.string.storage_wizard_migrate_v2_checklist_media),
mDisk.getShortDescription()));
getDiskShortDescription()));
}
protected void setBackButtonText(int resId, CharSequence... args) {
@@ -228,6 +229,26 @@ public abstract class StorageWizardBase extends Activity {
}
}
protected @NonNull CharSequence getDiskDescription() {
if (mDisk != null) {
return mDisk.getDescription();
} else if (mVolume != null) {
return mVolume.getDescription();
} else {
return getText(R.string.unknown);
}
}
protected @NonNull CharSequence getDiskShortDescription() {
if (mDisk != null) {
return mDisk.getShortDescription();
} else if (mVolume != null) {
return mVolume.getDescription();
} else {
return getText(R.string.unknown);
}
}
private final StorageEventListener mStorageListener = new StorageEventListener() {
@Override
public void onDiskDestroyed(DiskInfo disk) {

View File

@@ -57,8 +57,8 @@ public class StorageWizardFormatProgress extends StorageWizardBase {
mFormatPrivate = getIntent().getBooleanExtra(EXTRA_FORMAT_PRIVATE, false);
setHeaderText(R.string.storage_wizard_format_progress_title, mDisk.getShortDescription());
setBodyText(R.string.storage_wizard_format_progress_body, mDisk.getDescription());
setHeaderText(R.string.storage_wizard_format_progress_title, getDiskShortDescription());
setBodyText(R.string.storage_wizard_format_progress_body, getDiskDescription());
mTask = (PartitionTask) getLastNonConfigurationInstance();
if (mTask == null) {

View File

@@ -39,10 +39,10 @@ public class StorageWizardFormatSlow extends StorageWizardBase {
mFormatPrivate = getIntent().getBooleanExtra(EXTRA_FORMAT_PRIVATE, false);
setHeaderText(R.string.storage_wizard_slow_v2_title, mDisk.getShortDescription());
setBodyText(R.string.storage_wizard_slow_v2_body, mDisk.getDescription(),
mDisk.getShortDescription(), mDisk.getShortDescription(),
mDisk.getShortDescription());
setHeaderText(R.string.storage_wizard_slow_v2_title, getDiskShortDescription());
setBodyText(R.string.storage_wizard_slow_v2_body, getDiskDescription(),
getDiskShortDescription(), getDiskShortDescription(),
getDiskShortDescription());
setBackButtonText(R.string.storage_wizard_slow_v2_start_over);
setNextButtonText(R.string.storage_wizard_slow_v2_continue);

View File

@@ -45,7 +45,7 @@ public class StorageWizardInit extends StorageWizardBase {
mIsPermittedToAdopt = UserManager.get(this).isAdminUser()
&& !ActivityManager.isUserAMonkey();
setHeaderText(R.string.storage_wizard_init_v2_title, mDisk.getShortDescription());
setHeaderText(R.string.storage_wizard_init_v2_title, getDiskShortDescription());
mExternal = requireViewById(R.id.storage_wizard_init_external);
mInternal = requireViewById(R.id.storage_wizard_init_internal);

View File

@@ -59,7 +59,7 @@ public class StorageWizardMigrateConfirm extends StorageWizardBase {
}
setIcon(R.drawable.ic_swap_horiz);
setHeaderText(R.string.storage_wizard_migrate_v2_title, mDisk.getShortDescription());
setHeaderText(R.string.storage_wizard_migrate_v2_title, getDiskShortDescription());
setBodyText(R.string.memory_calculating_size);
setAuxChecklist();
@@ -67,7 +67,7 @@ public class StorageWizardMigrateConfirm extends StorageWizardBase {
@Override
public void onPostExecute(String size, String time) {
setBodyText(R.string.storage_wizard_migrate_v2_body,
mDisk.getDescription(), size, time);
getDiskDescription(), size, time);
}
};

View File

@@ -33,20 +33,20 @@ public class StorageWizardReady extends StorageWizardBase {
}
setContentView(R.layout.storage_wizard_generic);
setHeaderText(R.string.storage_wizard_ready_title, mDisk.getShortDescription());
setHeaderText(R.string.storage_wizard_ready_title, getDiskShortDescription());
final VolumeInfo privateVol = findFirstVolume(VolumeInfo.TYPE_PRIVATE);
if (privateVol != null) {
if (getIntent().getBooleanExtra(EXTRA_MIGRATE_SKIP, false)) {
setBodyText(R.string.storage_wizard_ready_v2_internal_body,
mDisk.getDescription());
getDiskDescription());
} else {
setBodyText(R.string.storage_wizard_ready_v2_internal_moved_body,
mDisk.getDescription(), mDisk.getShortDescription());
getDiskDescription(), getDiskShortDescription());
}
} else {
setBodyText(R.string.storage_wizard_ready_v2_external_body,
mDisk.getDescription());
getDiskDescription());
}
setNextButtonText(R.string.done);

View File

@@ -0,0 +1,32 @@
/*
* 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.deviceinfo.legal;
import android.content.Context;
import android.content.Intent;
public class CopyrightPreferenceController extends LegalPreferenceController {
private static final Intent INTENT = new Intent("android.settings.COPYRIGHT");
public CopyrightPreferenceController(Context context, String key) {
super(context, key);
}
@Override
protected Intent getIntent() {
return INTENT;
}
}

View File

@@ -0,0 +1,96 @@
/*
* 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.deviceinfo.legal;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.BasePreferenceController;
import java.util.List;
public abstract class LegalPreferenceController extends BasePreferenceController {
private final PackageManager mPackageManager;
private Preference mPreference;
public LegalPreferenceController(Context context, String key) {
super(context, key);
mPackageManager = mContext.getPackageManager();
}
@Override
public int getAvailabilityStatus() {
if (findMatchingSpecificActivity() != null) {
return AVAILABLE;
} else {
return DISABLED_UNSUPPORTED;
}
}
@Override
public void displayPreference(PreferenceScreen screen) {
mPreference = screen.findPreference(getPreferenceKey());
super.displayPreference(screen);
if (getAvailabilityStatus() == AVAILABLE) {
replacePreferenceIntent();
}
}
protected abstract Intent getIntent();
private ResolveInfo findMatchingSpecificActivity() {
final Intent intent = getIntent();
if (intent == null) {
return null;
}
// Find the activity that is in the system image
final List<ResolveInfo> list = mPackageManager.queryIntentActivities(intent, 0);
if (list == null) {
return null;
}
for (ResolveInfo resolveInfo : list) {
if ((resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM)
!= 0) {
return resolveInfo;
}
}
// Did not find a matching activity
return null;
}
private void replacePreferenceIntent() {
final ResolveInfo resolveInfo = findMatchingSpecificActivity();
if (resolveInfo == null) {
return;
}
// Replace the intent with this specific activity
mPreference.setIntent(new Intent().setClassName(
resolveInfo.activityInfo.packageName,
resolveInfo.activityInfo.name));
mPreference.setTitle(resolveInfo.loadLabel(mPackageManager));
}
}

View File

@@ -0,0 +1,32 @@
/*
* 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.deviceinfo.legal;
import android.content.Context;
import android.content.Intent;
public class LicensePreferenceController extends LegalPreferenceController {
private static final Intent INTENT = new Intent("android.settings.LICENSE");
public LicensePreferenceController(Context context, String key) {
super(context, key);
}
@Override
protected Intent getIntent() {
return INTENT;
}
}

View File

@@ -0,0 +1,32 @@
/*
* 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.deviceinfo.legal;
import android.content.Context;
import android.content.Intent;
public class TermsPreferenceController extends LegalPreferenceController {
private static final Intent INTENT = new Intent("android.settings.TERMS");
public TermsPreferenceController(Context context, String key) {
super(context, key);
}
@Override
protected Intent getIntent() {
return INTENT;
}
}

View File

@@ -0,0 +1,35 @@
/*
* 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.deviceinfo.legal;
import android.content.Context;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
public class WallpaperAttributionsPreferenceController extends BasePreferenceController {
public WallpaperAttributionsPreferenceController(Context context, String key) {
super(context, key);
}
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_wallpaper_attribution)
? AVAILABLE
: DISABLED_UNSUPPORTED;
}
}

View File

@@ -0,0 +1,32 @@
/*
* 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.deviceinfo.legal;
import android.content.Context;
import android.content.Intent;
public class WebViewLicensePreferenceController extends LegalPreferenceController {
private static final Intent INTENT = new Intent("android.settings.WEBVIEW_LICENSE");
public WebViewLicensePreferenceController(Context context, String key) {
super(context, key);
}
@Override
protected Intent getIntent() {
return INTENT;
}
}

View File

@@ -416,6 +416,11 @@ public class BatteryUtils {
mAppOpsManager.setMode(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, uid, packageName, mode);
}
public boolean isForceAppStandbyEnabled(int uid, String packageName) {
return mAppOpsManager.checkOpNoThrow(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, uid,
packageName) == AppOpsManager.MODE_IGNORED;
}
public void initBatteryStatsHelper(BatteryStatsHelper statsHelper, Bundle bundle,
UserManager userManager) {
statsHelper.create(bundle);

View File

@@ -109,7 +109,8 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
BatteryHeaderPreferenceController mBatteryHeaderPreferenceController;
@VisibleForTesting
boolean mNeedUpdateBatteryTip;
private BatteryTipPreferenceController mBatteryTipPreferenceController;
@VisibleForTesting
BatteryTipPreferenceController mBatteryTipPreferenceController;
private int mStatsType = BatteryStats.STATS_SINCE_CHARGED;
@VisibleForTesting
@@ -215,8 +216,8 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
mAnomalySparseArray = new SparseArray<>();
restartBatteryInfoLoader();
mNeedUpdateBatteryTip = icicle == null;
mBatteryTipPreferenceController.restoreInstanceState(icicle);
updateBatteryTipFlag(icicle);
}
@Override
@@ -384,6 +385,11 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
}
}
@VisibleForTesting
void updateBatteryTipFlag(Bundle icicle) {
mNeedUpdateBatteryTip = icicle == null || mBatteryTipPreferenceController.needUpdate();
}
@Override
public boolean onLongClick(View view) {
showBothEstimates();

View File

@@ -133,7 +133,8 @@ public class RestrictedAppDetails extends DashboardFragment {
try {
final ApplicationInfo applicationInfo = mPackageManager.getApplicationInfoAsUser(
appInfo.packageName, 0 /* flags */, UserHandle.getUserId(appInfo.uid));
checkBoxPreference.setChecked(true);
checkBoxPreference.setChecked(
mBatteryUtils.isForceAppStandbyEnabled(appInfo.uid, appInfo.packageName));
checkBoxPreference.setTitle(mPackageManager.getApplicationLabel(applicationInfo));
checkBoxPreference.setIcon(
Utils.getBadgedIcon(mIconDrawableFactory, mPackageManager,

View File

@@ -52,6 +52,7 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
private Map<String, BatteryTip> mBatteryTipMap;
private SettingsActivity mSettingsActivity;
private MetricsFeatureProvider mMetricsFeatureProvider;
private boolean mNeedUpdate;
@VisibleForTesting
PreferenceGroup mPreferenceGroup;
@VisibleForTesting
@@ -71,6 +72,7 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
mFragment = fragment;
mSettingsActivity = settingsActivity;
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
mNeedUpdate = true;
}
@Override
@@ -111,6 +113,7 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
mBatteryTipMap.put(preference.getKey(), batteryTip);
mPreferenceGroup.addPreference(preference);
batteryTip.log(mContext, mMetricsFeatureProvider);
mNeedUpdate = batteryTip.needUpdate();
break;
}
}
@@ -153,6 +156,10 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
outState.putParcelableList(KEY_BATTERY_TIPS, mBatteryTips);
}
public boolean needUpdate() {
return mNeedUpdate;
}
/**
* Listener to give the control back to target fragment
*/

View File

@@ -86,17 +86,23 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
protected int mType;
protected int mState;
protected boolean mShowDialog;
/**
* Whether we need to update battery tip when configuration change
*/
protected boolean mNeedUpdate;
BatteryTip(Parcel in) {
mType = in.readInt();
mState = in.readInt();
mShowDialog = in.readBoolean();
mNeedUpdate = in.readBoolean();
}
BatteryTip(int type, int state, boolean showDialog) {
mType = type;
mState = state;
mShowDialog = showDialog;
mNeedUpdate = true;
}
@Override
@@ -109,6 +115,7 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
dest.writeInt(mType);
dest.writeInt(mState);
dest.writeBoolean(mShowDialog);
dest.writeBoolean(mNeedUpdate);
}
public abstract CharSequence getTitle(Context context);
@@ -144,6 +151,10 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
return mShowDialog;
}
public boolean needUpdate() {
return mNeedUpdate;
}
public String getKey() {
return KEY_PREFIX + mType;
}

View File

@@ -42,12 +42,14 @@ public class RestrictAppTip extends BatteryTip {
public RestrictAppTip(@StateType int state, List<AppInfo> restrictApps) {
super(TipType.APP_RESTRICTION, state, state == StateType.NEW /* showDialog */);
mRestrictAppList = restrictApps;
mNeedUpdate = false;
}
public RestrictAppTip(@StateType int state, AppInfo appInfo) {
super(TipType.APP_RESTRICTION, state, state == StateType.NEW /* showDialog */);
mRestrictAppList = new ArrayList<>();
mRestrictAppList.add(appInfo);
mNeedUpdate = false;
}
@VisibleForTesting

View File

@@ -0,0 +1,162 @@
/*
* 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.inputmethod;
import android.app.Fragment;
import android.content.Context;
import android.hardware.input.InputDeviceIdentifier;
import android.hardware.input.InputManager;
import android.hardware.input.KeyboardLayout;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.view.InputDevice;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class KeyboardLayoutPickerController extends BasePreferenceController implements
InputManager.InputDeviceListener, LifecycleObserver, OnStart, OnStop {
private final InputManager mIm;
private final Map<SwitchPreference, KeyboardLayout> mPreferenceMap;
private Fragment mParent;
private int mInputDeviceId;
private InputDeviceIdentifier mInputDeviceIdentifier;
private KeyboardLayout[] mKeyboardLayouts;
private PreferenceScreen mScreen;
public KeyboardLayoutPickerController(Context context, String key) {
super(context, key);
mIm = (InputManager) context.getSystemService(Context.INPUT_SERVICE);
mInputDeviceId = -1;
mPreferenceMap = new HashMap<>();
}
public void initialize(Fragment parent, InputDeviceIdentifier inputDeviceIdentifier) {
mParent = parent;
mInputDeviceIdentifier = inputDeviceIdentifier;
mKeyboardLayouts = mIm.getKeyboardLayoutsForInputDevice(mInputDeviceIdentifier);
Arrays.sort(mKeyboardLayouts);
}
@Override
public void onStart() {
mIm.registerInputDeviceListener(this, null);
final InputDevice inputDevice =
mIm.getInputDeviceByDescriptor(mInputDeviceIdentifier.getDescriptor());
if (inputDevice == null) {
mParent.getActivity().finish();
return;
}
mInputDeviceId = inputDevice.getId();
updateCheckedState();
}
@Override
public void onStop() {
mIm.unregisterInputDeviceListener(this);
mInputDeviceId = -1;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mScreen = screen;
createPreferenceHierarchy();
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (!(preference instanceof SwitchPreference)) {
return false;
}
final SwitchPreference switchPref = (SwitchPreference) preference;
final KeyboardLayout layout = mPreferenceMap.get(switchPref);
if (layout != null) {
final boolean checked = switchPref.isChecked();
if (checked) {
mIm.addKeyboardLayoutForInputDevice(mInputDeviceIdentifier,
layout.getDescriptor());
} else {
mIm.removeKeyboardLayoutForInputDevice(mInputDeviceIdentifier,
layout.getDescriptor());
}
}
return true;
}
@Override
public void onInputDeviceAdded(int deviceId) {
}
@Override
public void onInputDeviceRemoved(int deviceId) {
if (mInputDeviceId >= 0 && deviceId == mInputDeviceId) {
mParent.getActivity().finish();
}
}
@Override
public void onInputDeviceChanged(int deviceId) {
if (mInputDeviceId >= 0 && deviceId == mInputDeviceId) {
updateCheckedState();
}
}
private void updateCheckedState() {
final String[] enabledKeyboardLayouts = mIm.getEnabledKeyboardLayoutsForInputDevice(
mInputDeviceIdentifier);
Arrays.sort(enabledKeyboardLayouts);
for (Map.Entry<SwitchPreference, KeyboardLayout> entry : mPreferenceMap.entrySet()) {
entry.getKey().setChecked(Arrays.binarySearch(enabledKeyboardLayouts,
entry.getValue().getDescriptor()) >= 0);
}
}
private void createPreferenceHierarchy() {
for (KeyboardLayout layout : mKeyboardLayouts) {
final SwitchPreference pref = new SwitchPreference(mScreen.getContext());
pref.setTitle(layout.getLabel());
pref.setSummary(layout.getCollection());
pref.setKey(layout.getDescriptor());
mScreen.addPreference(pref);
mPreferenceMap.put(pref, layout);
}
}
}

View File

@@ -18,29 +18,15 @@ package com.android.settings.inputmethod;
import android.content.Context;
import android.hardware.input.InputDeviceIdentifier;
import android.hardware.input.InputManager;
import android.hardware.input.InputManager.InputDeviceListener;
import android.hardware.input.KeyboardLayout;
import android.os.Bundle;
import android.support.v7.preference.CheckBoxPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.view.InputDevice;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class KeyboardLayoutPickerFragment extends SettingsPreferenceFragment
implements InputDeviceListener {
private InputDeviceIdentifier mInputDeviceIdentifier;
private int mInputDeviceId = -1;
private InputManager mIm;
private KeyboardLayout[] mKeyboardLayouts;
private HashMap<CheckBoxPreference, KeyboardLayout> mPreferenceMap = new HashMap<>();
public class KeyboardLayoutPickerFragment extends DashboardFragment {
private static final String TAG = "KeyboardLayoutPicker";
/**
* Intent extra: The input device descriptor of the keyboard whose keyboard
@@ -54,105 +40,25 @@ public class KeyboardLayoutPickerFragment extends SettingsPreferenceFragment
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
public void onAttach(Context context) {
super.onAttach(context);
mInputDeviceIdentifier = getActivity().getIntent().getParcelableExtra(
EXTRA_INPUT_DEVICE_IDENTIFIER);
if (mInputDeviceIdentifier == null) {
final InputDeviceIdentifier inputDeviceIdentifier = getActivity().getIntent().
getParcelableExtra(EXTRA_INPUT_DEVICE_IDENTIFIER);
if (inputDeviceIdentifier == null) {
getActivity().finish();
}
mIm = (InputManager) getSystemService(Context.INPUT_SERVICE);
mKeyboardLayouts = mIm.getKeyboardLayoutsForInputDevice(mInputDeviceIdentifier);
Arrays.sort(mKeyboardLayouts);
setPreferenceScreen(createPreferenceHierarchy());
use(KeyboardLayoutPickerController.class).initialize(this /*parent*/,
inputDeviceIdentifier);
}
@Override
public void onResume() {
super.onResume();
mIm.registerInputDeviceListener(this, null);
InputDevice inputDevice =
mIm.getInputDeviceByDescriptor(mInputDeviceIdentifier.getDescriptor());
if (inputDevice == null) {
getActivity().finish();
return;
}
mInputDeviceId = inputDevice.getId();
updateCheckedState();
protected String getLogTag() {
return TAG;
}
@Override
public void onPause() {
mIm.unregisterInputDeviceListener(this);
mInputDeviceId = -1;
super.onPause();
}
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (preference instanceof CheckBoxPreference) {
CheckBoxPreference checkboxPref = (CheckBoxPreference)preference;
KeyboardLayout layout = mPreferenceMap.get(checkboxPref);
if (layout != null) {
boolean checked = checkboxPref.isChecked();
if (checked) {
mIm.addKeyboardLayoutForInputDevice(mInputDeviceIdentifier,
layout.getDescriptor());
} else {
mIm.removeKeyboardLayoutForInputDevice(mInputDeviceIdentifier,
layout.getDescriptor());
}
return true;
}
}
return super.onPreferenceTreeClick(preference);
}
@Override
public void onInputDeviceAdded(int deviceId) {
}
@Override
public void onInputDeviceChanged(int deviceId) {
if (mInputDeviceId >= 0 && deviceId == mInputDeviceId) {
updateCheckedState();
}
}
@Override
public void onInputDeviceRemoved(int deviceId) {
if (mInputDeviceId >= 0 && deviceId == mInputDeviceId) {
getActivity().finish();
}
}
private PreferenceScreen createPreferenceHierarchy() {
PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity());
for (KeyboardLayout layout : mKeyboardLayouts) {
CheckBoxPreference pref = new CheckBoxPreference(getPrefContext());
pref.setTitle(layout.getLabel());
pref.setSummary(layout.getCollection());
root.addPreference(pref);
mPreferenceMap.put(pref, layout);
}
return root;
}
private void updateCheckedState() {
String[] enabledKeyboardLayouts = mIm.getEnabledKeyboardLayoutsForInputDevice(
mInputDeviceIdentifier);
Arrays.sort(enabledKeyboardLayouts);
for (Map.Entry<CheckBoxPreference, KeyboardLayout> entry : mPreferenceMap.entrySet()) {
entry.getKey().setChecked(Arrays.binarySearch(enabledKeyboardLayouts,
entry.getValue().getDescriptor()) >= 0);
}
protected int getPreferenceScreenResId() {
return R.xml.keyboard_layout_picker_fragment;
}
}

View File

@@ -60,8 +60,8 @@ public class UserDictionaryAddWordContents {
private String mSavedShortcut;
/* package */ UserDictionaryAddWordContents(final View view, final Bundle args) {
mWordEditText = (EditText)view.findViewById(R.id.user_dictionary_add_word_text);
mShortcutEditText = (EditText)view.findViewById(R.id.user_dictionary_add_shortcut);
mWordEditText = (EditText) view.findViewById(R.id.user_dictionary_add_word_text);
mShortcutEditText = (EditText) view.findViewById(R.id.user_dictionary_add_shortcut);
final String word = args.getString(EXTRA_WORD);
if (null != word) {
mWordEditText.setText(word);
@@ -81,8 +81,8 @@ public class UserDictionaryAddWordContents {
/* package */ UserDictionaryAddWordContents(final View view,
final UserDictionaryAddWordContents oldInstanceToBeEdited) {
mWordEditText = (EditText)view.findViewById(R.id.user_dictionary_add_word_text);
mShortcutEditText = (EditText)view.findViewById(R.id.user_dictionary_add_shortcut);
mWordEditText = (EditText) view.findViewById(R.id.user_dictionary_add_word_text);
mShortcutEditText = (EditText) view.findViewById(R.id.user_dictionary_add_shortcut);
mMode = MODE_EDIT;
mOldWord = oldInstanceToBeEdited.mSavedWord;
mOldShortcut = oldInstanceToBeEdited.mSavedShortcut;
@@ -167,23 +167,24 @@ public class UserDictionaryAddWordContents {
return UserDictionaryAddWordActivity.CODE_WORD_ADDED;
}
private static final String[] HAS_WORD_PROJECTION = { UserDictionary.Words.WORD };
private static final String[] HAS_WORD_PROJECTION = {UserDictionary.Words.WORD};
private static final String HAS_WORD_SELECTION_ONE_LOCALE = UserDictionary.Words.WORD
+ "=? AND " + UserDictionary.Words.LOCALE + "=?";
private static final String HAS_WORD_SELECTION_ALL_LOCALES = UserDictionary.Words.WORD
+ "=? AND " + UserDictionary.Words.LOCALE + " is null";
private boolean hasWord(final String word, final Context context) {
final Cursor cursor;
// mLocale == "" indicates this is an entry for all languages. Here, mLocale can't
// be null at all (it's ensured by the updateLocale method).
if ("".equals(mLocale)) {
cursor = context.getContentResolver().query(UserDictionary.Words.CONTENT_URI,
HAS_WORD_PROJECTION, HAS_WORD_SELECTION_ALL_LOCALES,
new String[] { word }, null /* sort order */);
HAS_WORD_PROJECTION, HAS_WORD_SELECTION_ALL_LOCALES,
new String[] {word}, null /* sort order */);
} else {
cursor = context.getContentResolver().query(UserDictionary.Words.CONTENT_URI,
HAS_WORD_PROJECTION, HAS_WORD_SELECTION_ONE_LOCALE,
new String[] { word, mLocale }, null /* sort order */);
HAS_WORD_PROJECTION, HAS_WORD_SELECTION_ONE_LOCALE,
new String[] {word, mLocale}, null /* sort order */);
}
try {
if (null == cursor) return false;
@@ -196,6 +197,7 @@ public class UserDictionaryAddWordContents {
public static class LocaleRenderer {
private final String mLocaleString;
private final String mDescription;
// LocaleString may NOT be null.
public LocaleRenderer(final Context context, final String localeString) {
mLocaleString = localeString;
@@ -207,13 +209,16 @@ public class UserDictionaryAddWordContents {
mDescription = Utils.createLocaleFromString(localeString).getDisplayName();
}
}
@Override
public String toString() {
return mDescription;
}
public String getLocaleString() {
return mLocaleString;
}
// "More languages..." is null ; "All languages" is the empty string.
public boolean isMoreLanguages() {
return null == mLocaleString;
@@ -229,7 +234,8 @@ public class UserDictionaryAddWordContents {
// Helper method to get the list of locales to display for this word
public ArrayList<LocaleRenderer> getLocalesList(final Activity activity) {
final TreeSet<String> locales = UserDictionaryList.getUserDictionaryLocalesSet(activity);
final TreeSet<String> locales =
UserDictionaryListPreferenceController.getUserDictionaryLocalesSet(activity);
// Remove our locale if it's in, because we're always gonna put it at the top
locales.remove(mLocale); // mLocale may not be null
final String systemLocale = Locale.getDefault().toString();

View File

@@ -16,33 +16,17 @@
package com.android.settings.inputmethod;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.UserDictionary;
import android.support.annotation.NonNull;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup;
import android.text.TextUtils;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import com.android.settings.dashboard.DashboardFragment;
import java.util.List;
import java.util.Locale;
import java.util.TreeSet;
public class UserDictionaryList extends DashboardFragment {
public class UserDictionaryList extends SettingsPreferenceFragment {
public static final String USER_DICTIONARY_SETTINGS_INTENT_ACTION =
"android.settings.USER_DICTIONARY_SETTINGS";
private String mLocale;
private static final String TAG = "UserDictionaryList";
@Override
public int getMetricsCategory() {
@@ -50,15 +34,8 @@ public class UserDictionaryList extends SettingsPreferenceFragment {
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setPreferenceScreen(getPreferenceManager().createPreferenceScreen(getActivity()));
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getActivity().getActionBar().setTitle(R.string.user_dict_settings_title);
public void onAttach(Context context) {
super.onAttach(context);
final Intent intent = getActivity().getIntent();
final String localeFromIntent =
@@ -76,122 +53,17 @@ public class UserDictionaryList extends SettingsPreferenceFragment {
} else {
locale = null;
}
mLocale = locale;
}
@NonNull
public static TreeSet<String> getUserDictionaryLocalesSet(Context context) {
final Cursor cursor = context.getContentResolver().query(
UserDictionary.Words.CONTENT_URI, new String[]{UserDictionary.Words.LOCALE},
null, null, null);
final TreeSet<String> localeSet = new TreeSet<>();
if (cursor == null) {
// The user dictionary service is not present or disabled. Return empty set.
return localeSet;
}
try {
if (cursor.moveToFirst()) {
final int columnIndex = cursor.getColumnIndex(UserDictionary.Words.LOCALE);
do {
final String locale = cursor.getString(columnIndex);
localeSet.add(null != locale ? locale : "");
} while (cursor.moveToNext());
}
} finally {
cursor.close();
}
// CAVEAT: Keep this for consistency of the implementation between Keyboard and Settings
// if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
// // For ICS, we need to show "For all languages" in case that the keyboard locale
// // is different from the system locale
// localeSet.add("");
// }
final InputMethodManager imm =
(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
final List<InputMethodInfo> imis = imm.getEnabledInputMethodList();
for (final InputMethodInfo imi : imis) {
final List<InputMethodSubtype> subtypes =
imm.getEnabledInputMethodSubtypeList(
imi, true /* allowsImplicitlySelectedSubtypes */);
for (InputMethodSubtype subtype : subtypes) {
final String locale = subtype.getLocale();
if (!TextUtils.isEmpty(locale)) {
localeSet.add(locale);
}
}
}
// We come here after we have collected locales from existing user dictionary entries and
// enabled subtypes. If we already have the locale-without-country version of the system
// locale, we don't add the system locale to avoid confusion even though it's technically
// correct to add it.
if (!localeSet.contains(Locale.getDefault().getLanguage().toString())) {
localeSet.add(Locale.getDefault().toString());
}
return localeSet;
}
/**
* Creates the entries that allow the user to go into the user dictionary for each locale.
*
* @param userDictGroup The group to put the settings in.
*/
protected void createUserDictSettings(PreferenceGroup userDictGroup) {
final Activity activity = getActivity();
userDictGroup.removeAll();
final TreeSet<String> localeSet =
UserDictionaryList.getUserDictionaryLocalesSet(activity);
if (mLocale != null) {
// If the caller explicitly specify empty string as a locale, we'll show "all languages"
// in the list.
localeSet.add(mLocale);
}
if (localeSet.size() > 1) {
// Have an "All languages" entry in the languages list if there are two or more active
// languages
localeSet.add("");
}
if (localeSet.isEmpty()) {
userDictGroup.addPreference(createUserDictionaryPreference(null, activity));
} else {
for (String locale : localeSet) {
userDictGroup.addPreference(createUserDictionaryPreference(locale, activity));
}
}
}
/**
* Create a single User Dictionary Preference object, with its parameters set.
*
* @param locale The locale for which this user dictionary is for.
* @return The corresponding preference.
*/
protected Preference createUserDictionaryPreference(String locale, Activity activity) {
final Preference newPref = new Preference(getPrefContext());
final Intent intent = new Intent(USER_DICTIONARY_SETTINGS_INTENT_ACTION);
if (null == locale) {
newPref.setTitle(Locale.getDefault().getDisplayName());
} else {
if ("".equals(locale)) {
newPref.setTitle(getString(R.string.user_dict_settings_all_languages));
} else {
newPref.setTitle(Utils.createLocaleFromString(locale).getDisplayName());
}
intent.putExtra("locale", locale);
newPref.getExtras().putString("locale", locale);
}
newPref.setIntent(intent);
newPref.setFragment(UserDictionarySettings.class.getName());
return newPref;
use(UserDictionaryListPreferenceController.class).setLocale(locale);
}
@Override
public void onResume() {
super.onResume();
createUserDictSettings(getPreferenceScreen());
protected int getPreferenceScreenResId() {
return R.xml.user_dictionary_list_fragment;
}
@Override
protected String getLogTag() {
return TAG;
}
}

View File

@@ -0,0 +1,211 @@
/*
* 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.inputmethod;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.provider.UserDictionary;
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import java.util.List;
import java.util.Locale;
import java.util.TreeSet;
public class UserDictionaryListPreferenceController extends BasePreferenceController implements
LifecycleObserver, OnStart {
public static final String USER_DICTIONARY_SETTINGS_INTENT_ACTION =
"android.settings.USER_DICTIONARY_SETTINGS";
private final String KEY_ALL_LANGUAGE = "all_languages";
private String mLocale;
private PreferenceScreen mScreen;
public UserDictionaryListPreferenceController(Context context, String key) {
super(context, key);
}
public void setLocale(String locale) {
mLocale = locale;
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
// This is to make newly inserted languages being sorted alphabetically when updating
// the existing preferenceScreen, and for "For all languages" to be always on the top.
screen.setOrderingAsAdded(false);
mScreen = screen;
}
@Override
public void onStart() {
createUserDictSettings();
}
@NonNull
public static TreeSet<String> getUserDictionaryLocalesSet(Context context) {
final Cursor cursor = context.getContentResolver().query(
UserDictionary.Words.CONTENT_URI, new String[] {UserDictionary.Words.LOCALE},
null, null, null);
final TreeSet<String> localeSet = new TreeSet<>();
if (cursor == null) {
// The user dictionary service is not present or disabled. Return empty set.
return localeSet;
}
try {
if (cursor.moveToFirst()) {
final int columnIndex = cursor.getColumnIndex(UserDictionary.Words.LOCALE);
do {
final String locale = cursor.getString(columnIndex);
localeSet.add(null != locale ? locale : "");
} while (cursor.moveToNext());
}
} finally {
cursor.close();
}
// CAVEAT: Keep this for consistency of the implementation between Keyboard and Settings
// if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
// // For ICS, we need to show "For all languages" in case that the keyboard locale
// // is different from the system locale
// localeSet.add("");
// }
final InputMethodManager imm =
(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
final List<InputMethodInfo> imis = imm.getEnabledInputMethodList();
for (final InputMethodInfo imi : imis) {
final List<InputMethodSubtype> subtypes =
imm.getEnabledInputMethodSubtypeList(
imi, true /* allowsImplicitlySelectedSubtypes */);
for (InputMethodSubtype subtype : subtypes) {
final String locale = subtype.getLocale();
if (!TextUtils.isEmpty(locale)) {
localeSet.add(locale);
}
}
}
// We come here after we have collected locales from existing user dictionary entries and
// enabled subtypes. If we already have the locale-without-country version of the system
// locale, we don't add the system locale to avoid confusion even though it's technically
// correct to add it.
if (!localeSet.contains(Locale.getDefault().getLanguage().toString())) {
localeSet.add(Locale.getDefault().toString());
}
return localeSet;
}
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
TreeSet<String> getUserDictLocalesSet(Context context) {
return getUserDictionaryLocalesSet(context);
}
/**
* Creates the entries that allow the user to go into the user dictionary for each locale.
*/
private void createUserDictSettings() {
final TreeSet<String> localeSet = getUserDictLocalesSet(mContext);
final int prefCount = mScreen.getPreferenceCount();
String prefKey;
if (mLocale != null) {
// If the caller explicitly specify empty string as a locale, we'll show "all languages"
// in the list.
localeSet.add(mLocale);
}
if (localeSet.size() > 1) {
// Have an "All languages" entry in the languages list if there are two or more active
// languages
localeSet.add("");
}
// Update the existing preferenceScreen according to the corresponding data set.
if (prefCount > 0) {
for (int i = prefCount - 1; i >= 0; i--) {
prefKey = mScreen.getPreference(i).getKey();
if (KEY_ALL_LANGUAGE.equals(prefKey)) {
prefKey = "";
}
if (!localeSet.isEmpty() && localeSet.contains(prefKey)) {
localeSet.remove(prefKey);
continue;
}
mScreen.removePreference(mScreen.findPreference(prefKey));
}
}
if (localeSet.isEmpty() && prefCount == 0) {
mScreen.addPreference(createUserDictionaryPreference(null));
} else {
for (String locale : localeSet) {
mScreen.addPreference(createUserDictionaryPreference(locale));
}
}
}
/**
* Create a single User Dictionary Preference object, with its parameters set.
*
* @param locale The locale for which this user dictionary is for.
* @return The corresponding preference.
*/
private Preference createUserDictionaryPreference(String locale) {
final String KEY_LOCALE = "locale";
final Preference newPref = new Preference(mScreen.getContext());
final Intent intent = new Intent(USER_DICTIONARY_SETTINGS_INTENT_ACTION);
if (locale == null) {
newPref.setTitle(Locale.getDefault().getDisplayName());
newPref.setKey(Locale.getDefault().toString());
} else {
if (TextUtils.isEmpty(locale)) {
newPref.setTitle(mContext.getString(R.string.user_dict_settings_all_languages));
newPref.setKey(KEY_ALL_LANGUAGE);
newPref.setOrder(0);
} else {
newPref.setTitle(Utils.createLocaleFromString(locale).getDisplayName());
newPref.setKey(locale);
}
intent.putExtra(KEY_LOCALE, locale);
newPref.getExtras().putString(KEY_LOCALE, locale);
}
newPref.setIntent(intent);
newPref.setFragment(UserDictionarySettings.class.getName());
return newPref;
}
}

View File

@@ -23,6 +23,7 @@ import android.support.v7.preference.Preference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.inputmethod.UserDictionaryList;
import com.android.settings.inputmethod.UserDictionaryListPreferenceController;
import com.android.settings.inputmethod.UserDictionarySettings;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -61,10 +62,10 @@ public class UserDictionaryPreferenceController extends AbstractPreferenceContro
// parameter in the extras. This will be interpreted by the
// UserDictionarySettings class as meaning
// "the current locale". Note that with the current code for
// UserDictionaryList#getUserDictionaryLocalesSet()
// UserDictionaryListPreferenceController#getUserDictionaryLocalesSet()
// the locale list always has at least one element, since it
// always includes the current locale explicitly.
// @see UserDictionaryList.getUserDictionaryLocalesSet().
// @see UserDictionaryListPreferenceController.getUserDictionaryLocalesSet().
extras.putString("locale", localeSet.first());
}
targetFragment = UserDictionarySettings.class;
@@ -75,6 +76,6 @@ public class UserDictionaryPreferenceController extends AbstractPreferenceContro
}
protected TreeSet<String> getDictionaryLocales() {
return UserDictionaryList.getUserDictionaryLocalesSet(mContext);
return UserDictionaryListPreferenceController.getUserDictionaryLocalesSet(mContext);
}
}

View File

@@ -28,6 +28,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.provider.Telephony;
import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.MultiSelectListPreference;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.EditTextPreference;
@@ -47,7 +48,6 @@ import android.view.MenuItem;
import android.view.View;
import android.view.View.OnKeyListener;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.util.ArrayUtils;
@@ -309,6 +309,16 @@ public class ApnEditor extends SettingsPreferenceFragment
fillUI(icicle == null);
}
@VisibleForTesting
static String formatInteger(String value) {
try {
final int intValue = Integer.parseInt(value);
return String.format("%d", intValue);
} catch (NumberFormatException e) {
return value;
}
}
/**
* Check if passed in array of APN types indicates all APN types
* @param apnTypes array of APN types. "*" indicates all types.
@@ -547,8 +557,8 @@ public class ApnEditor extends SettingsPreferenceFragment
mMmsProxy.setSummary(checkNull(mMmsProxy.getText()));
mMmsPort.setSummary(checkNull(mMmsPort.getText()));
mMmsc.setSummary(checkNull(mMmsc.getText()));
mMcc.setSummary(checkNull(mMcc.getText()));
mMnc.setSummary(checkNull(mMnc.getText()));
mMcc.setSummary(formatInteger(checkNull(mMcc.getText())));
mMnc.setSummary(formatInteger(checkNull(mMnc.getText())));
mApnType.setSummary(checkNull(mApnType.getText()));
String authVal = mAuthType.getValue();
@@ -598,20 +608,6 @@ public class ApnEditor extends SettingsPreferenceFragment
}
}
private String bearerDescription(String raw) {
int mBearerIndex = mBearerMulti.findIndexOfValue(raw);
if (mBearerIndex == -1) {
return null;
} else {
String[] values = getResources().getStringArray(R.array.bearer_entries);
try {
return values[mBearerIndex];
} catch (ArrayIndexOutOfBoundsException e) {
return null;
}
}
}
private String bearerMultiDescription(Set<String> raw) {
String[] values = getResources().getStringArray(R.array.bearer_entries);
StringBuilder retVal = new StringBuilder();

View File

@@ -23,6 +23,7 @@ import android.app.AlertDialog;
import android.app.Dialog;
import android.app.Fragment;
import android.content.Context;
import android.icu.text.ListFormatter;
import android.provider.SearchIndexableResource;
import android.support.annotation.VisibleForTesting;
import android.text.BidiFormatter;
@@ -175,25 +176,22 @@ public class NetworkDashboardFragment extends DashboardFragment implements
@Override
public void setListening(boolean listening) {
if (listening) {
String summary = BidiFormatter.getInstance()
.unicodeWrap(mContext.getString(R.string.wifi_settings_title));
final List<String> summaries = new ArrayList<>();
summaries.add(BidiFormatter.getInstance()
.unicodeWrap(mContext.getString(R.string.wifi_settings_title)));
if (mMobileNetworkPreferenceController.isAvailable()) {
final String mobileSettingSummary = mContext.getString(
R.string.network_dashboard_summary_mobile);
summary = mContext.getString(R.string.join_many_items_middle, summary,
mobileSettingSummary);
summaries.add(mContext.getString(
R.string.network_dashboard_summary_mobile));
}
final String dataUsageSettingSummary = mContext.getString(
R.string.network_dashboard_summary_data_usage);
summary = mContext.getString(R.string.join_many_items_middle, summary,
dataUsageSettingSummary);
summaries.add(dataUsageSettingSummary);
if (mTetherPreferenceController.isAvailable()) {
final String hotspotSettingSummary = mContext.getString(
R.string.network_dashboard_summary_hotspot);
summary = mContext.getString(R.string.join_many_items_middle, summary,
hotspotSettingSummary);
summaries.add(mContext.getString(
R.string.network_dashboard_summary_hotspot));
}
mSummaryLoader.setSummary(this, summary);
mSummaryLoader.setSummary(this, ListFormatter.getInstance().format(summaries));
}
}
}

View File

@@ -125,7 +125,7 @@ public class AppNotificationSettings extends NotificationSettingsBase {
mControllers.add(new VibrationPreferenceController(context, mBackend));
mControllers.add(new VisibilityPreferenceController(context, new LockPatternUtils(context),
mBackend));
mControllers.add(new DndPreferenceController(context, getLifecycle(), mBackend));
mControllers.add(new DndPreferenceController(context, mBackend));
mControllers.add(new AppLinkPreferenceController(context));
mControllers.add(new DescriptionPreferenceController(context));
mControllers.add(new NotificationsOffPreferenceController(context));

View File

@@ -18,13 +18,16 @@ package com.android.settings.notification;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import android.util.Log;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.applications.AppInfoBase;
import com.android.settingslib.core.AbstractPreferenceController;
import java.util.ArrayList;
@@ -38,6 +41,19 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
return MetricsEvent.NOTIFICATION_TOPIC_NOTIFICATION;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final PreferenceScreen screen = getPreferenceScreen();
Bundle args = getArguments();
// If linking to this screen from an external app, expand settings
if (screen != null && args != null) {
if (!args.getBoolean(ARG_FROM_SETTINGS, false)) {
screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE);
}
}
}
@Override
public void onResume() {
super.onResume();
@@ -92,7 +108,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
mBackend));
mControllers.add(new LightsPreferenceController(context, mBackend));
mControllers.add(new BadgePreferenceController(context, mBackend));
mControllers.add(new DndPreferenceController(context, getLifecycle(), mBackend));
mControllers.add(new DndPreferenceController(context, mBackend));
mControllers.add(new NotificationsOffPreferenceController(context));
return new ArrayList<>(mControllers);
}

View File

@@ -26,14 +26,12 @@ import android.os.UserHandle;
import android.provider.SearchIndexableResource;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
import android.text.TextUtils;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.RingtonePreference;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.gestures.SwipeToNotificationPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -97,21 +95,17 @@ public class ConfigureNotificationSettings extends DashboardFragment {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
final BadgingNotificationPreferenceController badgeController =
new BadgingNotificationPreferenceController(context);
final PulseNotificationPreferenceController pulseController =
new PulseNotificationPreferenceController(context);
final LockScreenNotificationPreferenceController lockScreenNotificationController =
new LockScreenNotificationPreferenceController(context,
KEY_LOCKSCREEN,
KEY_LOCKSCREEN_WORK_PROFILE_HEADER,
KEY_LOCKSCREEN_WORK_PROFILE);
if (lifecycle != null) {
lifecycle.addObserver(pulseController);
lifecycle.addObserver(lockScreenNotificationController);
}
controllers.add(new RecentNotifyingAppsPreferenceController(
context, new NotificationBackend(), app, host));
controllers.add(badgeController);
controllers.add(pulseController);
controllers.add(lockScreenNotificationController);
controllers.add(new NotificationRingtonePreferenceController(context) {
@Override

View File

@@ -28,17 +28,12 @@ import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnResume;
public class DndPreferenceController extends NotificationPreferenceController
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener,
LifecycleObserver {
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
private static final String KEY_BYPASS_DND = "bypass_dnd";
public DndPreferenceController(Context context, Lifecycle lifecycle,
NotificationBackend backend) {
public DndPreferenceController(Context context, NotificationBackend backend) {
super(context, backend);
if (lifecycle != null) {
lifecycle.addObserver(this);
}
}
@Override

View File

@@ -58,6 +58,7 @@ import java.util.List;
abstract public class NotificationSettingsBase extends DashboardFragment {
private static final String TAG = "NotifiSettingsBase";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
protected static final String ARG_FROM_SETTINGS = "fromSettings";
protected PackageManager mPm;
protected NotificationBackend mBackend = new NotificationBackend();
@@ -249,6 +250,7 @@ abstract public class NotificationSettingsBase extends DashboardFragment {
channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid);
channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mPkg);
channelArgs.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
channelArgs.putBoolean(ARG_FROM_SETTINGS, true);
channelPref.setIntent(new SubSettingLauncher(getActivity())
.setDestination(ChannelNotificationSettings.class.getName())
.setArguments(channelArgs)

View File

@@ -24,33 +24,28 @@ import android.os.Handler;
import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.support.v7.preference.TwoStatePreference;
import android.util.Log;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.core.lifecycle.events.OnPause;
import com.android.settingslib.core.lifecycle.events.OnResume;
import static android.provider.Settings.System.NOTIFICATION_LIGHT_PULSE;
public class PulseNotificationPreferenceController extends AbstractPreferenceController
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener,
LifecycleObserver, OnResume, OnPause {
public class PulseNotificationPreferenceController extends TogglePreferenceController
implements OnResume, OnPause {
private static final String TAG = "PulseNotifPrefContr";
private static final String KEY_NOTIFICATION_PULSE = "notification_pulse";
private static final int ON = 1;
private static final int OFF = 0;
private SettingObserver mSettingObserver;
public PulseNotificationPreferenceController(Context context) {
super(context);
public PulseNotificationPreferenceController(Context context, String key) {
super(context, key);
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
Preference preference = screen.findPreference(KEY_NOTIFICATION_PULSE);
Preference preference = screen.findPreference(getPreferenceKey());
if (preference != null) {
mSettingObserver = new SettingObserver(preference);
}
@@ -71,32 +66,22 @@ public class PulseNotificationPreferenceController extends AbstractPreferenceCon
}
@Override
public String getPreferenceKey() {
return KEY_NOTIFICATION_PULSE;
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(
com.android.internal.R.bool.config_intrusiveNotificationLed) ? AVAILABLE
: DISABLED_UNSUPPORTED;
}
@Override
public boolean isAvailable() {
return mContext.getResources()
.getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed);
public boolean isChecked() {
return Settings.System.getInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE, OFF)
== ON;
}
@Override
public void updateState(Preference preference) {
try {
final boolean checked = Settings.System.getInt(mContext.getContentResolver(),
NOTIFICATION_LIGHT_PULSE) == 1;
((TwoStatePreference) preference).setChecked(checked);
} catch (Settings.SettingNotFoundException snfe) {
Log.e(TAG, NOTIFICATION_LIGHT_PULSE + " not found");
}
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean val = (Boolean) newValue;
return Settings.System.putInt(mContext.getContentResolver(),
NOTIFICATION_LIGHT_PULSE, val ? 1 : 0);
public boolean setChecked(boolean isChecked) {
return Settings.System.putInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE,
isChecked ? ON : OFF);
}
class SettingObserver extends ContentObserver {

View File

@@ -17,6 +17,8 @@
package com.android.settings.notification;
import android.app.NotificationManager;
import android.arch.lifecycle.LifecycleObserver;
import android.arch.lifecycle.OnLifecycleEvent;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -31,6 +33,7 @@ import android.os.Vibrator;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settingslib.core.lifecycle.Lifecycle;
import java.util.Objects;
@@ -58,6 +61,7 @@ public class RingVolumePreferenceController extends VolumeSeekBarPreferenceContr
updateRingerMode();
}
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
@Override
public void onResume() {
super.onResume();
@@ -66,6 +70,7 @@ public class RingVolumePreferenceController extends VolumeSeekBarPreferenceContr
updatePreferenceIcon();
}
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
@Override
public void onPause() {
super.onPause();
@@ -118,11 +123,10 @@ public class RingVolumePreferenceController extends VolumeSeekBarPreferenceContr
private void updatePreferenceIcon() {
if (mPreference != null) {
mPreference.showIcon(mSuppressor != null
? com.android.internal.R.drawable.ic_audio_ring_notif_mute
: mRingerMode == AudioManager.RINGER_MODE_VIBRATE || wasRingerModeVibrate()
? com.android.internal.R.drawable.ic_audio_ring_notif_vibrate
: com.android.internal.R.drawable.ic_audio_ring_notif);
mPreference.showIcon(
mRingerMode == AudioManager.RINGER_MODE_VIBRATE || wasRingerModeVibrate()
? com.android.internal.R.drawable.ic_audio_ring_notif_vibrate
: com.android.internal.R.drawable.ic_audio_ring_notif);
}
}

View File

@@ -148,10 +148,16 @@ public class SoundSettings extends DashboardFragment {
@Override
public void onAttach(Context context) {
super.onAttach(context);
use(AlarmVolumePreferenceController.class).setCallback(mVolumeCallback);
use(MediaVolumePreferenceController.class).setCallback(mVolumeCallback);
use(RingVolumePreferenceController.class).setCallback(mVolumeCallback);
use(NotificationVolumePreferenceController.class).setCallback(mVolumeCallback);
ArrayList<VolumeSeekBarPreferenceController> volumeControllers = new ArrayList<>();
volumeControllers.add(use(AlarmVolumePreferenceController.class));
volumeControllers.add(use(MediaVolumePreferenceController.class));
volumeControllers.add(use(RingVolumePreferenceController.class));
volumeControllers.add(use(NotificationVolumePreferenceController.class));
for (VolumeSeekBarPreferenceController controller : volumeControllers) {
controller.setCallback(mVolumeCallback);
getLifecycle().addObserver(controller);
}
}
// === Volumes ===
@@ -207,8 +213,6 @@ public class SoundSettings extends DashboardFragment {
new DialPadTonePreferenceController(context, fragment, lifecycle);
final ScreenLockSoundPreferenceController screenLockSoundPreferenceController =
new ScreenLockSoundPreferenceController(context, fragment, lifecycle);
final ChargingSoundPreferenceController chargingSoundPreferenceController =
new ChargingSoundPreferenceController(context, fragment, lifecycle);
final DockingSoundPreferenceController dockingSoundPreferenceController =
new DockingSoundPreferenceController(context, fragment, lifecycle);
final TouchSoundPreferenceController touchSoundPreferenceController =
@@ -224,7 +228,6 @@ public class SoundSettings extends DashboardFragment {
controllers.add(dialPadTonePreferenceController);
controllers.add(screenLockSoundPreferenceController);
controllers.add(chargingSoundPreferenceController);
controllers.add(dockingSoundPreferenceController);
controllers.add(touchSoundPreferenceController);
controllers.add(vibrateOnTouchPreferenceController);
@@ -235,7 +238,6 @@ public class SoundSettings extends DashboardFragment {
"other_sounds_and_vibrations_category").setChildren(
Arrays.asList(dialPadTonePreferenceController,
screenLockSoundPreferenceController,
chargingSoundPreferenceController,
dockingSoundPreferenceController,
touchSoundPreferenceController,
vibrateOnTouchPreferenceController,

View File

@@ -196,8 +196,7 @@ public class VolumeSeekBarPreference extends SeekBarPreference {
if (mSuppressionTextView != null && mSeekBar != null) {
mSuppressionTextView.setText(mSuppressionText);
final boolean showSuppression = !TextUtils.isEmpty(mSuppressionText);
mSuppressionTextView.setVisibility(showSuppression ? View.VISIBLE : View.INVISIBLE);
mSeekBar.setVisibility(showSuppression ? View.INVISIBLE : View.VISIBLE);
mSuppressionTextView.setVisibility(showSuppression ? View.VISIBLE : View.GONE);
}
}

View File

@@ -75,7 +75,7 @@ public class ZenAutomaticRuleHeaderPreferenceController extends AbstractZenModeP
.newInstance(mFragment.getActivity(), mFragment,
pref.findViewById(R.id.entity_header));
mController.setEditZenRuleNameListener(new View.OnClickListener() {
mController.setEditListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ZenRuleNameDialog.show(mFragment, mRule.getName(), null,
@@ -89,7 +89,7 @@ public class ZenAutomaticRuleHeaderPreferenceController extends AbstractZenModeP
.setPackageName(mRule.getOwner().getPackageName())
.setUid(mContext.getUserId())
.setHasAppInfoLink(false)
.setButtonActions(EntityHeaderController.ActionType.ACTION_DND_RULE_PREFERENCE,
.setButtonActions(EntityHeaderController.ActionType.ACTION_EDIT_PREFERENCE,
EntityHeaderController.ActionType.ACTION_NONE)
.done(mFragment.getActivity(), mContext);

View File

@@ -24,6 +24,7 @@ import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settings.widget.DisabledCheckBoxPreference;
public class ZenModeVisEffectPreferenceController
extends AbstractZenModePreferenceController
@@ -78,9 +79,9 @@ public class ZenModeVisEffectPreferenceController
if (parentSuppressed) {
((CheckBoxPreference) preference).setChecked(parentSuppressed);
onPreferenceChange(preference, parentSuppressed);
preference.setEnabled(false);
((DisabledCheckBoxPreference) preference).enableCheckbox(false);
} else {
preference.setEnabled(true);
((DisabledCheckBoxPreference) preference).enableCheckbox(true);
((CheckBoxPreference) preference).setChecked(suppressed);
}
}

View File

@@ -19,8 +19,6 @@ package com.android.settings.security;
import android.content.Context;
import android.os.UserHandle;
import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.v7.preference.TwoStatePreference;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.core.BasePreferenceController;
@@ -28,12 +26,10 @@ import com.android.settings.core.TogglePreferenceController;
public class LockdownButtonPreferenceController extends TogglePreferenceController {
private static final String KEY_LOCKDOWN_ENALBED = "security_setting_lockdown_enabled";
private final LockPatternUtils mLockPatternUtils;
public LockdownButtonPreferenceController(Context context) {
super(context, KEY_LOCKDOWN_ENALBED);
public LockdownButtonPreferenceController(Context context, String key) {
super(context, key);
mLockPatternUtils = new LockPatternUtils(context);
}

View File

@@ -93,7 +93,6 @@ public class LockscreenDashboardFragment extends DashboardFragment
mOwnerInfoPreferenceController =
new OwnerInfoPreferenceController(context, this, lifecycle);
controllers.add(mOwnerInfoPreferenceController);
controllers.add(new LockdownButtonPreferenceController(context));
return controllers;
}
@@ -124,7 +123,6 @@ public class LockscreenDashboardFragment extends DashboardFragment
KEY_ADD_USER_FROM_LOCK_SCREEN, null /* lifecycle */));
controllers.add(new OwnerInfoPreferenceController(
context, null /* fragment */, null /* lifecycle */));
controllers.add(new LockdownButtonPreferenceController(context));
return controllers;
}

Some files were not shown because too many files have changed in this diff Show More