Snap for 5127330 from 4864624c3d to qt-release
Change-Id: Ie38c0fbb6aa0047419637b02410fcbafe60e0735
This commit is contained in:
@@ -1245,6 +1245,22 @@
|
||||
column="5"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="HardCodedColor"
|
||||
severity="Error"
|
||||
message="Avoid using hardcoded color"
|
||||
category="Correctness"
|
||||
priority="4"
|
||||
summary="Using hardcoded color"
|
||||
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
|
||||
errorLine1=" <color name="homepage_privacy_background">#1A73E8</color>"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values/colors.xml"
|
||||
line="130"
|
||||
column="5"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="HardCodedColor"
|
||||
severity="Error"
|
||||
@@ -1257,7 +1273,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values/colors.xml"
|
||||
line="134"
|
||||
line="135"
|
||||
column="5"/>
|
||||
</issue>
|
||||
|
||||
@@ -1273,7 +1289,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values/colors.xml"
|
||||
line="135"
|
||||
line="136"
|
||||
column="5"/>
|
||||
</issue>
|
||||
|
||||
@@ -1289,7 +1305,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values/colors.xml"
|
||||
line="136"
|
||||
line="137"
|
||||
column="5"/>
|
||||
</issue>
|
||||
|
||||
@@ -1305,7 +1321,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values/colors.xml"
|
||||
line="137"
|
||||
line="138"
|
||||
column="5"/>
|
||||
</issue>
|
||||
|
||||
@@ -1321,7 +1337,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values/colors.xml"
|
||||
line="138"
|
||||
line="139"
|
||||
column="5"/>
|
||||
</issue>
|
||||
|
||||
@@ -1337,7 +1353,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values/colors.xml"
|
||||
line="139"
|
||||
line="140"
|
||||
column="5"/>
|
||||
</issue>
|
||||
|
||||
@@ -1353,7 +1369,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values/colors.xml"
|
||||
line="142"
|
||||
line="143"
|
||||
column="5"/>
|
||||
</issue>
|
||||
|
||||
@@ -1369,7 +1385,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values/colors.xml"
|
||||
line="143"
|
||||
line="144"
|
||||
column="5"/>
|
||||
</issue>
|
||||
|
||||
@@ -1385,7 +1401,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values/colors.xml"
|
||||
line="144"
|
||||
line="145"
|
||||
column="5"/>
|
||||
</issue>
|
||||
|
||||
@@ -1401,7 +1417,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values/colors.xml"
|
||||
line="145"
|
||||
line="146"
|
||||
column="5"/>
|
||||
</issue>
|
||||
|
||||
@@ -1417,7 +1433,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values/colors.xml"
|
||||
line="146"
|
||||
line="147"
|
||||
column="5"/>
|
||||
</issue>
|
||||
|
||||
@@ -1901,6 +1917,22 @@
|
||||
column="17"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="HardCodedColor"
|
||||
severity="Error"
|
||||
message="Avoid using hardcoded color"
|
||||
category="Correctness"
|
||||
priority="4"
|
||||
summary="Using hardcoded color"
|
||||
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
|
||||
errorLine1=" android:color="@color/homepage_location_background" />"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/drawable/ic_homepage_privacy.xml"
|
||||
line="23"
|
||||
column="17"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="HardCodedColor"
|
||||
severity="Error"
|
||||
|
||||
36
res/drawable/ic_homepage_privacy.xml
Normal file
36
res/drawable/ic_homepage_privacy.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid
|
||||
android:color="@color/homepage_privacy_background"/>
|
||||
<size
|
||||
android:width="@dimen/dashboard_tile_image_size"
|
||||
android:height="@dimen/dashboard_tile_image_size"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:width="@dimen/dashboard_tile_foreground_image_size"
|
||||
android:height="@dimen/dashboard_tile_foreground_image_size"
|
||||
android:start="@dimen/dashboard_tile_foreground_image_inset"
|
||||
android:top="@dimen/dashboard_tile_foreground_image_inset"
|
||||
android:drawable="@drawable/ic_settings_privacy"/>
|
||||
</layer-list>
|
||||
31
res/drawable/ic_settings_privacy.xml
Normal file
31
res/drawable/ic_settings_privacy.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M21.25,16.5v-0.66c0,-1.13 -1.03,-2.09 -2.25,-2.09s-2.25,0.96 -2.25,2.09v0.66H16V22h6v-5.5H21.25zM19.75,16.5h-1.5v-0.66c0,-0.29 0.38,-0.59 0.75,-0.59s0.75,0.3 0.75,0.59V16.5z"/>
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M12,17c-3.79,0 -7.17,-2.13 -8.82,-5.5C4.83,8.13 8.21,6 12,6s7.17,2.13 8.82,5.5H23C21.27,7.11 17,4 12,4S2.73,7.11 1,11.5C2.73,15.89 7,19 12,19c0.68,0 1.35,-0.06 2,-0.17v-2.05C13.35,16.91 12.69,17 12,17z"/>
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M16.43,12.23c0.04,-0.24 0.07,-0.48 0.07,-0.73C16.5,9.02 14.48,7 12,7s-4.5,2.02 -4.5,4.5S9.52,16 12,16c0.77,0 1.48,-0.21 2.12,-0.55C14.41,14.08 15.27,12.93 16.43,12.23zM12,14.2c-1.49,0 -2.7,-1.21 -2.7,-2.7s1.21,-2.7 2.7,-2.7s2.7,1.21 2.7,2.7S13.49,14.2 12,14.2z"/>
|
||||
</vector>
|
||||
@@ -20,6 +20,4 @@
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/horizontal_divider_height"
|
||||
android:layout_marginTop="@dimen/horizontal_divider_margin_top"
|
||||
android:layout_marginBottom="@dimen/horizontal_divider_margin_bottom"
|
||||
android:background="?android:attr/dividerHorizontal"/>
|
||||
@@ -27,5 +27,4 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layoutAnimation="@anim/layout_animation_fall_down"/>
|
||||
|
||||
<include layout="@layout/horizontal_divider"/>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -127,6 +127,7 @@
|
||||
<color name="homepage_generic_icon_background">#1A73E8</color>
|
||||
<color name="homepage_location_background">#2EC7DC</color>
|
||||
<color name="homepage_about_background">#9FA8DA</color>
|
||||
<color name="homepage_privacy_background">#5E97F6</color>
|
||||
<!-- End of dashboard/homepage icon background colors -->
|
||||
|
||||
<color name="glif_error_color">@*android:color/material_red_A700</color>
|
||||
|
||||
@@ -6658,6 +6658,8 @@
|
||||
<string name="help_url_auto_brightness" translatable="false" />
|
||||
<!-- Help URL, Previously connected bluetooth devices [DO NOT TRANSLATE] -->
|
||||
<string name="help_url_previously_connected_devices" translatable="false"></string>
|
||||
<!-- Help URL, Top level privacy settings [DO NOT TRANSLATE] -->
|
||||
<string name="help_url_privacy_dashboard" translatable="false"></string>
|
||||
|
||||
<string name="help_url_network_dashboard" translatable="false"></string>
|
||||
<string name="help_url_connected_devices" translatable="false"></string>
|
||||
@@ -10278,4 +10280,10 @@
|
||||
<string name="force_desktop_mode">Force desktop mode</string>
|
||||
<!-- UI debug setting: force desktop mode summary [CHAR LIMIT=NONE] -->
|
||||
<string name="force_desktop_mode_summary">Force experimental desktop mode on secondary displays</string>
|
||||
|
||||
<!-- Title for the top level Privacy Settings [CHAR LIMIT=30]-->
|
||||
<string name="privacy_dashboard_title">Privacy</string>
|
||||
<!-- Summary for the top level Privacy Settings [CHAR LIMIT=NONE]-->
|
||||
<string name="privacy_dashboard_summary">Permission, permission usage</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -476,13 +476,11 @@
|
||||
<style name="ConditionHalfCardBorderlessButton"
|
||||
parent="@style/ConditionCardBorderlessButton">
|
||||
<item name="android:textAlignment">viewStart</item>
|
||||
<item name="android:paddingStart">0dp</item>
|
||||
</style>
|
||||
|
||||
<style name="ConditionFullCardBorderlessButton"
|
||||
parent="@style/ConditionCardBorderlessButton">
|
||||
<item name="android:textAlignment">viewEnd</item>
|
||||
<item name="android:paddingEnd">0dp</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
45
res/xml/privacy_dashboard_settings.xml
Normal file
45
res/xml/privacy_dashboard_settings.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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="privacy_dashboard_page"
|
||||
android:title="@string/privacy_dashboard_title">
|
||||
|
||||
<Preference
|
||||
android:key="privacy_manage_perms"
|
||||
android:title="@string/app_permissions"
|
||||
settings:keywords="@string/keywords_app_permissions"
|
||||
settings:controller="com.android.settings.applications.AppPermissionsPreferenceController">
|
||||
<intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
|
||||
</Preference>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="show_password"
|
||||
android:title="@string/show_password"
|
||||
android:summary="@string/show_password_summary"
|
||||
settings:controller="com.android.settings.security.ShowPasswordPreferenceController"/>
|
||||
|
||||
<!-- Privacy Service -->
|
||||
<PreferenceCategory
|
||||
android:key="privacy_services"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="dashboard_tile_placeholder"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -89,20 +89,6 @@
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<!-- security_settings_misc.xml -->
|
||||
<PreferenceCategory
|
||||
android:order="30"
|
||||
android:key="security_settings_misc_category"
|
||||
android:title="@string/security_passwords_title">
|
||||
|
||||
<SwitchPreference
|
||||
android:key="show_password"
|
||||
android:title="@string/show_password"
|
||||
android:summary="@string/show_password_summary"
|
||||
settings:controller="com.android.settings.security.ShowPasswordPreferenceController" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:order="40"
|
||||
android:key="security_settings_device_admin_category">
|
||||
|
||||
@@ -82,6 +82,14 @@
|
||||
android:fragment="com.android.settings.deviceinfo.StorageSettings"
|
||||
settings:controller="com.android.settings.deviceinfo.TopLevelStoragePreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:key="top_level_privacy"
|
||||
android:title="@string/privacy_dashboard_title"
|
||||
android:summary="@string/privacy_dashboard_summary"
|
||||
android:icon="@drawable/ic_homepage_privacy"
|
||||
android:order="-55"
|
||||
android:fragment="com.android.settings.privacy.PrivacyDashboardFragment"/>
|
||||
|
||||
<Preference
|
||||
android:key="top_level_location"
|
||||
android:title="@string/location_settings_title"
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.net.ConnectivityManager;
|
||||
import android.net.NetworkPolicyManager;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.net.wifi.p2p.WifiP2pManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.RecoverySystem;
|
||||
@@ -129,6 +130,8 @@ public class ResetNetworkConfirm extends InstrumentedFragment {
|
||||
wifiManager.factoryReset();
|
||||
}
|
||||
|
||||
p2pFactoryReset(context);
|
||||
|
||||
TelephonyManager telephonyManager = (TelephonyManager)
|
||||
context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
if (telephonyManager != null) {
|
||||
@@ -180,6 +183,20 @@ public class ResetNetworkConfirm extends InstrumentedFragment {
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void p2pFactoryReset(Context context) {
|
||||
WifiP2pManager wifiP2pManager = (WifiP2pManager)
|
||||
context.getSystemService(Context.WIFI_P2P_SERVICE);
|
||||
if (wifiP2pManager != null) {
|
||||
WifiP2pManager.Channel channel = wifiP2pManager.initialize(
|
||||
context.getApplicationContext(), context.getMainLooper(),
|
||||
null /* listener */);
|
||||
if (channel != null) {
|
||||
wifiP2pManager.factoryReset(channel, null /* listener */);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore APN settings to default.
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.settings.applications.appinfo;
|
||||
|
||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_OPEN_APP_SETTING;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
@@ -61,8 +62,10 @@ public class AppSettingPreferenceController extends AppInfoPreferenceControllerB
|
||||
return false;
|
||||
}
|
||||
FeatureFactory.getFactory(mContext).getMetricsFeatureProvider()
|
||||
.actionWithSource(mContext, mParent.getMetricsCategory(),
|
||||
ACTION_OPEN_APP_SETTING);
|
||||
.action(SettingsEnums.PAGE_UNKNOWN,
|
||||
ACTION_OPEN_APP_SETTING,
|
||||
mParent.getMetricsCategory(),
|
||||
null, 0);
|
||||
mContext.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SubSettings;
|
||||
import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
public class SubSettingLauncher {
|
||||
|
||||
@@ -150,7 +150,7 @@ public class SubSettingLauncher {
|
||||
if (mLaunchRequest.sourceMetricsCategory < 0) {
|
||||
throw new IllegalArgumentException("Source metrics category must be set");
|
||||
}
|
||||
intent.putExtra(VisibilityLoggerMixin.EXTRA_SOURCE_METRICS_CATEGORY,
|
||||
intent.putExtra(MetricsFeatureProvider.EXTRA_SOURCE_METRICS_CATEGORY,
|
||||
mLaunchRequest.sourceMetricsCategory);
|
||||
|
||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, mLaunchRequest.arguments);
|
||||
|
||||
@@ -112,6 +112,7 @@ import com.android.settings.password.ChooseLockPassword;
|
||||
import com.android.settings.password.ChooseLockPattern;
|
||||
import com.android.settings.print.PrintJobSettingsFragment;
|
||||
import com.android.settings.print.PrintSettingsFragment;
|
||||
import com.android.settings.privacy.PrivacyDashboardFragment;
|
||||
import com.android.settings.security.CryptKeeperSettings;
|
||||
import com.android.settings.security.LockscreenDashboardFragment;
|
||||
import com.android.settings.security.SecuritySettings;
|
||||
@@ -167,6 +168,7 @@ public class SettingsGateway {
|
||||
ProcessStatsUi.class.getName(),
|
||||
NotificationStation.class.getName(),
|
||||
LocationSettings.class.getName(),
|
||||
PrivacyDashboardFragment.class.getName(),
|
||||
ScanningSettings.class.getName(),
|
||||
SecuritySettings.class.getName(),
|
||||
UsageAccessDetails.class.getName(),
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.core.instrumentation;
|
||||
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
public class SettingsMetricsFeatureProvider extends MetricsFeatureProvider {
|
||||
@Override
|
||||
protected void installLogWriters() {
|
||||
super.installLogWriters();
|
||||
mLoggerWriters.add(new StatsLogWriter());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* 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.core.instrumentation;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.util.Pair;
|
||||
import android.util.StatsLog;
|
||||
|
||||
import com.android.settingslib.core.instrumentation.LogWriter;
|
||||
|
||||
public class StatsLogWriter implements LogWriter {
|
||||
|
||||
@Override
|
||||
public void visible(Context context, int attribution, int pageId) {
|
||||
StatsLog.write(StatsLog.SETTINGS_UI_CHANGED /* Atom name */,
|
||||
attribution,
|
||||
SettingsEnums.PAGE_VISIBLE /* action */,
|
||||
pageId,
|
||||
null /* changedPreferenceKey */,
|
||||
0 /* changedPreferenceIntValue */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hidden(Context context, int pageId) {
|
||||
StatsLog.write(StatsLog.SETTINGS_UI_CHANGED /* Atom name */,
|
||||
SettingsEnums.PAGE_UNKNOWN /* attribution */,
|
||||
SettingsEnums.PAGE_HIDE /* action */,
|
||||
pageId,
|
||||
null /* changedPreferenceKey */,
|
||||
0 /* changedPreferenceIntValue */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Context context, int action, Pair<Integer, Object>... taggedData) {
|
||||
action(SettingsEnums.PAGE_UNKNOWN /* attribution */,
|
||||
action,
|
||||
SettingsEnums.PAGE_UNKNOWN /* pageId */,
|
||||
null /* changedPreferenceKey */,
|
||||
0 /* changedPreferenceIntValue */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Context context, int action, int value) {
|
||||
action(SettingsEnums.PAGE_UNKNOWN /* attribution */,
|
||||
action,
|
||||
SettingsEnums.PAGE_UNKNOWN /* pageId */,
|
||||
null /* changedPreferenceKey */,
|
||||
value /* changedPreferenceIntValue */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Context context, int action, boolean value) {
|
||||
action(SettingsEnums.PAGE_UNKNOWN /* attribution */,
|
||||
action,
|
||||
SettingsEnums.PAGE_UNKNOWN /* pageId */,
|
||||
null /* changedPreferenceKey */,
|
||||
value ? 1 : 0 /* changedPreferenceIntValue */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Context context, int action, String pkg,
|
||||
Pair<Integer, Object>... taggedData) {
|
||||
action(SettingsEnums.PAGE_UNKNOWN /* attribution */,
|
||||
action,
|
||||
SettingsEnums.PAGE_UNKNOWN /* pageId */,
|
||||
pkg /* changedPreferenceKey */,
|
||||
1 /* changedPreferenceIntValue */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(int attribution, int action, int pageId, String key, int value) {
|
||||
StatsLog.write(StatsLog.SETTINGS_UI_CHANGED /* atomName */,
|
||||
attribution,
|
||||
action,
|
||||
pageId,
|
||||
key,
|
||||
value);
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,6 @@ import com.android.settings.dashboard.profileselector.ProfileSelectDialog;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.widget.RoundedHomepageIcon;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
|
||||
import com.android.settingslib.drawer.DashboardCategory;
|
||||
import com.android.settingslib.drawer.Tile;
|
||||
import com.android.settingslib.drawer.TileUtils;
|
||||
@@ -126,7 +125,7 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
pref.setFragment(clsName);
|
||||
} else {
|
||||
final Intent intent = new Intent(tile.getIntent());
|
||||
intent.putExtra(VisibilityLoggerMixin.EXTRA_SOURCE_METRICS_CATEGORY,
|
||||
intent.putExtra(MetricsFeatureProvider.EXTRA_SOURCE_METRICS_CATEGORY,
|
||||
sourceMetricsCategory);
|
||||
if (action != null) {
|
||||
intent.setAction(action);
|
||||
@@ -160,7 +159,7 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
return;
|
||||
}
|
||||
final Intent intent = new Intent(tile.getIntent())
|
||||
.putExtra(VisibilityLoggerMixin.EXTRA_SOURCE_METRICS_CATEGORY,
|
||||
.putExtra(MetricsFeatureProvider.EXTRA_SOURCE_METRICS_CATEGORY,
|
||||
MetricsEvent.DASHBOARD_SUMMARY)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
launchIntentOrSelectProfile(activity, tile, intent, MetricsEvent.DASHBOARD_SUMMARY);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.android.settings.dashboard;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Icon;
|
||||
@@ -211,8 +212,9 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
||||
|
||||
@Override
|
||||
public void onExpandButtonClick() {
|
||||
mMetricsFeatureProvider.actionWithSource(getContext(), getMetricsCategory(),
|
||||
MetricsEvent.ACTION_SETTINGS_ADVANCED_BUTTON_EXPAND);
|
||||
mMetricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN,
|
||||
MetricsEvent.ACTION_SETTINGS_ADVANCED_BUTTON_EXPAND,
|
||||
getMetricsCategory(), null, 0);
|
||||
}
|
||||
|
||||
protected boolean shouldForceRoundedIcon() {
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.android.settings.network.NetworkDashboardFragment;
|
||||
import com.android.settings.notification.ConfigureNotificationSettings;
|
||||
import com.android.settings.notification.SoundSettings;
|
||||
import com.android.settings.notification.ZenModeSettings;
|
||||
import com.android.settings.privacy.PrivacyDashboardFragment;
|
||||
import com.android.settings.security.LockscreenDashboardFragment;
|
||||
import com.android.settings.security.SecuritySettings;
|
||||
import com.android.settings.system.SystemDashboardFragment;
|
||||
@@ -104,6 +105,8 @@ public class DashboardFragmentRegistry {
|
||||
CategoryKey.CATEGORY_GESTURES);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(NightDisplaySettings.class.getName(),
|
||||
CategoryKey.CATEGORY_NIGHT_DISPLAY);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(PrivacyDashboardFragment.class.getName(),
|
||||
CategoryKey.CATEGORY_PRIVACY);
|
||||
|
||||
CATEGORY_KEY_TO_PARENT_MAP = new ArrayMap<>(PARENT_TO_CATEGORY_KEY_MAP.size());
|
||||
|
||||
|
||||
@@ -16,16 +16,12 @@
|
||||
|
||||
package com.android.settings.gestures;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
@@ -42,7 +38,7 @@ public class WakeScreenGestureSettings extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.SETTINGS_GESTURE_WAKE_SCREEN;
|
||||
return SettingsEnums.SETTINGS_GESTURE_WAKE_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,6 +33,8 @@ import androidx.annotation.VisibleForTesting;
|
||||
import androidx.slice.Slice;
|
||||
|
||||
import com.android.settings.homepage.contextualcards.deviceinfo.BatterySlice;
|
||||
import com.android.settings.homepage.contextualcards.slices.ConnectedDeviceSlice;
|
||||
import com.android.settings.wifi.WifiSlice;
|
||||
import com.android.settingslib.utils.AsyncLoaderCompat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -40,9 +42,13 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>> {
|
||||
private static final String TAG = "ContextualCardLoader";
|
||||
|
||||
@VisibleForTesting
|
||||
static final int DEFAULT_CARD_COUNT = 4;
|
||||
static final int CARD_CONTENT_LOADER_ID = 1;
|
||||
|
||||
private static final String TAG = "ContextualCardLoader";
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public interface CardContentLoaderListener {
|
||||
@@ -77,7 +83,30 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
}
|
||||
}
|
||||
}
|
||||
return filterEligibleCards(result);
|
||||
return getFinalDisplayableCards(result);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
List<ContextualCard> getFinalDisplayableCards(List<ContextualCard> candidates) {
|
||||
List<ContextualCard> eligibleCards = filterEligibleCards(candidates);
|
||||
eligibleCards = eligibleCards.stream().limit(DEFAULT_CARD_COUNT).collect(
|
||||
Collectors.toList());
|
||||
|
||||
if (eligibleCards.size() <= 2 || getNumberOfLargeCard(eligibleCards) == 0) {
|
||||
return eligibleCards;
|
||||
}
|
||||
|
||||
if (eligibleCards.size() == DEFAULT_CARD_COUNT) {
|
||||
eligibleCards.remove(eligibleCards.size() - 1);
|
||||
}
|
||||
|
||||
if (getNumberOfLargeCard(eligibleCards) == 1) {
|
||||
return eligibleCards;
|
||||
}
|
||||
|
||||
eligibleCards.remove(eligibleCards.size() - 1);
|
||||
|
||||
return eligibleCards;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -139,6 +168,13 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
return true;
|
||||
}
|
||||
|
||||
private int getNumberOfLargeCard(List<ContextualCard> cards) {
|
||||
return (int) cards.stream()
|
||||
.filter(card -> card.getSliceUri().equals(WifiSlice.WIFI_URI)
|
||||
|| card.getSliceUri().equals(ConnectedDeviceSlice.CONNECTED_DEVICE_URI))
|
||||
.count();
|
||||
}
|
||||
|
||||
private long getAppVersionCode() {
|
||||
try {
|
||||
return mContext.getPackageManager().getPackageInfo(mContext.getPackageName(),
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.settings.homepage.contextualcards;
|
||||
|
||||
import static com.android.settings.homepage.contextualcards.ContextualCardsAdapter.SPAN_COUNT;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -26,7 +27,6 @@ import android.view.ViewGroup;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.InstrumentedFragment;
|
||||
|
||||
@@ -69,6 +69,6 @@ public class ContextualCardsFragment extends InstrumentedFragment {
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsEvent.SETTINGS_HOMEPAGE;
|
||||
return SettingsEnums.SETTINGS_HOMEPAGE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
|
||||
package com.android.settings.homepage.contextualcards.conditional;
|
||||
|
||||
import static android.content.Context.NOTIFICATION_SERVICE;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
@@ -32,14 +28,11 @@ import java.util.Objects;
|
||||
public class RingerMutedConditionController extends AbnormalRingerConditionController {
|
||||
static final int ID = Objects.hash("RingerMutedConditionController");
|
||||
|
||||
private final NotificationManager mNotificationManager;
|
||||
private final Context mAppContext;
|
||||
|
||||
public RingerMutedConditionController(Context appContext, ConditionManager conditionManager) {
|
||||
super(appContext, conditionManager);
|
||||
mAppContext = appContext;
|
||||
mNotificationManager =
|
||||
(NotificationManager) appContext.getSystemService(NOTIFICATION_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,14 +42,7 @@ public class RingerMutedConditionController extends AbnormalRingerConditionContr
|
||||
|
||||
@Override
|
||||
public boolean isDisplayable() {
|
||||
int zen = Settings.Global.ZEN_MODE_OFF;
|
||||
if (mNotificationManager != null) {
|
||||
zen = mNotificationManager.getZenMode();
|
||||
}
|
||||
final boolean zenModeEnabled = zen != Settings.Global.ZEN_MODE_OFF;
|
||||
final boolean isSilent =
|
||||
mAudioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_SILENT;
|
||||
return isSilent && !zenModeEnabled;
|
||||
return mAudioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_SILENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.network.telephony;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@@ -31,7 +32,6 @@ import android.util.Log;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.internal.telephony.TelephonyIntents;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.RestrictedDashboardFragment;
|
||||
@@ -75,7 +75,7 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment {
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.MOBILE_NETWORK;
|
||||
return SettingsEnums.MOBILE_NETWORK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
*/
|
||||
package com.android.settings.network.telephony;
|
||||
|
||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.MOBILE_NETWORK_SELECT;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -203,7 +202,7 @@ public class NetworkSelectSettings extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MOBILE_NETWORK_SELECT;
|
||||
return SettingsEnums.MOBILE_NETWORK_SELECT;
|
||||
}
|
||||
|
||||
private final Handler mHandler = new Handler() {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.network.telephony.gsm;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
@@ -26,7 +27,6 @@ import android.telephony.TelephonyManager;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
@@ -100,7 +100,7 @@ public class AutoSelectPreferenceController extends TogglePreferenceController {
|
||||
bundle.putInt(Settings.EXTRA_SUB_ID, mSubId);
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(NetworkSelectSettings.class.getName())
|
||||
.setSourceMetricsCategory(MetricsProto.MetricsEvent.MOBILE_NETWORK_SELECT)
|
||||
.setSourceMetricsCategory(SettingsEnums.MOBILE_NETWORK_SELECT)
|
||||
.setTitleRes(R.string.choose_network_title)
|
||||
.setArguments(bundle)
|
||||
.launch();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.network.telephony.gsm;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
@@ -27,7 +28,6 @@ import android.text.TextUtils;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
@@ -88,7 +88,7 @@ public class OpenNetworkSelectPagePreferenceController extends BasePreferenceCon
|
||||
bundle.putInt(Settings.EXTRA_SUB_ID, mSubId);
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(NetworkSelectSettings.class.getName())
|
||||
.setSourceMetricsCategory(MetricsProto.MetricsEvent.MOBILE_NETWORK_SELECT)
|
||||
.setSourceMetricsCategory(SettingsEnums.MOBILE_NETWORK_SELECT)
|
||||
.setTitleRes(R.string.choose_network_title)
|
||||
.setArguments(bundle)
|
||||
.launch();
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.android.settings.accounts.AccountFeatureProviderImpl;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.applications.ApplicationFeatureProviderImpl;
|
||||
import com.android.settings.connecteddevice.dock.DockUpdaterFeatureProviderImpl;
|
||||
import com.android.settings.core.instrumentation.SettingsMetricsFeatureProvider;
|
||||
import com.android.settings.dashboard.DashboardFeatureProvider;
|
||||
import com.android.settings.dashboard.DashboardFeatureProviderImpl;
|
||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
||||
@@ -80,7 +81,7 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
@Override
|
||||
public MetricsFeatureProvider getMetricsFeatureProvider() {
|
||||
if (mMetricsFeatureProvider == null) {
|
||||
mMetricsFeatureProvider = new MetricsFeatureProvider();
|
||||
mMetricsFeatureProvider = new SettingsMetricsFeatureProvider();
|
||||
}
|
||||
return mMetricsFeatureProvider;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.privacy;
|
||||
|
||||
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.settings.security.ShowPasswordPreferenceController;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class PrivacyDashboardFragment extends DashboardFragment {
|
||||
private static final String TAG = "PrivacyDashboardFragment";
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsEvent.TOP_LEVEL_PRIVACY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.privacy_dashboard_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHelpResource() {
|
||||
return R.string.help_url_privacy_dashboard;
|
||||
}
|
||||
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.privacy_dashboard_settings;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -108,7 +108,6 @@ public class SecuritySettings extends DashboardFragment {
|
||||
controllers.add(new ManageTrustAgentsPreferenceController(context));
|
||||
controllers.add(new ScreenPinningPreferenceController(context));
|
||||
controllers.add(new SimLockPreferenceController(context));
|
||||
controllers.add(new ShowPasswordPreferenceController(context));
|
||||
controllers.add(new EncryptionStatusPreferenceController(context,
|
||||
PREF_KEY_ENCRYPTION_SECURITY_PAGE));
|
||||
controllers.add(new TrustAgentListPreferenceController(context, host, lifecycle));
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.annotation.IdRes;
|
||||
import android.annotation.UserIdInt;
|
||||
import android.app.ActionBar;
|
||||
import android.app.Activity;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
@@ -355,14 +356,13 @@ public class EntityHeaderController {
|
||||
if (mAppNotifPrefIntent == null) {
|
||||
button.setVisibility(View.GONE);
|
||||
} else {
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FeatureFactory.getFactory(mAppContext).getMetricsFeatureProvider()
|
||||
.actionWithSource(mAppContext, mMetricsCategory,
|
||||
ACTION_OPEN_APP_NOTIFICATION_SETTING);
|
||||
mFragment.startActivity(mAppNotifPrefIntent);
|
||||
}
|
||||
button.setOnClickListener(v -> {
|
||||
FeatureFactory.getFactory(mAppContext).getMetricsFeatureProvider()
|
||||
.action(SettingsEnums.PAGE_UNKNOWN,
|
||||
ACTION_OPEN_APP_NOTIFICATION_SETTING,
|
||||
mMetricsCategory,
|
||||
null, 0);
|
||||
mFragment.startActivity(mAppNotifPrefIntent);
|
||||
});
|
||||
button.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.settings.widget;
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Rect;
|
||||
@@ -143,8 +144,13 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mDisabledByAdmin) {
|
||||
mMetricsFeatureProvider.count(mContext,
|
||||
mMetricsTag + "/switch_bar|restricted", 1);
|
||||
mMetricsFeatureProvider.action(
|
||||
SettingsEnums.PAGE_UNKNOWN,
|
||||
SettingsEnums.ACTION_SETTINGS_PREFERENCE_CHANGE,
|
||||
SettingsEnums.PAGE_UNKNOWN,
|
||||
mMetricsTag + "/switch_bar|restricted",
|
||||
1);
|
||||
|
||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(context,
|
||||
mEnforcedAdmin);
|
||||
}
|
||||
@@ -287,7 +293,12 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (mLoggingIntialized) {
|
||||
mMetricsFeatureProvider.count(mContext, mMetricsTag + "/switch_bar|" + isChecked, 1);
|
||||
mMetricsFeatureProvider.action(
|
||||
SettingsEnums.PAGE_UNKNOWN,
|
||||
SettingsEnums.ACTION_SETTINGS_PREFERENCE_CHANGE,
|
||||
SettingsEnums.PAGE_UNKNOWN,
|
||||
mMetricsTag + "/switch_bar",
|
||||
isChecked ? 1 : 0);
|
||||
}
|
||||
mLoggingIntialized = true;
|
||||
propagateChecked(isChecked);
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.app.Activity;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.ShadowRecoverySystem;
|
||||
import com.android.settings.testutils.shadow.ShadowWifiP2pManager;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -35,7 +36,7 @@ import org.robolectric.Robolectric;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(shadows = {ShadowRecoverySystem.class})
|
||||
@Config(shadows = {ShadowRecoverySystem.class, ShadowWifiP2pManager.class})
|
||||
public class ResetNetworkConfirmTest {
|
||||
|
||||
private Activity mActivity;
|
||||
@@ -52,6 +53,7 @@ public class ResetNetworkConfirmTest {
|
||||
@After
|
||||
public void tearDown() {
|
||||
ShadowRecoverySystem.reset();
|
||||
ShadowWifiP2pManager.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -76,4 +78,16 @@ public class ResetNetworkConfirmTest {
|
||||
assertThat(ShadowRecoverySystem.getWipeEuiccCalledCount())
|
||||
.isEqualTo(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for WifiP2pManager factoryReset method.
|
||||
*/
|
||||
@Test
|
||||
public void testResetNetworkData_resetP2p() {
|
||||
|
||||
mResetNetworkConfirm.p2pFactoryReset(mActivity);
|
||||
|
||||
assertThat(ShadowWifiP2pManager.getFactoryResetCount())
|
||||
.isEqualTo(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -103,7 +103,7 @@ public class SubSettingLauncherTest {
|
||||
assertThat(intent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT))
|
||||
.isEqualTo(SubSettingLauncherTest.class.getName());
|
||||
assertThat(intent.getFlags()).isEqualTo(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
assertThat(intent.getIntExtra(VisibilityLoggerMixin.EXTRA_SOURCE_METRICS_CATEGORY, -1))
|
||||
assertThat(intent.getIntExtra(MetricsFeatureProvider.EXTRA_SOURCE_METRICS_CATEGORY, -1))
|
||||
.isEqualTo(123);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.ShadowThreadUtils;
|
||||
import com.android.settings.testutils.shadow.ShadowTileUtils;
|
||||
import com.android.settings.testutils.shadow.ShadowUserManager;
|
||||
import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settingslib.drawer.CategoryKey;
|
||||
import com.android.settingslib.drawer.Tile;
|
||||
import com.android.settingslib.drawer.TileUtils;
|
||||
@@ -338,7 +338,7 @@ public class DashboardFeatureProviderImplTest {
|
||||
final Intent launchIntent = shadowActivity.getNextStartedActivityForResult().intent;
|
||||
assertThat(launchIntent.getAction())
|
||||
.isEqualTo("TestAction");
|
||||
assertThat(launchIntent.getIntExtra(VisibilityLoggerMixin.EXTRA_SOURCE_METRICS_CATEGORY, 0))
|
||||
assertThat(launchIntent.getIntExtra(MetricsFeatureProvider.EXTRA_SOURCE_METRICS_CATEGORY, 0))
|
||||
.isEqualTo(MetricsEvent.SETTINGS_GESTURES);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.android.settings.dashboard;
|
||||
|
||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.DASHBOARD_CONTAINER;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
@@ -25,6 +27,7 @@ import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.os.Bundle;
|
||||
@@ -185,9 +188,9 @@ public class DashboardFragmentTest {
|
||||
= mFakeFeatureFactory.getMetricsFeatureProvider();
|
||||
mTestFragment.onExpandButtonClick();
|
||||
|
||||
verify(metricsFeatureProvider).actionWithSource(
|
||||
RuntimeEnvironment.application, MetricsEvent.DASHBOARD_CONTAINER,
|
||||
MetricsEvent.ACTION_SETTINGS_ADVANCED_BUTTON_EXPAND);
|
||||
verify(metricsFeatureProvider).action(SettingsEnums.PAGE_UNKNOWN,
|
||||
MetricsEvent.ACTION_SETTINGS_ADVANCED_BUTTON_EXPAND,
|
||||
DASHBOARD_CONTAINER, null, 0);
|
||||
}
|
||||
|
||||
public static class TestPreferenceController extends AbstractPreferenceController
|
||||
@@ -243,7 +246,7 @@ public class DashboardFragmentTest {
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsEvent.DASHBOARD_CONTAINER;
|
||||
return DASHBOARD_CONTAINER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,21 +16,31 @@
|
||||
|
||||
package com.android.settings.homepage.contextualcards;
|
||||
|
||||
import static com.android.settings.homepage.contextualcards.ContextualCardLoader.DEFAULT_CARD_COUNT;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.android.settings.homepage.contextualcards.deviceinfo.BatterySlice;
|
||||
import com.android.settings.homepage.contextualcards.slices.ConnectedDeviceSlice;
|
||||
import com.android.settings.slices.SettingsSliceProvider;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.wifi.WifiSlice;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.shadows.ShadowContentResolver;
|
||||
import org.robolectric.shadows.ShadowLog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -45,7 +55,7 @@ public class ContextualCardLoaderTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mContextualCardLoader = new ContextualCardLoader(mContext);
|
||||
mContextualCardLoader = spy(new ContextualCardLoader(mContext));
|
||||
mProvider = new SettingsSliceProvider();
|
||||
ShadowContentResolver.registerProviderInternal(SettingsSliceProvider.SLICE_AUTHORITY,
|
||||
mProvider);
|
||||
@@ -92,6 +102,57 @@ public class ContextualCardLoaderTest {
|
||||
getContextualCard(sliceUri))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFinalDisplayableCards_twoEligibleCards_shouldShowAll() {
|
||||
final List<ContextualCard> cards = getContextualCardList().stream().limit(2)
|
||||
.collect(Collectors.toList());
|
||||
doReturn(cards).when(mContextualCardLoader).filterEligibleCards(any(List.class));
|
||||
|
||||
final List<ContextualCard> result = mContextualCardLoader.getFinalDisplayableCards(cards);
|
||||
|
||||
assertThat(result).hasSize(cards.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFinalDisplayableCards_fiveEligibleCardsNoLarge_shouldShowDefaultCardCount() {
|
||||
final List<ContextualCard> fiveCards = getContextualCardListWithNoLargeCard();
|
||||
doReturn(fiveCards).when(mContextualCardLoader).filterEligibleCards(any(List.class));
|
||||
|
||||
final List<ContextualCard> result = mContextualCardLoader.getFinalDisplayableCards(
|
||||
fiveCards);
|
||||
|
||||
assertThat(result).hasSize(DEFAULT_CARD_COUNT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFinalDisplayableCards_threeEligibleCardsOneLarge_shouldShowThreeCards() {
|
||||
final List<ContextualCard> cards = getContextualCardList().stream().limit(2)
|
||||
.collect(Collectors.toList());
|
||||
cards.add(new ContextualCard.Builder()
|
||||
.setName("test_gesture")
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setSliceUri(Uri.parse(
|
||||
"content://com.android.settings.test.slices/action/gesture_pick_up"))
|
||||
.build());
|
||||
doReturn(cards).when(mContextualCardLoader).filterEligibleCards(any(List.class));
|
||||
|
||||
final List<ContextualCard> result = mContextualCardLoader.getFinalDisplayableCards(cards);
|
||||
|
||||
assertThat(result).hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFinalDisplayableCards_threeEligibleCardsTwoLarge_shouldShowTwoCards() {
|
||||
final List<ContextualCard> threeCards = getContextualCardList().stream().limit(3)
|
||||
.collect(Collectors.toList());
|
||||
doReturn(threeCards).when(mContextualCardLoader).filterEligibleCards(any(List.class));
|
||||
|
||||
final List<ContextualCard> result = mContextualCardLoader.getFinalDisplayableCards(
|
||||
threeCards);
|
||||
|
||||
assertThat(result).hasSize(2);
|
||||
}
|
||||
|
||||
private ContextualCard getContextualCard(String sliceUri) {
|
||||
return new ContextualCard.Builder()
|
||||
.setName("test_card")
|
||||
@@ -99,4 +160,69 @@ public class ContextualCardLoaderTest {
|
||||
.setSliceUri(Uri.parse(sliceUri))
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<ContextualCard> getContextualCardList() {
|
||||
final List<ContextualCard> cards = new ArrayList<>();
|
||||
cards.add(new ContextualCard.Builder()
|
||||
.setName("test_wifi")
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setSliceUri(WifiSlice.WIFI_URI)
|
||||
.build());
|
||||
cards.add(new ContextualCard.Builder()
|
||||
.setName("test_flashlight")
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setSliceUri(
|
||||
Uri.parse("content://com.android.settings.test.slices/action/flashlight"))
|
||||
.build());
|
||||
cards.add(new ContextualCard.Builder()
|
||||
.setName("test_connected")
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setSliceUri(ConnectedDeviceSlice.CONNECTED_DEVICE_URI)
|
||||
.build());
|
||||
cards.add(new ContextualCard.Builder()
|
||||
.setName("test_gesture")
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setSliceUri(Uri.parse(
|
||||
"content://com.android.settings.test.slices/action/gesture_pick_up"))
|
||||
.build());
|
||||
cards.add(new ContextualCard.Builder()
|
||||
.setName("test_battery")
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setSliceUri(BatterySlice.BATTERY_CARD_URI)
|
||||
.build());
|
||||
return cards;
|
||||
}
|
||||
|
||||
private List<ContextualCard> getContextualCardListWithNoLargeCard() {
|
||||
final List<ContextualCard> cards = new ArrayList<>();
|
||||
cards.add(new ContextualCard.Builder()
|
||||
.setName("test_rotate")
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setSliceUri(
|
||||
Uri.parse("content://com.android.settings.test.slices/action/auto_rotate"))
|
||||
.build());
|
||||
cards.add(new ContextualCard.Builder()
|
||||
.setName("test_flashlight")
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setSliceUri(
|
||||
Uri.parse("content://com.android.settings.test.slices/action/flashlight"))
|
||||
.build());
|
||||
cards.add(new ContextualCard.Builder()
|
||||
.setName("test_bt")
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setSliceUri(Uri.parse("content://android.settings.test.slices/action/bluetooth"))
|
||||
.build());
|
||||
cards.add(new ContextualCard.Builder()
|
||||
.setName("test_gesture")
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setSliceUri(Uri.parse(
|
||||
"content://com.android.settings.test.slices/action/gesture_pick_up"))
|
||||
.build());
|
||||
cards.add(new ContextualCard.Builder()
|
||||
.setName("test_battery")
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setSliceUri(BatterySlice.BATTERY_CARD_URI)
|
||||
.build());
|
||||
return cards;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.testutils.shadow;
|
||||
|
||||
import android.net.wifi.p2p.WifiP2pManager;
|
||||
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
import org.robolectric.annotation.Resetter;
|
||||
|
||||
/**
|
||||
* Shadown class for WifiP2pManager.
|
||||
*/
|
||||
@Implements(value = WifiP2pManager.class)
|
||||
public class ShadowWifiP2pManager extends org.robolectric.shadows.ShadowWifiP2pManager {
|
||||
|
||||
private static int sFactoryResetCount;
|
||||
|
||||
/**
|
||||
* factoryReset mock method.
|
||||
*/
|
||||
@Implementation
|
||||
public void factoryReset(WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener) {
|
||||
if (c != null) {
|
||||
sFactoryResetCount++;
|
||||
} else {
|
||||
throw new IllegalArgumentException("channel must be non-null.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset variables in shadow class.
|
||||
*/
|
||||
@Resetter
|
||||
public static void reset() {
|
||||
sFactoryResetCount = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the count of factoryReset called.
|
||||
*
|
||||
* @return the count of factoryReset called.
|
||||
*/
|
||||
public static int getFactoryResetCount() {
|
||||
return sFactoryResetCount;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user