Snap for 5286292 from 9285d84aa4 to qt-release

Change-Id: Ibadf30376fd8a4b53204b514fcb9f4c43736308c
This commit is contained in:
android-build-team Robot
2019-02-06 04:06:16 +00:00
44 changed files with 502 additions and 325 deletions

View File

@@ -57,6 +57,7 @@
<uses-permission android:name="android.permission.READ_SYNC_STATS" /> <uses-permission android:name="android.permission.READ_SYNC_STATS" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" /> <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" /> <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.READ_DEVICE_CONFIG" />
<uses-permission android:name="android.permission.STATUS_BAR" /> <uses-permission android:name="android.permission.STATUS_BAR" />
<uses-permission android:name="android.permission.MANAGE_USB" /> <uses-permission android:name="android.permission.MANAGE_USB" />
<uses-permission android:name="android.permission.MANAGE_DEBUGGING" /> <uses-permission android:name="android.permission.MANAGE_DEBUGGING" />

View File

@@ -18,13 +18,10 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="oval"> <com.android.settings.homepage.AdaptiveIconShapeDrawable
<solid
android:color="@color/homepage_about_background" />
<size
android:width="@dimen/dashboard_tile_image_size" android:width="@dimen/dashboard_tile_image_size"
android:height="@dimen/dashboard_tile_image_size" /> android:height="@dimen/dashboard_tile_image_size"
</shape> android:color="@color/homepage_about_background" />
</item> </item>
<item <item

View File

@@ -18,13 +18,10 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="oval"> <com.android.settings.homepage.AdaptiveIconShapeDrawable
<solid
android:color="@color/homepage_accessibility_background" />
<size
android:width="@dimen/dashboard_tile_image_size" android:width="@dimen/dashboard_tile_image_size"
android:height="@dimen/dashboard_tile_image_size" /> android:height="@dimen/dashboard_tile_image_size"
</shape> android:color="@color/homepage_accessibility_background" />
</item> </item>
<item <item

View File

@@ -18,13 +18,10 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="oval"> <com.android.settings.homepage.AdaptiveIconShapeDrawable
<solid
android:color="@color/homepage_accounts_background" />
<size
android:width="@dimen/dashboard_tile_image_size" android:width="@dimen/dashboard_tile_image_size"
android:height="@dimen/dashboard_tile_image_size" /> android:height="@dimen/dashboard_tile_image_size"
</shape> android:color="@color/homepage_accounts_background" />
</item> </item>
<item <item

View File

@@ -18,13 +18,10 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="oval"> <com.android.settings.homepage.AdaptiveIconShapeDrawable
<solid
android:color="@color/homepage_app_and_notification_background" />
<size
android:width="@dimen/dashboard_tile_image_size" android:width="@dimen/dashboard_tile_image_size"
android:height="@dimen/dashboard_tile_image_size" /> android:height="@dimen/dashboard_tile_image_size"
</shape> android:color="@color/homepage_app_and_notification_background" />
</item> </item>
<item <item

View File

@@ -18,13 +18,10 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="oval"> <com.android.settings.homepage.AdaptiveIconShapeDrawable
<solid
android:color="@color/homepage_battery_background" />
<size
android:width="@dimen/dashboard_tile_image_size" android:width="@dimen/dashboard_tile_image_size"
android:height="@dimen/dashboard_tile_image_size" /> android:height="@dimen/dashboard_tile_image_size"
</shape> android:color="@color/homepage_battery_background" />
</item> </item>
<item <item

View File

@@ -18,13 +18,10 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="oval"> <com.android.settings.homepage.AdaptiveIconShapeDrawable
<solid
android:color="@color/homepage_connected_device_background" />
<size
android:width="@dimen/dashboard_tile_image_size" android:width="@dimen/dashboard_tile_image_size"
android:height="@dimen/dashboard_tile_image_size" /> android:height="@dimen/dashboard_tile_image_size"
</shape> android:color="@color/homepage_connected_device_background" />
</item> </item>
<item <item

View File

@@ -18,13 +18,10 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="oval"> <com.android.settings.homepage.AdaptiveIconShapeDrawable
<solid
android:color="@color/homepage_display_background" />
<size
android:width="@dimen/dashboard_tile_image_size" android:width="@dimen/dashboard_tile_image_size"
android:height="@dimen/dashboard_tile_image_size" /> android:height="@dimen/dashboard_tile_image_size"
</shape> android:color="@color/homepage_display_background" />
</item> </item>
<item <item

View File

@@ -1,24 +0,0 @@
<?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.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="@color/homepage_generic_icon_background" />
<size
android:width="@dimen/dashboard_tile_image_size"
android:height="@dimen/dashboard_tile_image_size" />
</shape>

View File

@@ -18,13 +18,10 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="oval"> <com.android.settings.homepage.AdaptiveIconShapeDrawable
<solid
android:color="@color/homepage_location_background"/>
<size
android:width="@dimen/dashboard_tile_image_size" android:width="@dimen/dashboard_tile_image_size"
android:height="@dimen/dashboard_tile_image_size"/> android:height="@dimen/dashboard_tile_image_size"
</shape> android:color="@color/homepage_location_background" />
</item> </item>
<item <item

View File

@@ -18,13 +18,10 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="oval"> <com.android.settings.homepage.AdaptiveIconShapeDrawable
<solid
android:color="@color/homepage_network_background" />
<size
android:width="@dimen/dashboard_tile_image_size" android:width="@dimen/dashboard_tile_image_size"
android:height="@dimen/dashboard_tile_image_size" /> android:height="@dimen/dashboard_tile_image_size"
</shape> android:color="@color/homepage_network_background" />
</item> </item>
<item <item

View File

@@ -18,13 +18,10 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="oval"> <com.android.settings.homepage.AdaptiveIconShapeDrawable
<solid
android:color="@color/homepage_privacy_background"/>
<size
android:width="@dimen/dashboard_tile_image_size" android:width="@dimen/dashboard_tile_image_size"
android:height="@dimen/dashboard_tile_image_size"/> android:height="@dimen/dashboard_tile_image_size"
</shape> android:color="@color/homepage_privacy_background" />
</item> </item>
<item <item

View File

@@ -18,13 +18,10 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="oval"> <com.android.settings.homepage.AdaptiveIconShapeDrawable
<solid
android:color="@color/homepage_security_background" />
<size
android:width="@dimen/dashboard_tile_image_size" android:width="@dimen/dashboard_tile_image_size"
android:height="@dimen/dashboard_tile_image_size" /> android:height="@dimen/dashboard_tile_image_size"
</shape> android:color="@color/homepage_security_background" />
</item> </item>
<item <item

View File

