Merge "Check for null before invoking finish()"
diff --git a/Android.mk b/Android.mk
index cc45130..e385b34 100644
--- a/Android.mk
+++ b/Android.mk
@@ -20,8 +20,6 @@
LOCAL_MODULE_TAGS := optional
LOCAL_USE_AAPT2 := true
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_STATIC_ANDROID_LIBRARIES := \
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6cb0023..84b12dc 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -41,7 +41,7 @@
<uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WRITE_APN_SETTINGS"/>
<uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"/>
<uses-permission android:name="android.permission.READ_USER_DICTIONARY"/>
diff --git a/res/layout-land/storage_summary_donut.xml b/res/layout-land/storage_summary_donut.xml
index f43737a..db91547 100644
--- a/res/layout-land/storage_summary_donut.xml
+++ b/res/layout-land/storage_summary_donut.xml
@@ -18,7 +18,6 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="?android:attr/colorPrimary"
android:gravity="center_vertical"
android:orientation="horizontal" >
diff --git a/res/layout-sw360dp/storage_summary_donut.xml b/res/layout-sw360dp/storage_summary_donut.xml
index f43737a..db91547 100644
--- a/res/layout-sw360dp/storage_summary_donut.xml
+++ b/res/layout-sw360dp/storage_summary_donut.xml
@@ -18,7 +18,6 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="?android:attr/colorPrimary"
android:gravity="center_vertical"
android:orientation="horizontal" >
diff --git a/res/layout/storage_summary_donut.xml b/res/layout/storage_summary_donut.xml
index 1637189..88f5b36 100644
--- a/res/layout/storage_summary_donut.xml
+++ b/res/layout/storage_summary_donut.xml
@@ -17,7 +17,6 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="?android:attr/colorPrimary"
android:gravity="center"
android:orientation="vertical"
android:paddingTop="32dp"
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index cdbeada..617feb3 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -23,6 +23,7 @@
<color name="homepage_support_background">#3F5FBD</color>
<!-- 80% black for status bar of homepage -->
<color name="homepage_status_bar_color">#cc000000</color>
- <color name="homepage_card_dismissal_background">@*android:color/material_grey_800</color>
+ <color name="homepage_card_dismissal_background">@*android:color/material_grey_900</color>
+ <color name="contextual_card_background">@*android:color/material_grey_900</color>
</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index f6723a8..a10d1d7 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -100,8 +100,10 @@
<color name="homepage_location_background">#2EC7DC</color>
<color name="homepage_about_background">#9FA8DA</color>
<color name="homepage_privacy_background">#5E97F6</color>
+
<color name="homepage_card_stroke_color">#1f000000</color>
<color name="homepage_card_dismissal_background">@*android:color/material_grey_50</color>
+ <color name="contextual_card_background">@*android:color/background_device_default_light</color>
<!-- End of dashboard/homepage icon background colors -->
<color name="switchbar_text_color">@android:color/white</color>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9281979..7bd9950 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6857,10 +6857,10 @@
<!-- Wizard finish button label [CHAR LIMIT=25] -->
<string name="wizard_finish">Finish</string>
- <!-- An option in a photo selection dialog, if there is no photo yet [CHAR LIMIT=50] -->
- <string name="user_image_take_photo" msgid="7496128293167402354">Take photo</string>
- <!-- An option in a photo selection dialog, if there is no photo yet [CHAR LIMIT=50] -->
- <string name="user_image_choose_photo" msgid="3746334626214970837">Choose photo from Gallery</string>
+ <!-- An option in a photo selection dialog to take a new photo [CHAR LIMIT=50] -->
+ <string name="user_image_take_photo" msgid="7496128293167402354">Take a photo</string>
+ <!-- An option in a photo selection dialog to choose a pre-existing image [CHAR LIMIT=50] -->
+ <string name="user_image_choose_photo" msgid="3746334626214970837">Choose an image</string>
<!-- Accessibility message for the photo selector which is a button/popup with the current photo [CHAR LIMIT=50] -->
<string name="user_image_photo_selector">Select photo</string>
@@ -7078,7 +7078,7 @@
<string name="keywords_display_auto_brightness">dim screen, touchscreen, battery, smart brightness, dynamic brightness</string>
<!-- Search keywords for adaptive sleep setting [CHAR LIMIT=NONE]-->
- <string name="keywords_display_adaptive_sleep">dim screen, sleep, battery, timeout, attention</string>
+ <string name="keywords_display_adaptive_sleep">dim screen, sleep, battery, timeout, attention, display, screen, inactivity</string>
<!-- List of synonyms for the auto rotate (rotate the virtual display when the device rotates) setting, used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_auto_rotate">rotate, flip, rotation, portrait, landscape, orientation, vertical, horizontal</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index b8f6732..323d39b 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -277,6 +277,7 @@
<style name="TextAppearance.ConditionCardTitle"
parent="@*android:style/TextAppearance.DeviceDefault.Subhead">
+ <item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
<item name="android:textSize">16sp</item>
</style>
@@ -410,6 +411,7 @@
<item name="android:layout_marginBottom">@dimen/homepage_card_vertical_margin</item>
<item name="android:layout_marginStart">@dimen/homepage_card_side_margin</item>
<item name="android:layout_marginEnd">@dimen/homepage_card_side_margin</item>
+ <item name="cardBackgroundColor">@color/contextual_card_background</item>
<item name="cardCornerRadius">@*android:dimen/config_dialogCornerRadius</item>
<item name="cardElevation">0dp</item>
<item name="strokeColor">@color/homepage_card_stroke_color</item>
diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml
index c5765d3..6833922 100644
--- a/res/xml/security_lockscreen_settings.xml
+++ b/res/xml/security_lockscreen_settings.xml
@@ -60,6 +60,12 @@
settings:controller="com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController" />
<Preference
+ android:key="ambient_display_wake_screen"
+ android:title="@string/ambient_display_wake_screen_title"
+ android:fragment="com.android.settings.gestures.WakeScreenGestureSettings"
+ settings:controller="com.android.settings.gestures.WakeScreenGesturePreferenceController" />
+
+ <Preference
android:key="ambient_display_tap"
android:title="@string/ambient_display_tap_screen_title"
android:fragment="com.android.settings.gestures.TapScreenGestureSettings"
@@ -77,12 +83,6 @@
android:fragment="com.android.settings.gestures.PickupGestureSettings"
settings:controller="com.android.settings.gestures.PickupGesturePreferenceController" />
- <Preference
- android:key="ambient_display_wake_screen"
- android:title="@string/ambient_display_wake_screen_title"
- android:fragment="com.android.settings.gestures.WakeScreenGestureSettings"
- settings:controller="com.android.settings.gestures.WakeScreenGesturePreferenceController" />
-
<SwitchPreference
android:key="ambient_display_notification"
android:title="@string/doze_title"
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index 8dad57f..58bc58c 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -65,10 +65,10 @@
import com.android.settings.password.ConfirmLockPattern;
import com.android.settingslib.RestrictedLockUtilsInternal;
-import com.google.android.setupcompat.TemplateLayout;
import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupcompat.template.FooterButton.ButtonType;
+import com.google.android.setupdesign.GlifLayout;
import java.util.List;
@@ -416,7 +416,7 @@
return;
}
- final TemplateLayout layout = mContentView.findViewById(R.id.setup_wizard_layout);
+ final GlifLayout layout = mContentView.findViewById(R.id.setup_wizard_layout);
final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
mixin.setPrimaryButton(
new FooterButton.Builder(getActivity())
diff --git a/src/com/android/settings/MasterClearConfirm.java b/src/com/android/settings/MasterClearConfirm.java
index c25f2af..618dd2c 100644
--- a/src/com/android/settings/MasterClearConfirm.java
+++ b/src/com/android/settings/MasterClearConfirm.java
@@ -44,10 +44,10 @@
import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper;
import com.android.settingslib.RestrictedLockUtilsInternal;
-import com.google.android.setupcompat.TemplateLayout;
import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupcompat.template.FooterButton.ButtonType;
+import com.google.android.setupdesign.GlifLayout;
/**
* Confirm and execute a reset of the device to a clean "just out of the box"
@@ -152,7 +152,7 @@
* Configure the UI for the final confirmation interaction
*/
private void establishFinalConfirmationState() {
- final TemplateLayout layout = mContentView.findViewById(R.id.setup_wizard_layout);
+ final GlifLayout layout = mContentView.findViewById(R.id.setup_wizard_layout);
final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
mixin.setPrimaryButton(
diff --git a/src/com/android/settings/development/BluetoothSnoopLogPreferenceController.java b/src/com/android/settings/development/BluetoothSnoopLogPreferenceController.java
index d26f0dd..d698436 100644
--- a/src/com/android/settings/development/BluetoothSnoopLogPreferenceController.java
+++ b/src/com/android/settings/development/BluetoothSnoopLogPreferenceController.java
@@ -55,8 +55,7 @@
mListEntries = context.getResources().getStringArray(R.array.bt_hci_snoop_log_entries);
}
- // Default mode is FILTERED on userdebug/eng build, DISABLED on user build,
- // or can be changed by modifying the global setting.
+ // Default mode is DISABLED. It can also be changed by modifying the global setting.
public int getDefaultModeIndex() {
if (!Build.IS_DEBUGGABLE) {
return BTSNOOP_LOG_MODE_DISABLED_INDEX;
@@ -71,7 +70,7 @@
}
}
- return BTSNOOP_LOG_MODE_FILTERED_INDEX;
+ return BTSNOOP_LOG_MODE_DISABLED_INDEX;
}
@Override
diff --git a/src/com/android/settings/gestures/WakeScreenGesturePreferenceController.java b/src/com/android/settings/gestures/WakeScreenGesturePreferenceController.java
index a43fad1..96a3580 100644
--- a/src/com/android/settings/gestures/WakeScreenGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/WakeScreenGesturePreferenceController.java
@@ -53,7 +53,18 @@
|| !mFeatureProvider.isSupported(mContext)) {
return UNSUPPORTED_ON_DEVICE;
}
- return mFeatureProvider.isEnabled(mContext) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+
+ if (!mFeatureProvider.isEnabled(mContext)) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+
+ return getAmbientConfig().alwaysOnEnabled(mUserId)
+ ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
+ }
+
+ @Override
+ protected boolean canHandleClicks() {
+ return getAmbientConfig().alwaysOnEnabled(mUserId);
}
@Override
diff --git a/src/com/android/settings/network/SubscriptionUtil.java b/src/com/android/settings/network/SubscriptionUtil.java
index 237e08a..224fc41 100644
--- a/src/com/android/settings/network/SubscriptionUtil.java
+++ b/src/com/android/settings/network/SubscriptionUtil.java
@@ -38,7 +38,7 @@
if (sResultsForTesting != null) {
return sResultsForTesting;
}
- List<SubscriptionInfo> subscriptions = manager.getAvailableSubscriptionInfoList();
+ List<SubscriptionInfo> subscriptions = manager.getSelectableSubscriptionInfoList();
if (subscriptions == null) {
subscriptions = new ArrayList<>();
}
diff --git a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
index 9c5a98e..a9606ab 100644
--- a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
@@ -54,6 +54,8 @@
public int getAvailabilityStatus(int subId) {
boolean visible;
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+ final TelephonyManager telephonyManager = TelephonyManager
+ .from(mContext).createForSubscriptionId(subId);
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
visible = false;
} else if (carrierConfig == null) {
@@ -63,8 +65,8 @@
visible = false;
} else if (carrierConfig.getBoolean(
CarrierConfigManager.KEY_HIDE_PREFERRED_NETWORK_TYPE_BOOL)
- && !mTelephonyManager.getServiceState().getRoaming()
- && mTelephonyManager.getServiceState().getDataRegState()
+ && !telephonyManager.getServiceState().getRoaming()
+ && telephonyManager.getServiceState().getDataRegState()
== ServiceState.STATE_IN_SERVICE) {
visible = false;
} else if (carrierConfig.getBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL)) {
diff --git a/src/com/android/settings/network/telephony/MobileNetworkActivity.java b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
index 821b1e1e..3c0940d 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkActivity.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
@@ -160,7 +160,7 @@
final int subId = intent.getIntExtra(Settings.EXTRA_SUB_ID, SUB_ID_NULL);
if (subId != SUB_ID_NULL) {
for (SubscriptionInfo subscription :
- mSubscriptionManager.getAvailableSubscriptionInfoList()) {
+ mSubscriptionManager.getSelectableSubscriptionInfoList()) {
if (subscription.getSubscriptionId() == subId) {
return subscription;
}
diff --git a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
index 27a7bce..294f05f 100644
--- a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
@@ -30,7 +30,6 @@
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.settings.R;
-import com.android.settings.core.BasePreferenceController;
/**
* Preference controller for "Preferred network mode"
@@ -51,6 +50,8 @@
@Override
public int getAvailabilityStatus(int subId) {
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+ final TelephonyManager telephonyManager = TelephonyManager
+ .from(mContext).createForSubscriptionId(subId);
boolean visible;
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
visible = false;
@@ -61,8 +62,8 @@
visible = false;
} else if (carrierConfig.getBoolean(
CarrierConfigManager.KEY_HIDE_PREFERRED_NETWORK_TYPE_BOOL)
- && !mTelephonyManager.getServiceState().getRoaming()
- && mTelephonyManager.getServiceState().getDataRegState()
+ && !telephonyManager.getServiceState().getRoaming()
+ && telephonyManager.getServiceState().getDataRegState()
== ServiceState.STATE_IN_SERVICE) {
visible = false;
} else if (carrierConfig.getBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL)) {
diff --git a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
index 44984e6..8c32df0 100644
--- a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
@@ -34,7 +34,6 @@
import androidx.preference.SwitchPreference;
import com.android.ims.ImsManager;
-import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -49,7 +48,6 @@
private Preference mPreference;
private TelephonyManager mTelephonyManager;
private CarrierConfigManager mCarrierConfigManager;
- private PersistableBundle mCarrierConfig;
@VisibleForTesting
ImsManager mImsManager;
private PhoneCallStateListener mPhoneStateListener;
@@ -67,7 +65,7 @@
return subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
&& MobileNetworkUtils.isWifiCallingEnabled(mContext,
SubscriptionManager.getPhoneId(subId))
- && isVideoCallEnabled()
+ && isVideoCallEnabled(subId)
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
@@ -94,7 +92,7 @@
public void updateState(Preference preference) {
super.updateState(preference);
final SwitchPreference switchPreference = (SwitchPreference) preference;
- final boolean videoCallEnabled = isVideoCallEnabled();
+ final boolean videoCallEnabled = isVideoCallEnabled(mSubId, mImsManager);
switchPreference.setVisible(videoCallEnabled);
if (videoCallEnabled) {
final boolean is4gLteEnabled = mImsManager.isEnhanced4gLteModeSettingEnabledByUser()
@@ -119,7 +117,6 @@
public VideoCallingPreferenceController init(int subId) {
mSubId = subId;
mTelephonyManager = TelephonyManager.from(mContext).createForSubscriptionId(mSubId);
- mCarrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
if (mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
mImsManager = ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(mSubId));
}
@@ -127,15 +124,25 @@
return this;
}
+ private boolean isVideoCallEnabled(int subId) {
+ final ImsManager imsManager = subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
+ ? ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(subId))
+ : null;
+ return isVideoCallEnabled(subId, imsManager);
+ }
+
@VisibleForTesting
- boolean isVideoCallEnabled() {
- return mCarrierConfig != null && mImsManager != null
- && mImsManager.isVtEnabledByPlatform()
- && mImsManager.isVtProvisionedOnDevice()
- && MobileNetworkUtils.isImsServiceStateReady(mImsManager)
- && (mCarrierConfig.getBoolean(
+ boolean isVideoCallEnabled(int subId, ImsManager imsManager) {
+ final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+ final TelephonyManager telephonyManager = TelephonyManager
+ .from(mContext).createForSubscriptionId(subId);
+ return carrierConfig != null && imsManager != null
+ && imsManager.isVtEnabledByPlatform()
+ && imsManager.isVtProvisionedOnDevice()
+ && MobileNetworkUtils.isImsServiceStateReady(imsManager)
+ && (carrierConfig.getBoolean(
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS)
- || mTelephonyManager.isDataEnabled());
+ || telephonyManager.isDataEnabled());
}
@Override
diff --git a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
index 26c4d06..dfa1271 100644
--- a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
@@ -67,7 +67,7 @@
public int getAvailabilityStatus(int subId) {
return subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
&& MobileNetworkUtils.isWifiCallingEnabled(mContext,
- SubscriptionManager.getPhoneId(mSubId))
+ SubscriptionManager.getPhoneId(subId))
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
diff --git a/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java b/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
index a5498bc..ea7d82f 100644
--- a/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
+++ b/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
@@ -29,8 +29,8 @@
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
-import com.android.settings.core.BasePreferenceController;
import com.android.settings.network.telephony.MobileNetworkUtils;
+import com.android.settings.network.telephony.TelephonyBasePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -38,7 +38,7 @@
/**
* Preference controller related to CDMA category
*/
-public abstract class CdmaBasePreferenceController extends BasePreferenceController
+public abstract class CdmaBasePreferenceController extends TelephonyBasePreferenceController
implements LifecycleObserver, OnStart, OnStop {
protected Preference mPreference;
@@ -64,8 +64,8 @@
}
@Override
- public int getAvailabilityStatus() {
- return MobileNetworkUtils.isCdmaOptions(mContext, mSubId)
+ public int getAvailabilityStatus(int subId) {
+ return MobileNetworkUtils.isCdmaOptions(mContext, subId)
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
diff --git a/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java b/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java
index c653890..e6c1c22 100644
--- a/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java
+++ b/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java
@@ -44,8 +44,8 @@
}
@Override
- public int getAvailabilityStatus() {
- return MobileNetworkUtils.isCdmaOptions(mContext, mSubId) && deviceSupportsNvAndRuim()
+ public int getAvailabilityStatus(int subId) {
+ return MobileNetworkUtils.isCdmaOptions(mContext, subId) && deviceSupportsNvAndRuim()
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
diff --git a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
index fdc9f7f..a5d445f 100644
--- a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
+++ b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
@@ -29,9 +29,9 @@
import com.android.settings.R;
import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.core.TogglePreferenceController;
import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settings.network.telephony.NetworkSelectSettings;
+import com.android.settings.network.telephony.TelephonyTogglePreferenceController;
import java.util.ArrayList;
import java.util.List;
@@ -39,7 +39,7 @@
/**
* Preference controller for "Auto Select Network"
*/
-public class AutoSelectPreferenceController extends TogglePreferenceController {
+public class AutoSelectPreferenceController extends TelephonyTogglePreferenceController {
private int mSubId;
private TelephonyManager mTelephonyManager;
@@ -54,8 +54,8 @@
}
@Override
- public int getAvailabilityStatus() {
- return MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext,mSubId)
+ public int getAvailabilityStatus(int subId) {
+ return MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, subId)
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
diff --git a/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java b/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
index e8a392a..9ac0d12 100644
--- a/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
+++ b/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
@@ -33,11 +33,13 @@
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settings.network.telephony.NetworkSelectSettings;
+import com.android.settings.network.telephony.TelephonyBasePreferenceController;
/**
* Preference controller for "Open network select"
*/
-public class OpenNetworkSelectPagePreferenceController extends BasePreferenceController implements
+public class OpenNetworkSelectPagePreferenceController extends
+ TelephonyBasePreferenceController implements
AutoSelectPreferenceController.OnNetworkSelectModeListener {
private int mSubId;
@@ -51,8 +53,8 @@
}
@Override
- public int getAvailabilityStatus() {
- return MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, mSubId)
+ public int getAvailabilityStatus(int subId) {
+ return MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, subId)
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
diff --git a/src/com/android/settings/panel/InternetConnectivityPanel.java b/src/com/android/settings/panel/InternetConnectivityPanel.java
index d20b75a..4e4fc0c 100644
--- a/src/com/android/settings/panel/InternetConnectivityPanel.java
+++ b/src/com/android/settings/panel/InternetConnectivityPanel.java
@@ -16,6 +16,7 @@
package com.android.settings.panel;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -64,4 +65,9 @@
public Intent getSeeMoreIntent() {
return new Intent(Settings.ACTION_WIRELESS_SETTINGS);
}
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.PANEL_INTERNET_CONNECTIVITY;
+ }
}
diff --git a/src/com/android/settings/panel/MediaOutputPanel.java b/src/com/android/settings/panel/MediaOutputPanel.java
index f7639d9..c42906d 100644
--- a/src/com/android/settings/panel/MediaOutputPanel.java
+++ b/src/com/android/settings/panel/MediaOutputPanel.java
@@ -19,6 +19,7 @@
import static com.android.settings.media.MediaOutputSlice.MEDIA_PACKAGE_NAME;
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_SLICE_URI;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -71,4 +72,9 @@
public Intent getSeeMoreIntent() {
return null;
}
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.PANEL_MEDIA_OUTPUT;
+ }
}
diff --git a/src/com/android/settings/panel/NfcPanel.java b/src/com/android/settings/panel/NfcPanel.java
index 70452a3..8fa41d9 100644
--- a/src/com/android/settings/panel/NfcPanel.java
+++ b/src/com/android/settings/panel/NfcPanel.java
@@ -50,4 +50,9 @@
intent.setClassName(mContext.getPackageName(), SubSettings.class.getName());
return intent;
}
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.PANEL_NFC;
+ }
}
diff --git a/src/com/android/settings/panel/PanelContent.java b/src/com/android/settings/panel/PanelContent.java
index bd84c2f..496bac3 100644
--- a/src/com/android/settings/panel/PanelContent.java
+++ b/src/com/android/settings/panel/PanelContent.java
@@ -19,12 +19,14 @@
import android.content.Intent;
import android.net.Uri;
+import com.android.settingslib.core.instrumentation.Instrumentable;
+
import java.util.List;
/**
* Represents the data class needed to create a Settings Panel. See {@link PanelFragment}.
*/
-public interface PanelContent {
+public interface PanelContent extends Instrumentable {
/**
* @return a string for the title of the Panel.
diff --git a/src/com/android/settings/panel/PanelFeatureProvider.java b/src/com/android/settings/panel/PanelFeatureProvider.java
index 5af5ac8..85e098d 100644
--- a/src/com/android/settings/panel/PanelFeatureProvider.java
+++ b/src/com/android/settings/panel/PanelFeatureProvider.java
@@ -21,7 +21,8 @@
public interface PanelFeatureProvider {
/**
- * Returns {@link PanelContent} as specified by the {@code panelType} and {@code packageName}.
+ * Returns {@link PanelContent} as specified by the {@param panelType}, and
+ * {@param mediaPackageName}.
*/
- PanelContent getPanel(Context context, String panelType, String packageName);
+ PanelContent getPanel(Context context, String panelType, String mediaPackageName);
}
diff --git a/src/com/android/settings/panel/PanelFeatureProviderImpl.java b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
index c3d611d..6b096a1 100644
--- a/src/com/android/settings/panel/PanelFeatureProviderImpl.java
+++ b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
@@ -24,7 +24,7 @@
public class PanelFeatureProviderImpl implements PanelFeatureProvider {
@Override
- public PanelContent getPanel(Context context, String panelType, String packageName) {
+ public PanelContent getPanel(Context context, String panelType, String mediaPackageName) {
switch (panelType) {
case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
return InternetConnectivityPanel.create(context);
@@ -33,7 +33,7 @@
case Settings.Panel.ACTION_NFC:
return NfcPanel.create(context);
case ACTION_MEDIA_OUTPUT:
- return MediaOutputPanel.create(context, packageName);
+ return MediaOutputPanel.create(context, mediaPackageName);
}
throw new IllegalStateException("No matching panel for: " + panelType);
diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java
index db0bf0e..a222d36 100644
--- a/src/com/android/settings/panel/PanelFragment.java
+++ b/src/com/android/settings/panel/PanelFragment.java
@@ -16,9 +16,9 @@
package com.android.settings.panel;
-import android.content.Intent;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
import android.os.Bundle;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -35,6 +35,8 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.panel.PanelLoggingContract.PanelClosedKeys;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
public class PanelFragment extends Fragment {
@@ -45,15 +47,15 @@
private Button mDoneButton;
private RecyclerView mPanelSlices;
+ private PanelContent mPanel;
+ private final MetricsFeatureProvider mMetricsProvider;
+
@VisibleForTesting
PanelSlicesAdapter mAdapter;
- private View.OnClickListener mDoneButtonListener = (v) -> {
- Log.d(TAG, "Closing dialog");
- getActivity().finish();
- };
-
public PanelFragment() {
+ final Context context = getActivity();
+ mMetricsProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
@Nullable
@@ -69,38 +71,70 @@
mTitleView = view.findViewById(R.id.panel_title);
final Bundle arguments = getArguments();
- final String panelType = arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
- final String packageName =
- arguments.getString(SettingsPanelActivity.KEY_PANEL_PACKAGE_NAME);
+ final String panelType =
+ arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
+ final String callingPackageName =
+ arguments.getString(SettingsPanelActivity.KEY_CALLING_PACKAGE_NAME);
+ final String mediaPackageName =
+ arguments.getString(SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME);
- final PanelContent panel = FeatureFactory.getFactory(activity)
+ // TODO (b/124399577) transform interface to take a context and bundle.
+ mPanel = FeatureFactory.getFactory(activity)
.getPanelFeatureProvider()
- .getPanel(activity, panelType, packageName);
+ .getPanel(activity, panelType, mediaPackageName);
- mAdapter = new PanelSlicesAdapter(this, panel.getSlices());
+ // Log panel opened.
+ mMetricsProvider.action(
+ 0 /* attribution */,
+ SettingsEnums.PAGE_VISIBLE /* opened panel - Action */,
+ mPanel.getMetricsCategory(),
+ callingPackageName,
+ 0 /* value */);
+
+ mAdapter = new PanelSlicesAdapter(this, mPanel);
mPanelSlices.setHasFixedSize(true);
mPanelSlices.setLayoutManager(new LinearLayoutManager((activity)));
mPanelSlices.setAdapter(mAdapter);
- mTitleView.setText(panel.getTitle());
+ mTitleView.setText(mPanel.getTitle());
- mSeeMoreButton.setOnClickListener(getSeeMoreListener(panel.getSeeMoreIntent()));
- mDoneButton.setOnClickListener(mDoneButtonListener);
+ mSeeMoreButton.setOnClickListener(getSeeMoreListener());
+ mDoneButton.setOnClickListener(getCloseListener());
//If getSeeMoreIntent() is null, hide the mSeeMoreButton.
- if (panel.getSeeMoreIntent() == null) {
+ if (mPanel.getSeeMoreIntent() == null) {
mSeeMoreButton.setVisibility(View.GONE);
}
return view;
}
- private View.OnClickListener getSeeMoreListener(final Intent intent) {
+ @VisibleForTesting
+ View.OnClickListener getSeeMoreListener() {
return (v) -> {
+ mMetricsProvider.action(
+ 0 /* attribution */,
+ SettingsEnums.PAGE_HIDE ,
+ mPanel.getMetricsCategory(),
+ PanelClosedKeys.KEY_SEE_MORE,
+ 0 /* value */);
final FragmentActivity activity = getActivity();
- activity.startActivity(intent);
+ activity.startActivityForResult(mPanel.getSeeMoreIntent(), 0);
activity.finish();
};
}
+
+ @VisibleForTesting
+ View.OnClickListener getCloseListener() {
+ return (v) -> {
+ mMetricsProvider.action(
+ 0 /* attribution */,
+ SettingsEnums.PAGE_HIDE,
+ mPanel.getMetricsCategory(),
+ PanelClosedKeys.KEY_DONE,
+ 0 /* value */);
+ getActivity().finish();
+ };
+ }
}
diff --git a/src/com/android/settings/panel/PanelLoggingContract.java b/src/com/android/settings/panel/PanelLoggingContract.java
new file mode 100644
index 0000000..e149186
--- /dev/null
+++ b/src/com/android/settings/panel/PanelLoggingContract.java
@@ -0,0 +1,46 @@
+/*
+ * 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.panel;
+
+/**
+ * Simple contract class to track keys in Panel logging.
+ *
+ * <p>
+ * Constants should only be removed if underlying panel, or use case is removed.
+ * </p>
+ */
+public class PanelLoggingContract {
+
+ /**
+ * Keys tracking different ways users exit Panels.
+ */
+ interface PanelClosedKeys {
+ /**
+ * The user clicked the See More button linking deeper into Settings.
+ */
+ String KEY_SEE_MORE = "see_more";
+
+ /**
+ * The user clicked the Done button, closing the Panel.
+ */
+ String KEY_DONE = "done";
+
+ /**
+ * The user clicked outside the dialog, closing the Panel.
+ */
+ String KEY_CLICKED_OUT = "clicked_out";
+ }
+}
diff --git a/src/com/android/settings/panel/PanelSlicesAdapter.java b/src/com/android/settings/panel/PanelSlicesAdapter.java
index f688512..c1cb049 100644
--- a/src/com/android/settings/panel/PanelSlicesAdapter.java
+++ b/src/com/android/settings/panel/PanelSlicesAdapter.java
@@ -16,6 +16,7 @@
package com.android.settings.panel;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.net.Uri;
import android.view.LayoutInflater;
@@ -31,8 +32,8 @@
import androidx.slice.widget.SliceView;
import com.android.settings.R;
+import com.android.settings.overlay.FeatureFactory;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -43,10 +44,12 @@
private final List<Uri> mSliceUris;
private final PanelFragment mPanelFragment;
+ private final PanelContent mPanelContent;
- public PanelSlicesAdapter(PanelFragment fragment, List<Uri> sliceUris) {
+ public PanelSlicesAdapter(PanelFragment fragment, PanelContent panel) {
mPanelFragment = fragment;
- mSliceUris = new ArrayList<>(sliceUris);
+ mSliceUris = panel.getSlices();
+ mPanelContent = panel;
}
@NonNull
@@ -56,7 +59,7 @@
final LayoutInflater inflater = LayoutInflater.from(context);
final View view = inflater.inflate(R.layout.panel_slice_row, viewGroup, false);
- return new SliceRowViewHolder(view);
+ return new SliceRowViewHolder(view, mPanelContent);
}
@Override
@@ -79,22 +82,38 @@
*/
public static class SliceRowViewHolder extends RecyclerView.ViewHolder {
+ private final PanelContent mPanelContent;
+
@VisibleForTesting
LiveData<Slice> sliceLiveData;
@VisibleForTesting
final SliceView sliceView;
- public SliceRowViewHolder(View view) {
+ public SliceRowViewHolder(View view, PanelContent panelContent) {
super(view);
sliceView = view.findViewById(R.id.slice_view);
sliceView.setMode(SliceView.MODE_LARGE);
+ mPanelContent = panelContent;
}
public void onBind(PanelFragment fragment, Uri sliceUri) {
final Context context = sliceView.getContext();
sliceLiveData = SliceLiveData.fromUri(context, sliceUri);
sliceLiveData.observe(fragment.getViewLifecycleOwner(), sliceView);
+
+ // Log Panel interaction
+ sliceView.setOnSliceActionListener(
+ ((eventInfo, sliceItem) -> {
+ FeatureFactory.getFactory(context)
+ .getMetricsFeatureProvider()
+ .action(0 /* attribution */,
+ SettingsEnums.ACTION_PANEL_INTERACTION,
+ mPanelContent.getMetricsCategory(),
+ sliceUri.toString() /* log key */,
+ eventInfo.actionType /* value */);
+ })
+ );
}
}
}
diff --git a/src/com/android/settings/panel/SettingsPanelActivity.java b/src/com/android/settings/panel/SettingsPanelActivity.java
index 4cf535e..3819c80 100644
--- a/src/com/android/settings/panel/SettingsPanelActivity.java
+++ b/src/com/android/settings/panel/SettingsPanelActivity.java
@@ -19,11 +19,13 @@
import static com.android.settingslib.media.MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT;
import static com.android.settingslib.media.MediaOutputSliceConstants.EXTRA_PACKAGE_NAME;
+import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
+import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;
@@ -34,6 +36,8 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.panel.PanelLoggingContract.PanelClosedKeys;
/**
* Dialog Activity to host Settings Slices.
@@ -49,7 +53,16 @@
* Key specifying which Panel the app is requesting.
*/
public static final String KEY_PANEL_TYPE_ARGUMENT = "PANEL_TYPE_ARGUMENT";
- public static final String KEY_PANEL_PACKAGE_NAME = "PANEL_PACKAGE_NAME";
+
+ /**
+ * Key specifying the package which requested the Panel.
+ */
+ public static final String KEY_CALLING_PACKAGE_NAME = "PANEL_CALLING_PACKAGE_NAME";
+
+ /**
+ * Key specifying the package name for which the
+ */
+ public static final String KEY_MEDIA_PACKAGE_NAME = "PANEL_MEDIA_PACKAGE_NAME";
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -62,12 +75,12 @@
return;
}
- final String packageName =
+ final String mediaPackageName =
callingIntent.getStringExtra(EXTRA_PACKAGE_NAME);
if (TextUtils.equals(ACTION_MEDIA_OUTPUT, callingIntent.getAction())
- && TextUtils.isEmpty(packageName)) {
- Log.e(TAG, "Null package name, closing Panel Activity");
+ && TextUtils.isEmpty(mediaPackageName)) {
+ Log.e(TAG, "Missing EXTRA_PACKAGE_NAME, closing Panel Activity");
finish();
return;
}
@@ -81,7 +94,8 @@
WindowManager.LayoutParams.WRAP_CONTENT);
mBundle.putString(KEY_PANEL_TYPE_ARGUMENT, callingIntent.getAction());
- mBundle.putString(KEY_PANEL_PACKAGE_NAME, packageName);
+ mBundle.putString(KEY_CALLING_PACKAGE_NAME, getCallingPackage());
+ mBundle.putString(KEY_MEDIA_PACKAGE_NAME, mediaPackageName);
final PanelFragment panelFragment = new PanelFragment();
panelFragment.setArguments(mBundle);
@@ -92,4 +106,21 @@
fragmentManager.beginTransaction().add(R.id.main_content, panelFragment).commit();
}
}
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
+ final PanelContent panelContent = FeatureFactory.getFactory(this)
+ .getPanelFeatureProvider()
+ .getPanel(this, getIntent().getAction(), null /* Media Package Name */);
+ FeatureFactory.getFactory(this)
+ .getMetricsFeatureProvider()
+ .action(0 /* attribution */,
+ SettingsEnums.PAGE_HIDE,
+ panelContent.getMetricsCategory(),
+ PanelClosedKeys.KEY_CLICKED_OUT,
+ 0 /* value */);
+ }
+ return super.onTouchEvent(event);
+ }
}
diff --git a/src/com/android/settings/panel/VolumePanel.java b/src/com/android/settings/panel/VolumePanel.java
index 352fed5..20c2272 100644
--- a/src/com/android/settings/panel/VolumePanel.java
+++ b/src/com/android/settings/panel/VolumePanel.java
@@ -21,6 +21,7 @@
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_MEDIA_URI;
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_RINGER_URI;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -62,4 +63,9 @@
public Intent getSeeMoreIntent() {
return new Intent(Settings.ACTION_SOUND_SETTINGS);
}
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.PANEL_VOLUME;
+ }
}
\ No newline at end of file
diff --git a/src/com/android/settings/widget/AdaptiveHomepageIcon.java b/src/com/android/settings/widget/AdaptiveHomepageIcon.java
index bec5d8d..bc7aaa7 100644
--- a/src/com/android/settings/widget/AdaptiveHomepageIcon.java
+++ b/src/com/android/settings/widget/AdaptiveHomepageIcon.java
@@ -72,11 +72,13 @@
// If found anything, use it.
if (bgColor != 0) {
setBackgroundColor(bgColor);
+ return;
}
}
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Failed to set background color for " + tile.getPackageName());
}
+ setBackgroundColor(context.getColor(R.color.homepage_generic_icon_background));
}
public void setBackgroundColor(int color) {
diff --git a/tests/robotests/src/com/android/settings/gestures/WakeScreenGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/WakeScreenGesturePreferenceControllerTest.java
index 6149539..ecda5fd 100644
--- a/tests/robotests/src/com/android/settings/gestures/WakeScreenGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/WakeScreenGesturePreferenceControllerTest.java
@@ -17,12 +17,14 @@
package com.android.settings.gestures;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.when;
import android.content.Context;
@@ -77,6 +79,7 @@
@Test
public void getAvailabilityStatus_gestureNotSupported_UNSUPPORTED_ON_DEVICE() {
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(false);
final int availabilityStatus = mController.getAvailabilityStatus();
@@ -85,6 +88,7 @@
@Test
public void getAvailabilityStatus_gestureSupported_AVAILABLE() {
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(true);
final int availabilityStatus = mController.getAvailabilityStatus();
@@ -92,6 +96,25 @@
}
@Test
+ public void getAvailabilityStatus_gestureSupported_DISABLED_DEPENDENT_SETTING() {
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(false);
+ when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(true);
+ final int availabilityStatus = mController.getAvailabilityStatus();
+
+ assertThat(availabilityStatus).isEqualTo(DISABLED_DEPENDENT_SETTING);
+ }
+
+ @Test
+ public void canHandleClicks_onlyWhenAlwaysOn() {
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(false);
+ assertThat(mController.canHandleClicks()).isEqualTo(false);
+
+ reset(mAmbientDisplayConfiguration);
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
+ assertThat(mController.canHandleClicks()).isEqualTo(true);
+ }
+
+ @Test
public void isSliceableCorrectKey_returnsTrue() {
final WakeScreenGesturePreferenceController controller =
new WakeScreenGesturePreferenceController(mContext, "gesture_wake_screen");
diff --git a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
index e0334b1..dbc122a 100644
--- a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
+++ b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
@@ -47,7 +47,7 @@
@Test
public void getAvailableSubscriptions_nullInfoFromSubscriptionManager_nonNullResult() {
- when(mManager.getAvailableSubscriptionInfoList()).thenReturn(null);
+ when(mManager.getSelectableSubscriptionInfoList()).thenReturn(null);
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
assertThat(subs).isNotNull();
assertThat(subs).isEmpty();
@@ -57,7 +57,7 @@
public void getAvailableSubscriptions_oneSubscription_oneResult() {
final SubscriptionInfo info = mock(SubscriptionInfo.class);
when(info.getMncString()).thenReturn("fake1234");
- when(mManager.getAvailableSubscriptionInfoList()).thenReturn(Arrays.asList(info));
+ when(mManager.getSelectableSubscriptionInfoList()).thenReturn(Arrays.asList(info));
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
assertThat(subs).isNotNull();
assertThat(subs).hasSize(1);
@@ -69,7 +69,7 @@
final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
when(info1.getMncString()).thenReturn("fake1234");
when(info2.getMncString()).thenReturn("fake5678");
- when(mManager.getAvailableSubscriptionInfoList()).thenReturn(Arrays.asList(info1, info2));
+ when(mManager.getSelectableSubscriptionInfoList()).thenReturn(Arrays.asList(info1, info2));
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
assertThat(subs).isNotNull();
assertThat(subs).hasSize(2);
@@ -82,7 +82,7 @@
final SubscriptionInfo info3 = mock(SubscriptionInfo.class);
when(info1.getSubscriptionId()).thenReturn(1);
when(info1.getMncString()).thenReturn("fake1234");
- when(mManager.getAvailableSubscriptionInfoList()).thenReturn(
+ when(mManager.getSelectableSubscriptionInfoList()).thenReturn(
new ArrayList<>(Arrays.asList(info1, info2, info3)));
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
assertThat(subs).isNotNull();
@@ -100,7 +100,7 @@
when(info1.getMncString()).thenReturn("fake1234");
when(info4.getSubscriptionId()).thenReturn(4);
when(info4.getMncString()).thenReturn("fake5678");
- when(mManager.getAvailableSubscriptionInfoList()).thenReturn(new ArrayList<>(
+ when(mManager.getSelectableSubscriptionInfoList()).thenReturn(new ArrayList<>(
Arrays.asList(info1, info2, info3, info4)));
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
assertThat(subs).isNotNull();
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
index 447931e..3b5cdf9 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
@@ -148,7 +148,7 @@
doReturn(intent).when(mMobileNetworkActivity).getIntent();
mSubscriptionInfos.add(mSubscriptionInfo);
mSubscriptionInfos.add(mSubscriptionInfo2);
- doReturn(mSubscriptionInfos).when(mSubscriptionManager).getAvailableSubscriptionInfoList();
+ doReturn(mSubscriptionInfos).when(mSubscriptionManager).getSelectableSubscriptionInfoList();
doReturn(true).when(mSubscriptionManager).isActiveSubscriptionId(CURRENT_SUB_ID);
assertThat(mMobileNetworkActivity.getSubscriptionId()).isEqualTo(CURRENT_SUB_ID);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
index a057022..d904ab3 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
@@ -84,14 +84,14 @@
@Test
public void isVideoCallEnabled_allFlagsOn_returnTrue() {
- assertThat(mController.isVideoCallEnabled()).isTrue();
+ assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isTrue();
}
@Test
public void isVideoCallEnabled_disabledByPlatform_returnFalse() {
doReturn(false).when(mImsManager).isVtEnabledByPlatform();
- assertThat(mController.isVideoCallEnabled()).isFalse();
+ assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
}
@Test
@@ -100,7 +100,7 @@
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, false);
doReturn(false).when(mTelephonyManager).isDataEnabled();
- assertThat(mController.isVideoCallEnabled()).isFalse();
+ assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/panel/FakePanelContent.java b/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
index 1d79952..8f54115 100644
--- a/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
+++ b/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
@@ -18,6 +18,7 @@
import static com.android.settings.slices.CustomSliceRegistry.WIFI_SLICE_URI;
+import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.net.Uri;
@@ -53,4 +54,9 @@
public Intent getSeeMoreIntent() {
return INTENT;
}
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.TESTING;
+ }
}
diff --git a/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java b/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
index 389c31e..be8d8bc 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
@@ -22,10 +22,13 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
+import android.view.View;
import android.widget.LinearLayout;
import com.android.settings.R;
@@ -71,13 +74,14 @@
.get()
.getSupportFragmentManager()
.findFragmentById(R.id.main_content));
+
+ final Bundle bundle = new Bundle();
+ bundle.putString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT, FAKE_EXTRA);
+ doReturn(bundle).when(mPanelFragment).getArguments();
}
@Test
public void onCreateView_adapterGetsDataset() {
- final Bundle bundle = new Bundle();
- bundle.putString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT, FAKE_EXTRA);
- doReturn(bundle).when(mPanelFragment).getArguments();
mPanelFragment.onCreateView(LayoutInflater.from(mContext),
new LinearLayout(mContext), null);
PanelSlicesAdapter adapter = mPanelFragment.mAdapter;
@@ -85,4 +89,43 @@
assertThat(adapter.getData()).containsAllIn(mFakePanelContent.getSlices());
}
+ @Test
+ public void onCreate_logsOpenEvent() {
+ verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+ 0,
+ SettingsEnums.PAGE_VISIBLE,
+ mFakePanelContent.getMetricsCategory(),
+ null,
+ 0);
+ }
+
+ @Test
+ public void panelSeeMoreClick_logsCloseEvent() {
+ final View.OnClickListener listener = mPanelFragment.getSeeMoreListener();
+
+ listener.onClick(null);
+
+ verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+ 0,
+ SettingsEnums.PAGE_HIDE,
+ mFakePanelContent.getMetricsCategory(),
+ PanelLoggingContract.PanelClosedKeys.KEY_SEE_MORE,
+ 0
+ );
+ }
+
+ @Test
+ public void panelDoneClick_logsCloseEvent() {
+ final View.OnClickListener listener = mPanelFragment.getCloseListener();
+
+ listener.onClick(null);
+
+ verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+ 0,
+ SettingsEnums.PAGE_HIDE,
+ mFakePanelContent.getMetricsCategory(),
+ PanelLoggingContract.PanelClosedKeys.KEY_DONE,
+ 0
+ );
+ }
}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java b/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
index abefa67..4dce15e 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
@@ -71,7 +71,7 @@
.getSupportFragmentManager()
.findFragmentById(R.id.main_content));
- mAdapter = new PanelSlicesAdapter(mPanelFragment, mFakePanelContent.getSlices());
+ mAdapter = new PanelSlicesAdapter(mPanelFragment, mFakePanelContent);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java b/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
index 359cf5d..a51b7b0 100644
--- a/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
+++ b/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
@@ -16,13 +16,25 @@
package com.android.settings.panel;
-import static com.android.settings.panel.SettingsPanelActivity.KEY_PANEL_PACKAGE_NAME;
+import static com.android.settings.panel.SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME;
import static com.android.settings.panel.SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT;
import static com.google.common.truth.Truth.assertThat;
-import android.content.Intent;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import android.app.settings.SettingsEnums;
+import android.content.Intent;
+import android.view.MotionEvent;
+
+import com.android.settings.testutils.FakeFeatureFactory;
+
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
@@ -31,6 +43,22 @@
@RunWith(RobolectricTestRunner.class)
public class SettingsPanelActivityTest {
+ private FakeFeatureFactory mFakeFeatureFactory;
+ private FakeSettingsPanelActivity mSettingsPanelActivity;
+ private PanelFeatureProvider mPanelFeatureProvider;
+ private FakePanelContent mFakePanelContent;
+
+ @Before
+ public void setUp() {
+ mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
+ mSettingsPanelActivity = Robolectric.buildActivity(FakeSettingsPanelActivity.class)
+ .create().get();
+ mPanelFeatureProvider = spy(new PanelFeatureProviderImpl());
+ mFakeFeatureFactory.panelFeatureProvider = mPanelFeatureProvider;
+ mFakePanelContent = new FakePanelContent();
+ doReturn(mFakePanelContent).when(mPanelFeatureProvider).getPanel(any(), any(), any());
+ }
+
@Test
public void startMediaOutputSlice_withPackageName_bundleShouldHaveValue() {
final Intent intent = new Intent()
@@ -41,7 +69,7 @@
final SettingsPanelActivity activity =
Robolectric.buildActivity(SettingsPanelActivity.class, intent).create().get();
- assertThat(activity.mBundle.getString(KEY_PANEL_PACKAGE_NAME))
+ assertThat(activity.mBundle.getString(KEY_MEDIA_PACKAGE_NAME))
.isEqualTo("com.google.android.music");
assertThat(activity.mBundle.getString(KEY_PANEL_TYPE_ARGUMENT))
.isEqualTo("com.android.settings.panel.action.MEDIA_OUTPUT");
@@ -55,7 +83,23 @@
final SettingsPanelActivity activity =
Robolectric.buildActivity(SettingsPanelActivity.class, intent).create().get();
- assertThat(activity.mBundle.containsKey(KEY_PANEL_PACKAGE_NAME)).isFalse();
+ assertThat(activity.mBundle.containsKey(KEY_MEDIA_PACKAGE_NAME)).isFalse();
assertThat(activity.mBundle.containsKey(KEY_PANEL_TYPE_ARGUMENT)).isFalse();
}
+
+ @Test
+ public void onTouchEvent_outsideAction_logsPanelClosed() {
+ final MotionEvent event = mock(MotionEvent.class);
+ when(event.getAction()).thenReturn(MotionEvent.ACTION_OUTSIDE);
+
+ mSettingsPanelActivity.onTouchEvent(event);
+
+ verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+ 0,
+ SettingsEnums.PAGE_HIDE,
+ SettingsEnums.TESTING,
+ PanelLoggingContract.PanelClosedKeys.KEY_CLICKED_OUT,
+ 0
+ );
+ }
}
diff --git a/tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java b/tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java
index db8a85c..05a9cfb 100644
--- a/tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java
+++ b/tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java
@@ -97,6 +97,20 @@
}
@Test
+ public void setBackgroundColor_tileWithoutBackgroundColor_shouldSetDefaultBackgroundColor() {
+ final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
+ doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings_accent))
+ .when(tile).getIcon(mContext);
+ final AdaptiveHomepageIcon icon =
+ new AdaptiveHomepageIcon(mContext, new ColorDrawable(Color.BLACK));
+
+ icon.setBackgroundColor(mContext, tile);
+
+ assertThat(icon.mBackgroundColor).isEqualTo(
+ mContext.getColor(R.color.homepage_generic_icon_background));
+ }
+
+ @Test
public void onBindTile_externalTileWithBackgroundColorHint_shouldUpdateIcon() {
final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON_BACKGROUND_HINT,