Merge "Refined the Search Bar layout"
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index 83c0d53..787c559 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -2,6 +2,18 @@
<issues format="4">
<issue
+ id="LintError"
+ severity="Error"
+ message="No `.class` files were found in project ".", so none of the classfile based checks could be run. Does the project need to be built first?"
+ category="Lint"
+ priority="10"
+ summary="Lint Failure"
+ explanation="This issue type represents a problem running lint itself. Examples include failure to find bytecode for source files (which means certain detectors could not be run), parsing errors in lint configuration files, etc.
These errors are not errors in your own code, but they are shown to make it clear that some checks were not completed.">
+ <location
+ file="."/>
+ </issue>
+
+ <issue
id="HardCodedColor"
severity="Error"
message="Avoid using hardcoded color"
@@ -809,8 +821,8 @@
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="wifi_details_icon_color">#8A000000</color>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" <color name="fallback_tintColor">#89000000</color>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
line="87"
@@ -1561,22 +1573,6 @@
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:tint="@color/wifi_details_icon_color">"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/drawable/ic_frequency_antenna.xml"
- line="22"
- column="9"/>
- </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_about_background" />"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
@@ -1897,22 +1893,6 @@
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:tint="@color/wifi_details_icon_color">"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/drawable/ic_security_lock_24dp.xml"
- line="22"
- column="9"/>
- </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=" <background android:drawable="@color/shortcut_background"/>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
diff --git a/res/drawable/ic_frequency_antenna.xml b/res/drawable/ic_frequency_antenna.xml
index 581b83e..716a98a 100644
--- a/res/drawable/ic_frequency_antenna.xml
+++ b/res/drawable/ic_frequency_antenna.xml
@@ -19,7 +19,7 @@
android:viewportHeight="24"
android:width="24dp"
android:height="24dp"
- android:tint="@color/wifi_details_icon_color">
+ android:tint="?android:attr/colorControlNormal">
<path
android:pathData="M12,5c-3.9,0-7,3.1-7,7h2c0-2.8,2.2-5,5-5s5,2.2,5,5h2C19,8.1,15.9,5,12,5z M13,14.3c0.9-0.4,1.5-1.3,1.5-2.3
c0-1.4-1.1-2.5-2.5-2.5S9.5,10.6,9.5,12c0,1,0.6,1.9,1.5,2.3v3.3L7.6,21L9,22.4l3-3l3,3l1.4-1.4L13,17.6V14.3z M12,1
diff --git a/res/drawable/ic_security_lock_24dp.xml b/res/drawable/ic_security_lock_24dp.xml
index fd49b23..40b5109 100644
--- a/res/drawable/ic_security_lock_24dp.xml
+++ b/res/drawable/ic_security_lock_24dp.xml
@@ -19,7 +19,7 @@
android:viewportHeight="24"
android:width="24dp"
android:height="24dp"
- android:tint="@color/wifi_details_icon_color">
+ android:tint="?android:attr/colorControlNormal">
<path
android:pathData="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"
android:fillColor="#FFFFFFFF" />
diff --git a/res/layout/wifi_dpp_add_device_fragment.xml b/res/layout/wifi_dpp_add_device_fragment.xml
new file mode 100644
index 0000000..03add62
--- /dev/null
+++ b/res/layout/wifi_dpp_add_device_fragment.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/root"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <include layout="@layout/wifi_dpp_fragment_header"/>
+
+ <ProgressBar
+ android:id="@+id/progress_bar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:indeterminate="true"/>
+
+ <ImageView
+ android:id="@+id/wifi_ap_picture_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"/>
+
+ <TextView android:id="@+id/choose_different_network"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"/>
+
+ <include layout="@layout/wifi_dpp_fragment_footer"
+ android:gravity="center|bottom"/>
+
+</LinearLayout>
+
diff --git a/res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml b/res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml
new file mode 100644
index 0000000..a65cf3e
--- /dev/null
+++ b/res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/root"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <include layout="@layout/wifi_dpp_fragment_header"/>
+
+ <ListView android:id="@+id/saved_wifi_network_list"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+
+ <include layout="@layout/wifi_dpp_fragment_footer"
+ android:gravity="center|bottom"/>
+
+</LinearLayout>
+
diff --git a/res/layout/wifi_dpp_qrcode_generator_fragment.xml b/res/layout/wifi_dpp_qrcode_generator_fragment.xml
new file mode 100644
index 0000000..789b3a3
--- /dev/null
+++ b/res/layout/wifi_dpp_qrcode_generator_fragment.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/root"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <include layout="@layout/wifi_dpp_fragment_header"/>
+
+ <ImageView
+ android:id="@+id/barcode_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"/>
+
+</LinearLayout>
+
diff --git a/res/layout/wifi_dpp_qrcode_scanner_fragment.xml b/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
index 130bb6d..a864f51 100644
--- a/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
+++ b/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
@@ -17,7 +17,6 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
diff --git a/res/values/colors.xml b/res/values/colors.xml
index d10cb5f..587184b 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -83,8 +83,8 @@
<!-- Color for the background of the shortcut icons.-->
<color name="shortcut_background">#fff5f5f5</color>
- <!-- Color for preference icons on the Wifi Network Details page -->
- <color name="wifi_details_icon_color">#8A000000</color>
+ <!-- The fallback color for tinting icons. Only used when colorControlNormal is unavailable -->
+ <color name="fallback_tintColor">#89000000</color>
<!-- Dashboard/homepage icon background colors -->
<color name="homepage_network_background">#2196F3</color>
diff --git a/res/values/config.xml b/res/values/config.xml
index 6b0a10e..edd948f 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -151,6 +151,9 @@
com.android.settings.intelligence
</string>
+ <!-- Settings intelligence interaction log intent action -->
+ <string name="config_settingsintelligence_log_action" translatable="false"></string>
+
<!-- Emergency app package name -->
<string name="config_emergency_package_name" translatable="false">
com.android.emergency
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e1948d4..fb8ab20 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3456,9 +3456,9 @@
<!-- Button title to factory data reset the entire device. The "(factory reset)" part is optional for translation. [CHAR LIMIT=30 BACKUP_MESSAGE_ID=3531267871084279512]-->
<string name="master_clear_short_title">Erase all data (factory reset)</string>
<!-- SD card & phone storage settings screen, message on screen after user selects Factory data reset [CHAR LIMIT=NONE] -->
- <string name="master_clear_desc" product="tablet">"This will erase all data from your tablet\u2019s <b>internal storage</b>, including:\n\n<li>Your Google account</li>\n<li>System and app data and settings</li>\n<li>Downloaded apps</li>"</string>
+ <string name="master_clear_desc" product="tablet">"This will erase all data from your tablet\u2019s <b>internal storage</b>, including:\n\n<li>Your Google Account</li>\n<li>System and app data and settings</li>\n<li>Downloaded apps</li>"</string>
<!-- SD card & phone storage settings screen, message on screen after user selects Factory data reset [CHAR LIMIT=NONE] -->
- <string name="master_clear_desc" product="default">"This will erase all data from your phone\u2019s <b>internal storage</b>, including:\n\n<li>Your Google account</li>\n<li>System and app data and settings</li>\n<li>Downloaded apps</li>"</string>
+ <string name="master_clear_desc" product="default">"This will erase all data from your phone\u2019s <b>internal storage</b>, including:\n\n<li>Your Google Account</li>\n<li>System and app data and settings</li>\n<li>Downloaded apps</li>"</string>
<!-- SD card & phone storage settings screen, instructions and list of current accounts. The list of accounts follows this text[CHAR LIMIT=NONE] -->
<string name="master_clear_accounts" product="default">"\n\nYou are currently signed into the following accounts:\n"</string>
<!-- SD card & phone storage settings screen, notification if other users are present on the device [CHAR LIMIT=NONE] -->
@@ -3488,17 +3488,17 @@
<!-- SD card & phone storage settings screen, description for check box to erase eSIMs for tablets [CHAR LIMIT=NONE] -->
<string name="erase_esim_storage_description" product="tablet">Erase all eSIMs on the tablet. This will not cancel your mobile service plan.</string>
<!-- SD card & phone storage settings screen, button on screen after user selects Factory data reset -->
- <string name="master_clear_button_text" product="tablet">Reset tablet</string>
+ <string name="master_clear_button_text" product="tablet">Erase all data</string>
<!-- SD card & phone storage settings screen, button on screen after user selects Factory data reset -->
- <string name="master_clear_button_text" product="default">Reset phone</string>
+ <string name="master_clear_button_text" product="default">Erase all data</string>
<!-- SD card & phone storage settings screen, message on screen after user selects Reset phone button -->
- <string name="master_clear_final_desc">Erase all your personal information and downloaded apps? You can\u2019t undo this action!</string>
+ <string name="master_clear_final_desc">All of your personal information and downloaded apps will be deleted. You can\u2019t undo this action!</string>
<!-- SD card & phone storage settings screen, button on screen after user selects Reset phone button -->
<string name="master_clear_final_button_text">Erase everything</string>
<!-- Master clear failed message -->
<string name="master_clear_failed">No reset was performed because the System Clear service isn\u2019t available.</string>
<!-- Master clear confirmation screen title [CHAR LIMIT=30] -->
- <string name="master_clear_confirm_title">Reset?</string>
+ <string name="master_clear_confirm_title">Erase all data?</string>
<!-- Error message for users that aren't allowed to factory reset [CHAR LIMIT=none] -->
<string name="master_clear_not_available">Factory reset is not available for this user</string>
<!-- Master clear progress screen title [CHAR LIMIT=30] -->
@@ -10238,9 +10238,9 @@
<!-- UI debug setting: force desktop mode summary [CHAR LIMIT=NONE] -->
<string name="force_desktop_mode_summary">Force experimental desktop mode on secondary displays</string>
- <!-- UI debug setting: Force enable "smart dark" UI rendering feature [CHAR LIMIT=40] -->
+ <!-- UI debug setting: Force enable "smart dark" UI rendering feature [CHAR LIMIT=60] -->
<string name="hwui_force_dark_title">Override force-dark</string>
- <!-- UI debug setting: Force enable "smart dark" UI rendering feature summary [CHAR LIMIT=100] -->
+ <!-- UI debug setting: Force enable "smart dark" UI rendering feature summary [CHAR LIMIT=NONE] -->
<string name="hwui_force_dark_summary">Overrides the force-dark feature to be always-on</string>
<!-- Title for the top level Privacy Settings [CHAR LIMIT=30]-->
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index b0e362c..50a5649 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -44,7 +44,6 @@
android:title="@string/auto_brightness_title"
android:summary="@string/summary_placeholder"
android:fragment="com.android.settings.display.AutoBrightnessSettings"
- settings:searchable="false"
settings:controller="com.android.settings.display.AutoBrightnessPreferenceController" />
<com.android.settingslib.RestrictedPreference
diff --git a/src/com/android/settings/bluetooth/BluetoothSliceBuilder.java b/src/com/android/settings/bluetooth/BluetoothSliceBuilder.java
index 1462f91..0a2e8ce 100644
--- a/src/com/android/settings/bluetooth/BluetoothSliceBuilder.java
+++ b/src/com/android/settings/bluetooth/BluetoothSliceBuilder.java
@@ -20,7 +20,6 @@
import android.annotation.ColorInt;
import android.app.PendingIntent;
import android.bluetooth.BluetoothAdapter;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -37,6 +36,7 @@
import com.android.settings.R;
import com.android.settings.SubSettings;
import com.android.settings.connecteddevice.BluetoothDashboardFragment;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.SliceBroadcastReceiver;
import com.android.settings.slices.SliceBuilderUtils;
@@ -48,16 +48,6 @@
private static final String TAG = "BluetoothSliceBuilder";
/**
- * Backing Uri for the Bluetooth Slice.
- */
- public static final Uri BLUETOOTH_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSlicesContract.AUTHORITY)
- .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
- .appendPath(SettingsSlicesContract.KEY_BLUETOOTH)
- .build();
-
- /**
* Action notifying a change on the BluetoothSlice.
*/
public static final String ACTION_BLUETOOTH_SLICE_CHANGED =
@@ -74,7 +64,7 @@
}
/**
- * Return a Bluetooth Slice bound to {@link #BLUETOOTH_URI}.
+ * Return a Bluetooth Slice bound to {@link CustomSliceRegistry#BLUETOOTH_URI}.
* <p>
* Note that you should register a listener for {@link #INTENT_FILTER} to get changes for
* Bluetooth.
@@ -92,7 +82,7 @@
final SliceAction toggleSliceAction = new SliceAction(toggleAction, null /* actionTitle */,
isBluetoothEnabled);
- return new ListBuilder(context, BLUETOOTH_URI, ListBuilder.INFINITY)
+ return new ListBuilder(context, CustomSliceRegistry.BLUETOOTH_URI, ListBuilder.INFINITY)
.setAccentColor(color)
.addRow(new RowBuilder()
.setTitle(title)
diff --git a/src/com/android/settings/datausage/DataUsageList.java b/src/com/android/settings/datausage/DataUsageList.java
index 8f0026f..24192cd 100644
--- a/src/com/android/settings/datausage/DataUsageList.java
+++ b/src/com/android/settings/datausage/DataUsageList.java
@@ -193,17 +193,13 @@
public void onResume() {
super.onResume();
mDataStateListener.setListener(true, mSubId, getContext());
- updateBody();
// kick off background task to update stats
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
- // wait a few seconds before kicking off
- Thread.sleep(2 * DateUtils.SECOND_IN_MILLIS);
services.mStatsService.forceUpdate();
- } catch (InterruptedException e) {
} catch (RemoteException e) {
}
return null;
@@ -211,9 +207,7 @@
@Override
protected void onPostExecute(Void result) {
- if (isAdded()) {
- updateBody();
- }
+ updateBody();
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
diff --git a/src/com/android/settings/datausage/DataUsageListV2.java b/src/com/android/settings/datausage/DataUsageListV2.java
index 4432fee..3a71935 100644
--- a/src/com/android/settings/datausage/DataUsageListV2.java
+++ b/src/com/android/settings/datausage/DataUsageListV2.java
@@ -187,28 +187,6 @@
super.onResume();
mDataStateListener.setListener(true, mSubId, getContext());
updateBody();
-
- // kick off background task to update stats
- new AsyncTask<Void, Void, Void>() {
- @Override
- protected Void doInBackground(Void... params) {
- try {
- // wait a few seconds before kicking off
- Thread.sleep(2 * DateUtils.SECOND_IN_MILLIS);
- services.mStatsService.forceUpdate();
- } catch (InterruptedException e) {
- } catch (RemoteException e) {
- }
- return null;
- }
-
- @Override
- protected void onPostExecute(Void result) {
- if (isAdded()) {
- updateBody();
- }
- }
- }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
@Override
diff --git a/src/com/android/settings/display/AutoBrightnessPreferenceController.java b/src/com/android/settings/display/AutoBrightnessPreferenceController.java
index 3f5f2b0..3b53fa8 100644
--- a/src/com/android/settings/display/AutoBrightnessPreferenceController.java
+++ b/src/com/android/settings/display/AutoBrightnessPreferenceController.java
@@ -52,7 +52,7 @@
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(
com.android.internal.R.bool.config_automatic_brightness_available)
- ? AVAILABLE_UNSEARCHABLE
+ ? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
@@ -67,4 +67,4 @@
? R.string.auto_brightness_summary_on
: R.string.auto_brightness_summary_off);
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/flashlight/FlashlightSliceBuilder.java b/src/com/android/settings/flashlight/FlashlightSliceBuilder.java
index d21739e..57d99ef 100644
--- a/src/com/android/settings/flashlight/FlashlightSliceBuilder.java
+++ b/src/com/android/settings/flashlight/FlashlightSliceBuilder.java
@@ -22,17 +22,14 @@
import android.annotation.ColorInt;
import android.app.PendingIntent;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager;
-import android.net.Uri;
import android.provider.Settings;
import android.provider.Settings.Secure;
-import android.provider.SettingsSlicesContract;
import android.util.Log;
import androidx.core.graphics.drawable.IconCompat;
@@ -43,7 +40,7 @@
import com.android.settings.R;
import com.android.settings.Utils;
-import com.android.settings.slices.SettingsSliceProvider;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.SliceBroadcastReceiver;
@@ -54,37 +51,23 @@
private static final String TAG = "FlashlightSliceBuilder";
- public static final String KEY_FLASHLIGHT = "flashlight";
-
- /**
- * Backing Uri for the Flashlight Slice.
- */
- public static final Uri FLASHLIGHT_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSliceProvider.SLICE_AUTHORITY)
- .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
- .appendPath(KEY_FLASHLIGHT)
- .build();
-
/**
* Action notifying a change on the Flashlight Slice.
*/
public static final String ACTION_FLASHLIGHT_SLICE_CHANGED =
- "com.android.settings.flashlight.action.FLASHLIGHT_SLICE_CHANGED";
+ "com.android.settings.flashlight.action.FLASHLIGHT_SLICE_CHANGED";
/**
* Action broadcasting a change on whether flashlight is on or off.
*/
public static final String ACTION_FLASHLIGHT_CHANGED =
- "com.android.settings.flashlight.action.FLASHLIGHT_CHANGED";
+ "com.android.settings.flashlight.action.FLASHLIGHT_CHANGED";
public static final IntentFilter INTENT_FILTER = new IntentFilter(ACTION_FLASHLIGHT_CHANGED);
- private FlashlightSliceBuilder() {}
+ private FlashlightSliceBuilder() {
+ }
- /**
- * Return a Flashlight Slice bound to {@link #FLASHLIGHT_URI}.
- */
public static Slice getSlice(Context context) {
if (!isFlashlightAvailable(context)) {
return null;
@@ -93,14 +76,15 @@
@ColorInt final int color = Utils.getColorAccentDefaultColor(context);
final IconCompat icon =
IconCompat.createWithResource(context, R.drawable.ic_signal_flashlight);
- return new ListBuilder(context, FLASHLIGHT_URI, ListBuilder.INFINITY)
- .setAccentColor(color)
- .addRow(new RowBuilder()
- .setTitle(context.getText(R.string.power_flashlight))
- .setTitleItem(icon, ICON_IMAGE)
- .setPrimaryAction(
- new SliceAction(toggleAction, null, isFlashlightEnabled(context))))
- .build();
+ return new ListBuilder(context, CustomSliceRegistry.FLASHLIGHT_SLICE_URI,
+ ListBuilder.INFINITY)
+ .setAccentColor(color)
+ .addRow(new RowBuilder()
+ .setTitle(context.getText(R.string.power_flashlight))
+ .setTitleItem(icon, ICON_IMAGE)
+ .setPrimaryAction(
+ new SliceAction(toggleAction, null, isFlashlightEnabled(context))))
+ .build();
}
/**
@@ -119,7 +103,7 @@
} catch (CameraAccessException e) {
Log.e(TAG, "Camera couldn't set torch mode.", e);
}
- context.getContentResolver().notifyChange(FLASHLIGHT_URI, null);
+ context.getContentResolver().notifyChange(CustomSliceRegistry.FLASHLIGHT_SLICE_URI, null);
}
private static String getCameraId(Context context) throws CameraAccessException {
@@ -130,7 +114,7 @@
Boolean flashAvailable = c.get(CameraCharacteristics.FLASH_INFO_AVAILABLE);
Integer lensFacing = c.get(CameraCharacteristics.LENS_FACING);
if (flashAvailable != null && flashAvailable
- && lensFacing != null && lensFacing == CameraCharacteristics.LENS_FACING_BACK) {
+ && lensFacing != null && lensFacing == CameraCharacteristics.LENS_FACING_BACK) {
return id;
}
}
@@ -141,16 +125,16 @@
final Intent intent = new Intent(ACTION_FLASHLIGHT_SLICE_CHANGED);
intent.setClass(context, SliceBroadcastReceiver.class);
return PendingIntent.getBroadcast(context, 0 /* requestCode */, intent,
- PendingIntent.FLAG_CANCEL_CURRENT);
+ PendingIntent.FLAG_CANCEL_CURRENT);
}
private static boolean isFlashlightAvailable(Context context) {
return Settings.Secure.getInt(
- context.getContentResolver(), Secure.FLASHLIGHT_AVAILABLE, 0) == 1;
+ context.getContentResolver(), Secure.FLASHLIGHT_AVAILABLE, 0) == 1;
}
private static boolean isFlashlightEnabled(Context context) {
return Settings.Secure.getInt(
- context.getContentResolver(), Secure.FLASHLIGHT_ENABLED, 0) == 1;
+ context.getContentResolver(), Secure.FLASHLIGHT_ENABLED, 0) == 1;
}
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
index eac2bf5..0d9b1c4 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
@@ -42,6 +42,9 @@
* Controller in charge of the battery tip group
*/
public class BatteryTipPreferenceController extends BasePreferenceController {
+
+ public static final String PREF_NAME = "battery_tip";
+
private static final String TAG = "BatteryTipPreferenceController";
private static final int REQUEST_ANOMALY_ACTION = 0;
private static final String KEY_BATTERY_TIPS = "key_battery_tips";
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProvider.java b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProvider.java
new file mode 100644
index 0000000..8583f38
--- /dev/null
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProvider.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.homepage.contextualcards;
+
+import android.content.Context;
+
+import java.util.List;
+
+/** Feature provider for the contextual card feature. */
+public interface ContextualCardFeatureProvider {
+
+ /** Homepage displays. */
+ public void logHomepageDisplay(Context context, Long latency);
+
+ /** When user clicks dismiss in contextual card */
+ public void logContextualCardDismiss(Context context, ContextualCard card);
+
+ /** After ContextualCardManager decides which cards will be displayed/hidden */
+ public void logContextualCardDisplay(Context context, List<ContextualCard> showedCards,
+ List<ContextualCard> hiddenCards);
+
+ /** When user clicks toggle/title area of a contextual card. */
+ public void logContextualCardClick(Context context, ContextualCard card, int row,
+ int tapTarget);
+}
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
new file mode 100644
index 0000000..e437e2b
--- /dev/null
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImpl.java
@@ -0,0 +1,136 @@
+/*
+ * 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.homepage.contextualcards;
+
+import android.content.Context;
+import android.content.Intent;
+import android.text.TextUtils;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.slice.widget.EventInfo;
+
+import com.android.settings.R;
+
+import java.util.List;
+
+public class ContextualCardFeatureProviderImpl implements ContextualCardFeatureProvider {
+ private static final String TAG = "ContextualCardFeature";
+
+ // Contextual card interaction logs
+ // Settings Homepage shows
+ private static final int CONTEXTUAL_HOME_SHOW = 38;
+
+ // Contextual card shows, log card name and rank
+ private static final int CONTEXTUAL_CARD_SHOW = 39;
+
+ // Contextual card is eligible to be shown, but doesn't rank high
+ // enough, log card name and score
+ private static final int CONTEXTUAL_CARD_NOT_SHOW = 40;
+
+ // Contextual card is dismissed, log card name
+ private static final int CONTEXTUAL_CARD_DISMISS = 41;
+
+ // Contextual card is clicked , log card name, score, tap area
+ private static final int CONTEXTUAL_CARD_CLICK = 42;
+
+ // SettingsLogBroadcastReceiver contracts
+ // contextual card name
+ private static final String EXTRA_CONTEXTUALCARD_NAME = "name";
+
+ // contextual card score
+ private static final String EXTRA_CONTEXTUALCARD_SCORE = "score";
+
+ // contextual card clicked row
+ private static final String EXTRA_CONTEXTUALCARD_ROW = "row";
+
+ // contextual card tap target
+ private static final String EXTRA_CONTEXTUALCARD_TAP_TARGET = "target";
+
+ // contextual homepage display latency
+ private static final String EXTRA_LATENCY = "latency";
+
+ // log type
+ private static final String EXTRA_CONTEXTUALCARD_ACTION_TYPE = "type";
+
+
+ // Contextual card tap target
+ private static final int TARGET_DEFAULT = 0;
+
+ // Click title area
+ private static final int TARGET_TITLE = 1;
+
+ // Click toggle
+ private static final int TARGET_TOGGLE = 2;
+
+ // Click slider
+ private static final int TARGET_SLIDER = 3;
+
+ @Override
+ public void logHomepageDisplay(Context context, Long latency) {
+ }
+
+ @Override
+ public void logContextualCardDismiss(Context context, ContextualCard card) {
+ final Intent intent = new Intent();
+ intent.putExtra(EXTRA_CONTEXTUALCARD_ACTION_TYPE, CONTEXTUAL_CARD_DISMISS);
+ intent.putExtra(EXTRA_CONTEXTUALCARD_NAME, card.getName());
+ intent.putExtra(EXTRA_CONTEXTUALCARD_SCORE, card.getRankingScore());
+ sendBroadcast(context, intent);
+ }
+
+ @Override
+ public void logContextualCardDisplay(Context context, List<ContextualCard> showCards,
+ List<ContextualCard> hiddenCards) {
+ }
+
+ @Override
+ public void logContextualCardClick(Context context, ContextualCard card, int row,
+ int actionType) {
+ final Intent intent = new Intent();
+ intent.putExtra(EXTRA_CONTEXTUALCARD_ACTION_TYPE, CONTEXTUAL_CARD_CLICK);
+ intent.putExtra(EXTRA_CONTEXTUALCARD_NAME, card.getName());
+ intent.putExtra(EXTRA_CONTEXTUALCARD_SCORE, card.getRankingScore());
+ intent.putExtra(EXTRA_CONTEXTUALCARD_ROW, row);
+ intent.putExtra(EXTRA_CONTEXTUALCARD_TAP_TARGET, actionTypeToTapTarget(actionType));
+ sendBroadcast(context, intent);
+ }
+
+ @VisibleForTesting
+ void sendBroadcast(final Context context, final Intent intent) {
+ intent.setPackage(context.getString(R.string.config_settingsintelligence_package_name));
+ final String action = context.getString(R.string.config_settingsintelligence_log_action);
+ if (!TextUtils.isEmpty(action)) {
+ intent.setAction(action);
+ context.sendBroadcast(intent);
+ }
+ }
+
+ private int actionTypeToTapTarget(int actionType) {
+ switch (actionType) {
+ case EventInfo.ACTION_TYPE_CONTENT:
+ return TARGET_TITLE;
+ case EventInfo.ACTION_TYPE_TOGGLE:
+ return TARGET_TOGGLE;
+ case EventInfo.ACTION_TYPE_SLIDER:
+ return TARGET_SLIDER;
+ default:
+ Log.w(TAG, "unknown type " + actionType);
+ return TARGET_DEFAULT;
+ }
+ }
+}
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
index 4c06601..3ef4653 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
@@ -34,8 +34,7 @@
import androidx.annotation.VisibleForTesting;
import androidx.slice.Slice;
-import com.android.settings.homepage.contextualcards.slices.ConnectedDeviceSlice;
-import com.android.settings.wifi.WifiSlice;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settingslib.utils.AsyncLoaderCompat;
import java.util.ArrayList;
@@ -170,8 +169,8 @@
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))
+ .filter(card -> card.getSliceUri().equals(CustomSliceRegistry.WIFI_SLICE_URI)
+ || card.getSliceUri().equals(CustomSliceRegistry.CONNECTED_DEVICE_SLICE_URI))
.count();
}
diff --git a/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProvider.java b/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProvider.java
index 5ff3e90..376bb83 100644
--- a/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProvider.java
+++ b/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProvider.java
@@ -16,16 +16,11 @@
package com.android.settings.homepage.contextualcards;
-import static android.provider.SettingsSlicesContract.KEY_WIFI;
-
import android.annotation.Nullable;
-import com.android.settings.homepage.contextualcards.slices.BatteryFixSlice;
-import com.android.settings.homepage.contextualcards.slices.ConnectedDeviceSlice;
-import com.android.settings.homepage.contextualcards.slices.LowStorageSlice;
import com.android.settings.intelligence.ContextualCardProto.ContextualCard;
import com.android.settings.intelligence.ContextualCardProto.ContextualCardList;
-import com.android.settings.wifi.WifiSlice;
+import com.android.settings.slices.CustomSliceRegistry;
import com.google.android.settings.intelligence.libs.contextualcards.ContextualCardProvider;
@@ -39,26 +34,26 @@
public ContextualCardList getContextualCards() {
final ContextualCard wifiCard =
ContextualCard.newBuilder()
- .setSliceUri(WifiSlice.WIFI_URI.toString())
- .setCardName(KEY_WIFI)
+ .setSliceUri(CustomSliceRegistry.WIFI_SLICE_URI.toString())
+ .setCardName(CustomSliceRegistry.WIFI_SLICE_URI.toString())
.setCardCategory(ContextualCard.Category.IMPORTANT)
.build();
final ContextualCard connectedDeviceCard =
ContextualCard.newBuilder()
- .setSliceUri(ConnectedDeviceSlice.CONNECTED_DEVICE_URI.toString())
- .setCardName(ConnectedDeviceSlice.PATH_CONNECTED_DEVICE)
+ .setSliceUri(CustomSliceRegistry.CONNECTED_DEVICE_SLICE_URI.toString())
+ .setCardName(CustomSliceRegistry.CONNECTED_DEVICE_SLICE_URI.toString())
.setCardCategory(ContextualCard.Category.IMPORTANT)
.build();
final ContextualCard lowStorageCard =
ContextualCard.newBuilder()
- .setSliceUri(LowStorageSlice.LOW_STORAGE_URI.toString())
- .setCardName(LowStorageSlice.PATH_LOW_STORAGE)
+ .setSliceUri(CustomSliceRegistry.LOW_STORAGE_SLICE_URI.toString())
+ .setCardName(CustomSliceRegistry.LOW_STORAGE_SLICE_URI.toString())
.setCardCategory(ContextualCard.Category.IMPORTANT)
.build();
final ContextualCard batteryFixCard =
ContextualCard.newBuilder()
- .setSliceUri(BatteryFixSlice.BATTERY_FIX_URI.toString())
- .setCardName(BatteryFixSlice.PATH_BATTERY_FIX)
+ .setSliceUri(CustomSliceRegistry.BATTERY_FIX_SLICE_URI.toString())
+ .setCardName(CustomSliceRegistry.BATTERY_FIX_SLICE_URI.toString())
.setCardCategory(ContextualCard.Category.IMPORTANT)
.build();
final ContextualCardList cards = ContextualCardList.newBuilder()
diff --git a/src/com/android/settings/homepage/contextualcards/deviceinfo/BatterySlice.java b/src/com/android/settings/homepage/contextualcards/deviceinfo/BatterySlice.java
index 873b942..222e9dd 100644
--- a/src/com/android/settings/homepage/contextualcards/deviceinfo/BatterySlice.java
+++ b/src/com/android/settings/homepage/contextualcards/deviceinfo/BatterySlice.java
@@ -16,8 +16,9 @@
package com.android.settings.homepage.contextualcards.deviceinfo;
+import static com.android.settings.slices.CustomSliceRegistry.BATTERY_INFO_SLICE_URI;
+
import android.app.PendingIntent;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -37,7 +38,6 @@
import com.android.settings.fuelgauge.BatteryInfo;
import com.android.settings.fuelgauge.PowerUsageSummary;
import com.android.settings.slices.CustomSliceable;
-import com.android.settings.slices.SettingsSliceProvider;
import com.android.settings.slices.SliceBuilderUtils;
/**
@@ -46,20 +46,6 @@
public class BatterySlice implements CustomSliceable {
private static final String TAG = "BatterySlice";
- /**
- * The path denotes the unique name of battery slice.
- */
- public static final String PATH_BATTERY_INFO = "battery_card";
-
- /**
- * Backing Uri for the Battery Slice.
- */
- public static final Uri BATTERY_CARD_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSliceProvider.SLICE_AUTHORITY)
- .appendPath(PATH_BATTERY_INFO)
- .build();
-
private final Context mContext;
private BatteryInfo mBatteryInfo;
@@ -69,9 +55,6 @@
mContext = context;
}
- /**
- * Return a {@link BatterySlice} bound to {@link #BATTERY_CARD_URI}
- */
@Override
public Slice getSlice() {
if (mBatteryInfo == null) {
@@ -82,7 +65,7 @@
R.drawable.ic_settings_battery);
final CharSequence title = mContext.getText(R.string.power_usage_summary_title);
final SliceAction primarySliceAction = new SliceAction(getPrimaryAction(), icon, title);
- final Slice slice = new ListBuilder(mContext, BATTERY_CARD_URI, ListBuilder.INFINITY)
+ final Slice slice = new ListBuilder(mContext, BATTERY_INFO_SLICE_URI, ListBuilder.INFINITY)
.setAccentColor(Utils.getColorAccentDefaultColor(mContext))
.setHeader(new ListBuilder.HeaderBuilder().setTitle(title))
.addRow(new ListBuilder.RowBuilder()
@@ -97,7 +80,7 @@
@Override
public Uri getUri() {
- return BATTERY_CARD_URI;
+ return BATTERY_INFO_SLICE_URI;
}
@Override
@@ -108,12 +91,10 @@
@Override
public Intent getIntent() {
final String screenTitle = mContext.getText(R.string.power_usage_summary_title).toString();
- final Uri contentUri = new Uri.Builder().appendPath(PATH_BATTERY_INFO).build();
return SliceBuilderUtils.buildSearchResultPageIntent(mContext,
- PowerUsageSummary.class.getName(), PATH_BATTERY_INFO, screenTitle,
+ PowerUsageSummary.class.getName(), "" /* key */, screenTitle,
MetricsProto.MetricsEvent.SLICE)
- .setClassName(mContext.getPackageName(), SubSettings.class.getName())
- .setData(contentUri);
+ .setClassName(mContext.getPackageName(), SubSettings.class.getName());
}
@Override
diff --git a/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSlice.java b/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSlice.java
index 6296b1e..9be4b61 100644
--- a/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSlice.java
@@ -17,7 +17,6 @@
package com.android.settings.homepage.contextualcards.deviceinfo;
import android.app.PendingIntent;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -39,8 +38,8 @@
import com.android.settings.Utils;
import com.android.settings.datausage.DataUsageSummary;
import com.android.settings.datausage.DataUsageUtils;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.CustomSliceable;
-import com.android.settings.slices.SettingsSliceProvider;
import com.android.settings.slices.SliceBuilderUtils;
import com.android.settingslib.net.DataUsageController;
@@ -50,19 +49,6 @@
private static final String TAG = "DataUsageSlice";
private static final long MILLIS_IN_A_DAY = TimeUnit.DAYS.toMillis(1);
- /**
- * The path denotes the unique name of data usage slice.
- */
- public static final String PATH_DATA_USAGE = "data_usage_card";
-
- /**
- * Backing Uri for the Data usage Slice.
- */
- public static final Uri DATA_USAGE_CARD_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSliceProvider.SLICE_AUTHORITY)
- .appendPath(PATH_DATA_USAGE)
- .build();
private final Context mContext;
@@ -72,12 +58,9 @@
@Override
public Uri getUri() {
- return DATA_USAGE_CARD_URI;
+ return CustomSliceRegistry.DATA_USAGE_SLICE_URI;
}
- /**
- * Return a Data usage Slice bound to {@link #DATA_USAGE_CARD_URI}
- */
@Override
public Slice getSlice() {
final IconCompat icon = IconCompat.createWithResource(mContext,
@@ -87,7 +70,8 @@
final DataUsageController dataUsageController = new DataUsageController(mContext);
final DataUsageController.DataUsageInfo info = dataUsageController.getDataUsageInfo();
final ListBuilder listBuilder =
- new ListBuilder(mContext, DATA_USAGE_CARD_URI, ListBuilder.INFINITY)
+ new ListBuilder(mContext, CustomSliceRegistry.DATA_USAGE_SLICE_URI,
+ ListBuilder.INFINITY)
.setAccentColor(Utils.getColorAccentDefaultColor(mContext))
.setHeader(new ListBuilder.HeaderBuilder().setTitle(title));
if (DataUsageUtils.hasSim(mContext)) {
@@ -106,12 +90,10 @@
@Override
public Intent getIntent() {
final String screenTitle = mContext.getText(R.string.data_usage_wifi_title).toString();
- final Uri contentUri = new Uri.Builder().appendPath(PATH_DATA_USAGE).build();
return SliceBuilderUtils.buildSearchResultPageIntent(mContext,
- DataUsageSummary.class.getName(), PATH_DATA_USAGE, screenTitle,
+ DataUsageSummary.class.getName(), "" /* key */, screenTitle,
MetricsProto.MetricsEvent.SLICE)
- .setClassName(mContext.getPackageName(), SubSettings.class.getName())
- .setData(contentUri);
+ .setClassName(mContext.getPackageName(), SubSettings.class.getName());
}
private PendingIntent getPrimaryAction() {
diff --git a/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSlice.java b/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSlice.java
index b8751f8..b7c662e 100644
--- a/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSlice.java
@@ -17,7 +17,6 @@
package com.android.settings.homepage.contextualcards.deviceinfo;
import android.app.PendingIntent;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -39,8 +38,8 @@
import com.android.settings.Utils;
import com.android.settings.deviceinfo.DeviceModelPreferenceController;
import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.CustomSliceable;
-import com.android.settings.slices.SettingsSliceProvider;
import com.android.settings.slices.SliceBuilderUtils;
import com.android.settingslib.DeviceInfoUtils;
@@ -49,20 +48,6 @@
public class DeviceInfoSlice implements CustomSliceable {
private static final String TAG = "DeviceInfoSlice";
- /**
- * The path denotes the unique name of device info slice
- */
- public static final String PATH_DEVICE_INFO = "device_info_card";
-
- /**
- * Backing Uri for the Device info Slice.
- */
- public static final Uri DEVICE_INFO_CARD_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSliceProvider.SLICE_AUTHORITY)
- .appendPath(PATH_DEVICE_INFO)
- .build();
-
private final Context mContext;
private final SubscriptionManager mSubscriptionManager;
@@ -71,16 +56,14 @@
mSubscriptionManager = mContext.getSystemService(SubscriptionManager.class);
}
- /**
- * Return a device info slice bound to {@Link #DEVICE_INFO_CARD_URI}
- */
@Override
public Slice getSlice() {
final IconCompat icon = IconCompat.createWithResource(mContext,
R.drawable.ic_info_outline_24dp);
final String title = mContext.getString(R.string.device_info_label);
final SliceAction primaryAction = new SliceAction(getPrimaryAction(), icon, title);
- return new ListBuilder(mContext, DEVICE_INFO_CARD_URI, ListBuilder.INFINITY)
+ return new ListBuilder(mContext, CustomSliceRegistry.DEVICE_INFO_SLICE_URI,
+ ListBuilder.INFINITY)
.setAccentColor((Utils.getColorAccentDefaultColor(mContext)))
.setHeader(new ListBuilder.HeaderBuilder().setTitle(title))
.addRow(new ListBuilder.RowBuilder()
@@ -92,18 +75,16 @@
@Override
public Uri getUri() {
- return DEVICE_INFO_CARD_URI;
+ return CustomSliceRegistry.DEVICE_INFO_SLICE_URI;
}
@Override
public Intent getIntent() {
final String screenTitle = mContext.getText(R.string.device_info_label).toString();
- final Uri contentUri = new Uri.Builder().appendPath(PATH_DEVICE_INFO).build();
return SliceBuilderUtils.buildSearchResultPageIntent(mContext,
- MyDeviceInfoFragment.class.getName(), PATH_DEVICE_INFO, screenTitle,
+ MyDeviceInfoFragment.class.getName(), "" /* key */, screenTitle,
MetricsProto.MetricsEvent.SLICE)
- .setClassName(mContext.getPackageName(), SubSettings.class.getName())
- .setData(contentUri);
+ .setClassName(mContext.getPackageName(), SubSettings.class.getName());
}
private PendingIntent getPrimaryAction() {
diff --git a/src/com/android/settings/homepage/contextualcards/deviceinfo/EmergencyInfoSlice.java b/src/com/android/settings/homepage/contextualcards/deviceinfo/EmergencyInfoSlice.java
index aff34f4..dfadc72 100644
--- a/src/com/android/settings/homepage/contextualcards/deviceinfo/EmergencyInfoSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/deviceinfo/EmergencyInfoSlice.java
@@ -17,10 +17,8 @@
package com.android.settings.homepage.contextualcards.deviceinfo;
import android.app.PendingIntent;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
-import android.net.Uri;
import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
@@ -28,39 +26,27 @@
import androidx.slice.builders.SliceAction;
import com.android.settings.R;
-import com.android.settings.slices.SettingsSliceProvider;
+import com.android.settings.slices.CustomSliceRegistry;
// This is a slice helper class for EmergencyInfo
public class EmergencyInfoSlice {
- /**
- * The path denotes the unique name of emergency info slice.
- */
- public static final String PATH_EMERGENCY_INFO_CARD = "emergency_info_card";
-
- /**
- * Backing Uri for the Emergency Info Slice.
- */
- public static final Uri EMERGENCY_INFO_CARD_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSliceProvider.SLICE_AUTHORITY)
- .appendPath(PATH_EMERGENCY_INFO_CARD)
- .build();
private static final String ACTION_EDIT_EMERGENCY_INFO = "android.settings.EDIT_EMERGENCY_INFO";
public static Slice getSlice(Context context) {
- final ListBuilder listBuilder = new ListBuilder(context, EMERGENCY_INFO_CARD_URI,
+ final ListBuilder listBuilder = new ListBuilder(context,
+ CustomSliceRegistry.EMERGENCY_INFO_SLICE_URI,
ListBuilder.INFINITY);
listBuilder.addRow(
new ListBuilder.RowBuilder()
.setTitle(context.getText(R.string.emergency_info_title))
.setSubtitle(
context.getText(R.string.emergency_info_contextual_card_summary))
- .setPrimaryAction(generatePrimaryAction(context)));
+ .setPrimaryAction(createPrimaryAction(context)));
return listBuilder.build();
}
- private static SliceAction generatePrimaryAction(Context context) {
+ private static SliceAction createPrimaryAction(Context context) {
PendingIntent pendingIntent =
PendingIntent.getActivity(
context,
diff --git a/src/com/android/settings/homepage/contextualcards/deviceinfo/StorageSlice.java b/src/com/android/settings/homepage/contextualcards/deviceinfo/StorageSlice.java
index c61a8a0..1e07f7a 100644
--- a/src/com/android/settings/homepage/contextualcards/deviceinfo/StorageSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/deviceinfo/StorageSlice.java
@@ -17,7 +17,6 @@
package com.android.settings.homepage.contextualcards.deviceinfo;
import android.app.PendingIntent;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -36,8 +35,8 @@
import com.android.settings.Utils;
import com.android.settings.deviceinfo.StorageDashboardFragment;
import com.android.settings.deviceinfo.storage.StorageSummaryDonutPreferenceController;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.CustomSliceable;
-import com.android.settings.slices.SettingsSliceProvider;
import com.android.settings.slices.SliceBuilderUtils;
import com.android.settingslib.deviceinfo.PrivateStorageInfo;
import com.android.settingslib.deviceinfo.StorageManagerVolumeProvider;
@@ -45,20 +44,6 @@
public class StorageSlice implements CustomSliceable {
private static final String TAG = "StorageSlice";
- /**
- * The path denotes the unique name of storage slicel
- */
- public static final String PATH_STORAGE_INFO = "storage_card";
-
- /**
- * Backing Uri for the storage slice.
- */
- public static final Uri STORAGE_CARD_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSliceProvider.SLICE_AUTHORITY)
- .appendPath(PATH_STORAGE_INFO)
- .build();
-
private final Context mContext;
public StorageSlice(Context context) {
@@ -67,12 +52,9 @@
@Override
public Uri getUri() {
- return STORAGE_CARD_URI;
+ return CustomSliceRegistry.STORAGE_SLICE_URI;
}
- /**
- * Return a storage slice bound to {@link #STORAGE_CARD_URI}
- */
@Override
public Slice getSlice() {
final IconCompat icon = IconCompat.createWithResource(mContext,
@@ -80,7 +62,8 @@
final String title = mContext.getString(R.string.storage_label);
final SliceAction primaryAction = new SliceAction(getPrimaryAction(), icon, title);
final PrivateStorageInfo info = getPrivateStorageInfo();
- return new ListBuilder(mContext, STORAGE_CARD_URI, ListBuilder.INFINITY)
+ return new ListBuilder(mContext, CustomSliceRegistry.STORAGE_SLICE_URI,
+ ListBuilder.INFINITY)
.setAccentColor(Utils.getColorAccentDefaultColor(mContext))
.setHeader(new ListBuilder.HeaderBuilder().setTitle(title))
.addRow(new ListBuilder.RowBuilder()
@@ -93,12 +76,10 @@
@Override
public Intent getIntent() {
final String screenTitle = mContext.getText(R.string.storage_label).toString();
- final Uri contentUri = new Uri.Builder().appendPath(PATH_STORAGE_INFO).build();
return SliceBuilderUtils.buildSearchResultPageIntent(mContext,
- StorageDashboardFragment.class.getName(), PATH_STORAGE_INFO, screenTitle,
+ StorageDashboardFragment.class.getName(), "" /* key */, screenTitle,
MetricsProto.MetricsEvent.SLICE)
- .setClassName(mContext.getPackageName(), SubSettings.class.getName())
- .setData(contentUri);
+ .setClassName(mContext.getPackageName(), SubSettings.class.getName());
}
private PendingIntent getPrimaryAction() {
diff --git a/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java
index 23ff172..cae222a 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java
@@ -19,7 +19,6 @@
import static android.content.Context.MODE_PRIVATE;
import android.app.PendingIntent;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -34,7 +33,6 @@
import androidx.slice.builders.SliceAction;
import com.android.internal.logging.nano.MetricsProto;
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.os.BatteryStatsHelper;
import com.android.settings.R;
import com.android.settings.SubSettings;
@@ -42,9 +40,10 @@
import com.android.settings.fuelgauge.BatteryStatsHelperLoader;
import com.android.settings.fuelgauge.PowerUsageSummary;
import com.android.settings.fuelgauge.batterytip.BatteryTipLoader;
+import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.CustomSliceable;
-import com.android.settings.slices.SettingsSliceProvider;
import com.android.settings.slices.SliceBackgroundWorker;
import com.android.settings.slices.SliceBuilderUtils;
import com.android.settingslib.utils.ThreadUtils;
@@ -53,20 +52,6 @@
public class BatteryFixSlice implements CustomSliceable {
- /**
- * Unique name of Battery Fix Slice.
- */
- public static final String PATH_BATTERY_FIX = "battery_fix";
-
- /**
- * Uri for Battery Fix Slice.
- */
- public static final Uri BATTERY_FIX_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSliceProvider.SLICE_AUTHORITY)
- .appendPath(PATH_BATTERY_FIX)
- .build();
-
@VisibleForTesting
static final String PREFS = "battery_fix_prefs";
@VisibleForTesting
@@ -82,12 +67,9 @@
@Override
public Uri getUri() {
- return BATTERY_FIX_URI;
+ return CustomSliceRegistry.BATTERY_FIX_SLICE_URI;
}
- /**
- * Return a Slice bound to {@link #BATTERY_FIX_URI}.
- */
@Override
public Slice getSlice() {
IconCompat icon;
@@ -109,7 +91,8 @@
primaryAction = new SliceAction(getPrimaryAction(),
icon,
batteryTip.getTitle(mContext));
- slice = new ListBuilder(mContext, BATTERY_FIX_URI, ListBuilder.INFINITY)
+ slice = new ListBuilder(mContext, CustomSliceRegistry.BATTERY_FIX_SLICE_URI,
+ ListBuilder.INFINITY)
.setAccentColor(Utils.getColorAccentDefaultColor(mContext))
.addRow(new RowBuilder()
.setTitle(batteryTip.getTitle(mContext))
@@ -125,7 +108,8 @@
R.drawable.ic_battery_status_good_24dp);
final String title = mContext.getString(R.string.power_usage_summary_title);
primaryAction = new SliceAction(getPrimaryAction(), icon, title);
- slice = new ListBuilder(mContext, BATTERY_FIX_URI, ListBuilder.INFINITY)
+ slice = new ListBuilder(mContext, CustomSliceRegistry.BATTERY_FIX_SLICE_URI,
+ ListBuilder.INFINITY)
.setAccentColor(Utils.getColorAccentDefaultColor(mContext))
.addRow(new RowBuilder()
.setTitle(title)
@@ -140,10 +124,11 @@
public Intent getIntent() {
final String screenTitle = mContext.getText(R.string.power_usage_summary_title)
.toString();
- final Uri contentUri = new Uri.Builder().appendPath(PATH_BATTERY_FIX).build();
+ final Uri contentUri = new Uri.Builder()
+ .appendPath(BatteryTipPreferenceController.PREF_NAME).build();
return SliceBuilderUtils.buildSearchResultPageIntent(mContext,
- PowerUsageSummary.class.getName(), PATH_BATTERY_FIX,
+ PowerUsageSummary.class.getName(), BatteryTipPreferenceController.PREF_NAME,
screenTitle,
MetricsProto.MetricsEvent.SLICE)
.setClassName(mContext.getPackageName(), SubSettings.class.getName())
diff --git a/src/com/android/settings/homepage/contextualcards/slices/ConnectedDeviceSlice.java b/src/com/android/settings/homepage/contextualcards/slices/ConnectedDeviceSlice.java
index ef7c1bd..fe907f3 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/ConnectedDeviceSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/ConnectedDeviceSlice.java
@@ -18,7 +18,6 @@
import android.app.PendingIntent;
import android.bluetooth.BluetoothAdapter;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
@@ -43,8 +42,8 @@
import com.android.settings.bluetooth.BluetoothDeviceDetailsFragment;
import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.CustomSliceable;
-import com.android.settings.slices.SettingsSliceProvider;
import com.android.settings.slices.SliceBuilderUtils;
import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
@@ -68,20 +67,6 @@
public class ConnectedDeviceSlice implements CustomSliceable {
/**
- * The path denotes the unique name of Connected device Slice.
- */
- public static final String PATH_CONNECTED_DEVICE = "connected_device";
-
- /**
- * Backing Uri for Connected device Slice.
- */
- public static final Uri CONNECTED_DEVICE_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSliceProvider.SLICE_AUTHORITY)
- .appendPath(PATH_CONNECTED_DEVICE)
- .build();
-
- /**
* To sort the Bluetooth devices by {@link CachedBluetoothDevice}.
* Refer compareTo method from {@link com.android.settings.bluetooth.BluetoothDevicePreference}.
*/
@@ -109,12 +94,9 @@
@Override
public Uri getUri() {
- return CONNECTED_DEVICE_URI;
+ return CustomSliceRegistry.CONNECTED_DEVICE_SLICE_URI;
}
- /**
- * Return a Connected Device Slice bound to {@link #CONNECTED_DEVICE_URI}.
- */
@Override
public Slice getSlice() {
final IconCompat icon = IconCompat.createWithResource(mContext,
@@ -127,7 +109,8 @@
final SliceAction primarySliceAction = new SliceAction(primaryActionIntent, icon,
title);
final ListBuilder listBuilder =
- new ListBuilder(mContext, CONNECTED_DEVICE_URI, ListBuilder.INFINITY)
+ new ListBuilder(mContext, CustomSliceRegistry.CONNECTED_DEVICE_SLICE_URI,
+ ListBuilder.INFINITY)
.setAccentColor(Utils.getColorAccentDefaultColor(mContext));
// Get row builders by connected devices, e.g. Bluetooth.
@@ -159,14 +142,12 @@
public Intent getIntent() {
final String screenTitle = mContext.getText(R.string.connected_devices_dashboard_title)
.toString();
- final Uri contentUri = new Uri.Builder().appendPath(PATH_CONNECTED_DEVICE).build();
return SliceBuilderUtils.buildSearchResultPageIntent(mContext,
- ConnectedDeviceDashboardFragment.class.getName(), PATH_CONNECTED_DEVICE,
+ ConnectedDeviceDashboardFragment.class.getName(), "" /* key */,
screenTitle,
MetricsProto.MetricsEvent.SLICE)
- .setClassName(mContext.getPackageName(), SubSettings.class.getName())
- .setData(contentUri);
+ .setClassName(mContext.getPackageName(), SubSettings.class.getName());
}
@Override
diff --git a/src/com/android/settings/homepage/contextualcards/slices/LowStorageSlice.java b/src/com/android/settings/homepage/contextualcards/slices/LowStorageSlice.java
index 7f6efcc..b3b0b0a 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/LowStorageSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/LowStorageSlice.java
@@ -17,7 +17,6 @@
package com.android.settings.homepage.contextualcards.slices;
import android.app.PendingIntent;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -36,8 +35,8 @@
import com.android.settings.SubSettings;
import com.android.settings.Utils;
import com.android.settings.deviceinfo.StorageSettings;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.CustomSliceable;
-import com.android.settings.slices.SettingsSliceProvider;
import com.android.settings.slices.SliceBuilderUtils;
import com.android.settingslib.deviceinfo.PrivateStorageInfo;
import com.android.settingslib.deviceinfo.StorageManagerVolumeProvider;
@@ -46,20 +45,6 @@
public class LowStorageSlice implements CustomSliceable {
- /**
- * The path denotes the unique name of Low storage Slice.
- */
- public static final String PATH_LOW_STORAGE = "low_storage";
-
- /**
- * Backing Uri for Low storage Slice.
- */
- public static final Uri LOW_STORAGE_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSliceProvider.SLICE_AUTHORITY)
- .appendPath(PATH_LOW_STORAGE)
- .build();
-
private static final String TAG = "LowStorageSlice";
/**
@@ -73,9 +58,6 @@
mContext = context;
}
- /**
- * Return a Low storage Slice bound to {@link #LOW_STORAGE_URI}
- */
@Override
public Slice getSlice() {
// Get current storage percentage from StorageManager.
@@ -108,7 +90,8 @@
* Slices doesn't support "Icon on the left" in header. Now we intend to start with Icon
* right aligned. Will update the icon to left until Slices support it.
*/
- return new ListBuilder(mContext, LOW_STORAGE_URI, ListBuilder.INFINITY)
+ return new ListBuilder(mContext, CustomSliceRegistry.LOW_STORAGE_SLICE_URI,
+ ListBuilder.INFINITY)
.setAccentColor(Utils.getColorAccentDefaultColor(mContext))
.addRow(new RowBuilder()
.setTitle(title)
@@ -120,7 +103,7 @@
@Override
public Uri getUri() {
- return LOW_STORAGE_URI;
+ return CustomSliceRegistry.LOW_STORAGE_SLICE_URI;
}
@Override
@@ -132,13 +115,11 @@
public Intent getIntent() {
final String screenTitle = mContext.getText(R.string.storage_label)
.toString();
- final Uri contentUri = new Uri.Builder().appendPath(PATH_LOW_STORAGE).build();
return SliceBuilderUtils.buildSearchResultPageIntent(mContext,
- StorageSettings.class.getName(), PATH_LOW_STORAGE,
+ StorageSettings.class.getName(), "" /* key */,
screenTitle,
MetricsProto.MetricsEvent.SLICE)
- .setClassName(mContext.getPackageName(), SubSettings.class.getName())
- .setData(contentUri);
+ .setClassName(mContext.getPackageName(), SubSettings.class.getName());
}
}
\ No newline at end of file
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardController.java b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardController.java
index 3368580..4378be3 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardController.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardController.java
@@ -26,8 +26,10 @@
import com.android.settings.homepage.contextualcards.CardDatabaseHelper;
import com.android.settings.homepage.contextualcards.ContextualCard;
import com.android.settings.homepage.contextualcards.ContextualCardController;
+import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
import com.android.settings.homepage.contextualcards.ContextualCardFeedbackDialog;
import com.android.settings.homepage.contextualcards.ContextualCardUpdateListener;
+import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.utils.ThreadUtils;
/**
@@ -67,6 +69,9 @@
dbHelper.markContextualCardAsDismissed(mContext, card.getName());
});
showFeedbackDialog(card);
+ final ContextualCardFeatureProvider contexualCardFeatureProvider =
+ FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider();
+ contexualCardFeatureProvider.logContextualCardDismiss(mContext, card);
}
@Override
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
index 74f25eb..a2d6e2b 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
@@ -20,6 +20,7 @@
import android.content.Context;
import android.net.Uri;
import android.util.ArrayMap;
+import android.util.ArraySet;
import android.util.Log;
import android.view.View;
import android.widget.Button;
@@ -38,10 +39,13 @@
import com.android.settings.R;
import com.android.settings.homepage.contextualcards.ContextualCard;
+import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
import com.android.settings.homepage.contextualcards.ContextualCardRenderer;
import com.android.settings.homepage.contextualcards.ControllerRendererPool;
+import com.android.settings.overlay.FeatureFactory;
import java.util.Map;
+import java.util.Set;
/**
* Card renderer for {@link ContextualCard} built as slices.
@@ -58,6 +62,7 @@
private final Context mContext;
private final LifecycleOwner mLifecycleOwner;
private final ControllerRendererPool mControllerRendererPool;
+ private final Set<ContextualCard> mCardSet;
public SliceContextualCardRenderer(Context context, LifecycleOwner lifecycleOwner,
ControllerRendererPool controllerRendererPool) {
@@ -65,6 +70,7 @@
mLifecycleOwner = lifecycleOwner;
mSliceLiveDataMap = new ArrayMap<>();
mControllerRendererPool = controllerRendererPool;
+ mCardSet = new ArraySet<>();
}
@Override
@@ -99,6 +105,7 @@
sliceLiveData = SliceLiveData.fromUri(mContext, uri);
mSliceLiveDataMap.put(uri.toString(), sliceLiveData);
}
+ mCardSet.add(card);
sliceLiveData.removeObservers(mLifecycleOwner);
sliceLiveData.observe(mLifecycleOwner, slice -> {
@@ -128,14 +135,27 @@
final Button btnRemove = cardHolder.itemView.findViewById(R.id.remove);
btnRemove.setOnClickListener(v -> {
- mControllerRendererPool.getController(mContext, card.getCardType()).onDismissed(
- card);
+ mControllerRendererPool.getController(mContext, card.getCardType()).onDismissed(card);
});
}
@Override
public void onSliceAction(@NonNull EventInfo eventInfo, @NonNull SliceItem sliceItem) {
//TODO(b/79698338): Log user interaction
+
+ // sliceItem.getSlice().getUri() is like
+ // content://android.settings.slices/action/wifi/_gen/0/_gen/0
+ // contextualCard.getSliceUri() is prefix of sliceItem.getSlice().getUri()
+ for (ContextualCard card : mCardSet) {
+ if (sliceItem.getSlice().getUri().toString().startsWith(
+ card.getSliceUri().toString())) {
+ ContextualCardFeatureProvider contexualCardFeatureProvider =
+ FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider();
+ contexualCardFeatureProvider.logContextualCardClick(mContext, card,
+ eventInfo.rowIndex, eventInfo.actionType);
+ break;
+ }
+ }
}
public static class SliceViewHolder extends RecyclerView.ViewHolder {
diff --git a/src/com/android/settings/location/LocationSliceBuilder.java b/src/com/android/settings/location/LocationSliceBuilder.java
index 56cf676..1d79ada 100644
--- a/src/com/android/settings/location/LocationSliceBuilder.java
+++ b/src/com/android/settings/location/LocationSliceBuilder.java
@@ -23,11 +23,9 @@
import android.annotation.ColorInt;
import android.app.PendingIntent;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
-import android.provider.SettingsSlicesContract;
import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
@@ -39,6 +37,7 @@
import com.android.settings.R;
import com.android.settings.SubSettings;
import com.android.settings.Utils;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.SliceBuilderUtils;
/**
@@ -46,21 +45,11 @@
*/
public class LocationSliceBuilder {
- /**
- * Backing Uri for the Location Slice.
- */
- public static final Uri LOCATION_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSlicesContract.AUTHORITY)
- .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
- .appendPath(KEY_LOCATION)
- .build();
-
private LocationSliceBuilder() {
}
/**
- * Return a Location Slice bound to {@link #LOCATION_URI}.
+ * Return a Location Slice bound to {@link CustomSliceRegistry#LOCATION_SLICE_URI}.
*/
public static Slice getSlice(Context context) {
final IconCompat icon = IconCompat.createWithResource(context,
@@ -70,7 +59,8 @@
final PendingIntent primaryAction = getPrimaryAction(context);
final SliceAction primarySliceAction = new SliceAction(primaryAction, icon, title);
- return new ListBuilder(context, LOCATION_URI, ListBuilder.INFINITY)
+ return new ListBuilder(context, CustomSliceRegistry.LOCATION_SLICE_URI,
+ ListBuilder.INFINITY)
.setAccentColor(color)
.addRow(new RowBuilder()
.setTitle(title)
diff --git a/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java b/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
index b198f92..aff1211 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
@@ -19,7 +19,6 @@
import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
import android.app.PendingIntent;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -40,9 +39,8 @@
import com.android.ims.ImsManager;
import com.android.settings.R;
import com.android.settings.Utils;
-import com.android.settings.slices.SettingsSliceProvider;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.SliceBroadcastReceiver;
-import com.android.settings.slices.SliceBuilderUtils;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -57,12 +55,7 @@
*/
public class Enhanced4gLteSliceHelper {
- private static final String TAG = "Enhanced4gLteSliceHelper";
-
- /**
- * Settings slice path to enhanced 4g LTE setting.
- */
- public static final String PATH_ENHANCED_4G_LTE = "enhanced_4g_lte";
+ private static final String TAG = "Enhanced4gLteSlice";
/**
* Action passed for changes to enhanced 4g LTE slice (toggle).
@@ -71,14 +64,6 @@
"com.android.settings.mobilenetwork.action.ENHANCED_4G_LTE_CHANGED";
/**
- * Slice Uri for Enhanced 4G slice
- */
- public static final Uri SLICE_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSliceProvider.SLICE_AUTHORITY)
- .appendPath(PATH_ENHANCED_4G_LTE)
- .build();
- /**
* Action for mobile network settings activity which
* allows setting configuration for Enhanced 4G LTE
* related settings
@@ -225,8 +210,7 @@
}
// notify change in slice in any case to get re-queried. This would result in displaying
// appropriate message with the updated setting.
- final Uri uri = SliceBuilderUtils.getUri(PATH_ENHANCED_4G_LTE, false /*isPlatformSlice*/);
- mContext.getContentResolver().notifyChange(uri, null);
+ mContext.getContentResolver().notifyChange(CustomSliceRegistry.ENHANCED_4G_SLICE_URI, null);
}
private CharSequence getEnhanced4glteModeTitle(int subId) {
diff --git a/src/com/android/settings/notification/ZenModePreferenceController.java b/src/com/android/settings/notification/ZenModePreferenceController.java
index 44ad2ff..22eb0c0 100644
--- a/src/com/android/settings/notification/ZenModePreferenceController.java
+++ b/src/com/android/settings/notification/ZenModePreferenceController.java
@@ -35,6 +35,9 @@
public class ZenModePreferenceController extends BasePreferenceController
implements LifecycleObserver, OnResume, OnPause {
+
+ public static final String ZEN_MODE_KEY = "zen_mode";
+
private SettingObserver mSettingObserver;
private ZenModeSettings.SummaryBuilder mSummaryBuilder;
diff --git a/src/com/android/settings/notification/ZenModeSliceBuilder.java b/src/com/android/settings/notification/ZenModeSliceBuilder.java
index bd6ad0b..f5208c1 100644
--- a/src/com/android/settings/notification/ZenModeSliceBuilder.java
+++ b/src/com/android/settings/notification/ZenModeSliceBuilder.java
@@ -18,16 +18,16 @@
import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
+import static com.android.settings.notification.ZenModePreferenceController.ZEN_MODE_KEY;
+
import android.annotation.ColorInt;
import android.app.NotificationManager;
import android.app.PendingIntent;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.provider.Settings;
-import android.provider.SettingsSlicesContract;
import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
@@ -39,7 +39,7 @@
import com.android.settings.R;
import com.android.settings.SubSettings;
import com.android.settings.Utils;
-import com.android.settings.slices.SettingsSliceProvider;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.SliceBroadcastReceiver;
import com.android.settings.slices.SliceBuilderUtils;
@@ -47,18 +47,6 @@
private static final String TAG = "ZenModeSliceBuilder";
- private static final String ZEN_MODE_KEY = "zen_mode";
-
- /**
- * Backing Uri for the Zen Mode Slice.
- */
- public static final Uri ZEN_MODE_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSliceProvider.SLICE_AUTHORITY)
- .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
- .appendPath(ZEN_MODE_KEY)
- .build();
-
/**
* Action notifying a change on the Zen Mode Slice.
*/
@@ -77,7 +65,7 @@
}
/**
- * Return a ZenMode Slice bound to {@link #ZEN_MODE_URI}.
+ * Return a ZenMode Slice bound to {@link CustomSliceRegistry#ZEN_MODE_URI}.
* <p>
* Note that you should register a listener for {@link #INTENT_FILTER} to get changes for
* ZenMode.
@@ -93,7 +81,8 @@
final SliceAction toggleSliceAction = new SliceAction(toggleAction, null /* actionTitle */,
isZenModeEnabled);
- return new ListBuilder(context, ZEN_MODE_URI, ListBuilder.INFINITY)
+ return new ListBuilder(context, CustomSliceRegistry.ZEN_MODE_SLICE_URI,
+ ListBuilder.INFINITY)
.setAccentColor(color)
.addRow(new RowBuilder()
.setTitle(title)
diff --git a/src/com/android/settings/overlay/FeatureFactory.java b/src/com/android/settings/overlay/FeatureFactory.java
index 02468b8..a52619b 100644
--- a/src/com/android/settings/overlay/FeatureFactory.java
+++ b/src/com/android/settings/overlay/FeatureFactory.java
@@ -28,6 +28,7 @@
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
import com.android.settings.gestures.AssistGestureFeatureProvider;
+import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
import com.android.settings.localepicker.LocaleFeatureProvider;
import com.android.settings.panel.PanelFeatureProvider;
import com.android.settings.search.SearchFeatureProvider;
@@ -108,6 +109,8 @@
public abstract PanelFeatureProvider getPanelFeatureProvider();
+ public abstract ContextualCardFeatureProvider getContextualCardFeatureProvider();
+
public static final class FactoryNotFoundException extends RuntimeException {
public FactoryNotFoundException(Throwable throwable) {
super("Unable to create factory. Did you misconfigure Proguard?", throwable);
diff --git a/src/com/android/settings/overlay/FeatureFactoryImpl.java b/src/com/android/settings/overlay/FeatureFactoryImpl.java
index 8d6d4b6..3515ac0 100644
--- a/src/com/android/settings/overlay/FeatureFactoryImpl.java
+++ b/src/com/android/settings/overlay/FeatureFactoryImpl.java
@@ -40,6 +40,8 @@
import com.android.settings.fuelgauge.PowerUsageFeatureProviderImpl;
import com.android.settings.gestures.AssistGestureFeatureProvider;
import com.android.settings.gestures.AssistGestureFeatureProviderImpl;
+import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
+import com.android.settings.homepage.contextualcards.ContextualCardFeatureProviderImpl;
import com.android.settings.localepicker.LocaleFeatureProvider;
import com.android.settings.localepicker.LocaleFeatureProviderImpl;
import com.android.settings.panel.PanelFeatureProvider;
@@ -75,6 +77,7 @@
private SlicesFeatureProvider mSlicesFeatureProvider;
private AccountFeatureProvider mAccountFeatureProvider;
private PanelFeatureProvider mPanelFeatureProvider;
+ private ContextualCardFeatureProvider mContextualCardFeatureProvider;
@Override
public SupportFeatureProvider getSupportFeatureProvider(Context context) {
@@ -220,4 +223,11 @@
}
return mPanelFeatureProvider;
}
+
+ public ContextualCardFeatureProvider getContextualCardFeatureProvider() {
+ if (mContextualCardFeatureProvider == null) {
+ mContextualCardFeatureProvider = new ContextualCardFeatureProviderImpl();
+ }
+ return mContextualCardFeatureProvider;
+ }
}
diff --git a/src/com/android/settings/panel/InternetConnectivityPanel.java b/src/com/android/settings/panel/InternetConnectivityPanel.java
index b6fe53b..1e01e71 100644
--- a/src/com/android/settings/panel/InternetConnectivityPanel.java
+++ b/src/com/android/settings/panel/InternetConnectivityPanel.java
@@ -16,16 +16,12 @@
package com.android.settings.panel;
-import androidx.annotation.VisibleForTesting;
-
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
-import android.provider.SettingsSlicesContract;
import com.android.settings.R;
-import com.android.settings.wifi.WifiSlice;
+import com.android.settings.slices.CustomSliceRegistry;
import java.util.ArrayList;
import java.util.List;
@@ -34,19 +30,11 @@
* Represents the Internet Connectivity Panel.
*
* <p>
- * Displays Wifi (full Slice) and Airplane mode.
+ * Displays Wifi (full Slice) and Airplane mode.
* </p>
*/
public class InternetConnectivityPanel implements PanelContent {
- @VisibleForTesting
- static final Uri AIRPLANE_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSlicesContract.AUTHORITY)
- .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
- .appendPath(SettingsSlicesContract.KEY_AIRPLANE_MODE)
- .build();
-
private final Context mContext;
public static InternetConnectivityPanel create(Context context) {
@@ -65,8 +53,8 @@
@Override
public List<Uri> getSlices() {
final List<Uri> uris = new ArrayList<>();
- uris.add(WifiSlice.WIFI_URI);
- uris.add(AIRPLANE_URI);
+ uris.add(CustomSliceRegistry.WIFI_SLICE_URI);
+ uris.add(CustomSliceRegistry.AIRPLANE_URI);
return uris;
}
diff --git a/src/com/android/settings/slices/CustomSliceManager.java b/src/com/android/settings/slices/CustomSliceManager.java
index 99e22a1..bef72b7 100644
--- a/src/com/android/settings/slices/CustomSliceManager.java
+++ b/src/com/android/settings/slices/CustomSliceManager.java
@@ -101,13 +101,13 @@
}
private void addSlices() {
- mUriMap.put(WifiSlice.WIFI_URI, WifiSlice.class);
- mUriMap.put(DataUsageSlice.DATA_USAGE_CARD_URI, DataUsageSlice.class);
- mUriMap.put(DeviceInfoSlice.DEVICE_INFO_CARD_URI, DeviceInfoSlice.class);
- mUriMap.put(StorageSlice.STORAGE_CARD_URI, StorageSlice.class);
- mUriMap.put(BatterySlice.BATTERY_CARD_URI, BatterySlice.class);
- mUriMap.put(ConnectedDeviceSlice.CONNECTED_DEVICE_URI, ConnectedDeviceSlice.class);
- mUriMap.put(LowStorageSlice.LOW_STORAGE_URI, LowStorageSlice.class);
- mUriMap.put(BatteryFixSlice.BATTERY_FIX_URI, BatteryFixSlice.class);
+ mUriMap.put(CustomSliceRegistry.BATTERY_FIX_SLICE_URI, BatteryFixSlice.class);
+ mUriMap.put(CustomSliceRegistry.BATTERY_INFO_SLICE_URI, BatterySlice.class);
+ mUriMap.put(CustomSliceRegistry.CONNECTED_DEVICE_SLICE_URI, ConnectedDeviceSlice.class);
+ mUriMap.put(CustomSliceRegistry.DATA_USAGE_SLICE_URI, DataUsageSlice.class);
+ mUriMap.put(CustomSliceRegistry.DEVICE_INFO_SLICE_URI, DeviceInfoSlice.class);
+ mUriMap.put(CustomSliceRegistry.LOW_STORAGE_SLICE_URI, LowStorageSlice.class);
+ mUriMap.put(CustomSliceRegistry.STORAGE_SLICE_URI, StorageSlice.class);
+ mUriMap.put(CustomSliceRegistry.WIFI_SLICE_URI, WifiSlice.class);
}
}
diff --git a/src/com/android/settings/slices/CustomSliceRegistry.java b/src/com/android/settings/slices/CustomSliceRegistry.java
new file mode 100644
index 0000000..f2b3299
--- /dev/null
+++ b/src/com/android/settings/slices/CustomSliceRegistry.java
@@ -0,0 +1,184 @@
+/*
+ * 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.slices;
+
+import static android.provider.SettingsSlicesContract.KEY_LOCATION;
+import static android.provider.SettingsSlicesContract.KEY_WIFI;
+
+import static com.android.settings.notification.ZenModePreferenceController.ZEN_MODE_KEY;
+
+import android.content.ContentResolver;
+import android.net.Uri;
+import android.provider.SettingsSlicesContract;
+
+import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController;
+import com.android.settings.wifi.calling.WifiCallingSliceHelper;
+
+/**
+ * A registry of custom slice Uris.
+ */
+public class CustomSliceRegistry {
+
+ /**
+ * Uri for Airplane mode Slice.
+ */
+ public static final Uri AIRPLANE_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSlicesContract.AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .appendPath(SettingsSlicesContract.KEY_AIRPLANE_MODE)
+ .build();
+
+ /**
+ * Uri for Battery Fix Slice.
+ */
+ public static final Uri BATTERY_FIX_SLICE_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendEncodedPath(SettingsSlicesContract.PATH_SETTING_INTENT)
+ .appendPath(BatteryTipPreferenceController.PREF_NAME)
+ .build();
+ /**
+ * Backing Uri for the Battery info Slice.
+ */
+ public static final Uri BATTERY_INFO_SLICE_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendEncodedPath(SettingsSlicesContract.PATH_SETTING_INTENT)
+ .appendPath("battery_card")
+ .build();
+ /**
+ * Backing Uri for the Bluetooth Slice.
+ */
+ public static final Uri BLUETOOTH_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSlicesContract.AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .appendPath(SettingsSlicesContract.KEY_BLUETOOTH)
+ .build();
+
+ /**
+ * Backing Uri for Connected device Slice.
+ */
+ public static final Uri CONNECTED_DEVICE_SLICE_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .appendPath("connected_device")
+ .build();
+ /**
+ * Backing Uri for the Data usage Slice.
+ */
+ public static final Uri DATA_USAGE_SLICE_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath("data_usage_card")
+ .build();
+ /**
+ * Backing Uri for the Device info Slice.
+ */
+ public static final Uri DEVICE_INFO_SLICE_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath("device_info_card")
+ .build();
+ /**
+ * Backing Uri for the Emergency Info Slice.
+ */
+ public static final Uri EMERGENCY_INFO_SLICE_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath("emergency_info_card")
+ .build();
+ /**
+ * Slice Uri for Enhanced 4G slice
+ */
+ public static final Uri ENHANCED_4G_SLICE_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath("enhanced_4g_lte")
+ .build();
+ /**
+ * Backing Uri for the Flashlight Slice.
+ */
+ public static final Uri FLASHLIGHT_SLICE_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .appendPath("flashlight")
+ .build();
+ /**
+ * Backing Uri for the Location Slice.
+ */
+ public static final Uri LOCATION_SLICE_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSlicesContract.AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .appendPath(KEY_LOCATION)
+ .build();
+ /**
+ * Backing Uri for Low storage Slice.
+ */
+ public static final Uri LOW_STORAGE_SLICE_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendEncodedPath(SettingsSlicesContract.PATH_SETTING_INTENT)
+ .appendPath("low_storage")
+ .build();
+ /**
+ * Backing Uri for the storage slice.
+ */
+ public static final Uri STORAGE_SLICE_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath("storage_card")
+ .build();
+ /**
+ * Full {@link Uri} for the Wifi Calling Slice.
+ */
+ public static final Uri WIFI_CALLING_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath(WifiCallingSliceHelper.PATH_WIFI_CALLING)
+ .build();
+ /**
+ * Full {@link Uri} for the Wifi Calling Preference Slice.
+ */
+ public static final Uri WIFI_CALLING_PREFERENCE_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath(WifiCallingSliceHelper.PATH_WIFI_CALLING_PREFERENCE)
+ .build();
+ /**
+ * Backing Uri for the Wifi Slice.
+ */
+ public static final Uri WIFI_SLICE_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSlicesContract.AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .appendPath(KEY_WIFI)
+ .build();
+ /**
+ * Backing Uri for the Zen Mode Slice.
+ */
+ public static final Uri ZEN_MODE_SLICE_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .appendPath(ZEN_MODE_KEY)
+ .build();
+}
diff --git a/src/com/android/settings/slices/SettingsSliceProvider.java b/src/com/android/settings/slices/SettingsSliceProvider.java
index 952fc8b..109f02e 100644
--- a/src/com/android/settings/slices/SettingsSliceProvider.java
+++ b/src/com/android/settings/slices/SettingsSliceProvider.java
@@ -44,11 +44,8 @@
import com.android.settings.flashlight.FlashlightSliceBuilder;
import com.android.settings.homepage.contextualcards.deviceinfo.EmergencyInfoSlice;
import com.android.settings.location.LocationSliceBuilder;
-import com.android.settings.network.telephony.Enhanced4gLteSliceHelper;
import com.android.settings.notification.ZenModeSliceBuilder;
import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.wifi.WifiSlice;
-import com.android.settings.wifi.calling.WifiCallingSliceHelper;
import com.android.settingslib.SliceBroadcastRelay;
import com.android.settingslib.utils.ThreadUtils;
@@ -175,23 +172,21 @@
if (filter != null) {
registerIntentToUri(filter, sliceUri);
}
- ThreadUtils.postOnMainThread(() -> {
- startBackgroundWorker(sliceable);
- });
+ ThreadUtils.postOnMainThread(() -> startBackgroundWorker(sliceable));
return;
}
- if (ZenModeSliceBuilder.ZEN_MODE_URI.equals(sliceUri)) {
+ if (CustomSliceRegistry.ZEN_MODE_SLICE_URI.equals(sliceUri)) {
registerIntentToUri(ZenModeSliceBuilder.INTENT_FILTER, sliceUri);
return;
- } else if (BluetoothSliceBuilder.BLUETOOTH_URI.equals(sliceUri)) {
+ } else if (CustomSliceRegistry.BLUETOOTH_URI.equals(sliceUri)) {
registerIntentToUri(BluetoothSliceBuilder.INTENT_FILTER, sliceUri);
return;
- } else if (FlashlightSliceBuilder.FLASHLIGHT_URI.equals(sliceUri)) {
+ } else if (CustomSliceRegistry.FLASHLIGHT_SLICE_URI.equals(sliceUri)) {
registerIntentToUri(FlashlightSliceBuilder.INTENT_FILTER, sliceUri);
mRegisteredUris.add(sliceUri);
return;
- } else if (EmergencyInfoSlice.EMERGENCY_INFO_CARD_URI.equals(sliceUri)) {
+ } else if (CustomSliceRegistry.EMERGENCY_INFO_SLICE_URI.equals(sliceUri)) {
return;
}
@@ -236,30 +231,30 @@
return sliceable.getSlice();
}
- if (WifiCallingSliceHelper.WIFI_CALLING_URI.equals(sliceUri)) {
+ if (CustomSliceRegistry.WIFI_CALLING_URI.equals(sliceUri)) {
return FeatureFactory.getFactory(getContext())
.getSlicesFeatureProvider()
.getNewWifiCallingSliceHelper(getContext())
.createWifiCallingSlice(sliceUri);
- } else if (ZenModeSliceBuilder.ZEN_MODE_URI.equals(sliceUri)) {
+ } else if (CustomSliceRegistry.ZEN_MODE_SLICE_URI.equals(sliceUri)) {
return ZenModeSliceBuilder.getSlice(getContext());
- } else if (BluetoothSliceBuilder.BLUETOOTH_URI.equals(sliceUri)) {
+ } else if (CustomSliceRegistry.BLUETOOTH_URI.equals(sliceUri)) {
return BluetoothSliceBuilder.getSlice(getContext());
- } else if (LocationSliceBuilder.LOCATION_URI.equals(sliceUri)) {
+ } else if (CustomSliceRegistry.LOCATION_SLICE_URI.equals(sliceUri)) {
return LocationSliceBuilder.getSlice(getContext());
- } else if (Enhanced4gLteSliceHelper.SLICE_URI.equals(sliceUri)) {
+ } else if (CustomSliceRegistry.ENHANCED_4G_SLICE_URI.equals(sliceUri)) {
return FeatureFactory.getFactory(getContext())
.getSlicesFeatureProvider()
.getNewEnhanced4gLteSliceHelper(getContext())
.createEnhanced4gLteSlice(sliceUri);
- } else if (WifiCallingSliceHelper.WIFI_CALLING_PREFERENCE_URI.equals(sliceUri)) {
+ } else if (CustomSliceRegistry.WIFI_CALLING_PREFERENCE_URI.equals(sliceUri)) {
return FeatureFactory.getFactory(getContext())
.getSlicesFeatureProvider()
.getNewWifiCallingSliceHelper(getContext())
.createWifiCallingPreferenceSlice(sliceUri);
- } else if (FlashlightSliceBuilder.FLASHLIGHT_URI.equals(sliceUri)) {
+ } else if (CustomSliceRegistry.FLASHLIGHT_SLICE_URI.equals(sliceUri)) {
return FlashlightSliceBuilder.getSlice(getContext());
- } else if (EmergencyInfoSlice.EMERGENCY_INFO_CARD_URI.equals(sliceUri)) {
+ } else if (CustomSliceRegistry.EMERGENCY_INFO_SLICE_URI.equals(sliceUri)) {
return EmergencyInfoSlice.getSlice(getContext());
}
@@ -476,16 +471,16 @@
private List<Uri> getSpecialCasePlatformUris() {
return Arrays.asList(
- WifiSlice.WIFI_URI,
- BluetoothSliceBuilder.BLUETOOTH_URI,
- LocationSliceBuilder.LOCATION_URI
+ CustomSliceRegistry.WIFI_SLICE_URI,
+ CustomSliceRegistry.BLUETOOTH_URI,
+ CustomSliceRegistry.LOCATION_SLICE_URI
);
}
private List<Uri> getSpecialCaseOemUris() {
return Arrays.asList(
- ZenModeSliceBuilder.ZEN_MODE_URI,
- FlashlightSliceBuilder.FLASHLIGHT_URI
+ CustomSliceRegistry.ZEN_MODE_SLICE_URI,
+ CustomSliceRegistry.FLASHLIGHT_SLICE_URI
);
}
diff --git a/src/com/android/settings/slices/SliceDeepLinkSpringBoard.java b/src/com/android/settings/slices/SliceDeepLinkSpringBoard.java
index 7531778..01708af 100644
--- a/src/com/android/settings/slices/SliceDeepLinkSpringBoard.java
+++ b/src/com/android/settings/slices/SliceDeepLinkSpringBoard.java
@@ -62,11 +62,11 @@
final CustomSliceable sliceable =
customSliceManager.getSliceableFromUri(sliceUri);
launchIntent = sliceable.getIntent();
- } else if (ZenModeSliceBuilder.ZEN_MODE_URI.equals(sliceUri)) {
+ } else if (CustomSliceRegistry.ZEN_MODE_SLICE_URI.equals(sliceUri)) {
launchIntent = ZenModeSliceBuilder.getIntent(this /* context */);
- } else if (BluetoothSliceBuilder.BLUETOOTH_URI.equals(sliceUri)) {
+ } else if (CustomSliceRegistry.BLUETOOTH_URI.equals(sliceUri)) {
launchIntent = BluetoothSliceBuilder.getIntent(this /* context */);
- } else if (LocationSliceBuilder.LOCATION_URI.equals(sliceUri)) {
+ } else if (CustomSliceRegistry.LOCATION_SLICE_URI.equals(sliceUri)) {
launchIntent = LocationSliceBuilder.getIntent(this /* context */);
} else {
final SlicesDatabaseAccessor slicesDatabaseAccessor =
diff --git a/src/com/android/settings/slices/SlicesDatabaseAccessor.java b/src/com/android/settings/slices/SlicesDatabaseAccessor.java
index 35a0a5d..c75f3ef 100644
--- a/src/com/android/settings/slices/SlicesDatabaseAccessor.java
+++ b/src/com/android/settings/slices/SlicesDatabaseAccessor.java
@@ -71,6 +71,9 @@
*/
public SliceData getSliceDataFromUri(Uri uri) {
Pair<Boolean, String> pathData = SliceBuilderUtils.getPathData(uri);
+ if (pathData == null) {
+ throw new IllegalStateException("Invalid Slices uri: " + uri);
+ }
Cursor cursor = getIndexedSliceData(pathData.second /* key */);
return buildSliceData(cursor, uri, pathData.first /* isIntentOnly */);
}
diff --git a/src/com/android/settings/wifi/WifiSlice.java b/src/com/android/settings/wifi/WifiSlice.java
index d06d830..0dbbfd5 100644
--- a/src/com/android/settings/wifi/WifiSlice.java
+++ b/src/com/android/settings/wifi/WifiSlice.java
@@ -19,9 +19,10 @@
import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
import static android.provider.SettingsSlicesContract.KEY_WIFI;
+import static com.android.settings.slices.CustomSliceRegistry.WIFI_SLICE_URI;
+
import android.annotation.ColorInt;
import android.app.PendingIntent;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -30,7 +31,6 @@
import android.net.wifi.WifiManager;
import android.net.wifi.WifiSsid;
import android.os.Bundle;
-import android.provider.SettingsSlicesContract;
import android.text.TextUtils;
import androidx.annotation.VisibleForTesting;
@@ -60,16 +60,6 @@
*/
public class WifiSlice implements CustomSliceable {
- /**
- * Backing Uri for the Wifi Slice.
- */
- public static final Uri WIFI_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSlicesContract.AUTHORITY)
- .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
- .appendPath(KEY_WIFI)
- .build();
-
@VisibleForTesting
static final int DEFAULT_EXPANDED_ROW_COUNT = 3;
@@ -81,7 +71,7 @@
@Override
public Uri getUri() {
- return WIFI_URI;
+ return WIFI_SLICE_URI;
}
@Override
@@ -92,9 +82,6 @@
return filter;
}
- /**
- * Return a Wifi Slice bound to {@link #WIFI_URI}.
- */
@Override
public Slice getSlice() {
final boolean isWifiEnabled = isWifiEnabled();
@@ -109,7 +96,8 @@
final SliceAction toggleSliceAction = new SliceAction(toggleAction, null /* actionTitle */,
isWifiEnabled);
- final ListBuilder listBuilder = new ListBuilder(mContext, WIFI_URI, ListBuilder.INFINITY)
+ final ListBuilder listBuilder = new ListBuilder(mContext, WIFI_SLICE_URI,
+ ListBuilder.INFINITY)
.setAccentColor(color)
.addRow(new RowBuilder()
.setTitle(title)
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
index 0629ad3..65012fc 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
@@ -18,9 +18,11 @@
import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
+import static com.android.settings.slices.CustomSliceRegistry.WIFI_CALLING_PREFERENCE_URI;
+import static com.android.settings.slices.CustomSliceRegistry.WIFI_CALLING_URI;
+
import android.app.PendingIntent;
import android.content.ComponentName;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -42,9 +44,7 @@
import com.android.ims.ImsManager;
import com.android.settings.R;
import com.android.settings.Utils;
-import com.android.settings.slices.SettingsSliceProvider;
import com.android.settings.slices.SliceBroadcastReceiver;
-import com.android.settings.slices.SliceBuilderUtils;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -104,24 +104,6 @@
"android.settings.WIFI_CALLING_SETTINGS";
/**
- * Full {@link Uri} for the Wifi Calling Slice.
- */
- public static final Uri WIFI_CALLING_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSliceProvider.SLICE_AUTHORITY)
- .appendPath(PATH_WIFI_CALLING)
- .build();
-
- /**
- * Full {@link Uri} for the Wifi Calling Preference Slice.
- */
- public static final Uri WIFI_CALLING_PREFERENCE_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsSliceProvider.SLICE_AUTHORITY)
- .appendPath(PATH_WIFI_CALLING_PREFERENCE)
- .build();
-
- /**
* Timeout for querying wifi calling setting from ims manager.
*/
private static final int TIMEOUT_MILLIS = 2000;
@@ -246,7 +228,7 @@
}
final boolean isWifiCallingPrefEditable = isCarrierConfigManagerKeyEnabled(
- CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL, subId,false);
+ CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL, subId, false);
final boolean isWifiOnlySupported = isCarrierConfigManagerKeyEnabled(
CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, subId, true);
final ImsManager imsManager = getImsManager(subId);
@@ -287,8 +269,8 @@
* Returns actionable wifi calling preference slice.
*
* @param isWifiOnlySupported adds row for wifi only if this is true
- * @param currentWfcPref current Preference {@link ImsConfig}
- * @param sliceUri sliceUri
+ * @param currentWfcPref current Preference {@link ImsConfig}
+ * @param sliceUri sliceUri
* @return Slice for actionable wifi calling preference settings
*/
private Slice getWifiCallingPreferenceSlice(boolean isWifiOnlySupported,
@@ -299,12 +281,12 @@
ListBuilder listBuilder = new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY)
.setAccentColor(Utils.getColorAccentDefaultColor(mContext));
listBuilder.setHeader(new ListBuilder.HeaderBuilder()
- .setTitle(mContext.getText(R.string.wifi_calling_mode_title))
- .setSubtitle(getWifiCallingPreferenceSummary(currentWfcPref))
- .setPrimaryAction(new SliceAction(
- getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY),
- icon,
- mContext.getText(R.string.wifi_calling_mode_title))));
+ .setTitle(mContext.getText(R.string.wifi_calling_mode_title))
+ .setSubtitle(getWifiCallingPreferenceSummary(currentWfcPref))
+ .setPrimaryAction(new SliceAction(
+ getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY),
+ icon,
+ mContext.getText(R.string.wifi_calling_mode_title))));
if (isWifiOnlySupported) {
listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder,
@@ -329,9 +311,9 @@
/**
* Returns RowBuilder for a new row containing specific wifi calling preference.
*
- * @param listBuilder ListBuilder that will be the parent for this RowBuilder
+ * @param listBuilder ListBuilder that will be the parent for this RowBuilder
* @param preferenceTitleResId resource Id for the preference row title
- * @param action action to be added for the row
+ * @param action action to be added for the row
* @return RowBuilder for the row
*/
private RowBuilder wifiPreferenceRowBuilder(ListBuilder listBuilder,
@@ -414,8 +396,7 @@
}
// notify change in slice in any case to get re-queried. This would result in displaying
// appropriate message with the updated setting.
- final Uri uri = SliceBuilderUtils.getUri(PATH_WIFI_CALLING, false /*isPlatformSlice*/);
- mContext.getContentResolver().notifyChange(uri, null);
+ mContext.getContentResolver().notifyChange(WIFI_CALLING_URI, null);
}
/**
@@ -433,7 +414,7 @@
if (subId > SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
final boolean isWifiCallingPrefEditable = isCarrierConfigManagerKeyEnabled(
- CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL, subId,false);
+ CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL, subId, false);
final boolean isWifiOnlySupported = isCarrierConfigManagerKeyEnabled(
CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, subId, true);
@@ -470,15 +451,13 @@
// notify change in slice in any case to get re-queried. This would result in displaying
// appropriate message.
- final Uri uri = SliceBuilderUtils.getUri(PATH_WIFI_CALLING_PREFERENCE,
- false /*isPlatformSlice*/);
- mContext.getContentResolver().notifyChange(uri, null);
+ mContext.getContentResolver().notifyChange(WIFI_CALLING_PREFERENCE_URI, null);
}
/**
* Returns Slice with the title and subtitle provided as arguments with wifi signal Icon.
*
- * @param title Title of the slice
+ * @param title Title of the slice
* @param subtitle Subtitle of the slice
* @param sliceUri slice uri
* @return Slice with title and subtitle
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index 48446c9..ba8241a 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -408,8 +408,7 @@
mEntityHeaderController.setIcon(wifiIcon).done(mFragment.getActivity(), true /* rebind */);
Drawable wifiIconDark = wifiIcon.getConstantState().newDrawable().mutate();
- wifiIconDark.setTint(mContext.getResources().getColor(
- R.color.wifi_details_icon_color, mContext.getTheme()));
+ wifiIconDark.setTintList(Utils.getColorAttr(mContext, android.R.attr.colorControlNormal));
mSignalStrengthPref.setIcon(wifiIconDark);
mSignalStrengthPref.setSummary(mSignalStr[mRssiSignalLevel]);
diff --git a/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java b/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
new file mode 100644
index 0000000..177e79d
--- /dev/null
+++ b/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
@@ -0,0 +1,37 @@
+/*
+ * 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.wifi.dpp;
+
+import android.os.Bundle;
+
+import com.android.settings.R;
+
+/**
+ * After getting Wi-Fi network information and(or) QR code, this fragment config a device to connect
+ * to the Wi-Fi network.
+ */
+public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
+ @Override
+ protected int getLayout() {
+ return R.layout.wifi_dpp_add_device_fragment;
+ }
+
+ @Override
+ public void onActivityCreated (Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ }
+}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragment.java b/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragment.java
new file mode 100644
index 0000000..7d031c1
--- /dev/null
+++ b/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragment.java
@@ -0,0 +1,37 @@
+/*
+ * 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.wifi.dpp;
+
+import android.os.Bundle;
+
+import com.android.settings.R;
+
+/**
+ * After a camera APP scanned a Wi-Fi DPP QR code, it can trigger
+ * {@code WifiDppConfiguratorActivity} to start with this fragment to choose a saved Wi-Fi network.
+ */
+public class WifiDppChooseSavedWifiNetworkFragment extends WifiDppQrCodeBaseFragment {
+ @Override
+ protected int getLayout() {
+ return R.layout.wifi_dpp_choose_saved_wifi_network_fragment;
+ }
+
+ @Override
+ public void onActivityCreated (Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ }
+}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
index bccb53a..e631c84 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
@@ -67,25 +67,48 @@
super.onCreate(savedInstanceState);
setContentView(R.layout.wifi_dpp_activity);
- // Hide action bar
- ActionBar action = getActionBar();
- if (action != null) {
- action.hide();
- }
-
mFragmentManager = getSupportFragmentManager();
mFragmentTransaction = getSupportFragmentManager().beginTransaction();
final int launchMode = getIntent().getIntExtra(EXTRA_LAUNCH_MODE,
LaunchMode.LAUNCH_MODE_NOT_DEFINED.getMode());
if (launchMode == LaunchMode.LAUNCH_MODE_QR_CODE_SCANNER.getMode()) {
- WifiDppQrCodeScannerFragment scanFragment = new WifiDppQrCodeScannerFragment();
- mFragmentTransaction.add(R.id.fragment_container, scanFragment);
- mFragmentTransaction.commit();
+ addQrCodeScannerFragment();
+ } else if (launchMode == LaunchMode.LAUNCH_MODE_QR_CODE_GENERATOR.getMode()) {
+ addQrCodeGeneratorFragment();
+ } else if (launchMode == LaunchMode.LAUNCH_MODE_CHOOSE_SAVED_WIFI_NETWORK.getMode()) {
+ addChooseSavedWifiNetworkFragment();
} else {
Log.e(TAG, "Launch with an invalid mode extra");
setResult(Activity.RESULT_CANCELED);
finish();
}
}
+
+ private void addQrCodeScannerFragment() {
+ WifiDppQrCodeScannerFragment fragment = new WifiDppQrCodeScannerFragment();
+ mFragmentTransaction.add(R.id.fragment_container, fragment);
+ mFragmentTransaction.addToBackStack(null);
+ mFragmentTransaction.commit();
+ }
+
+ private void addQrCodeGeneratorFragment() {
+ WifiDppQrCodeGeneratorFragment fragment = new WifiDppQrCodeGeneratorFragment();
+ mFragmentTransaction.add(R.id.fragment_container, fragment);
+ mFragmentTransaction.addToBackStack(null);
+ mFragmentTransaction.commit();
+ }
+
+ private void addChooseSavedWifiNetworkFragment() {
+ ActionBar action = getActionBar();
+ if (action != null) {
+ action.hide();
+ }
+
+ WifiDppChooseSavedWifiNetworkFragment fragment =
+ new WifiDppChooseSavedWifiNetworkFragment();
+ mFragmentTransaction.add(R.id.fragment_container, fragment);
+ mFragmentTransaction.addToBackStack(null);
+ mFragmentTransaction.commit();
+ }
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeBaseFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeBaseFragment.java
index 004cb18..0d30a79 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppQrCodeBaseFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeBaseFragment.java
@@ -22,6 +22,9 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.ProgressBar;
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto;
@@ -29,13 +32,37 @@
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.R;
+/**
+ * There are below 4 fragments for Wi-Fi DPP UI flow, to reduce redundant code of UI components,
+ * this parent fragment instantiates all UI components and provides setting APIs for them.
+ *
+ * {@code WifiDppQrCodeScannerFragment}
+ * {@code WifiDppQrCodeGeneratorFragment}
+ * {@code WifiDppChooseSavedWifiNetworkFragment}
+ * {@code WifiDppAddDeviceFragment}
+ */
public abstract class WifiDppQrCodeBaseFragment extends InstrumentedFragment {
private TextView mTitle;
private TextView mDescription;
- private SurfaceView mPreviewView;
- private TextView mErrorMessage; //optional, view used to surface connectivity errors to the user
- private Button mButtonLeft;
- private Button mButtonRight;
+
+ private SurfaceView mPreviewView; //optional, for WifiDppQrCodeScannerFragment
+ private ImageView mDecorateViiew; //optional, for WifiDppQrCodeScannerFragment
+ private TextView mErrorMessage; //optional, for WifiDppQrCodeScannerFragment
+
+ private ImageView mBarcodeView; //optional, for WifiDppQrCodeGeneratorFragment
+
+ private ListView mSavedWifiNetworkList; //optional, for WifiDppChooseSavedWifiNetworkFragment
+
+ private ProgressBar mProgressBar; //optional, for WifiDppAddDeviceFragment
+ private ImageView mWifiApPictureView; //optional, for WifiDppAddDeviceFragment
+ private TextView mChooseDifferentNetwork;//optional, for WifiDppAddDeviceFragment
+
+ private Button mButtonLeft; //optional, for WifiDppQrCodeScannerFragment,
+ // WifiDppChooseSavedWifiNetworkFragment,
+ // WifiDppAddDeviceFragment
+ private Button mButtonRight; //optional, for WifiDppQrCodeScannerFragment,
+ // WifiDppChooseSavedWifiNetworkFragment,
+ // WifiDppAddDeviceFragment
abstract protected int getLayout();
@@ -61,8 +88,19 @@
private void initView(View view) {
mTitle = view.findViewById(R.id.title);
mDescription = view.findViewById(R.id.description);
+
mPreviewView = view.findViewById(R.id.preview_view);
+ mDecorateViiew = view.findViewById(R.id.decorate_view);
mErrorMessage = view.findViewById(R.id.error_message);
+
+ mBarcodeView = view.findViewById(R.id.barcode_view);
+
+ mSavedWifiNetworkList = view.findViewById(R.id.saved_wifi_network_list);
+
+ mProgressBar = view.findViewById(R.id.progress_bar);
+ mWifiApPictureView = view.findViewById(R.id.wifi_ap_picture_view);
+ mChooseDifferentNetwork = view.findViewById(R.id.choose_different_network);
+
mButtonLeft = view.findViewById(R.id.button_left);
mButtonRight = view.findViewById(R.id.button_right);
}
@@ -75,33 +113,76 @@
mDescription.setText(description);
}
+ /** optional, for WifiDppQrCodeScannerFragment */
protected void setErrorMessage(String errorMessage) {
if (mErrorMessage != null) {
mErrorMessage.setText(errorMessage);
}
}
+ /**
+ * optional, for WifiDppQrCodeScannerFragment,
+ * WifiDppChooseSavedWifiNetworkFragment,
+ * WifiDppAddDeviceFragment
+ */
protected void setLeftButtonText(String text) {
- mButtonLeft.setText(text);
+ if (mButtonLeft != null) {
+ mButtonLeft.setText(text);
+ }
}
+ /**
+ * optional, for WifiDppQrCodeScannerFragment,
+ * WifiDppChooseSavedWifiNetworkFragment,
+ * WifiDppAddDeviceFragment
+ */
protected void setRightButtonText(String text) {
- mButtonRight.setText(text);
+ if (mButtonRight != null) {
+ mButtonRight.setText(text);
+ }
}
+ /**
+ * optional, for WifiDppQrCodeScannerFragment,
+ * WifiDppChooseSavedWifiNetworkFragment,
+ * WifiDppAddDeviceFragment
+ */
protected void hideLeftButton() {
- mButtonLeft.setVisibility(View.INVISIBLE);
+ if (mButtonLeft != null) {
+ mButtonLeft.setVisibility(View.INVISIBLE);
+ }
}
+ /**
+ * optional, for WifiDppQrCodeScannerFragment,
+ * WifiDppChooseSavedWifiNetworkFragment,
+ * WifiDppAddDeviceFragment
+ */
protected void hideRightButton() {
- mButtonRight.setVisibility(View.INVISIBLE);
+ if (mButtonRight != null) {
+ mButtonRight.setVisibility(View.INVISIBLE);
+ }
}
+ /**
+ * optional, for WifiDppQrCodeScannerFragment,
+ * WifiDppChooseSavedWifiNetworkFragment,
+ * WifiDppAddDeviceFragment
+ */
protected void setLeftButtonOnClickListener(View.OnClickListener listener) {
- mButtonLeft.setOnClickListener(listener);
+ if (mButtonLeft != null) {
+ mButtonLeft.setOnClickListener(listener);
+ }
}
+ /**
+ * optional, for WifiDppQrCodeScannerFragment,
+ * WifiDppChooseSavedWifiNetworkFragment,
+ * WifiDppAddDeviceFragment
+ */
protected void setRightButtonOnClickListener(View.OnClickListener listener) {
- mButtonRight.setOnClickListener(listener);
+ if (mButtonRight != null) {
+ mButtonRight.setOnClickListener(listener);
+ }
}
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
new file mode 100644
index 0000000..9935bf2
--- /dev/null
+++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
@@ -0,0 +1,37 @@
+/*
+ * 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.wifi.dpp;
+
+import android.os.Bundle;
+
+import com.android.settings.R;
+
+/**
+ * After sharing a saved Wi-Fi network, {@code WifiDppConfiguratorActivity} start with this fragment
+ * to generate a Wi-Fi DPP QR code for other device to initiate as an enrollee.
+ */
+public class WifiDppQrCodeGeneratorFragment extends WifiDppQrCodeBaseFragment {
+ @Override
+ protected int getLayout() {
+ return R.layout.wifi_dpp_qrcode_generator_fragment;
+ }
+
+ @Override
+ public void onActivityCreated (Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ }
+}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
index 0ee8434..cbaa5d5 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
@@ -19,10 +19,7 @@
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
import com.android.settings.R;
public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment {
diff --git a/tests/robotests/res/values-mcc999/config.xml b/tests/robotests/res/values-mcc999/config.xml
index 9bba3c3..c5c552e 100644
--- a/tests/robotests/res/values-mcc999/config.xml
+++ b/tests/robotests/res/values-mcc999/config.xml
@@ -73,6 +73,11 @@
<item>fake_package/fake_service</item>
</string-array>
+ <!-- Settings intelligence interaction log intent action -->
+ <string name="config_settingsintelligence_log_action" translatable="false">
+ aaa.bbb.ccc
+ </string>
+
<!-- List of packages that should be whitelisted for slice uri access. Do not translate -->
<string-array name="slice_whitelist_package_names" translatable="false">
<item>com.android.settings.slice_whitelist_package</item>
diff --git a/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java
index 6ff0dba..3d3a05a 100644
--- a/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java
@@ -51,7 +51,6 @@
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.ShadowPowerManager;
import com.android.settingslib.applications.AppUtils;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.applications.instantapps.InstantAppDataProvider;
@@ -93,6 +92,8 @@
private ApplicationsState.AppEntry mAppEntry;
@Mock
private ApplicationInfo mApplicationInfo;
+ @Mock
+ private PowerManager mPowerManager;
private Context mContext;
private RecentAppsPreferenceController mController;
@@ -104,6 +105,7 @@
doReturn(mUsageStatsManager).when(mContext).getSystemService(Context.USAGE_STATS_SERVICE);
doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
doReturn(mPackageManager).when(mContext).getPackageManager();
+ doReturn(mPowerManager).when(mContext).getSystemService(PowerManager.class);
mController = new RecentAppsPreferenceController(mContext, mAppState, null);
when(mScreen.findPreference(anyString())).thenReturn(mCategory);
@@ -174,15 +176,15 @@
// stat1, stat2 are valid apps. stat3 is invalid.
when(mAppState.getEntry(stat1.mPackageName, UserHandle.myUserId()))
- .thenReturn(mAppEntry);
+ .thenReturn(mAppEntry);
when(mAppState.getEntry(stat2.mPackageName, UserHandle.myUserId()))
- .thenReturn(mAppEntry);
+ .thenReturn(mAppEntry);
when(mAppState.getEntry(stat3.mPackageName, UserHandle.myUserId()))
- .thenReturn(null);
+ .thenReturn(null);
when(mPackageManager.resolveActivity(any(Intent.class), anyInt()))
- .thenReturn(new ResolveInfo());
+ .thenReturn(new ResolveInfo());
when(mUsageStatsManager.queryUsageStats(anyInt(), anyLong(), anyLong()))
- .thenReturn(stats);
+ .thenReturn(stats);
mAppEntry.info = mApplicationInfo;
mController.displayPreference(mScreen);
@@ -199,7 +201,7 @@
@Test
public void display_powerSaverMode_showNoRecents() {
- mContext.getSystemService(PowerManager.class).setPowerSaveMode(true);
+ when(mPowerManager.isPowerSaveMode()).thenReturn(true);
final List<UsageStats> stats = new ArrayList<>();
final UsageStats stat1 = new UsageStats();
@@ -251,7 +253,7 @@
// Only the regular app stat1 should have its intent resolve.
when(mPackageManager.resolveActivity(argThat(intentMatcher(stat1.mPackageName)), anyInt()))
- .thenReturn(new ResolveInfo());
+ .thenReturn(new ResolveInfo());
when(mUsageStatsManager.queryUsageStats(anyInt(), anyLong(), anyLong()))
.thenReturn(stats);
@@ -311,13 +313,13 @@
// stat1, stat2 are not displayable
when(mAppState.getEntry(stat1.mPackageName, UserHandle.myUserId()))
- .thenReturn(mock(ApplicationsState.AppEntry.class));
+ .thenReturn(mock(ApplicationsState.AppEntry.class));
when(mAppState.getEntry(stat2.mPackageName, UserHandle.myUserId()))
- .thenReturn(mock(ApplicationsState.AppEntry.class));
+ .thenReturn(mock(ApplicationsState.AppEntry.class));
when(mPackageManager.resolveActivity(any(Intent.class), anyInt()))
- .thenReturn(new ResolveInfo());
+ .thenReturn(new ResolveInfo());
when(mUsageStatsManager.queryUsageStats(anyInt(), anyLong(), anyLong()))
- .thenReturn(stats);
+ .thenReturn(stats);
mController.displayPreference(mScreen);
@@ -336,11 +338,11 @@
stats.add(stat1);
when(mAppState.getEntry(stat1.mPackageName, UserHandle.myUserId()))
- .thenReturn(mAppEntry);
+ .thenReturn(mAppEntry);
when(mPackageManager.resolveActivity(any(Intent.class), anyInt()))
- .thenReturn(new ResolveInfo());
+ .thenReturn(new ResolveInfo());
when(mUsageStatsManager.queryUsageStats(anyInt(), anyLong(), anyLong()))
- .thenReturn(stats);
+ .thenReturn(stats);
mAppEntry.info = mApplicationInfo;
mController.displayPreference(mScreen);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
index c09af2b..051ef39 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
@@ -21,6 +21,8 @@
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import android.content.Context;
import android.os.PowerManager;
@@ -37,22 +39,20 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowPowerManager;
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = ShadowPowerManager.class)
public class BatterySaverButtonPreferenceControllerTest {
private BatterySaverButtonPreferenceController mController;
private Context mContext;
private Button mButtonOn;
private Button mButtonOff;
- private PowerManager mPowerManager;
private TwoStateButtonPreference mPreference;
@Mock
+ private PowerManager mPowerManager;
+ @Mock
private PreferenceScreen mPreferenceScreen;
@Before
@@ -61,10 +61,11 @@
mContext = spy(RuntimeEnvironment.application);
mButtonOn = new Button(mContext);
mButtonOff = new Button(mContext);
- mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
mPreference = spy(new TwoStateButtonPreference(mContext, null /* AttributeSet */));
ReflectionHelpers.setField(mPreference, "mButtonOn", mButtonOn);
ReflectionHelpers.setField(mPreference, "mButtonOff", mButtonOff);
+
+ doReturn(mPowerManager).when(mContext).getSystemService(Context.POWER_SERVICE);
doReturn(mPreference).when(mPreferenceScreen).findPreference(anyString());
mController = new BatterySaverButtonPreferenceController(mContext, "test_key");
@@ -73,7 +74,7 @@
@Test
public void updateState_lowPowerOn_preferenceIsChecked() {
- mPowerManager.setPowerSaveMode(true);
+ when(mPowerManager.isPowerSaveMode()).thenReturn(true);
mController.updateState(mPreference);
@@ -82,7 +83,7 @@
@Test
public void testUpdateState_lowPowerOff_preferenceIsUnchecked() {
- mPowerManager.setPowerSaveMode(false);
+ when(mPowerManager.isPowerSaveMode()).thenReturn(false);
mController.updateState(mPreference);
@@ -93,13 +94,13 @@
public void setChecked_on_setPowerSaveMode() {
mController.setChecked(true);
- assertThat(mPowerManager.isPowerSaveMode()).isTrue();
+ verify(mPowerManager).setPowerSaveMode(true);
}
@Test
public void setChecked_off_unsetPowerSaveMode() {
mController.setChecked(false);
- assertThat(mPowerManager.isPowerSaveMode()).isFalse();
+ verify(mPowerManager).setPowerSaveMode(false);
}
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImplTest.java
new file mode 100644
index 0000000..08631f7
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardFeatureProviderImplTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.homepage.contextualcards;
+
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.content.Intent;
+
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class ContextualCardFeatureProviderImplTest {
+
+ private Context mContext;
+ private ContextualCardFeatureProviderImpl mImpl;
+
+ @Before
+ public void setUp() {
+ mContext = spy(RuntimeEnvironment.application);
+ mImpl = new ContextualCardFeatureProviderImpl();
+ }
+
+ @Test
+ public void sendBroadcast_emptyAction_notSendBroadcast() {
+ final Intent intent = new Intent();
+ mImpl.sendBroadcast(mContext, intent);
+
+ verify(mContext, never()).sendBroadcast(intent);
+ }
+
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void sendBroadcast_hasAction_sendBroadcast() {
+ final Intent intent = new Intent();
+ mImpl.sendBroadcast(mContext, intent);
+
+ verify(mContext).sendBroadcast(intent);
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
index e8cb674..4f50197 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
@@ -27,11 +27,9 @@
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.CustomSliceRegistry;
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;
@@ -153,7 +151,7 @@
cards.add(new ContextualCard.Builder()
.setName("test_wifi")
.setCardType(ContextualCard.CardType.SLICE)
- .setSliceUri(WifiSlice.WIFI_URI)
+ .setSliceUri(CustomSliceRegistry.WIFI_SLICE_URI)
.build());
cards.add(new ContextualCard.Builder()
.setName("test_flashlight")
@@ -164,7 +162,7 @@
cards.add(new ContextualCard.Builder()
.setName("test_connected")
.setCardType(ContextualCard.CardType.SLICE)
- .setSliceUri(ConnectedDeviceSlice.CONNECTED_DEVICE_URI)
+ .setSliceUri(CustomSliceRegistry.CONNECTED_DEVICE_SLICE_URI)
.build());
cards.add(new ContextualCard.Builder()
.setName("test_gesture")
@@ -175,7 +173,7 @@
cards.add(new ContextualCard.Builder()
.setName("test_battery")
.setCardType(ContextualCard.CardType.SLICE)
- .setSliceUri(BatterySlice.BATTERY_CARD_URI)
+ .setSliceUri(CustomSliceRegistry.BATTERY_INFO_SLICE_URI)
.build());
return cards;
}
@@ -208,7 +206,7 @@
cards.add(new ContextualCard.Builder()
.setName("test_battery")
.setCardType(ContextualCard.CardType.SLICE)
- .setSliceUri(BatterySlice.BATTERY_CARD_URI)
+ .setSliceUri(CustomSliceRegistry.BATTERY_INFO_SLICE_URI)
.build());
return cards;
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProviderTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProviderTest.java
index 6b1f8b1..4b0b085 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProviderTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/SettingsContextualCardProviderTest.java
@@ -23,15 +23,13 @@
import static org.mockito.Mockito.spy;
import android.app.slice.SliceManager;
-import android.content.ContentResolver;
import android.content.Context;
-import android.net.Uri;
import android.os.Bundle;
import com.android.settings.intelligence.ContextualCardProto.ContextualCard;
import com.android.settings.intelligence.ContextualCardProto.ContextualCardList;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.wifi.WifiSlice;
import com.google.android.settings.intelligence.libs.contextualcards.ContextualCardProvider;
@@ -48,18 +46,11 @@
@Mock
private SliceManager mSliceManager;
- private ContentResolver mResolver;
- private Uri mUri;
private SettingsContextualCardProvider mProvider;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mResolver = RuntimeEnvironment.application.getContentResolver();
- mUri = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(SettingsContextualCardProvider.CARD_AUTHORITY)
- .build();
mProvider = spy(Robolectric.setupContentProvider(SettingsContextualCardProvider.class));
final Context context = spy(RuntimeEnvironment.application);
doReturn(mSliceManager).when(context).getSystemService(SliceManager.class);
@@ -83,7 +74,7 @@
final ContextualCardList cards = mProvider.getContextualCards();
ContextualCard wifiCard = null;
for (ContextualCard card : cards.getCardList()) {
- if (card.getSliceUri().equals(WifiSlice.WIFI_URI.toString())) {
+ if (card.getSliceUri().equals(CustomSliceRegistry.WIFI_SLICE_URI.toString())) {
wifiCard = card;
}
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardControllerTest.java
index 29e309d..af3b2e8 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardControllerTest.java
@@ -18,9 +18,10 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
import android.content.ContentResolver;
import android.content.ContentValues;
@@ -33,6 +34,7 @@
import com.android.settings.homepage.contextualcards.ContextualCard;
import com.android.settings.homepage.contextualcards.ContextualCardFeedbackDialog;
import com.android.settings.homepage.contextualcards.ContextualCardsFragment;
+import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
@@ -57,6 +59,7 @@
private CardContentProvider mProvider;
private ContentResolver mResolver;
private SliceContextualCardController mController;
+ private FakeFeatureFactory mFeatureFactory;
@Before
public void setUp() {
@@ -67,6 +70,7 @@
mProvider);
mResolver = mContext.getContentResolver();
mController = spy(new SliceContextualCardController(mContext));
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
}
@Test
@@ -75,7 +79,8 @@
mResolver.insert(providerUri, generateOneRow());
doNothing().when(mController).showFeedbackDialog(any(ContextualCard.class));
- mController.onDismissed(getTestSliceCard());
+ final ContextualCard card = getTestSliceCard();
+ mController.onDismissed(card);
final String[] columns = {CardDatabaseHelper.CardColumns.CARD_DISMISSED};
final String selection = CardDatabaseHelper.CardColumns.NAME + "=?";
@@ -86,6 +91,8 @@
cr.close();
assertThat(qryDismissed).isEqualTo(1);
+ verify(mFeatureFactory.mContextualCardFeatureProvider).logContextualCardDismiss(
+ mContext, card);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
index d260a97..5269dd7 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
@@ -44,6 +44,7 @@
import com.android.ims.ImsManager;
import com.android.settings.R;
import com.android.settings.slices.CustomSliceManager;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.SettingsSliceProvider;
import com.android.settings.slices.SliceBroadcastReceiver;
import com.android.settings.slices.SlicesFeatureProvider;
@@ -107,7 +108,7 @@
mEnhanced4gLteSliceHelper.setDefaultVoiceSubId(-1);
final Slice slice = mEnhanced4gLteSliceHelper.createEnhanced4gLteSlice(
- Enhanced4gLteSliceHelper.SLICE_URI);
+ CustomSliceRegistry.ENHANCED_4G_SLICE_URI);
assertThat(slice).isNull();
}
@@ -117,7 +118,7 @@
when(mMockImsManager.isVolteEnabledByPlatform()).thenReturn(false);
final Slice slice = mEnhanced4gLteSliceHelper.createEnhanced4gLteSlice(
- Enhanced4gLteSliceHelper.SLICE_URI);
+ CustomSliceRegistry.ENHANCED_4G_SLICE_URI);
assertThat(mEnhanced4gLteSliceHelper.getDefaultVoiceSubId()).isEqualTo(1);
assertThat(slice).isNull();
@@ -132,7 +133,7 @@
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
final Slice slice = mEnhanced4gLteSliceHelper.createEnhanced4gLteSlice(
- Enhanced4gLteSliceHelper.SLICE_URI);
+ CustomSliceRegistry.ENHANCED_4G_SLICE_URI);
assertThat(mEnhanced4gLteSliceHelper.getDefaultVoiceSubId()).isEqualTo(1);
testEnhanced4gLteSettingsToggleSlice(slice);
@@ -148,7 +149,7 @@
when(mSlicesFeatureProvider.getNewEnhanced4gLteSliceHelper(mContext))
.thenReturn(mEnhanced4gLteSliceHelper);
- final Slice slice = mProvider.onBindSlice(Enhanced4gLteSliceHelper.SLICE_URI);
+ final Slice slice = mProvider.onBindSlice(CustomSliceRegistry.ENHANCED_4G_SLICE_URI);
assertThat(mEnhanced4gLteSliceHelper.getDefaultVoiceSubId()).isEqualTo(1);
testEnhanced4gLteSettingsToggleSlice(slice);
diff --git a/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java b/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java
index 3e210f5..243c19b 100644
--- a/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java
+++ b/tests/robotests/src/com/android/settings/panel/InternetConnectivityPanelTest.java
@@ -21,8 +21,8 @@
import android.net.Uri;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.wifi.WifiSlice;
import org.junit.Before;
import org.junit.Test;
@@ -46,7 +46,7 @@
public void getSlices_containsNecessarySlices() {
final List<Uri> uris = mPanel.getSlices();
- assertThat(uris).containsExactly(WifiSlice.WIFI_URI,
- InternetConnectivityPanel.AIRPLANE_URI);
+ assertThat(uris).containsExactly(CustomSliceRegistry.WIFI_SLICE_URI,
+ CustomSliceRegistry.AIRPLANE_URI);
}
}
diff --git a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
index 3c2cbdb..8e3c1c8 100644
--- a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
@@ -48,10 +48,6 @@
import androidx.slice.widget.SliceLiveData;
import com.android.settings.R;
-import com.android.settings.bluetooth.BluetoothSliceBuilder;
-import com.android.settings.flashlight.FlashlightSliceBuilder;
-import com.android.settings.location.LocationSliceBuilder;
-import com.android.settings.notification.ZenModeSliceBuilder;
import com.android.settings.testutils.DatabaseTestUtils;
import com.android.settings.testutils.FakeToggleController;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -113,14 +109,14 @@
private SliceManager mManager;
private static final List<Uri> SPECIAL_CASE_PLATFORM_URIS = Arrays.asList(
- WifiSlice.WIFI_URI,
- BluetoothSliceBuilder.BLUETOOTH_URI,
- LocationSliceBuilder.LOCATION_URI
+ CustomSliceRegistry.WIFI_SLICE_URI,
+ CustomSliceRegistry.BLUETOOTH_URI,
+ CustomSliceRegistry.LOCATION_SLICE_URI
);
private static final List<Uri> SPECIAL_CASE_OEM_URIS = Arrays.asList(
- ZenModeSliceBuilder.ZEN_MODE_URI,
- FlashlightSliceBuilder.FLASHLIGHT_URI
+ CustomSliceRegistry.ZEN_MODE_SLICE_URI,
+ CustomSliceRegistry.FLASHLIGHT_SLICE_URI
);
@Before
@@ -472,9 +468,9 @@
@Test
public void bindSlice_wifiSlice_returnsWifiSlice() {
- final Slice wifiSlice = mProvider.onBindSlice(WifiSlice.WIFI_URI);
+ final Slice wifiSlice = mProvider.onBindSlice(CustomSliceRegistry.WIFI_SLICE_URI);
- assertThat(wifiSlice.getUri()).isEqualTo(WifiSlice.WIFI_URI);
+ assertThat(wifiSlice.getUri()).isEqualTo(CustomSliceRegistry.WIFI_SLICE_URI);
}
@Test
@@ -482,9 +478,10 @@
Settings.Secure.putInt(
mContext.getContentResolver(), Settings.Secure.FLASHLIGHT_AVAILABLE, 1);
- final Slice flashlightSlice = mProvider.onBindSlice(FlashlightSliceBuilder.FLASHLIGHT_URI);
+ final Slice flashlightSlice = mProvider.onBindSlice(
+ CustomSliceRegistry.FLASHLIGHT_SLICE_URI);
- assertThat(flashlightSlice.getUri()).isEqualTo(FlashlightSliceBuilder.FLASHLIGHT_URI);
+ assertThat(flashlightSlice.getUri()).isEqualTo(CustomSliceRegistry.FLASHLIGHT_SLICE_URI);
}
@Test
@@ -526,22 +523,22 @@
@Test
public void onSlicePinned_backgroundWorker_started() {
- mProvider.onSlicePinned(WifiSlice.WIFI_URI);
+ mProvider.onSlicePinned(CustomSliceRegistry.WIFI_SLICE_URI);
verify(ShadowWifiScanWorker.getWifiTracker()).onStart();
}
@Test
public void onSlicePinned_backgroundWorker_stopped() {
- mProvider.onSlicePinned(WifiSlice.WIFI_URI);
- mProvider.onSliceUnpinned(WifiSlice.WIFI_URI);
+ mProvider.onSlicePinned(CustomSliceRegistry.WIFI_SLICE_URI);
+ mProvider.onSliceUnpinned(CustomSliceRegistry.WIFI_SLICE_URI);
verify(ShadowWifiScanWorker.getWifiTracker()).onStop();
}
@Test
public void shutdown_backgroundWorker_closed() {
- mProvider.onSlicePinned(WifiSlice.WIFI_URI);
+ mProvider.onSlicePinned(CustomSliceRegistry.WIFI_SLICE_URI);
mProvider.shutdown();
verify(ShadowWifiScanWorker.getWifiTracker()).onDestroy();
diff --git a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
index e14ef1f..978dd7d 100644
--- a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
+++ b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
@@ -28,6 +28,7 @@
import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
import com.android.settings.gestures.AssistGestureFeatureProvider;
+import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
import com.android.settings.localepicker.LocaleFeatureProvider;
import com.android.settings.overlay.DockUpdaterFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
@@ -63,6 +64,7 @@
public final AssistGestureFeatureProvider assistGestureFeatureProvider;
public final AccountFeatureProvider mAccountFeatureProvider;
public final PanelFeatureProvider mPanelFeatureProvider;
+ public final ContextualCardFeatureProvider mContextualCardFeatureProvider;
public SlicesFeatureProvider slicesFeatureProvider;
public SearchFeatureProvider searchFeatureProvider;
@@ -105,6 +107,7 @@
slicesFeatureProvider = mock(SlicesFeatureProvider.class);
mAccountFeatureProvider = mock(AccountFeatureProvider.class);
mPanelFeatureProvider = mock(PanelFeatureProvider.class);
+ mContextualCardFeatureProvider = mock(ContextualCardFeatureProvider.class);
}
@Override
@@ -191,4 +194,8 @@
public PanelFeatureProvider getPanelFeatureProvider() {
return mPanelFeatureProvider;
}
+
+ public ContextualCardFeatureProvider getContextualCardFeatureProvider() {
+ return mContextualCardFeatureProvider;
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java
index ae4c753..11dd56e 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java
@@ -49,6 +49,7 @@
import com.android.ims.ImsManager;
import com.android.settings.R;
import com.android.settings.slices.CustomSliceManager;
+import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.SettingsSliceProvider;
import com.android.settings.slices.SliceBroadcastReceiver;
import com.android.settings.slices.SliceData;
@@ -113,7 +114,7 @@
mWfcSliceHelper.setDefaultVoiceSubId(-1);
final Slice slice = mWfcSliceHelper.createWifiCallingSlice(
- WifiCallingSliceHelper.WIFI_CALLING_URI);
+ CustomSliceRegistry.WIFI_CALLING_URI);
assertThat(slice).isNull();
}
@@ -123,7 +124,7 @@
when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(false);
final Slice slice = mWfcSliceHelper.createWifiCallingSlice(
- WifiCallingSliceHelper.WIFI_CALLING_URI);
+ CustomSliceRegistry.WIFI_CALLING_URI);
assertThat(mWfcSliceHelper.getDefaultVoiceSubId()).isEqualTo(1);
assertThat(slice).isNull();
@@ -144,7 +145,7 @@
mWfcSliceHelper.setActivationAppIntent(new Intent()); // dummy Intent
final Slice slice = mWfcSliceHelper.createWifiCallingSlice(
- WifiCallingSliceHelper.WIFI_CALLING_URI);
+ CustomSliceRegistry.WIFI_CALLING_URI);
assertThat(mWfcSliceHelper.getDefaultVoiceSubId()).isEqualTo(1);
testWifiCallingSettingsUnavailableSlice(slice, null,
@@ -161,7 +162,7 @@
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
final Slice slice = mWfcSliceHelper.createWifiCallingSlice(
- WifiCallingSliceHelper.WIFI_CALLING_URI);
+ CustomSliceRegistry.WIFI_CALLING_URI);
assertThat(mWfcSliceHelper.getDefaultVoiceSubId()).isEqualTo(1);
testWifiCallingSettingsToggleSlice(slice, null);
@@ -177,7 +178,7 @@
when(mSlicesFeatureProvider.getNewWifiCallingSliceHelper(mContext))
.thenReturn(mWfcSliceHelper);
- final Slice slice = mProvider.onBindSlice(WifiCallingSliceHelper.WIFI_CALLING_URI);
+ final Slice slice = mProvider.onBindSlice(CustomSliceRegistry.WIFI_CALLING_URI);
assertThat(mWfcSliceHelper.getDefaultVoiceSubId()).isEqualTo(1);
testWifiCallingSettingsToggleSlice(slice, null);
@@ -217,7 +218,7 @@
mWfcSliceHelper.setIsWifiCallingPrefEditable(false);
final Slice slice = mWfcSliceHelper.createWifiCallingPreferenceSlice(
- WifiCallingSliceHelper.WIFI_CALLING_PREFERENCE_URI);
+ CustomSliceRegistry.WIFI_CALLING_PREFERENCE_URI);
assertThat(mWfcSliceHelper.getDefaultVoiceSubId()).isEqualTo(1);
assertThat(slice).isNull();
@@ -232,7 +233,7 @@
mWfcSliceHelper.setIsWifiCallingPrefEditable(true);
final Slice slice = mWfcSliceHelper.createWifiCallingPreferenceSlice(
- WifiCallingSliceHelper.WIFI_CALLING_PREFERENCE_URI);
+ CustomSliceRegistry.WIFI_CALLING_PREFERENCE_URI);
assertThat(mWfcSliceHelper.getDefaultVoiceSubId()).isEqualTo(1);
testWifiCallingSettingsUnavailableSlice(slice, null,
@@ -251,7 +252,7 @@
mWfcSliceHelper.setIsWifiCallingPrefEditable(true);
final Slice slice = mWfcSliceHelper.createWifiCallingPreferenceSlice(
- WifiCallingSliceHelper.WIFI_CALLING_PREFERENCE_URI);
+ CustomSliceRegistry.WIFI_CALLING_PREFERENCE_URI);
assertThat(mWfcSliceHelper.getDefaultVoiceSubId()).isEqualTo(1);
testWifiCallingPreferenceSlice(slice, null,
@@ -271,7 +272,7 @@
mWfcSliceHelper.setIsWifiCallingPrefEditable(true);
final Slice slice = mProvider.onBindSlice(
- WifiCallingSliceHelper.WIFI_CALLING_PREFERENCE_URI);
+ CustomSliceRegistry.WIFI_CALLING_PREFERENCE_URI);
assertThat(mWfcSliceHelper.getDefaultVoiceSubId()).isEqualTo(1);
testWifiCallingPreferenceSlice(slice, null,
diff --git a/tests/unit/src/com/android/settings/slices/SliceDeepLinkSpringBoardTest.java b/tests/unit/src/com/android/settings/slices/SliceDeepLinkSpringBoardTest.java
index 81f1fac..bd8649d 100644
--- a/tests/unit/src/com/android/settings/slices/SliceDeepLinkSpringBoardTest.java
+++ b/tests/unit/src/com/android/settings/slices/SliceDeepLinkSpringBoardTest.java
@@ -26,11 +26,6 @@
import android.support.test.filters.MediumTest;
import android.support.test.runner.AndroidJUnit4;
-import com.android.settings.bluetooth.BluetoothSliceBuilder;
-import com.android.settings.location.LocationSliceBuilder;
-import com.android.settings.notification.ZenModeSliceBuilder;
-import com.android.settings.wifi.WifiSlice;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -57,7 +52,8 @@
@Test
@Presubmit
public void launchesDeepLinkIntent_wifiSlice_shouldNotCrash() {
- final Intent deepLinkIntent = getSpringboardIntent(WifiSlice.WIFI_URI.toString());
+ final Intent deepLinkIntent = getSpringboardIntent(
+ CustomSliceRegistry.WIFI_SLICE_URI.toString());
mContext.startActivity(deepLinkIntent);
}
@@ -66,7 +62,7 @@
@Presubmit
public void launchesDeepLinkIntent_bluetoothSlice_shouldNotCrash() {
final Intent deepLinkIntent = getSpringboardIntent(
- BluetoothSliceBuilder.BLUETOOTH_URI.toString());
+ CustomSliceRegistry.BLUETOOTH_URI.toString());
mContext.startActivity(deepLinkIntent);
}
@@ -75,7 +71,7 @@
@Presubmit
public void launchesDeepLinkIntent_dndSlice_shouldNotCrash() {
final Intent deepLinkIntent = getSpringboardIntent(
- ZenModeSliceBuilder.ZEN_MODE_URI.toString());
+ CustomSliceRegistry.ZEN_MODE_SLICE_URI.toString());
mContext.startActivity(deepLinkIntent);
}
@@ -84,7 +80,7 @@
@Presubmit
public void launchesDeepLinkIntent_locationSlice_shouldNotCrash() {
final Intent deepLinkIntent = getSpringboardIntent(
- LocationSliceBuilder.LOCATION_URI.toString());
+ CustomSliceRegistry.LOCATION_SLICE_URI.toString());
mContext.startActivity(deepLinkIntent);
}
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
index d101c92..208c344 100644
--- a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
@@ -35,18 +35,38 @@
new ActivityTestRule<>(WifiDppConfiguratorActivity.class);
@Test
- public void testLaunchModeQrCodeScanner_shouldNotAutoFinish() {
+ public void launchActivity_modeQrCodeScanner_shouldNotAutoFinish() {
Intent intent = new Intent();
intent.putExtra(WifiDppConfiguratorActivity.EXTRA_LAUNCH_MODE,
WifiDppConfiguratorActivity.LaunchMode.LAUNCH_MODE_QR_CODE_SCANNER.getMode());
mActivityRule.launchActivity(intent);
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
- mActivityRule.finishActivity();
}
@Test
- public void testNoLaunchMode_shouldFinishActivityWithResultCodeCanceled() {
+ public void launchActivity_modeQrCodeGenerator_shouldNotAutoFinish() {
+ Intent intent = new Intent();
+ intent.putExtra(WifiDppConfiguratorActivity.EXTRA_LAUNCH_MODE,
+ WifiDppConfiguratorActivity.LaunchMode.LAUNCH_MODE_QR_CODE_GENERATOR.getMode());
+ mActivityRule.launchActivity(intent);
+
+ assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
+ }
+
+ @Test
+ public void launchActivity_modeChooseSavedWifiNetwork_shouldNotAutoFinish() {
+ Intent intent = new Intent();
+ intent.putExtra(WifiDppConfiguratorActivity.EXTRA_LAUNCH_MODE,
+ WifiDppConfiguratorActivity.LaunchMode
+ .LAUNCH_MODE_CHOOSE_SAVED_WIFI_NETWORK.getMode());
+ mActivityRule.launchActivity(intent);
+
+ assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(false);
+ }
+
+ @Test
+ public void launchActivity_noLaunchMode_shouldFinishActivityWithResultCodeCanceled() {
// If we do not specify launch mode, the activity will finish itself right away
Intent intent = new Intent();
mActivityRule.launchActivity(intent);
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragmentTest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragmentTest.java
index 58fa61f..0f4bfd9 100644
--- a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragmentTest.java
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragmentTest.java
@@ -47,8 +47,9 @@
}
@Test
- public void testLeftButton_shouldFinishActivityWithResultCodeCanceled() {
+ public void leftButton_shouldFinishActivityWithResultCodeCanceled() {
onView(withText("Cancel")).perform(click());
+
assertThat(mActivityRule.getActivityResult().getResultCode()).
isEqualTo(Activity.RESULT_CANCELED);
}