@@ -18,13 +18,10 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="oval"> <com.android.settings.homepage.AdaptiveIconShapeDrawable
<solid
android:color="@color/homepage_sound_background" />
<size
android:width="@dimen/dashboard_tile_image_size" android:width="@dimen/dashboard_tile_image_size"
android:height="@dimen/dashboard_tile_image_size" /> android:height="@dimen/dashboard_tile_image_size"
</shape> android:color="@color/homepage_sound_background" />
</item> </item>
<item <item

View File

@@ -18,13 +18,10 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="oval"> <com.android.settings.homepage.AdaptiveIconShapeDrawable
<solid
android:color="@color/homepage_storage_background" />
<size
android:width="@dimen/dashboard_tile_image_size" android:width="@dimen/dashboard_tile_image_size"
android:height="@dimen/dashboard_tile_image_size" /> android:height="@dimen/dashboard_tile_image_size"
</shape> android:color="@color/homepage_storage_background" />
</item> </item>
<item <item

View File

@@ -18,13 +18,10 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="oval"> <com.android.settings.homepage.AdaptiveIconShapeDrawable
<solid
android:color="@color/homepage_support_background" />
<size
android:width="@dimen/dashboard_tile_image_size" android:width="@dimen/dashboard_tile_image_size"
android:height="@dimen/dashboard_tile_image_size" /> android:height="@dimen/dashboard_tile_image_size"
</shape> android:color="@color/homepage_support_background" />
</item> </item>
<item <item

View File

@@ -18,13 +18,10 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<shape android:shape="oval"> <com.android.settings.homepage.AdaptiveIconShapeDrawable
<solid
android:color="@color/homepage_system_background" />
<size
android:width="@dimen/dashboard_tile_image_size" android:width="@dimen/dashboard_tile_image_size"
android:height="@dimen/dashboard_tile_image_size" /> android:height="@dimen/dashboard_tile_image_size"
</shape> android:color="@color/homepage_system_background" />
</item> </item>
<item <item

View File

@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorControlNormal">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>

View File

@@ -18,6 +18,6 @@
<item <item
android:id="@+id/vpn_create" android:id="@+id/vpn_create"
android:title="@string/vpn_create" android:title="@string/vpn_create"
android:icon="@drawable/ic_menu_add_white" android:icon="@drawable/ic_menu_add"
android:showAsAction="always" /> android:showAsAction="always" />
</menu> </menu>

View File

@@ -820,9 +820,9 @@
<string name="lockdown_settings_summary">Display power button option that turns off Smart Lock, fingerprint unlocking, and notifications on the lock screen</string> <string name="lockdown_settings_summary">Display power button option that turns off Smart Lock, fingerprint unlocking, and notifications on the lock screen</string>
<!-- Text shown for the title of the extend unlock mode option for trust agents [CHAR LIMIT=40] --> <!-- Text shown for the title of the extend unlock mode option for trust agents [CHAR LIMIT=40] -->
<string name="trust_agents_extend_unlock_title">SmartLock only extends unlock</string> <string name="trust_agents_extend_unlock_title">Trust agents only extend unlock</string>
<!-- Text shown for the description of the extend unlock mode option [CHAR LIMIT=NONE] --> <!-- Text shown for the description of the extend unlock mode option [CHAR LIMIT=NONE] -->
<string name="trust_agents_extend_unlock_summary">If enabled, SmartLock will keep your device unlocked for longer, but can no longer unlock a locked device.</string> <string name="trust_agents_extend_unlock_summary">If enabled, trust agents will keep your device unlocked for longer, but can no longer unlock a locked device.</string>
<!-- Text shown for the title of the lock when trust lost option [CHAR LIMIT=40] --> <!-- Text shown for the title of the lock when trust lost option [CHAR LIMIT=40] -->
<string name="trust_lost_locks_screen_title">Lock screen when trust is lost</string> <string name="trust_lost_locks_screen_title">Lock screen when trust is lost</string>
@@ -4771,13 +4771,13 @@
<!-- Summary for the accessibility preference for hearing aid when not connected. [CHAR LIMIT=50] --> <!-- Summary for the accessibility preference for hearing aid when not connected. [CHAR LIMIT=50] -->
<string name="accessibility_hearingaid_not_connected_summary">No hearing aids connected</string> <string name="accessibility_hearingaid_not_connected_summary">No hearing aids connected</string>
<!-- Summary for the accessibility preference for hearing aid when adding new devices. [CHAR LIMIT=50] --> <!-- Summary for the accessibility preference for hearing aid when adding new devices. [CHAR LIMIT=50] -->
<string name="accessibility_hearingaid_adding_summary">Add hearing aid</string> <string name="accessibility_hearingaid_adding_summary">Add hearing aids</string>
<!-- Message to ask the user that if they want to pair the hearing aid, then they should find and tap the hearing aid device from the list on the next screen. [CHAR LIMIT=NONE] --> <!-- Message to ask the user that if they want to pair the hearing aid, then they should find and tap the hearing aid device from the list on the next screen. [CHAR LIMIT=NONE] -->
<string name="accessibility_hearingaid_pair_instructions_first_message">To pair your hearing aids, find and tap your device on the next screen.</string> <string name="accessibility_hearingaid_pair_instructions_first_message">To pair your hearing aids, find and tap your device on the next screen.</string>
<!-- Message to ask the user to make sure that their hearing aid devices are in pairing mode. [CHAR LIMIT=NONE] --> <!-- Message to ask the user to make sure that their hearing aid devices are in pairing mode. [CHAR LIMIT=NONE] -->
<string name="accessibility_hearingaid_pair_instructions_second_message">Make sure your hearing aids are in pairing mode.</string> <string name="accessibility_hearingaid_pair_instructions_second_message">Make sure your hearing aids are in pairing mode.</string>
<!-- Summary for the accessibility preference for hearing aid when there is an active device. [CHAR LIMIT=50] --> <!-- Summary for the accessibility preference for hearing aid when there is an active device. [CHAR LIMIT=50] -->
<string name="accessibility_hearingaid_active_device_summary"><xliff:g id="device_name">%1$s</xliff:g> currently active</string> <string name="accessibility_hearingaid_active_device_summary"><xliff:g id="device_name">%1$s</xliff:g> active</string>
<!-- Summary for the accessibility preference for hearing aid when there are saved devices. [CHAR LIMIT=50] --> <!-- Summary for the accessibility preference for hearing aid when there are saved devices. [CHAR LIMIT=50] -->
<plurals name="show_number_hearingaid_count"> <plurals name="show_number_hearingaid_count">
<item quantity="one"><xliff:g id="number_device_count">%1$d</xliff:g> saved hearing aid</item> <item quantity="one"><xliff:g id="number_device_count">%1$d</xliff:g> saved hearing aid</item>
@@ -5850,6 +5850,10 @@
<string name="sms_access_restriction_enabled">Restrict SMS &amp; call log access</string> <string name="sms_access_restriction_enabled">Restrict SMS &amp; call log access</string>
<!-- Summary for whether to enable SMS access restriction [CHAR LIMIT=NONE]--> <!-- Summary for whether to enable SMS access restriction [CHAR LIMIT=NONE]-->
<string name="sms_access_restriction_enabled_summary">Only default phone and messaging apps have SMS &amp; call log permissions</string> <string name="sms_access_restriction_enabled_summary">Only default phone and messaging apps have SMS &amp; call log permissions</string>
<!-- Title for the new device identifier access restrictions [CHAR LIMIT=50]-->
<string name="device_identifier_access_restrictions_title">Enable device identifier restrictions</string>
<!-- Summary for the new device identifier access restrictions [CHAR LIMIT=NONE]-->
<string name="device_identifier_access_restrictions_summary">Enable the new access restrictions for device identifiers.</string>
<!-- Message when there are no available trust agents to display --> <!-- Message when there are no available trust agents to display -->
@@ -10270,11 +10274,11 @@
<!-- Summary for battery Suggestion. [CHAR LIMIT=55] --> <!-- Summary for battery Suggestion. [CHAR LIMIT=55] -->
<string name="battery_suggestion_summary"></string> <string name="battery_suggestion_summary"></string>
<!-- Title for prevent ringing gesture screen --> <!-- Title for prevent ringing gesture screen [CHAR LIMIT=60]-->
<string name="gesture_prevent_ringing_screen_title">Prevent ringing</string> <string name="gesture_prevent_ringing_screen_title">Prevent ringing</string>
<!-- Title for prevent ringing setting --> <!-- Title for prevent ringing setting [CHAR LIMIT=60]-->
<string name="gesture_prevent_ringing_title">Press Power &amp; Volume Up together to</string> <string name="gesture_prevent_ringing_title">Press Power &amp; Volume Up together to</string>
<!-- Title for prevent ringing setting --> <!-- Title for prevent ringing setting [CHAR LIMIT=60]-->
<string name="gesture_prevent_ringing_sound_title">Shortcut to prevent ringing</string> <string name="gesture_prevent_ringing_sound_title">Shortcut to prevent ringing</string>
<!-- Option for prevent ringing setting --> <!-- Option for prevent ringing setting -->
<string name="prevent_ringing_option_vibrate">Vibrate</string> <string name="prevent_ringing_option_vibrate">Vibrate</string>

View File

@@ -114,6 +114,17 @@
android:key="quick_settings_tiles" android:key="quick_settings_tiles"
android:title="@string/quick_settings_developer_tiles" android:title="@string/quick_settings_developer_tiles"
android:fragment="com.android.settings.development.qstile.DevelopmentTileConfigFragment" /> android:fragment="com.android.settings.development.qstile.DevelopmentTileConfigFragment" />
<!-- Configure trust agent behavior -->
<SwitchPreference
android:key="security_setting_trust_agents_extend_unlock"
android:title="@string/trust_agents_extend_unlock_title"
android:summary="@string/trust_agents_extend_unlock_summary" />
<SwitchPreference
android:key="security_setting_trust_lost_locks_screen"
android:title="@string/trust_lost_locks_screen_title"
android:summary="@string/trust_lost_locks_screen_summary" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
@@ -529,6 +540,11 @@
android:key="sms_access_restriction_enabled" android:key="sms_access_restriction_enabled"
android:title="@string/sms_access_restriction_enabled" android:title="@string/sms_access_restriction_enabled"
android:summary="@string/sms_access_restriction_enabled_summary" /> android:summary="@string/sms_access_restriction_enabled_summary" />
<SwitchPreference
android:key="device_identifier_access_restrictions"
android:title="@string/device_identifier_access_restrictions_title"
android:summary="@string/device_identifier_access_restrictions_summary" />
</PreferenceCategory> </PreferenceCategory>
<com.android.settings.development.autofill.AutofillPreferenceCategory <com.android.settings.development.autofill.AutofillPreferenceCategory

View File

@@ -28,7 +28,7 @@
<PreferenceCategory <PreferenceCategory
android:key="location_advanced_settings" android:key="location_advanced_settings"
settings:initialExpandedChildrenCount="0"> settings:initialExpandedChildrenCount="2">
<!-- This preference category gets removed if new_recent_location_ui is disabled --> <!-- This preference category gets removed if new_recent_location_ui is disabled -->
<Preference <Preference

View File

@@ -40,17 +40,4 @@
android:key="power_button_instantly_locks" android:key="power_button_instantly_locks"
android:title="@string/lockpattern_settings_enable_power_button_instantly_locks" /> android:title="@string/lockpattern_settings_enable_power_button_instantly_locks" />
<!-- Temporarily available to evaluate extend unlock mode for SmartLock -->
<SwitchPreference
android:key="security_setting_trust_agents_extend_unlock"
android:title="@string/trust_agents_extend_unlock_title"
android:summary="@string/trust_agents_extend_unlock_summary"
settings:controller="com.android.settings.security.trustagent.TrustAgentsExtendUnlockPreferenceController" />
<SwitchPreference
android:key="security_setting_trust_lost_locks_screen"
android:title="@string/trust_lost_locks_screen_title"
android:summary="@string/trust_lost_locks_screen_summary"
settings:controller="com.android.settings.security.trustagent.TrustLostLocksScreenPreferenceController" />
</PreferenceScreen> </PreferenceScreen>

View File

@@ -89,7 +89,7 @@ public class AppDataUsagePreferenceController extends AppInfoPreferenceControlle
public Loader<List<NetworkCycleDataForUid>> onCreateLoader(int id, Bundle args) { public Loader<List<NetworkCycleDataForUid>> onCreateLoader(int id, Bundle args) {
final NetworkTemplate template = getTemplate(mContext); final NetworkTemplate template = getTemplate(mContext);
return NetworkCycleDataForUidLoader.builder(mContext) return NetworkCycleDataForUidLoader.builder(mContext)
.setUid(mParent.getAppEntry().info.uid) .addUid(mParent.getAppEntry().info.uid)
.setRetrieveDetail(false) .setRetrieveDetail(false)
.setNetworkTemplate(template) .setNetworkTemplate(template)
.setSubscriberId(template.getSubscriberId()) .setSubscriberId(template.getSubscriberId())

View File

@@ -46,7 +46,7 @@ import com.android.settings.R;
import com.android.settings.SettingsActivity; import com.android.settings.SettingsActivity;
import com.android.settings.dashboard.profileselector.ProfileSelectDialog; import com.android.settings.dashboard.profileselector.ProfileSelectDialog;
import com.android.settings.overlay.FeatureFactory; import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.RoundedHomepageIcon; import com.android.settings.widget.AdaptiveHomepageIcon;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.drawer.DashboardCategory; import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile; import com.android.settingslib.drawer.Tile;
@@ -197,8 +197,8 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
Drawable iconDrawable = tileIcon.loadDrawable(preference.getContext()); Drawable iconDrawable = tileIcon.loadDrawable(preference.getContext());
if (forceRoundedIcon if (forceRoundedIcon
&& !TextUtils.equals(mContext.getPackageName(), tile.getPackageName())) { && !TextUtils.equals(mContext.getPackageName(), tile.getPackageName())) {
iconDrawable = new RoundedHomepageIcon(mContext, iconDrawable); iconDrawable = new AdaptiveHomepageIcon(mContext, iconDrawable);
((RoundedHomepageIcon) iconDrawable).setBackgroundColor(mContext, tile); ((AdaptiveHomepageIcon) iconDrawable).setBackgroundColor(mContext, tile);
} }
preference.setIcon(iconDrawable); preference.setIcon(iconDrawable);
} else if (tile.getMetaData() != null } else if (tile.getMetaData() != null

View File

@@ -94,10 +94,12 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
private SpinnerPreference mCycle; private SpinnerPreference mCycle;
private RestrictedSwitchPreference mUnrestrictedData; private RestrictedSwitchPreference mUnrestrictedData;
private DataSaverBackend mDataSaverBackend; private DataSaverBackend mDataSaverBackend;
private Context mContext;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
mContext = getContext();
mPackageManager = getPackageManager(); mPackageManager = getPackageManager();
final Bundle args = getArguments(); final Bundle args = getArguments();
@@ -105,9 +107,8 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
mTemplate = (args != null) ? (NetworkTemplate) args.getParcelable(ARG_NETWORK_TEMPLATE) mTemplate = (args != null) ? (NetworkTemplate) args.getParcelable(ARG_NETWORK_TEMPLATE)
: null; : null;
if (mTemplate == null) { if (mTemplate == null) {
Context context = getContext(); mTemplate = DataUsageUtils.getDefaultTemplate(mContext,
mTemplate = DataUsageUtils.getDefaultTemplate(context, DataUsageUtils.getDefaultSubscriptionId(mContext));
DataUsageUtils.getDefaultSubscriptionId(context));
} }
if (mAppItem == null) { if (mAppItem == null) {
int uid = (args != null) ? args.getInt(AppInfoBase.ARG_PACKAGE_UID, -1) int uid = (args != null) ? args.getInt(AppInfoBase.ARG_PACKAGE_UID, -1)
@@ -131,7 +132,7 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
mBackgroundUsage = findPreference(KEY_BACKGROUND_USAGE); mBackgroundUsage = findPreference(KEY_BACKGROUND_USAGE);
mCycle = (SpinnerPreference) findPreference(KEY_CYCLE); mCycle = (SpinnerPreference) findPreference(KEY_CYCLE);
mCycleAdapter = new CycleAdapter(getContext(), mCycle, mCycleListener); mCycleAdapter = new CycleAdapter(mContext, mCycle, mCycleListener);
if (mAppItem.key > 0) { if (mAppItem.key > 0) {
if (mPackages.size() != 0) { if (mPackages.size() != 0) {
@@ -155,7 +156,7 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
KEY_UNRESTRICTED_DATA); KEY_UNRESTRICTED_DATA);
mUnrestrictedData.setOnPreferenceChangeListener(this); mUnrestrictedData.setOnPreferenceChangeListener(this);
} }
mDataSaverBackend = new DataSaverBackend(getContext()); mDataSaverBackend = new DataSaverBackend(mContext);
mAppSettings = findPreference(KEY_APP_SETTINGS); mAppSettings = findPreference(KEY_APP_SETTINGS);
mAppSettingsIntent = new Intent(Intent.ACTION_MANAGE_NETWORK_USAGE); mAppSettingsIntent = new Intent(Intent.ACTION_MANAGE_NETWORK_USAGE);
@@ -256,7 +257,7 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
private void updatePrefs(boolean restrictBackground, boolean unrestrictData) { private void updatePrefs(boolean restrictBackground, boolean unrestrictData) {
final EnforcedAdmin admin = RestrictedLockUtilsInternal.checkIfMeteredDataRestricted( final EnforcedAdmin admin = RestrictedLockUtilsInternal.checkIfMeteredDataRestricted(
getContext(), mPackageName, UserHandle.getUserId(mAppItem.key)); mContext, mPackageName, UserHandle.getUserId(mAppItem.key));
if (mRestrictBackground != null) { if (mRestrictBackground != null) {
mRestrictBackground.setChecked(!restrictBackground); mRestrictBackground.setChecked(!restrictBackground);
mRestrictBackground.setDisabledByAdmin(admin); mRestrictBackground.setDisabledByAdmin(admin);
@@ -294,11 +295,10 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
foregroundBytes = data.getForegroudUsage(); foregroundBytes = data.getForegroudUsage();
} }
final long totalBytes = backgroundBytes + foregroundBytes; final long totalBytes = backgroundBytes + foregroundBytes;
final Context context = getContext();
mTotalUsage.setSummary(DataUsageUtils.formatDataUsage(context, totalBytes)); mTotalUsage.setSummary(DataUsageUtils.formatDataUsage(mContext, totalBytes));
mForegroundUsage.setSummary(DataUsageUtils.formatDataUsage(context, foregroundBytes)); mForegroundUsage.setSummary(DataUsageUtils.formatDataUsage(mContext, foregroundBytes));
mBackgroundUsage.setSummary(DataUsageUtils.formatDataUsage(context, backgroundBytes)); mBackgroundUsage.setSummary(DataUsageUtils.formatDataUsage(mContext, backgroundBytes));
} }
private boolean getAppRestrictBackground() { private boolean getAppRestrictBackground() {
@@ -364,16 +364,24 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
} }
}; };
private final LoaderManager.LoaderCallbacks<List<NetworkCycleDataForUid>> mUidDataCallbacks = @VisibleForTesting
final LoaderManager.LoaderCallbacks<List<NetworkCycleDataForUid>> mUidDataCallbacks =
new LoaderManager.LoaderCallbacks<List<NetworkCycleDataForUid>>() { new LoaderManager.LoaderCallbacks<List<NetworkCycleDataForUid>>() {
@Override @Override
public Loader<List<NetworkCycleDataForUid>> onCreateLoader(int id, Bundle args) { public Loader<List<NetworkCycleDataForUid>> onCreateLoader(int id, Bundle args) {
return NetworkCycleDataForUidLoader.builder(getContext()) final NetworkCycleDataForUidLoader.Builder builder
.setUid(mAppItem.key) = NetworkCycleDataForUidLoader.builder(mContext);
.setRetrieveDetail(true) builder.setRetrieveDetail(true)
.setNetworkTemplate(mTemplate) .setNetworkTemplate(mTemplate)
.setSubscriberId(mTemplate.getSubscriberId()) .setSubscriberId(mTemplate.getSubscriberId());
.build(); if (mAppItem.category == AppItem.CATEGORY_USER) {
for (int i = 0; i < mAppItem.uids.size(); i++) {
builder.addUid(mAppItem.uids.keyAt(i));
}
} else {
builder.addUid(mAppItem.key);
}
return builder.build();
} }
@Override @Override

View File

@@ -478,6 +478,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
controllers.add(new FreeformWindowsPreferenceController(context)); controllers.add(new FreeformWindowsPreferenceController(context));
controllers.add(new DesktopModePreferenceController(context)); controllers.add(new DesktopModePreferenceController(context));
controllers.add(new SmsAccessRestrictionPreferenceController(context)); controllers.add(new SmsAccessRestrictionPreferenceController(context));
controllers.add(new DeviceIdentifierAccessRestrictionsPreferenceController(context));
controllers.add(new ShortcutManagerThrottlingPreferenceController(context)); controllers.add(new ShortcutManagerThrottlingPreferenceController(context));
controllers.add(new EnableGnssRawMeasFullTrackingPreferenceController(context)); controllers.add(new EnableGnssRawMeasFullTrackingPreferenceController(context));
controllers.add(new DefaultLaunchPreferenceController(context, "running_apps")); controllers.add(new DefaultLaunchPreferenceController(context, "running_apps"));
@@ -497,6 +498,8 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
"android.theme.customization.font")); "android.theme.customization.font"));
controllers.add(new OverlayCategoryPreferenceController(context, controllers.add(new OverlayCategoryPreferenceController(context,
"android.theme.customization.adaptive_icon_shape")); "android.theme.customization.adaptive_icon_shape"));
controllers.add(new TrustAgentsExtendUnlockPreferenceController(context));
controllers.add(new TrustLostLocksScreenPreferenceController(context));
return controllers; return controllers;
} }

View File

@@ -0,0 +1,70 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.development;
import android.content.Context;
import android.provider.DeviceConfig;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class DeviceIdentifierAccessRestrictionsPreferenceController
extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String DEVICE_IDENTIFIER_ACCESS_RESTRICTIONS_KEY =
"device_identifier_access_restrictions";
public DeviceIdentifierAccessRestrictionsPreferenceController(Context context) {
super(context);
}
@Override
public String getPreferenceKey() {
return DEVICE_IDENTIFIER_ACCESS_RESTRICTIONS_KEY;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
writeSetting((boolean) newValue);
return true;
}
private void writeSetting(boolean isEnabled) {
DeviceConfig.setProperty(DeviceConfig.Privacy.NAMESPACE,
DeviceConfig.Privacy.PROPERTY_DEVICE_IDENTIFIER_ACCESS_RESTRICTIONS_DISABLED,
String.valueOf(!isEnabled), false);
}
@Override
public void updateState(Preference preference) {
boolean isEnabled = !Boolean.parseBoolean(
DeviceConfig.getProperty(DeviceConfig.Privacy.NAMESPACE,
DeviceConfig.Privacy.PROPERTY_DEVICE_IDENTIFIER_ACCESS_RESTRICTIONS_DISABLED));
((SwitchPreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeSetting(true);
((SwitchPreference) mPreference).setChecked(true);
}
}

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.development;
import android.content.Context;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class TrustAgentsExtendUnlockPreferenceController extends
DeveloperOptionsPreferenceController implements
Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String KEY_TRUST_AGENTS_EXTEND_UNLOCK =
"security_setting_trust_agents_extend_unlock";
public TrustAgentsExtendUnlockPreferenceController(Context context) {
super(context);
}
@Override
public String getPreferenceKey() {
return KEY_TRUST_AGENTS_EXTEND_UNLOCK;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.TRUST_AGENTS_EXTEND_UNLOCK, isEnabled ? 1 : 0);
return true;
}
@Override
public void updateState(Preference preference) {
int trustAgentsExtendUnlock = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.TRUST_AGENTS_EXTEND_UNLOCK, 0);
((SwitchPreference) mPreference).setChecked(trustAgentsExtendUnlock != 0);
}
}

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.development;
import android.content.Context;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class TrustLostLocksScreenPreferenceController
extends DeveloperOptionsPreferenceController implements
Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String KEY_TRUST_LOST_LOCKS_SCREEN =
"security_setting_trust_lost_locks_screen";
public TrustLostLocksScreenPreferenceController(Context context) {
super(context);
}
@Override
public String getPreferenceKey() {
return KEY_TRUST_LOST_LOCKS_SCREEN;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_WHEN_TRUST_LOST, isEnabled ? 1 : 0);
return true;
}
@Override
public void updateState(Preference preference) {
int lockOnTrustLost = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_WHEN_TRUST_LOST, 0);
((SwitchPreference) mPreference).setChecked(lockOnTrustLost != 0);
}
}

View File

@@ -0,0 +1,43 @@
package com.android.settings.homepage;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.graphics.Path;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.PathShape;
import android.util.AttributeSet;
import android.util.PathParser;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
/**
* Draws a filled {@link ShapeDrawable} using the path from {@link AdaptiveIconDrawable}.
*/
public class AdaptiveIconShapeDrawable extends ShapeDrawable {
public AdaptiveIconShapeDrawable() {
super();
}
public AdaptiveIconShapeDrawable(Resources resources) {
super();
init(resources);
}
@Override
public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme)
throws XmlPullParserException, IOException {
super.inflate(r, parser, attrs, theme);
init(r);
}
private void init(Resources resources) {
final float pathSize = AdaptiveIconDrawable.MASK_SIZE;
final Path path = new Path(PathParser.createPathFromPathData(
resources.getString(com.android.internal.R.string.config_icon_mask)));
setShape(new PathShape(path, pathSize, pathSize));
}
}

View File

@@ -154,7 +154,7 @@ public class UserDictionarySettings extends ListFragment implements Instrumentab
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
MenuItem actionItem = MenuItem actionItem =
menu.add(0, OPTIONS_MENU_ADD, 0, R.string.user_dict_settings_add_menu_title) menu.add(0, OPTIONS_MENU_ADD, 0, R.string.user_dict_settings_add_menu_title)
.setIcon(R.drawable.ic_menu_add_white); .setIcon(R.drawable.ic_menu_add);
actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM |
MenuItem.SHOW_AS_ACTION_WITH_TEXT); MenuItem.SHOW_AS_ACTION_WITH_TEXT);
} }

View File

@@ -18,6 +18,7 @@ import static java.util.concurrent.TimeUnit.DAYS;
import android.Manifest; import android.Manifest;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.provider.DeviceConfig;
import android.view.View; import android.view.View;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
@@ -60,7 +61,9 @@ public class RecentLocationAccessPreferenceController extends AbstractPreference
@Override @Override
public boolean isAvailable() { public boolean isAvailable() {
return true; return Boolean.parseBoolean(
DeviceConfig.getProperty(DeviceConfig.Privacy.NAMESPACE,
DeviceConfig.Privacy.PROPERTY_PERMISSIONS_HUB_ENABLED));
} }
@Override @Override

View File

@@ -351,7 +351,7 @@ public class ApnSettings extends RestrictedSettingsFragment
if (mAllowAddingApns) { if (mAllowAddingApns) {
menu.add(0, MENU_NEW, 0, menu.add(0, MENU_NEW, 0,
getResources().getString(R.string.menu_new)) getResources().getString(R.string.menu_new))
.setIcon(R.drawable.ic_menu_add_white) .setIcon(R.drawable.ic_menu_add)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
} }
menu.add(0, MENU_RESTORE, 0, menu.add(0, MENU_RESTORE, 0,

View File

@@ -26,6 +26,7 @@ import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.permission.PermissionControllerManager; import android.permission.PermissionControllerManager;
import android.permission.RuntimePermissionUsageInfo; import android.permission.RuntimePermissionUsageInfo;
import android.provider.DeviceConfig;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
@@ -38,6 +39,7 @@ import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.widget.BarChartInfo; import com.android.settingslib.widget.BarChartInfo;
import com.android.settingslib.widget.BarChartPreference; import com.android.settingslib.widget.BarChartPreference;
import com.android.settingslib.widget.BarViewInfo; import com.android.settingslib.widget.BarViewInfo;
import com.android.settingslib.Utils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
@@ -62,7 +64,10 @@ public class PermissionBarChartPreferenceController extends BasePreferenceContro
@Override @Override
public int getAvailabilityStatus() { public int getAvailabilityStatus() {
return AVAILABLE_UNSEARCHABLE; return Boolean.parseBoolean(
DeviceConfig.getProperty(DeviceConfig.Privacy.NAMESPACE,
DeviceConfig.Privacy.PROPERTY_PERMISSIONS_HUB_ENABLED)) ?
AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE;
} }
@Override @Override
@@ -143,6 +148,7 @@ public class PermissionBarChartPreferenceController extends BasePreferenceContro
try { try {
icon = mPackageManager.getPermissionGroupInfo(permissionGroup.toString(), 0) icon = mPackageManager.getPermissionGroupInfo(permissionGroup.toString(), 0)
.loadIcon(mPackageManager); .loadIcon(mPackageManager);
icon.setTintList(Utils.getColorAttr(mContext, android.R.attr.textColorSecondary));
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, "Cannot find group icon for " + permissionGroup, e); Log.w(TAG, "Cannot find group icon for " + permissionGroup, e);
} }

View File

@@ -1,47 +0,0 @@
/*
* 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.security.trustagent;
import android.content.Context;
import android.provider.Settings;
import com.android.settings.core.TogglePreferenceController;
public class TrustAgentsExtendUnlockPreferenceController extends TogglePreferenceController {
public TrustAgentsExtendUnlockPreferenceController(Context context, String key) {
super(context, key);
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
@Override
public boolean isChecked() {
return Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.TRUST_AGENTS_EXTEND_UNLOCK, 1) == 1;
}
@Override
public boolean setChecked(boolean isChecked) {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.TRUST_AGENTS_EXTEND_UNLOCK, isChecked ? 1 : 0);
return true;
}
}

View File

@@ -1,47 +0,0 @@
/*
* 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.security.trustagent;
import android.content.Context;
import android.provider.Settings;
import com.android.settings.core.TogglePreferenceController;
public class TrustLostLocksScreenPreferenceController extends TogglePreferenceController {
public TrustLostLocksScreenPreferenceController(Context context, String key) {
super(context, key);
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
@Override
public boolean isChecked() {
return Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_WHEN_TRUST_LOST, 1) == 1;
}
@Override
public boolean setChecked(boolean isChecked) {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_WHEN_TRUST_LOST, isChecked ? 1 : 0);
return true;
}
}

View File

@@ -75,9 +75,10 @@ public class SlicesDatabaseAccessor {
if (pathData == null) { if (pathData == null) {
throw new IllegalStateException("Invalid Slices uri: " + uri); throw new IllegalStateException("Invalid Slices uri: " + uri);
} }
Cursor cursor = getIndexedSliceData(pathData.second /* key */); try (Cursor cursor = getIndexedSliceData(pathData.second /* key */)) {
return buildSliceData(cursor, uri, pathData.first /* isIntentOnly */); return buildSliceData(cursor, uri, pathData.first /* isIntentOnly */);
} }
}
/** /**
* Query the slices database and return a {@link SliceData} object corresponding to the row * Query the slices database and return a {@link SliceData} object corresponding to the row
@@ -85,9 +86,10 @@ public class SlicesDatabaseAccessor {
* Used when handling the action of the {@link Slice}. * Used when handling the action of the {@link Slice}.
*/ */
public SliceData getSliceDataFromKey(String key) { public SliceData getSliceDataFromKey(String key) {
Cursor cursor = getIndexedSliceData(key); try (Cursor cursor = getIndexedSliceData(key)) {
return buildSliceData(cursor, null /* uri */, false /* isIntentOnly */); return buildSliceData(cursor, null /* uri */, false /* isIntentOnly */);
} }
}
/** /**
* @return a list of keys in the Slices database matching on {@param isPlatformSlice}. * @return a list of keys in the Slices database matching on {@param isPlatformSlice}.

View File

@@ -32,18 +32,19 @@ import android.util.Log;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.homepage.AdaptiveIconShapeDrawable;
import com.android.settingslib.drawer.Tile; import com.android.settingslib.drawer.Tile;
public class RoundedHomepageIcon extends LayerDrawable { public class AdaptiveHomepageIcon extends LayerDrawable {
private static final String TAG = "RoundedHomepageIcon"; private static final String TAG = "AdaptiveHomepageIcon";
@VisibleForTesting(otherwise = NONE) @VisibleForTesting(otherwise = NONE)
int mBackgroundColor = -1; int mBackgroundColor = -1;
public RoundedHomepageIcon(Context context, Drawable foreground) { public AdaptiveHomepageIcon(Context context, Drawable foreground) {
super(new Drawable[]{ super(new Drawable[]{
context.getDrawable(R.drawable.ic_homepage_generic_background), new AdaptiveIconShapeDrawable(context.getResources()),
foreground foreground
}); });
final int insetPx = context.getResources() final int insetPx = context.getResources()

View File

@@ -16,6 +16,8 @@
package com.android.settings.datausage; package com.android.settings.datausage;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt;
@@ -31,7 +33,9 @@ import static org.mockito.Mockito.when;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.NetworkPolicyManager; import android.net.NetworkPolicyManager;
import android.net.NetworkTemplate;
import android.os.Bundle; import android.os.Bundle;
import android.text.format.DateUtils;
import android.util.ArraySet; import android.util.ArraySet;
import android.view.View; import android.view.View;
@@ -47,6 +51,7 @@ import com.android.settingslib.AppItem;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.RestrictedSwitchPreference; import com.android.settingslib.RestrictedSwitchPreference;
import com.android.settingslib.net.NetworkCycleDataForUid; import com.android.settingslib.net.NetworkCycleDataForUid;
import com.android.settingslib.net.NetworkCycleDataForUidLoader;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
@@ -188,7 +193,7 @@ public class AppDataUsageTest {
ReflectionHelpers.setField(mFragment, "mBackgroundUsage", preference); ReflectionHelpers.setField(mFragment, "mBackgroundUsage", preference);
ReflectionHelpers.setField(mFragment, "mForegroundUsage", preference); ReflectionHelpers.setField(mFragment, "mForegroundUsage", preference);
ReflectionHelpers.setField(mFragment, "mTotalUsage", preference); ReflectionHelpers.setField(mFragment, "mTotalUsage", preference);
doReturn(RuntimeEnvironment.application).when(mFragment).getContext(); ReflectionHelpers.setField(mFragment, "mContext", RuntimeEnvironment.application);
mFragment.bindData(0 /* position */); mFragment.bindData(0 /* position */);
@@ -199,7 +204,7 @@ public class AppDataUsageTest {
public void bindData_hasAppUsageData_shouldShowCycleSpinnerAndUpdateUsageSummary() { public void bindData_hasAppUsageData_shouldShowCycleSpinnerAndUpdateUsageSummary() {
mFragment = spy(new AppDataUsage()); mFragment = spy(new AppDataUsage());
final Context context = RuntimeEnvironment.application; final Context context = RuntimeEnvironment.application;
doReturn(context).when(mFragment).getContext(); ReflectionHelpers.setField(mFragment, "mContext", context);
final long backgroundBytes = 1234L; final long backgroundBytes = 1234L;
final long foregroundBytes = 5678L; final long foregroundBytes = 5678L;
final List<NetworkCycleDataForUid> appUsage = new ArrayList<>(); final List<NetworkCycleDataForUid> appUsage = new ArrayList<>();
@@ -223,4 +228,53 @@ public class AppDataUsageTest {
verify(backgroundPref).setSummary(DataUsageUtils.formatDataUsage(context, backgroundBytes)); verify(backgroundPref).setSummary(DataUsageUtils.formatDataUsage(context, backgroundBytes));
verify(foregroundPref).setSummary(DataUsageUtils.formatDataUsage(context, foregroundBytes)); verify(foregroundPref).setSummary(DataUsageUtils.formatDataUsage(context, foregroundBytes));
} }
@Test
public void onCreateLoader_categoryApp_shouldQueryDataUsageUsingAppKey() {
mFragment = new AppDataUsage();
final Context context = RuntimeEnvironment.application;
final int testUid = 123123;
final AppItem appItem = new AppItem(testUid);
appItem.category = AppItem.CATEGORY_APP;
ReflectionHelpers.setField(mFragment, "mContext", context);
ReflectionHelpers.setField(mFragment, "mAppItem", appItem);
ReflectionHelpers.setField(mFragment, "mTemplate",
NetworkTemplate.buildTemplateWifiWildcard());
final long end = System.currentTimeMillis();
final long start = end - (DateUtils.WEEK_IN_MILLIS * 4);
final NetworkCycleDataForUidLoader loader = (NetworkCycleDataForUidLoader)
mFragment.mUidDataCallbacks.onCreateLoader(0, Bundle.EMPTY);
final List<Integer> uids = loader.getUids();
assertThat(uids).hasSize(1);
assertThat(uids.get(0)).isEqualTo(testUid);
}
@Test
public void onCreateLoader_categoryUser_shouldQueryDataUsageUsingAssociatedUids() {
mFragment = new AppDataUsage();
final Context context = RuntimeEnvironment.application;
final int testUserId = 11;
final AppItem appItem = new AppItem(testUserId);
appItem.category = AppItem.CATEGORY_USER;
appItem.addUid(123);
appItem.addUid(456);
appItem.addUid(789);
ReflectionHelpers.setField(mFragment, "mContext", context);
ReflectionHelpers.setField(mFragment, "mAppItem", appItem);
ReflectionHelpers.setField(mFragment, "mTemplate",
NetworkTemplate.buildTemplateWifiWildcard());
final long end = System.currentTimeMillis();
final long start = end - (DateUtils.WEEK_IN_MILLIS * 4);
final NetworkCycleDataForUidLoader loader = (NetworkCycleDataForUidLoader)
mFragment.mUidDataCallbacks.onCreateLoader(0, Bundle.EMPTY);
final List<Integer> uids = loader.getUids();
assertThat(uids).hasSize(3);
assertThat(uids.get(0)).isEqualTo(123);
assertThat(uids.get(1)).isEqualTo(456);
assertThat(uids.get(2)).isEqualTo(789);
}
} }

View File

@@ -24,6 +24,7 @@ import static org.mockito.Mockito.when;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.provider.DeviceConfig;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
@@ -32,9 +33,11 @@ import android.widget.TextView;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
import com.android.settingslib.location.RecentLocationAccesses; import com.android.settingslib.location.RecentLocationAccesses;
import com.android.settingslib.widget.LayoutPreference; import com.android.settingslib.widget.LayoutPreference;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
@@ -43,11 +46,13 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner; import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment; import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowDeviceConfig.class})
public class RecentLocationAccessPreferenceControllerTest { public class RecentLocationAccessPreferenceControllerTest {
@Mock @Mock
private LayoutPreference mLayoutPreference; private LayoutPreference mLayoutPreference;
@@ -76,6 +81,25 @@ public class RecentLocationAccessPreferenceControllerTest {
mAppEntitiesHeaderView); mAppEntitiesHeaderView);
} }
@After
public void tearDown() {
ShadowDeviceConfig.reset();
}
@Test
public void isAvailable_permissionHubNotSet_shouldReturnFalse() {
// We have not yet set the property to show the Permissions Hub.
assertThat(mController.isAvailable()).isEqualTo(false);
}
@Test
public void isAvailable_permissionHubEnabled_shouldReturnTrue() {
DeviceConfig.setProperty(DeviceConfig.Privacy.NAMESPACE,
DeviceConfig.Privacy.PROPERTY_PERMISSIONS_HUB_ENABLED, "true", true);
assertThat(mController.isAvailable()).isEqualTo(true);
}
/** Verifies the title text, details text are correct, and the click listener is set. */ /** Verifies the title text, details text are correct, and the click listener is set. */
@Test @Test
@Ignore @Ignore

View File

@@ -17,6 +17,7 @@
package com.android.settings.privacy; package com.android.settings.privacy;
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE; import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
@@ -28,13 +29,16 @@ import static org.mockito.Mockito.when;
import android.content.Context; import android.content.Context;
import android.permission.RuntimePermissionUsageInfo; import android.permission.RuntimePermissionUsageInfo;
import android.provider.DeviceConfig;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
import com.android.settingslib.widget.BarChartInfo; import com.android.settingslib.widget.BarChartInfo;
import com.android.settingslib.widget.BarChartPreference; import com.android.settingslib.widget.BarChartPreference;
import com.android.settingslib.widget.BarViewInfo; import com.android.settingslib.widget.BarViewInfo;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@@ -42,11 +46,13 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner; import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment; import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowDeviceConfig.class})
public class PermissionBarChartPreferenceControllerTest { public class PermissionBarChartPreferenceControllerTest {
@Mock @Mock
@@ -65,8 +71,22 @@ public class PermissionBarChartPreferenceControllerTest {
.thenReturn((BarChartPreference) mPreference); .thenReturn((BarChartPreference) mPreference);
} }
@After
public void tearDown() {
ShadowDeviceConfig.reset();
}
@Test @Test
public void getAvailabilityStatus_shouldReturnAvailableUnsearchable() { public void getAvailabilityStatus_permissionHubNotSet_shouldReturnUnsupported() {
// We have not yet set the property to show the Permissions Hub.
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
}
@Test
public void getAvailabilityStatus_permissionHubEnabled_shouldReturnAvailableUnsearchable() {
DeviceConfig.setProperty(DeviceConfig.Privacy.NAMESPACE,
DeviceConfig.Privacy.PROPERTY_PERMISSIONS_HUB_ENABLED, "true", true);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE); assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
} }

View File

@@ -19,21 +19,32 @@ package com.android.settings.testutils.shadow;
import org.robolectric.annotation.Config; import org.robolectric.annotation.Config;
import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements; import org.robolectric.annotation.Implements;
import org.robolectric.annotation.Resetter;
import java.util.HashMap;
import java.util.Map;
@Implements(android.provider.DeviceConfig.class) @Implements(android.provider.DeviceConfig.class)
public class ShadowDeviceConfig { public class ShadowDeviceConfig {
private static String configValue; private static Map<String, String> sPropertyMaps = new HashMap<>();
@Resetter
public static void reset() {
sPropertyMaps.clear();
}
@Implementation @Implementation
protected static boolean setProperty( public static boolean setProperty(
String namespace, String name, String value, boolean makeDefault) { String namespace, String name, String value, boolean makeDefault) {
configValue = value; sPropertyMaps.put(name, value);
return true; return true;
} }
@Implementation @Implementation
protected static String getProperty(String ns, String key) { return configValue; } public static String getProperty(String namespace, String name) {
return sPropertyMaps.get(name);
}
} }

View File

@@ -37,9 +37,9 @@ import android.graphics.drawable.ShapeDrawable;
import android.os.Bundle; import android.os.Bundle;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.homepage.AdaptiveIconShapeDrawable;
import com.android.settingslib.drawer.CategoryKey; import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.drawer.Tile; import com.android.settingslib.drawer.Tile;
import com.android.settingslib.testutils.DrawableTestHelper;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -48,7 +48,7 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment; import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public class RoundedHomepageIconTest { public class AdaptiveHomepageIconTest {
private Context mContext; private Context mContext;
private ActivityInfo mActivityInfo; private ActivityInfo mActivityInfo;
@@ -64,18 +64,17 @@ public class RoundedHomepageIconTest {
@Test @Test
public void createIcon_shouldSetBackgroundAndInset() { public void createIcon_shouldSetBackgroundAndInset() {
final RoundedHomepageIcon icon = final AdaptiveHomepageIcon icon =
new RoundedHomepageIcon(mContext, new ColorDrawable(Color.BLACK)); new AdaptiveHomepageIcon(mContext, new ColorDrawable(Color.BLACK));
assertThat(icon.getNumberOfLayers()).isEqualTo(2); assertThat(icon.getNumberOfLayers()).isEqualTo(2);
DrawableTestHelper.assertDrawableResId(icon.getDrawable(0), assertThat(icon.getDrawable(0)).isInstanceOf(AdaptiveIconShapeDrawable.class);
R.drawable.ic_homepage_generic_background);
} }
@Test @Test
public void setBackgroundColor_shouldUpdateColorFilter() { public void setBackgroundColor_shouldUpdateColorFilter() {
final RoundedHomepageIcon icon = final AdaptiveHomepageIcon icon =
spy(new RoundedHomepageIcon(mContext, new ColorDrawable(Color.BLACK))); spy(new AdaptiveHomepageIcon(mContext, new ColorDrawable(Color.BLACK)));
final ShapeDrawable background = mock(ShapeDrawable.class); final ShapeDrawable background = mock(ShapeDrawable.class);
when(icon.getDrawable(0)).thenReturn(background); when(icon.getDrawable(0)).thenReturn(background);
@@ -90,8 +89,8 @@ public class RoundedHomepageIconTest {
mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON_BACKGROUND_ARGB, 0xff0000); mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON_BACKGROUND_ARGB, 0xff0000);
doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings)) doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings))
.when(tile).getIcon(mContext); .when(tile).getIcon(mContext);
final RoundedHomepageIcon icon = final AdaptiveHomepageIcon icon =
new RoundedHomepageIcon(mContext, new ColorDrawable(Color.BLACK)); new AdaptiveHomepageIcon(mContext, new ColorDrawable(Color.BLACK));
icon.setBackgroundColor(mContext, tile); icon.setBackgroundColor(mContext, tile);
assertThat(icon.mBackgroundColor).isEqualTo(0xff0000); assertThat(icon.mBackgroundColor).isEqualTo(0xff0000);
@@ -105,8 +104,8 @@ public class RoundedHomepageIconTest {
doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings)) doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings))
.when(tile).getIcon(mContext); .when(tile).getIcon(mContext);
final RoundedHomepageIcon icon = final AdaptiveHomepageIcon icon =
new RoundedHomepageIcon(mContext, new ColorDrawable(Color.BLACK)); new AdaptiveHomepageIcon(mContext, new ColorDrawable(Color.BLACK));
icon.setBackgroundColor(mContext, tile); icon.setBackgroundColor(mContext, tile);
assertThat(icon.mBackgroundColor) assertThat(icon.mBackgroundColor)