diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 7c44a8ffded..e280b8394f9 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2475,33 +2475,41 @@
+ android:theme="@style/GlifTheme.Light"
+ android:exported="false"
+ android:configChanges="keyboardHidden|orientation|screenSize"/>
+ android:theme="@style/GlifTheme.Light"
+ android:exported="false"
+ android:configChanges="keyboardHidden|orientation|screenSize"/>
+ android:theme="@style/GlifTheme.Light"
+ android:exported="false"
+ android:configChanges="keyboardHidden|orientation|screenSize"/>
+ android:theme="@style/GlifTheme.Light"
+ android:exported="false"
+ android:configChanges="keyboardHidden|orientation|screenSize"/>
diff --git a/res/drawable/ic_storage_wizard_external.xml b/res/drawable/ic_storage_wizard_external.xml
index 99e2698633d..c6fefa1e99d 100644
--- a/res/drawable/ic_storage_wizard_external.xml
+++ b/res/drawable/ic_storage_wizard_external.xml
@@ -1,3 +1,4 @@
+
+ android:width="360dp"
+ android:height="262dp"
+ android:viewportWidth="360"
+ android:viewportHeight="262">
+
+ android:fillColor="@android:color/transparent"
+ android:pathData="M335.709 262H24.2913C10.9223 262 0 250.821 0 237.11V24.89C0 11.1787 10.9223 0 24.2913 0H335.796C349.078 0 360 11.1787 360 24.89V237.285C360 250.821 349.078 262 335.709 262Z" />
+ android:fillColor="@android:color/transparent"
+ android:pathData="M153.786 66.0239H319.806C322.777 66.0239 325.223 68.4693 325.311 71.4386V183.575H148.282V71.4386C148.282 68.4693 150.728 66.0239 153.786 66.0239Z"
+ android:strokeWidth="5"
+ android:strokeColor="#E8EAED"/>
+ android:fillColor="#BDC1C6"
+ android:pathData="M182.272 180.605H171.961V183.4H182.272V180.605Z" />
+ android:fillColor="#BDC1C6"
+ android:pathData="M195.204 180.605H184.893V183.4H195.204V180.605Z" />
-
+ android:pathData="M78.8155 104.538V100.521C78.8155 99.9967 78.3786 99.5601 77.8544 99.5601V78.6001C77.8544 75.8054 75.5825 73.6221 72.8738 73.6221H26.8252C24.0291 73.6221 21.8447 75.8054 21.8447 78.6001V174.492C21.8447 177.287 24.1165 179.47 26.8252 179.47H72.7864C75.5825 179.47 77.767 177.199 77.767 174.492V125.585C78.2913 125.585 78.7282 125.149 78.7282 124.625V114.581C78.7282 114.057 78.2913 113.621 77.767 113.621V105.586C78.3786 105.499 78.8155 105.062 78.8155 104.538ZM76.8058 174.492C76.8058 176.675 74.9709 178.509 72.7864 178.509H26.8252C24.6408 178.509 22.8058 176.675 22.8058 174.492V78.6001C22.8058 76.4167 24.5534 74.5827 26.8252 74.5827H72.7864C74.9709 74.5827 76.8058 76.3294 76.8058 78.6001V174.492Z" />
+ android:fillColor="#81C995"
+ android:pathData="M35.2136 102.18H47.534V89.8658H35.2136V102.18ZM35.2136 103.926C34.2524 103.926 33.466 103.14 33.466 102.18V89.8658C33.466 88.9051 34.2524 88.1191 35.2136 88.1191H47.534C47.9709 88.1191 48.4077 88.2938 48.7573 88.6431C49.1068 88.9925 49.2815 89.4291 49.2815 89.8658V102.18C49.2815 103.14 48.4951 103.926 47.534 103.926H35.2136ZM36.0874 100.433H46.5728L43.2524 96.0665L40.6311 99.5598L38.6213 96.9398L36.0874 100.433ZM35.2136 89.8658V102.18V89.8658Z" />
+
+
+
+
+
+
+
+
+
+ android:pathData="M134.65 182.09H338.854V184.186C338.854 185.758 337.631 186.981 336.058 186.981H137.447C135.874 186.981 134.65 185.758 134.65 184.186V182.09Z" />
+ android:fillColor="#81C995"
+ android:pathData="M177.204 129.69H193.456V113.446H177.204V129.69ZM177.204 132.048C175.893 132.048 174.845 131 174.845 129.69V113.446C174.845 112.136 175.893 111.088 177.204 111.088H193.456C194.767 111.088 195.816 112.136 195.816 113.446V129.69C195.816 131 194.767 132.048 193.456 132.048H177.204ZM178.34 127.332H192.32L187.951 121.481L184.456 126.109L181.835 122.616L178.34 127.332ZM177.204 113.359V129.69V113.359Z" />
+
+
+
+
+
+
+
+
+
+ android:pathData="M107.126 114.669H109.66V112.136H107.126V114.669ZM117.087 114.669H119.621V112.136H117.087V114.669ZM107.126 109.691H109.66V104.713H107.126V109.691ZM112.107 114.669H114.641V109.691H112.107V114.669ZM112.107 107.158H114.641V104.626H112.107V107.158ZM117.087 109.691H119.621V104.713H117.087V109.691ZM105.903 118.424C105.204 118.424 104.592 118.162 104.155 117.726C103.718 117.289 103.456 116.678 103.456 115.979V101.045L110.971 93.5342H120.932C121.631 93.5342 122.243 93.7962 122.68 94.2328C123.204 94.7568 123.379 95.2808 123.379 95.9795V115.892C123.379 116.59 123.116 117.202 122.68 117.638C122.155 118.162 121.631 118.337 120.932 118.337L105.903 118.424ZM105.903 115.892H120.845V95.9795H111.932L105.903 102.006V115.892ZM105.903 115.892V102.006L111.932 95.9795H120.845V115.892H105.903Z" />
+ android:pathData="M96.7281 150.388L101.447 145.672L98.8252 143.052L89.7379 152.222L98.8252 161.305L101.447 158.772L96.7281 154.056H137.01V150.388H96.7281Z" />
-
+ android:fillColor="?android:attr/colorAccent"
+ android:pathData="M130.019 137.026L125.301 141.742L127.922 144.362L137.01 135.192L127.922 126.109L125.301 128.642L130.019 133.358H89.7379V137.026H130.019Z" />
+
+
\ No newline at end of file
diff --git a/res/drawable/ic_storage_wizard_internal.xml b/res/drawable/ic_storage_wizard_internal.xml
index 41768f7727d..70bafa944ce 100644
--- a/res/drawable/ic_storage_wizard_internal.xml
+++ b/res/drawable/ic_storage_wizard_internal.xml
@@ -1,3 +1,4 @@
+
+ android:width="360dp"
+ android:height="262dp"
+ android:viewportWidth="360"
+ android:viewportHeight="262">
+
+ android:fillColor="@android:color/transparent"
+ android:pathData="M335.691 262H24.3087C10.9485 262 0 250.795 0 237.127V24.9075C0 11.2049 10.9485 0 24.3087 0H335.787C349.051 0 360 11.2049 360 24.8725V237.224C360 250.795 349.051 262 335.691 262Z" />
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+ android:pathData="M164.604 152.545H170.764V146.432H164.604V152.545ZM189.236 152.545H195.396V146.432H189.236V152.545ZM164.604 140.231H170.764V127.926H164.604V140.231ZM176.924 152.545H183.041V140.231H176.924V152.545ZM176.924 134.074H183.041V127.961H176.924V134.074ZM189.236 140.187H195.396V127.926H189.236V140.187ZM161.528 161.733C159.896 161.728 158.332 161.078 157.177 159.924C156.023 158.77 155.373 157.207 155.368 155.576V118.695L173.883 100.224H198.516C200.14 100.228 201.698 100.872 202.851 102.017C204.004 103.161 204.66 104.713 204.676 106.337V155.576C204.671 157.207 204.021 158.77 202.866 159.924C201.712 161.078 200.148 161.728 198.516 161.733H161.528ZM161.528 155.576H198.472V106.381H176.505L161.528 121.306V155.619V155.576ZM161.528 155.576V121.306L176.505 106.381H198.516V155.619H161.528V155.576Z" />
+
\ No newline at end of file
diff --git a/res/drawable/ic_storage_wizard_ready.xml b/res/drawable/ic_storage_wizard_ready.xml
new file mode 100644
index 00000000000..c09c9ec5310
--- /dev/null
+++ b/res/drawable/ic_storage_wizard_ready.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/drawable/ic_swap_horiz.xml b/res/drawable/ic_swap_horiz.xml
index a38833becab..c41c9a34381 100644
--- a/res/drawable/ic_swap_horiz.xml
+++ b/res/drawable/ic_swap_horiz.xml
@@ -20,5 +20,5 @@
android:viewportHeight="24.0">
+ android:fillColor="?android:attr/textColorPrimary"/>
diff --git a/res/drawable/ic_test_tick.xml b/res/drawable/ic_test_tick.xml
new file mode 100644
index 00000000000..9585806e985
--- /dev/null
+++ b/res/drawable/ic_test_tick.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/storage_internal_format.xml b/res/layout/storage_internal_format.xml
index 0b49d7e1660..f8224c4b6a4 100644
--- a/res/layout/storage_internal_format.xml
+++ b/res/layout/storage_internal_format.xml
@@ -14,16 +14,16 @@
limitations under the License.
-->
-
+ android:layout_height="wrap_content"
+ android:fillViewport="true">
-
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
-
-
-
-
+ android:padding="4dp">
+
+
+
-
+
diff --git a/res/layout/storage_wizard_generic.xml b/res/layout/storage_wizard_generic.xml
index e7881d3be87..fc0bab1a8d8 100644
--- a/res/layout/storage_wizard_generic.xml
+++ b/res/layout/storage_wizard_generic.xml
@@ -14,32 +14,52 @@
limitations under the License.
-->
-
+ android:layout_height="wrap_content"
+ android:fitsSystemWindows="true">
-
+ android:layout_height="match_parent">
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
diff --git a/res/layout/storage_wizard_init.xml b/res/layout/storage_wizard_init.xml
index e1e783312b1..2d21e0e983c 100644
--- a/res/layout/storage_wizard_init.xml
+++ b/res/layout/storage_wizard_init.xml
@@ -14,124 +14,30 @@
limitations under the License.
-->
-
+ android:layout_height="wrap_content"
+ android:fitsSystemWindows="true">
-
+ android:layout_height="match_parent">
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/res/layout/storage_wizard_init_external.xml b/res/layout/storage_wizard_init_external.xml
new file mode 100644
index 00000000000..38df28bc436
--- /dev/null
+++ b/res/layout/storage_wizard_init_external.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/storage_wizard_init_internal.xml b/res/layout/storage_wizard_init_internal.xml
new file mode 100644
index 00000000000..0a180703ed8
--- /dev/null
+++ b/res/layout/storage_wizard_init_internal.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/storage_wizard_progress.xml b/res/layout/storage_wizard_progress.xml
index 577ec3cbfc8..890be7076e9 100644
--- a/res/layout/storage_wizard_progress.xml
+++ b/res/layout/storage_wizard_progress.xml
@@ -14,47 +14,55 @@
limitations under the License.
-->
-
+ android:layout_height="wrap_content"
+ android:fitsSystemWindows="true">
-
+ android:layout_height="match_parent">
-
-
+
-
+
+
-
+
-
+
-
+
+
+
+
diff --git a/res/menu/storage_volume.xml b/res/menu/storage_volume.xml
index 422355d0fb7..b8725fb5d02 100644
--- a/res/menu/storage_volume.xml
+++ b/res/menu/storage_volume.xml
@@ -29,10 +29,10 @@
android:title="@string/storage_menu_format" />
+ android:title="@string/storage_menu_format_option" />
+ android:title="@string/storage_menu_format_option" />
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 520f78624de..c03532097f3 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -506,4 +506,6 @@
40dp
30dp
27dp
+
+ 88dp
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 406c4a27c0d..083064f75fc 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3603,12 +3603,14 @@
Mount
Eject
-
- Format
+
+ Format SD card for portable storage
+
+ Format card
Format as portable
-
- Format as internal
+
+ Format
Migrate data
@@ -3681,8 +3683,10 @@
\n\nTo use this ^1, you have to set it up first.
- After formatting, you can use this ^1 in other devices.
-\n\nAll data on this ^1 will be erased. Consider backing up first.
+ You can format this SD card to store photos, videos, music,
+ and more and access them on other devices.
+ \n\nAll data on this SD card will be erased.
+ \n\nBefore formatting
\n\nBack up photos & other media
\nMove your media files to alternative storage on this device, or transfer them to a computer using a USB cable.
\n\nBack up apps
@@ -3706,16 +3710,19 @@
System includes files used to run Android version %s
-
+
+ Guest mode users cannot format SD cards
+
+
Set up your ^1
- Use as portable storage
+ Format SD card for portable storage
- For moving photos and other media between devices.
+ Save photos, videos, music, and more and access them from other devices
- Use as internal storage
+ Format SD card for internal storage
- For storing anything on this device only, including apps and photos. Requires formatting that prevents it from working with other devices.
+ Save apps \u0026 media to use on this phone only
Format as internal storage
@@ -3770,13 +3777,11 @@
- Your ^1 is ready to use
+ ^1 formatted
- Your ^1 is all set to use with photos and other media.
+ You can start using your ^1
- Your new ^1 is working.
-\n\nTo move photos, files, and app data to this device, go to Settings > Storage.
-
+ You can start using your ^1
Move ^1
@@ -3806,26 +3811,26 @@
How will you use this ^1?
-
- Use for extra tablet storage
-
- For apps, files, and media on this tablet only
+
+ Format SD card for internal storage
+
+ Store apps \u0026 media to use on this tablet only. <a href="https://support.google.com/android/answer/12153449">Learn more about setting up an SD card</a>
- Tablet storage
-
- Use for extra phone storage
-
- For apps, files, and media on this phone only
+ Format
+
+ Format SD card for internal storage
+
+ Store apps \u0026 media to use on this phone only. <a href="https://support.google.com/android/answer/12153449">Learn more about setting up an SD card</a>
- Phone storage
+ Format
Or
-
- Use for portable storage
-
- For transferring files and media between devices
+
+ Format SD card for portable storage
+
+ Store photos, videos, music, and more and access them from other devices. <a href="https://support.google.com/android/answer/12153449">Learn more about setting up an SD card</a>
- Portable storage
+ Format
Set up later
@@ -3834,6 +3839,9 @@
This ^1 needs to be formatted to store apps, files, and media.
\n\nFormatting will erase existing content on the ^2. To avoid losing content, back it up to another ^3 or device.
+
+ This ^1 needs to be formatted to store photos, videos, music, and more.
+ \n\nFormatting will erase existing content on the ^2. To avoid losing content, back it up to another ^3 or device.
Format ^1
@@ -3877,12 +3885,11 @@
Continue
- You can move content to ^1
+ You can start using your ^1
- To move content to ^1, go to Settings > Storage
+ You can start using your ^1
- Your content was moved to ^1.
-\n\nTo manage this ^2, go to Settings > Storage.
+ You can start using your ^1
Battery status
@@ -6278,9 +6285,9 @@
See apps with highest usage
- Charging temporarily limited
+ Charging is paused
- To preserve your battery. Learn more.
+ Protecting battery to extend battery lifespan\nTap to learn more
%1$s
@@ -8220,6 +8227,10 @@
Back
Next
+
+ Switch to portable
+
+ Format another way
Finish
@@ -13623,6 +13634,10 @@
Pin media player
To quickly resume playback, media player stays open in Quick Settings
+
+ Show media on lock screen
+
+ To quickly resume playback, media player stays open on lock screen
Show media recommendations
diff --git a/res/xml/media_controls_settings.xml b/res/xml/media_controls_settings.xml
index 0318097ef3a..822639ac190 100644
--- a/res/xml/media_controls_settings.xml
+++ b/res/xml/media_controls_settings.xml
@@ -27,6 +27,12 @@
app:keywords="@string/keywords_media_controls"
app:controller="com.android.settings.sound.MediaControlsPreferenceController" />
+
+
+
+
+
+
+
+
vols = mStorage.getVolumes();
for (VolumeInfo vol : vols) {
if (Objects.equals(mDisk.getId(), vol.getDiskId()) && (vol.getType() == type)
- && (vol.getState() == VolumeInfo.STATE_MOUNTED)) {
+ && (vol.getState() == VolumeInfo.STATE_MOUNTED)) {
return vol;
}
}
if (--attempts > 0) {
Log.w(TAG, "Missing mounted volume of type " + type + " hosted by disk "
- + mDisk.getId() + "; trying again");
+ + mDisk.getId() + "; trying again");
SystemClock.sleep(250);
} else {
return null;
@@ -265,7 +268,8 @@ public abstract class StorageWizardBase extends FragmentActivity {
}
}
- protected @NonNull CharSequence getDiskDescription() {
+ protected @NonNull
+ CharSequence getDiskDescription() {
if (mDisk != null) {
return mDisk.getDescription();
} else if (mVolume != null) {
@@ -275,7 +279,8 @@ public abstract class StorageWizardBase extends FragmentActivity {
}
}
- protected @NonNull CharSequence getDiskShortDescription() {
+ protected @NonNull
+ CharSequence getDiskShortDescription() {
if (mDisk != null) {
return mDisk.getShortDescription();
} else if (mVolume != null) {
@@ -294,4 +299,4 @@ public abstract class StorageWizardBase extends FragmentActivity {
}
}
};
-}
+}
\ No newline at end of file
diff --git a/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java b/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
index 9c18a0da608..e2d8c7edddc 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardFormatConfirm.java
@@ -84,15 +84,23 @@ public class StorageWizardFormatConfirm extends InstrumentedDialogFragment {
builder.setTitle(TextUtils.expandTemplate(
getText(R.string.storage_wizard_format_confirm_v2_title),
disk.getShortDescription()));
- builder.setMessage(TextUtils.expandTemplate(
- getText(R.string.storage_wizard_format_confirm_v2_body),
+ if (formatPrivate) {
+ builder.setMessage(TextUtils.expandTemplate(
+ getText(R.string.storage_wizard_format_confirm_v2_body),
+ disk.getDescription(),
+ disk.getShortDescription(),
+ disk.getShortDescription()));
+ } else {
+ builder.setMessage(TextUtils.expandTemplate(
+ getText(R.string.storage_wizard_format_confirm_v2_body_external),
disk.getDescription(),
disk.getShortDescription(),
disk.getShortDescription()));
+ }
builder.setNegativeButton(android.R.string.cancel, null);
builder.setPositiveButton(
- TextUtils.expandTemplate(getText(R.string.storage_wizard_format_confirm_v2_action),
+ TextUtils.expandTemplate(getText(R.string.storage_menu_format_option),
disk.getShortDescription()),
(dialog, which) -> {
final Intent intent = new Intent(context, StorageWizardFormatProgress.class);
@@ -104,4 +112,4 @@ public class StorageWizardFormatConfirm extends InstrumentedDialogFragment {
return builder.create();
}
-}
+}
\ No newline at end of file
diff --git a/src/com/android/settings/deviceinfo/StorageWizardInit.java b/src/com/android/settings/deviceinfo/StorageWizardInit.java
index 426395c24fe..3a0f7e61df7 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardInit.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardInit.java
@@ -18,21 +18,27 @@ package com.android.settings.deviceinfo;
import android.app.ActivityManager;
import android.app.settings.SettingsEnums;
-import android.content.Intent;
import android.os.Bundle;
import android.os.UserManager;
-import android.os.storage.DiskInfo;
-import android.os.storage.VolumeInfo;
+import android.text.Html;
+import android.text.Spannable;
+import android.text.method.LinkMovementMethod;
+import android.text.style.TypefaceSpan;
+import android.text.style.URLSpan;
import android.view.View;
-import android.widget.Button;
+import android.widget.TextView;
+import android.widget.Toast;
+import android.widget.ViewFlipper;
import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
public class StorageWizardInit extends StorageWizardBase {
- private Button mInternal;
private boolean mIsPermittedToAdopt;
+ private boolean mPortable;
+
+ private ViewFlipper mFlipper;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -41,63 +47,119 @@ public class StorageWizardInit extends StorageWizardBase {
finish();
return;
}
- setContentView(R.layout.storage_wizard_init);
mIsPermittedToAdopt = UserManager.get(this).isAdminUser()
- && !ActivityManager.isUserAMonkey();
+ && !ActivityManager.isUserAMonkey();
- setHeaderText(R.string.storage_wizard_init_v2_title, getDiskShortDescription());
+ if (!mIsPermittedToAdopt) {
+ //Notify guest users as to why formatting is disallowed
+ Toast.makeText(getApplicationContext(),
+ R.string.storage_wizard_guest, Toast.LENGTH_LONG).show();
+ finish();
+ return;
+ }
- mInternal = requireViewById(R.id.storage_wizard_init_internal);
+ setContentView(R.layout.storage_wizard_init);
+ setupHyperlink();
+ mPortable = true;
- setBackButtonText(R.string.storage_wizard_init_v2_later);
- setNextButtonVisibility(View.INVISIBLE);
+ mFlipper = (ViewFlipper) findViewById(R.id.viewFlipper);
+ mFlipper.setDisplayedChild(0);
+ setHeaderText(R.string.storage_wizard_init_v2_external_title,
+ getDiskShortDescription());
+
+ setNextButtonText(R.string.storage_wizard_init_v2_external_action);
+ setBackButtonText(R.string.wizard_back_adoptable);
+ setNextButtonVisibility(View.VISIBLE);
if (!mDisk.isAdoptable()) {
- // If not adoptable, we only have one choice
- mInternal.setEnabled(false);
- onNavigateExternal(null);
- } else if (!mIsPermittedToAdopt) {
- // TODO: Show a message about why this is disabled for guest and
- // that only an admin user can adopt an sd card.
- mInternal.setEnabled(false);
+ setBackButtonVisibility(View.GONE);
}
}
@Override
- public void onNavigateBack(View view) {
- finish();
+ public void onBackPressed() {
+ if (mPortable) {
+ super.onBackPressed();
+ } else {
+ mFlipper.showPrevious();
+ setBackButtonText(R.string.wizard_back_adoptable);
+ setHeaderText(R.string.storage_wizard_init_v2_external_title,
+ getDiskShortDescription());
+ setNextButtonText(R.string.storage_wizard_init_v2_external_action);
+ mPortable = true;
+ }
+ }
+
+ @Override
+ public void onNavigateBack(View v) {
+ if (mPortable == false) {
+ return;
+ }
+ if (!mIsPermittedToAdopt) {
+ // TODO: Show a message about why this is disabled for guest and
+ // that only an admin user can adopt an sd card.
+
+ v.setEnabled(false);
+ } else {
+ mFlipper.showNext();
+ setHeaderText(R.string.storage_wizard_init_v2_internal_title,
+ getDiskShortDescription());
+ setNextButtonText(R.string.storage_wizard_init_v2_internal_action);
+ setBackButtonVisibility(View.INVISIBLE);
+ mPortable = false;
+ }
+ }
+
+ @Override
+ public void onNavigateNext(View v) {
+ if (mPortable) {
+ onNavigateExternal(v);
+ } else {
+ onNavigateInternal(v);
+ }
}
public void onNavigateExternal(View view) {
if (view != null) {
// User made an explicit choice for external
FeatureFactory.getFactory(this).getMetricsFeatureProvider().action(this,
- SettingsEnums.ACTION_STORAGE_INIT_EXTERNAL);
- }
-
- if (mVolume != null && mVolume.getType() == VolumeInfo.TYPE_PUBLIC
- && mVolume.getState() != VolumeInfo.STATE_UNMOUNTABLE) {
- // Remember that user made decision
- mStorage.setVolumeInited(mVolume.getFsUuid(), true);
-
- final Intent intent = new Intent(this, StorageWizardReady.class);
- intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
- startActivity(intent);
- finish();
-
- } else {
- // Gotta format to get there
- StorageWizardFormatConfirm.showPublic(this, mDisk.getId());
+ SettingsEnums.ACTION_STORAGE_INIT_EXTERNAL);
}
+ StorageWizardFormatConfirm.showPublic(this, mDisk.getId());
}
public void onNavigateInternal(View view) {
if (view != null) {
// User made an explicit choice for internal
FeatureFactory.getFactory(this).getMetricsFeatureProvider().action(this,
- SettingsEnums.ACTION_STORAGE_INIT_INTERNAL);
+ SettingsEnums.ACTION_STORAGE_INIT_INTERNAL);
}
-
StorageWizardFormatConfirm.showPrivate(this, mDisk.getId());
}
+
+ private void setupHyperlink() {
+ TextView external_storage_textview = findViewById(R.id.storage_wizard_init_external_text);
+ TextView internal_storage_textview = findViewById(R.id.storage_wizard_init_internal_text);
+ String external_storage_text = getResources().getString(R.string.
+ storage_wizard_init_v2_external_summary);
+ String internal_storage_text = getResources().getString(R.string.
+ storage_wizard_init_v2_internal_summary);
+
+ Spannable external_storage_spannable = styleFont(external_storage_text);
+ Spannable internal_storage_spannable = styleFont(internal_storage_text);
+ external_storage_textview.setText(external_storage_spannable);
+ internal_storage_textview.setText(internal_storage_spannable);
+
+ external_storage_textview.setMovementMethod(LinkMovementMethod.getInstance());
+ internal_storage_textview.setMovementMethod(LinkMovementMethod.getInstance());
+ }
+
+ private Spannable styleFont(String text) {
+ Spannable s = (Spannable) Html.fromHtml(text);
+ for (URLSpan span : s.getSpans(0, s.length(), URLSpan.class)) {
+ TypefaceSpan typefaceSpan = new TypefaceSpan("sans-serif-medium");
+ s.setSpan(typefaceSpan, s.getSpanStart(span), s.getSpanEnd(span), 0);
+ }
+ return s;
+ }
}
diff --git a/src/com/android/settings/deviceinfo/StorageWizardReady.java b/src/com/android/settings/deviceinfo/StorageWizardReady.java
index 813bcc6e201..8de94724afd 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardReady.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardReady.java
@@ -19,6 +19,7 @@ package com.android.settings.deviceinfo;
import android.os.Bundle;
import android.os.storage.VolumeInfo;
import android.view.View;
+import android.widget.ImageView;
import com.android.settings.R;
@@ -48,7 +49,9 @@ public class StorageWizardReady extends StorageWizardBase {
setBodyText(R.string.storage_wizard_ready_v2_external_body,
getDiskDescription());
}
-
+ ImageView img = (ImageView) findViewById(R.id.storage_wizard_body_image);
+ img.setImageResource(R.drawable.ic_storage_wizard_ready);
+ setIcon(R.drawable.ic_test_tick);
setNextButtonText(R.string.done);
setBackButtonVisibility(View.INVISIBLE);
}
diff --git a/src/com/android/settings/deviceinfo/VolumeOptionMenuController.java b/src/com/android/settings/deviceinfo/VolumeOptionMenuController.java
index 4b87e422c1b..289db520ec0 100644
--- a/src/com/android/settings/deviceinfo/VolumeOptionMenuController.java
+++ b/src/com/android/settings/deviceinfo/VolumeOptionMenuController.java
@@ -30,6 +30,7 @@ import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
+import android.widget.Toast;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
@@ -55,7 +56,9 @@ public class VolumeOptionMenuController implements LifecycleObserver, OnCreateOp
OnPrepareOptionsMenu, OnOptionsItemSelected {
private static final String TAG = "VolumeOptionMenuController";
-
+ private final Context mContext;
+ private final Fragment mFragment;
+ private final PackageManager mPackageManager;
@VisibleForTesting
MenuItem mRename;
@VisibleForTesting
@@ -74,18 +77,12 @@ public class VolumeOptionMenuController implements LifecycleObserver, OnCreateOp
MenuItem mFree;
@VisibleForTesting
MenuItem mForget;
-
- private final Context mContext;
- private final Fragment mFragment;
- private final PackageManager mPackageManager;
- private final StorageManager mStorageManager;
private StorageEntry mStorageEntry;
public VolumeOptionMenuController(Context context, Fragment parent, StorageEntry storageEntry) {
mContext = context;
mFragment = parent;
mPackageManager = context.getPackageManager();
- mStorageManager = context.getSystemService(StorageManager.class);
mStorageEntry = storageEntry;
}
@@ -162,12 +159,7 @@ public class VolumeOptionMenuController implements LifecycleObserver, OnCreateOp
if (mStorageEntry.isPublic()) {
mRename.setVisible(true);
mUnmount.setVisible(true);
- mFormat.setVisible(true);
- final DiskInfo diskInfo = mStorageManager.findDiskById(mStorageEntry.getDiskId());
- mFormatAsInternal.setVisible(diskInfo != null
- && diskInfo.isAdoptable()
- && UserManager.get(mContext).isAdminUser()
- && !ActivityManager.isUserAMonkey());
+ mFormatAsInternal.setVisible(true);
return;
}
}
@@ -225,6 +217,16 @@ public class VolumeOptionMenuController implements LifecycleObserver, OnCreateOp
}
if (menuId == R.id.storage_format_as_portable) {
if (mStorageEntry.isPrivate()) {
+ boolean mIsPermittedToAdopt = UserManager.get(mContext).isAdminUser()
+ && !ActivityManager.isUserAMonkey();
+
+ if(!mIsPermittedToAdopt){
+ //Notify guest users as to why formatting is disallowed
+ Toast.makeText(mFragment.getActivity(),
+ R.string.storage_wizard_guest,Toast.LENGTH_LONG).show();
+ (mFragment.getActivity()).finish();
+ return false;
+ }
final Bundle args = new Bundle();
args.putString(VolumeInfo.EXTRA_VOLUME_ID, mStorageEntry.getId());
new SubSettingLauncher(mContext)
@@ -239,8 +241,9 @@ public class VolumeOptionMenuController implements LifecycleObserver, OnCreateOp
}
if (menuId == R.id.storage_format_as_internal) {
if (mStorageEntry.isPublic()) {
- StorageWizardFormatConfirm.showPrivate(mFragment.getActivity(),
- mStorageEntry.getDiskId());
+ final Intent intent = new Intent(mFragment.getActivity(), StorageWizardInit.class);
+ intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, mStorageEntry.getId());
+ mContext.startActivity(intent);
return true;
}
return false;
@@ -269,4 +272,4 @@ public class VolumeOptionMenuController implements LifecycleObserver, OnCreateOp
updateOptionsMenu();
}
-}
+}
\ No newline at end of file
diff --git a/src/com/android/settings/notification/AppBubbleListPreferenceController.java b/src/com/android/settings/notification/AppBubbleListPreferenceController.java
index bf7fcc03756..6ebb376b5c1 100644
--- a/src/com/android/settings/notification/AppBubbleListPreferenceController.java
+++ b/src/com/android/settings/notification/AppBubbleListPreferenceController.java
@@ -51,7 +51,7 @@ public class AppBubbleListPreferenceController extends AppConversationListPrefer
private static final String KEY = "bubble_conversations";
public AppBubbleListPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY);
}
@Override
@@ -80,25 +80,25 @@ public class AppBubbleListPreferenceController extends AppConversationListPrefer
}
@Override
- public boolean isAvailable() {
+ public int getAvailabilityStatus() {
// copy rather than inherit super's isAvailable because apps can link to this page
// as part of onboarding, before they send a valid conversation notification
if (mAppRow == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mAppRow.banned) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mChannel != null) {
if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid)
|| NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
}
if (mAppRow.bubblePreference == BUBBLE_PREFERENCE_NONE) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
- return true;
+ return AVAILABLE;
}
@VisibleForTesting
diff --git a/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java b/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java
index e5afd9d3db0..12b807534f9 100644
--- a/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java
+++ b/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java
@@ -32,7 +32,7 @@ public class AddToHomeScreenPreferenceController extends NotificationPreferenceC
private static final String KEY = "add_to_home";
public AddToHomeScreenPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY);
}
@Override
@@ -41,11 +41,11 @@ public class AddToHomeScreenPreferenceController extends NotificationPreferenceC
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
- return mConversationInfo != null;
+ return mConversationInfo != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/AllowSoundPreferenceController.java b/src/com/android/settings/notification/app/AllowSoundPreferenceController.java
index 0664c544bec..99d08734c96 100644
--- a/src/com/android/settings/notification/app/AllowSoundPreferenceController.java
+++ b/src/com/android/settings/notification/app/AllowSoundPreferenceController.java
@@ -40,7 +40,7 @@ public class AllowSoundPreferenceController extends NotificationPreferenceContro
public AllowSoundPreferenceController(Context context,
NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY_IMPORTANCE);
mDependentFieldListener = dependentFieldListener;
}
@@ -50,11 +50,14 @@ public class AllowSoundPreferenceController extends NotificationPreferenceContro
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
- return mChannel != null && NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId());
+ if (mChannel != null && NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) {
+ return AVAILABLE;
+ }
+ return CONDITIONALLY_UNAVAILABLE;
}
diff --git a/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java b/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java
index 92cd911843a..6c2c0c3cf77 100644
--- a/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java
+++ b/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java
@@ -64,7 +64,7 @@ public class AppChannelsBypassingDndPreferenceController extends NotificationPre
public AppChannelsBypassingDndPreferenceController(
Context context,
NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY);
}
@Override
@@ -110,8 +110,8 @@ public class AppChannelsBypassingDndPreferenceController extends NotificationPre
}
@Override
- public boolean isAvailable() {
- return mAppRow != null;
+ public int getAvailabilityStatus() {
+ return mAppRow != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/AppConversationListPreferenceController.java b/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
index dd44a13f7c8..e7b23788968 100644
--- a/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
+++ b/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
@@ -49,7 +49,12 @@ public class AppConversationListPreferenceController extends NotificationPrefere
protected PreferenceCategory mPreference;
public AppConversationListPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend);
+ this(context, backend, KEY);
+ }
+
+ public AppConversationListPreferenceController(Context context, NotificationBackend backend,
+ String key) {
+ super(context, backend, key);
}
@Override
@@ -58,21 +63,24 @@ public class AppConversationListPreferenceController extends NotificationPrefere
}
@Override
- public boolean isAvailable() {
+ public int getAvailabilityStatus() {
if (mAppRow == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mAppRow.banned) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mChannel != null) {
if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid)
|| NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
}
- return mBackend.hasSentValidMsg(mAppRow.pkg, mAppRow.uid) || mBackend.isInInvalidMsgState(
- mAppRow.pkg, mAppRow.uid);
+ if (mBackend.hasSentValidMsg(mAppRow.pkg, mAppRow.uid) || mBackend.isInInvalidMsgState(
+ mAppRow.pkg, mAppRow.uid)) {
+ return AVAILABLE;
+ }
+ return CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/AppLinkPreferenceController.java b/src/com/android/settings/notification/app/AppLinkPreferenceController.java
index 043ae698f54..ecf9670cba9 100644
--- a/src/com/android/settings/notification/app/AppLinkPreferenceController.java
+++ b/src/com/android/settings/notification/app/AppLinkPreferenceController.java
@@ -32,7 +32,7 @@ public class AppLinkPreferenceController extends NotificationPreferenceControlle
private static final String KEY_APP_LINK = "app_link";
public AppLinkPreferenceController(Context context) {
- super(context, null);
+ super(context, null, KEY_APP_LINK);
}
@Override
@@ -41,11 +41,11 @@ public class AppLinkPreferenceController extends NotificationPreferenceControlle
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
- return mAppRow.settingsIntent != null;
+ return mAppRow.settingsIntent != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/BadgePreferenceController.java b/src/com/android/settings/notification/app/BadgePreferenceController.java
index 108fa1d7a07..f94dfb513ae 100644
--- a/src/com/android/settings/notification/app/BadgePreferenceController.java
+++ b/src/com/android/settings/notification/app/BadgePreferenceController.java
@@ -38,7 +38,7 @@ public class BadgePreferenceController extends NotificationPreferenceController
public BadgePreferenceController(Context context,
NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY_BADGE);
}
@Override
@@ -47,25 +47,29 @@ public class BadgePreferenceController extends NotificationPreferenceController
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mAppRow == null && mChannel == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (Settings.Secure.getInt(mContext.getContentResolver(),
NOTIFICATION_BADGING, SYSTEM_WIDE_ON) == SYSTEM_WIDE_OFF) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mChannel != null) {
if (isDefaultChannel()) {
- return true;
+ return AVAILABLE;
} else {
- return mAppRow == null ? false : mAppRow.showBadge;
+ return mAppRow == null
+ ? CONDITIONALLY_UNAVAILABLE
+ : mAppRow.showBadge
+ ? AVAILABLE
+ : CONDITIONALLY_UNAVAILABLE;
}
}
- return true;
+ return AVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/BlockPreferenceController.java b/src/com/android/settings/notification/app/BlockPreferenceController.java
index f4e213298a7..ea3eaeb3353 100644
--- a/src/com/android/settings/notification/app/BlockPreferenceController.java
+++ b/src/com/android/settings/notification/app/BlockPreferenceController.java
@@ -42,7 +42,7 @@ public class BlockPreferenceController extends NotificationPreferenceController
public BlockPreferenceController(Context context,
NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY_BLOCK);
mDependentFieldListener = dependentFieldListener;
}
@@ -52,14 +52,14 @@ public class BlockPreferenceController extends NotificationPreferenceController
}
@Override
- public boolean isAvailable() {
+ public int getAvailabilityStatus() {
if (mAppRow == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mPreferenceFilter != null && !isIncludedInFilter()) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
- return true;
+ return AVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java b/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java
index ad3a10cf381..da67afeeb33 100644
--- a/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java
+++ b/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java
@@ -32,15 +32,15 @@ public class BubbleCategoryPreferenceController extends NotificationPreferenceCo
static final int ON = 1;
public BubbleCategoryPreferenceController(Context context) {
- super(context, null);
+ super(context, null, KEY);
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
- return areBubblesEnabled();
+ return areBubblesEnabled() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java b/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java
index 0b9529b10b5..ed1c9b53079 100644
--- a/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java
+++ b/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java
@@ -32,15 +32,15 @@ public class BubbleLinkPreferenceController extends NotificationPreferenceContro
static final int ON = 1;
public BubbleLinkPreferenceController(Context context) {
- super(context, null);
+ super(context, null, KEY);
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
- return areBubblesEnabled();
+ return areBubblesEnabled() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/BubblePreferenceController.java b/src/com/android/settings/notification/app/BubblePreferenceController.java
index 351b4635bb6..516a45e482d 100644
--- a/src/com/android/settings/notification/app/BubblePreferenceController.java
+++ b/src/com/android/settings/notification/app/BubblePreferenceController.java
@@ -56,7 +56,7 @@ public class BubblePreferenceController extends NotificationPreferenceController
public BubblePreferenceController(Context context, @Nullable FragmentManager fragmentManager,
NotificationBackend backend, boolean isAppPage,
@Nullable NotificationSettings.DependentFieldListener listener) {
- super(context, backend);
+ super(context, backend, KEY);
mFragmentManager = fragmentManager;
mIsAppPage = isAppPage;
mListener = listener;
@@ -68,21 +68,24 @@ public class BubblePreferenceController extends NotificationPreferenceController
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
if (!mIsAppPage && !isEnabled()) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mChannel != null) {
if (isDefaultChannel()) {
- return true;
+ return AVAILABLE;
} else {
- return mAppRow != null && mAppRow.bubblePreference != BUBBLE_PREFERENCE_NONE;
+ if (mAppRow != null && mAppRow.bubblePreference != BUBBLE_PREFERENCE_NONE) {
+ return AVAILABLE;
+ }
+ return CONDITIONALLY_UNAVAILABLE;
}
}
- return true;
+ return AVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java b/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java
index 51370b16bef..abbe89e6fa8 100644
--- a/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java
+++ b/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java
@@ -42,28 +42,31 @@ public class BubbleSummaryPreferenceController extends NotificationPreferenceCon
static final int ON = 1;
public BubbleSummaryPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY);
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mAppRow == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mChannel != null) {
if (!isGloballyEnabled()) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (isDefaultChannel()) {
- return true;
+ return AVAILABLE;
} else {
- return mAppRow != null;
+ return mAppRow != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
}
- return isGloballyEnabled() && mBackend.hasSentValidBubble(mAppRow.pkg, mAppRow.uid);
+ if (isGloballyEnabled() && mBackend.hasSentValidBubble(mAppRow.pkg, mAppRow.uid)) {
+ return AVAILABLE;
+ }
+ return CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/ChannelListPreferenceController.java b/src/com/android/settings/notification/app/ChannelListPreferenceController.java
index 8db3b21f4be..8d079114a9e 100644
--- a/src/com/android/settings/notification/app/ChannelListPreferenceController.java
+++ b/src/com/android/settings/notification/app/ChannelListPreferenceController.java
@@ -28,6 +28,7 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
+import android.util.Slog;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -39,16 +40,19 @@ import androidx.preference.SwitchPreference;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.applications.AppInfoBase;
+import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.notification.NotificationBackend;
import com.android.settingslib.PrimarySwitchPreference;
import com.android.settingslib.RestrictedSwitchPreference;
+import com.android.settingslib.utils.ThreadUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-public class ChannelListPreferenceController extends NotificationPreferenceController {
+public class ChannelListPreferenceController extends NotificationPreferenceController
+ implements BasePreferenceController.UiBlocker {
private static final String KEY = "channels";
private static final String KEY_GENERAL_CATEGORY = "categories";
@@ -59,7 +63,7 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
private PreferenceCategory mPreference;
public ChannelListPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY);
}
@Override
@@ -68,20 +72,20 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
}
@Override
- public boolean isAvailable() {
+ public int getAvailabilityStatus() {
if (mAppRow == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mAppRow.banned) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mChannel != null) {
if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid)
|| NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
}
- return true;
+ return AVAILABLE;
}
@Override
@@ -91,24 +95,17 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
@Override
public void updateState(Preference preference) {
- mPreference = (PreferenceCategory) preference;
- // Load channel settings
- new AsyncTask() {
- @Override
- protected Void doInBackground(Void... unused) {
+ mPreference = (PreferenceCategory) preference;
+ // Load channel settings
+ ThreadUtils.postOnBackgroundThread(() -> {
mChannelGroupList = mBackend.getGroups(mAppRow.pkg, mAppRow.uid).getList();
Collections.sort(mChannelGroupList, CHANNEL_GROUP_COMPARATOR);
- return null;
- }
-
- @Override
- protected void onPostExecute(Void unused) {
- if (mContext == null) {
- return;
- }
+ ThreadUtils.getUiThreadHandler().getLooper().prepare();
updateFullList(mPreference, mChannelGroupList);
- }
- }.execute();
+ ThreadUtils.postOnMainThread(() -> {
+ showPreferences();
+ });
+ });
}
/**
@@ -144,6 +141,12 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
}
}
+ private void showPreferences() {
+ if (mUiBlockListener != null) {
+ mUiBlockListener.onBlockerWorkFinished(this);
+ }
+ }
+
/**
* Looks for the category for the given group's key at the expected index, if that doesn't
* match, it checks all groups, and if it can't find that group anywhere, it creates it.
diff --git a/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java b/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java
index 02f639c3157..ba7ca358b8b 100644
--- a/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java
@@ -37,7 +37,7 @@ public class ConversationDemotePreferenceController extends NotificationPreferen
public ConversationDemotePreferenceController(Context context,
SettingsPreferenceFragment hostFragment,
NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY);
mHostFragment = hostFragment;
}
@@ -47,14 +47,17 @@ public class ConversationDemotePreferenceController extends NotificationPreferen
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mAppRow == null || mChannel == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
- return !TextUtils.isEmpty(mChannel.getConversationId()) && !mChannel.isDemoted();
+ if (!TextUtils.isEmpty(mChannel.getConversationId()) && !mChannel.isDemoted()) {
+ return AVAILABLE;
+ }
+ return CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
index f99a56aabda..56de88b324a 100644
--- a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
@@ -45,7 +45,7 @@ public class ConversationHeaderPreferenceController extends NotificationPreferen
private boolean mStarted = false;
public ConversationHeaderPreferenceController(Context context, DashboardFragment fragment) {
- super(context, null);
+ super(context, null, PREF_KEY_APP_HEADER);
mFragment = fragment;
}
@@ -55,8 +55,8 @@ public class ConversationHeaderPreferenceController extends NotificationPreferen
}
@Override
- public boolean isAvailable() {
- return mAppRow != null;
+ public int getAvailabilityStatus() {
+ return mAppRow != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/ConversationPriorityPreferenceController.java b/src/com/android/settings/notification/app/ConversationPriorityPreferenceController.java
index ae169282484..46bc3c0c840 100644
--- a/src/com/android/settings/notification/app/ConversationPriorityPreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationPriorityPreferenceController.java
@@ -34,7 +34,7 @@ public class ConversationPriorityPreferenceController extends NotificationPrefer
public ConversationPriorityPreferenceController(Context context,
NotificationBackend backend, NotificationSettings.DependentFieldListener listener) {
- super(context, backend);
+ super(context, backend, KEY);
mDependentFieldListener = listener;
}
@@ -44,14 +44,14 @@ public class ConversationPriorityPreferenceController extends NotificationPrefer
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mAppRow == null || mChannel == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
- return true;
+ return AVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java b/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java
index 24c3d2ff6a1..a5ef569d620 100644
--- a/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java
@@ -37,7 +37,7 @@ public class ConversationPromotePreferenceController extends NotificationPrefere
public ConversationPromotePreferenceController(Context context,
SettingsPreferenceFragment hostFragment,
NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY);
mHostFragment = hostFragment;
}
@@ -47,14 +47,17 @@ public class ConversationPromotePreferenceController extends NotificationPrefere
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mAppRow == null || mChannel == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
- return !TextUtils.isEmpty(mChannel.getConversationId()) && mChannel.isDemoted();
+ if (!TextUtils.isEmpty(mChannel.getConversationId()) && mChannel.isDemoted()) {
+ return AVAILABLE;
+ }
+ return CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java b/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java
index 77a692f1488..cd160df1fd4 100644
--- a/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java
+++ b/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java
@@ -30,7 +30,7 @@ public class DeletedChannelsPreferenceController extends NotificationPreferenceC
private static final String KEY_DELETED = "deleted";
public DeletedChannelsPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY_DELETED);
}
@Override
@@ -39,16 +39,19 @@ public class DeletedChannelsPreferenceController extends NotificationPreferenceC
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
// only visible on app screen
if (mChannel != null || hasValidGroup()) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
- return mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid) > 0;
+ if (mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid) > 0) {
+ return AVAILABLE;
+ }
+ return CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/DescriptionPreferenceController.java b/src/com/android/settings/notification/app/DescriptionPreferenceController.java
index 0a5bb2f9260..413a876cec9 100644
--- a/src/com/android/settings/notification/app/DescriptionPreferenceController.java
+++ b/src/com/android/settings/notification/app/DescriptionPreferenceController.java
@@ -29,7 +29,7 @@ public class DescriptionPreferenceController extends NotificationPreferenceContr
private static final String KEY_DESC = "desc";
public DescriptionPreferenceController(Context context) {
- super(context, null);
+ super(context, null, KEY_DESC);
}
@Override
@@ -38,20 +38,20 @@ public class DescriptionPreferenceController extends NotificationPreferenceContr
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mChannel == null && !hasValidGroup()) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mChannel != null && !TextUtils.isEmpty(mChannel.getDescription())) {
- return true;
+ return AVAILABLE;
}
if (hasValidGroup() && !TextUtils.isEmpty(mChannelGroup.getDescription())) {
- return true;
+ return AVAILABLE;
}
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/DndPreferenceController.java b/src/com/android/settings/notification/app/DndPreferenceController.java
index b65928aa915..811eeb4ec79 100644
--- a/src/com/android/settings/notification/app/DndPreferenceController.java
+++ b/src/com/android/settings/notification/app/DndPreferenceController.java
@@ -31,7 +31,7 @@ public class DndPreferenceController extends NotificationPreferenceController
private static final String KEY_BYPASS_DND = "bypass_dnd";
public DndPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY_BYPASS_DND);
}
@Override
@@ -40,11 +40,11 @@ public class DndPreferenceController extends NotificationPreferenceController
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable() || mChannel == null) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE || mChannel == null) {
+ return CONDITIONALLY_UNAVAILABLE;
}
- return true;
+ return AVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/HeaderPreferenceController.java b/src/com/android/settings/notification/app/HeaderPreferenceController.java
index 7379d55395b..c4b0e598dff 100644
--- a/src/com/android/settings/notification/app/HeaderPreferenceController.java
+++ b/src/com/android/settings/notification/app/HeaderPreferenceController.java
@@ -45,7 +45,7 @@ public class HeaderPreferenceController extends NotificationPreferenceController
private boolean mStarted = false;
public HeaderPreferenceController(Context context, DashboardFragment fragment) {
- super(context, null);
+ super(context, null, PREF_KEY_APP_HEADER);
mFragment = fragment;
}
@@ -55,8 +55,8 @@ public class HeaderPreferenceController extends NotificationPreferenceController
}
@Override
- public boolean isAvailable() {
- return mAppRow != null;
+ public int getAvailabilityStatus() {
+ return mAppRow != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/HighImportancePreferenceController.java b/src/com/android/settings/notification/app/HighImportancePreferenceController.java
index d60668b9abe..98dc8a760e2 100644
--- a/src/com/android/settings/notification/app/HighImportancePreferenceController.java
+++ b/src/com/android/settings/notification/app/HighImportancePreferenceController.java
@@ -37,7 +37,7 @@ public class HighImportancePreferenceController extends NotificationPreferenceCo
public HighImportancePreferenceController(Context context,
NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY_IMPORTANCE);
mDependentFieldListener = dependentFieldListener;
}
@@ -47,17 +47,19 @@ public class HighImportancePreferenceController extends NotificationPreferenceCo
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mChannel == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (isDefaultChannel()) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
- return mChannel.getImportance() >= IMPORTANCE_DEFAULT;
+ return mChannel.getImportance() >= IMPORTANCE_DEFAULT
+ ? AVAILABLE
+ : CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/ImportancePreferenceController.java b/src/com/android/settings/notification/app/ImportancePreferenceController.java
index 3c32ca4b0bc..31ddac39373 100644
--- a/src/com/android/settings/notification/app/ImportancePreferenceController.java
+++ b/src/com/android/settings/notification/app/ImportancePreferenceController.java
@@ -38,7 +38,7 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
public ImportancePreferenceController(Context context,
NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY_IMPORTANCE);
mDependentFieldListener = dependentFieldListener;
}
@@ -48,14 +48,14 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mChannel == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
- return !isDefaultChannel();
+ return !isDefaultChannel() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java b/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java
index b937e80e0d6..bb2c58b728b 100644
--- a/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java
+++ b/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java
@@ -31,7 +31,7 @@ public class InvalidConversationInfoPreferenceController extends NotificationPre
public InvalidConversationInfoPreferenceController(Context context,
NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY);
}
@Override
@@ -40,17 +40,19 @@ public class InvalidConversationInfoPreferenceController extends NotificationPre
}
@Override
- public boolean isAvailable() {
+ public int getAvailabilityStatus() {
if (mAppRow == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mAppRow.banned) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mPreferenceFilter != null && !isIncludedInFilter()) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
- return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid);
+ return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid)
+ ? AVAILABLE
+ : CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java b/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
index 5c502dccbe0..219ccbcea85 100644
--- a/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
+++ b/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
@@ -31,7 +31,7 @@ public class InvalidConversationPreferenceController extends NotificationPrefere
private static final String KEY = "invalid_conversation_switch";
public InvalidConversationPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY);
}
@Override
@@ -40,17 +40,19 @@ public class InvalidConversationPreferenceController extends NotificationPrefere
}
@Override
- public boolean isAvailable() {
+ public int getAvailabilityStatus() {
if (mAppRow == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mAppRow.banned) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mPreferenceFilter != null && !isIncludedInFilter()) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
- return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid);
+ return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid)
+ ? AVAILABLE
+ : CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/LightsPreferenceController.java b/src/com/android/settings/notification/app/LightsPreferenceController.java
index d096922e348..f7f92442c9b 100644
--- a/src/com/android/settings/notification/app/LightsPreferenceController.java
+++ b/src/com/android/settings/notification/app/LightsPreferenceController.java
@@ -33,7 +33,7 @@ public class LightsPreferenceController extends NotificationPreferenceController
private static final String KEY_LIGHTS = "lights";
public LightsPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY_LIGHTS);
}
@Override
@@ -42,16 +42,18 @@ public class LightsPreferenceController extends NotificationPreferenceController
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mChannel == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
- return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT)
- && canPulseLight()
- && !isDefaultChannel();
+ if (checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && canPulseLight()
+ && !isDefaultChannel()) {
+ return AVAILABLE;
+ }
+ return CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/MinImportancePreferenceController.java b/src/com/android/settings/notification/app/MinImportancePreferenceController.java
index f8257636615..b2c0862b8f8 100644
--- a/src/com/android/settings/notification/app/MinImportancePreferenceController.java
+++ b/src/com/android/settings/notification/app/MinImportancePreferenceController.java
@@ -37,7 +37,7 @@ public class MinImportancePreferenceController extends NotificationPreferenceCon
public MinImportancePreferenceController(Context context,
NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY_IMPORTANCE);
mDependentFieldListener = dependentFieldListener;
}
@@ -47,17 +47,17 @@ public class MinImportancePreferenceController extends NotificationPreferenceCon
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mChannel == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (isDefaultChannel()) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
- return mChannel.getImportance() <= IMPORTANCE_LOW;
+ return mChannel.getImportance() <= IMPORTANCE_LOW ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/NotificationPreferenceController.java b/src/com/android/settings/notification/app/NotificationPreferenceController.java
index fb19d9d6b4c..271a83d76f8 100644
--- a/src/com/android/settings/notification/app/NotificationPreferenceController.java
+++ b/src/com/android/settings/notification/app/NotificationPreferenceController.java
@@ -17,26 +17,24 @@
package com.android.settings.notification.app;
import static android.app.NotificationManager.IMPORTANCE_NONE;
-import static android.os.UserHandle.USER_SYSTEM;
import android.annotation.Nullable;
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
import android.app.NotificationManager;
import android.content.Context;
-import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ShortcutInfo;
import android.graphics.drawable.Drawable;
import android.os.UserManager;
-import android.provider.Settings;
import android.util.Log;
+import android.util.Slog;
import androidx.preference.Preference;
+import com.android.settings.core.BasePreferenceController;
import com.android.settings.notification.NotificationBackend;
import com.android.settingslib.RestrictedLockUtils;
-import com.android.settingslib.core.AbstractPreferenceController;
import java.util.Comparator;
import java.util.List;
@@ -46,7 +44,7 @@ import java.util.Objects;
* Parent class for preferences appearing on notification setting pages at the app,
* notification channel group, or notification channel level.
*/
-public abstract class NotificationPreferenceController extends AbstractPreferenceController {
+public abstract class NotificationPreferenceController extends BasePreferenceController {
private static final String TAG = "ChannelPrefContr";
@Nullable
protected NotificationChannel mChannel;
@@ -71,8 +69,11 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
boolean overrideCanBlockValue;
boolean overrideCanConfigureValue;
- public NotificationPreferenceController(Context context, NotificationBackend backend) {
- super(context);
+ boolean mLoadedChannelState;
+
+ public NotificationPreferenceController(Context context, NotificationBackend backend,
+ String key) {
+ super(context, key);
mContext = context;
mNm = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
mBackend = backend;
@@ -81,28 +82,30 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
}
/**
- * Returns true if field's parent object is not blocked.
+ * Returns available if field's parent object is not blocked.
*/
@Override
- public boolean isAvailable() {
+ public int getAvailabilityStatus() {
if (mAppRow == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mAppRow.banned) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mChannelGroup != null) {
if (mChannelGroup.isBlocked()) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
}
if (mChannel != null) {
if (mPreferenceFilter != null && !isIncludedInFilter()) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+ if(mChannel.getImportance() == IMPORTANCE_NONE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
- return mChannel.getImportance() != IMPORTANCE_NONE;
}
- return true;
+ return AVAILABLE;
}
protected void onResume(NotificationBackend.AppRow appRow,
diff --git a/src/com/android/settings/notification/app/NotificationSettings.java b/src/com/android/settings/notification/app/NotificationSettings.java
index 192a0ee9fc7..5750167c271 100644
--- a/src/com/android/settings/notification/app/NotificationSettings.java
+++ b/src/com/android/settings/notification/app/NotificationSettings.java
@@ -41,6 +41,7 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
+import android.util.Slog;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
@@ -129,15 +130,52 @@ abstract public class NotificationSettings extends DashboardFragment {
}
}
+ mUserId = UserHandle.getUserId(mUid);
mPkgInfo = findPackageInfo(mPkg, mUid);
+ }
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ if (mIntent == null && mArgs == null) {
+ toastAndFinish("no intent");
+ return;
+ }
+
+ if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null) {
+ toastAndFinish("Missing package or uid or packageinfo");
+ return;
+ }
+
+ startListeningToPackageRemove();
+ }
+
+ @Override
+ public void onDestroy() {
+ stopListeningToPackageRemove();
+ super.onDestroy();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null) {
+ toastAndFinish("Missing package or uid or packageinfo");
+ return;
+ }
+ mPkgInfo = findPackageInfo(mPkg, mUid);
if (mPkgInfo != null) {
- mUserId = UserHandle.getUserId(mUid);
mSuspendedAppsAdmin = RestrictedLockUtilsInternal.checkIfApplicationIsSuspended(
mContext, mPkg, mUserId);
- loadChannel();
loadAppRow();
+ if (mAppRow == null) {
+ toastAndFinish("Can't load package");
+ return;
+ }
+ loadChannel();
+ loadConversation();
loadChannelGroup();
loadPreferencesFilter();
collectConfigActivities();
@@ -157,55 +195,6 @@ abstract public class NotificationSettings extends DashboardFragment {
}
}
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- if (mIntent == null && mArgs == null) {
- Log.w(TAG, "No intent");
- toastAndFinish();
- return;
- }
-
- if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null) {
- Log.w(TAG, "Missing package or uid or packageinfo");
- toastAndFinish();
- return;
- }
-
- startListeningToPackageRemove();
- }
-
- @Override
- public void onDestroy() {
- stopListeningToPackageRemove();
- super.onDestroy();
- }
-
- @Override
- public void onResume() {
- super.onResume();
- if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null || mAppRow == null) {
- Log.w(TAG, "Missing package or uid or packageinfo");
- finish();
- return;
- }
- // Reload app, channel, etc onResume in case they've changed. A little wasteful if we've
- // just done onAttach but better than making every preference controller reload all
- // the data
- loadAppRow();
- if (mAppRow == null) {
- Log.w(TAG, "Can't load package");
- finish();
- return;
- }
- loadChannel();
- loadConversation();
- loadChannelGroup();
- loadPreferencesFilter();
- collectConfigActivities();
- }
-
protected void animatePanel() {
if (mPreferenceFilter != null) {
mLayoutView = getActivity().findViewById(R.id.main_content);
@@ -307,7 +296,8 @@ abstract public class NotificationSettings extends DashboardFragment {
}
}
- protected void toastAndFinish() {
+ protected void toastAndFinish(String msg) {
+ Log.w(TAG, msg);
Toast.makeText(mContext, R.string.app_not_found_dlg_text, Toast.LENGTH_SHORT).show();
getActivity().finish();
}
diff --git a/src/com/android/settings/notification/app/NotificationsOffPreferenceController.java b/src/com/android/settings/notification/app/NotificationsOffPreferenceController.java
index 0c7cd2361e2..46625c3101a 100644
--- a/src/com/android/settings/notification/app/NotificationsOffPreferenceController.java
+++ b/src/com/android/settings/notification/app/NotificationsOffPreferenceController.java
@@ -30,7 +30,7 @@ public class NotificationsOffPreferenceController extends NotificationPreference
private static final String KEY_BLOCKED_DESC = "block_desc";
public NotificationsOffPreferenceController(Context context) {
- super(context, null);
+ super(context, null, KEY_BLOCKED_DESC);
}
@Override
@@ -39,16 +39,20 @@ public class NotificationsOffPreferenceController extends NotificationPreference
}
@Override
- public boolean isAvailable() {
+ public int getAvailabilityStatus() {
if (mAppRow == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mPreferenceFilter != null && !isIncludedInFilter()) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
// Available only when other controllers are unavailable - this UI replaces the UI that
// would give more detailed notification controls.
- return !super.isAvailable();
+ if (super.getAvailabilityStatus() == AVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
+ } else {
+ return AVAILABLE;
+ }
}
@Override
diff --git a/src/com/android/settings/notification/app/SoundPreferenceController.java b/src/com/android/settings/notification/app/SoundPreferenceController.java
index b23b4fc86cb..335b44226ce 100644
--- a/src/com/android/settings/notification/app/SoundPreferenceController.java
+++ b/src/com/android/settings/notification/app/SoundPreferenceController.java
@@ -47,7 +47,7 @@ public class SoundPreferenceController extends NotificationPreferenceController
public SoundPreferenceController(Context context, SettingsPreferenceFragment hostFragment,
NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY_SOUND);
mFragment = hostFragment;
mListener = dependentFieldListener;
}
@@ -58,14 +58,17 @@ public class SoundPreferenceController extends NotificationPreferenceController
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mChannel == null) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
- return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && !isDefaultChannel();
+ if (checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && !isDefaultChannel()) {
+ return AVAILABLE;
+ }
+ return CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/VibrationPreferenceController.java b/src/com/android/settings/notification/app/VibrationPreferenceController.java
index 34d1a543b56..f91999f074d 100644
--- a/src/com/android/settings/notification/app/VibrationPreferenceController.java
+++ b/src/com/android/settings/notification/app/VibrationPreferenceController.java
@@ -34,7 +34,7 @@ public class VibrationPreferenceController extends NotificationPreferenceControl
private final Vibrator mVibrator;
public VibrationPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY_VIBRATE);
mVibrator = context.getSystemService(Vibrator.class);
}
@@ -44,14 +44,15 @@ public class VibrationPreferenceController extends NotificationPreferenceControl
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable() || mChannel == null) {
- return false;
- }
- return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT)
- && !isDefaultChannel()
- && mVibrator != null
- && mVibrator.hasVibrator();
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE || mChannel == null) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+ if (checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && !isDefaultChannel()
+ && mVibrator != null && mVibrator.hasVibrator()) {
+ return AVAILABLE;
+ }
+ return CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/notification/app/VisibilityPreferenceController.java b/src/com/android/settings/notification/app/VisibilityPreferenceController.java
index a2a1d76b71c..3f33267a749 100644
--- a/src/com/android/settings/notification/app/VisibilityPreferenceController.java
+++ b/src/com/android/settings/notification/app/VisibilityPreferenceController.java
@@ -48,7 +48,7 @@ public class VisibilityPreferenceController extends NotificationPreferenceContro
public VisibilityPreferenceController(Context context, LockPatternUtils utils,
NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, KEY_VISIBILITY_OVERRIDE);
mLockPatternUtils = utils;
}
@@ -58,14 +58,18 @@ public class VisibilityPreferenceController extends NotificationPreferenceContro
}
@Override
- public boolean isAvailable() {
- if (!super.isAvailable()) {
- return false;
+ public int getAvailabilityStatus() {
+ if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
+ return CONDITIONALLY_UNAVAILABLE;
}
if (mChannel == null || mAppRow.banned) {
- return false;
+ return CONDITIONALLY_UNAVAILABLE;
}
- return checkCanBeVisible(NotificationManager.IMPORTANCE_LOW) && isLockScreenSecure();
+ if (checkCanBeVisible(NotificationManager.IMPORTANCE_LOW) && isLockScreenSecure()) {
+ return AVAILABLE;
+ }
+
+ return CONDITIONALLY_UNAVAILABLE;
}
@Override
diff --git a/src/com/android/settings/sound/MediaControlsLockScreenPreferenceController.java b/src/com/android/settings/sound/MediaControlsLockScreenPreferenceController.java
new file mode 100644
index 00000000000..009ab2e4dac
--- /dev/null
+++ b/src/com/android/settings/sound/MediaControlsLockScreenPreferenceController.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2022 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.sound;
+
+import static android.provider.Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.R;
+import com.android.settings.core.TogglePreferenceController;
+
+/**
+ * Toggle for media control resumption on lock screen.
+ */
+public class MediaControlsLockScreenPreferenceController extends TogglePreferenceController {
+ public MediaControlsLockScreenPreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public boolean isChecked() {
+ int val = Settings.Secure.getInt(mContext.getContentResolver(),
+ MEDIA_CONTROLS_LOCK_SCREEN, 1);
+ return val == 1;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ int val = isChecked ? 1 : 0;
+ return Settings.Secure.putInt(mContext.getContentResolver(),
+ MEDIA_CONTROLS_LOCK_SCREEN, val);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public int getSliceHighlightMenuRes() {
+ return R.string.menu_key_sound;
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
index 591c4e6b7f9..c5c47d27203 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
@@ -249,6 +249,8 @@ public class BatteryInfoTest {
@Test
public void testGetBatteryInfo_chargingWithOverheated_updateChargeLabel() {
+ final String expectedString =
+ mContext.getString(R.string.battery_tip_limited_temporarily_title);
doReturn(TEST_CHARGE_TIME_REMAINING)
.when(mBatteryUsageStats)
.getChargeTimeRemainingMs();
@@ -260,7 +262,7 @@ public class BatteryInfoTest {
false /* shortString */);
assertThat(info.isOverheated).isTrue();
- assertThat(info.chargeLabel).isEqualTo("50% - Charging temporarily limited");
+ assertThat(info.chargeLabel.toString()).contains(expectedString);
}
// Make our battery stats return a sequence of battery events.
diff --git a/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java
index b2f1673f317..bf529e67568 100644
--- a/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java
@@ -426,7 +426,7 @@ public class NotificationPreferenceControllerTest {
private final class TestPreferenceController extends NotificationPreferenceController {
private TestPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend);
+ super(context, backend, "key");
}
@Override
diff --git a/tests/unit/src/com/android/settings/deviceinfo/VolumeOptionMenuControllerTest.java b/tests/unit/src/com/android/settings/deviceinfo/VolumeOptionMenuControllerTest.java
index 8bd9b018d18..d347f919628 100644
--- a/tests/unit/src/com/android/settings/deviceinfo/VolumeOptionMenuControllerTest.java
+++ b/tests/unit/src/com/android/settings/deviceinfo/VolumeOptionMenuControllerTest.java
@@ -55,7 +55,6 @@ public class VolumeOptionMenuControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Menu mMenu;
@Mock private PackageManager mPackageManager;
- @Mock private StorageManager mStorageManager;
@Mock private VolumeInfo mExternalVolumeInfo;
@Mock private VolumeInfo mInternalVolumeInfo;
@@ -68,7 +67,6 @@ public class VolumeOptionMenuControllerTest {
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getPackageManager()).thenReturn(mPackageManager);
- when(mContext.getSystemService(StorageManager.class)).thenReturn(mStorageManager);
when(mInternalVolumeInfo.getId()).thenReturn(INTERNAL_VOLUME_ID);
when(mInternalVolumeInfo.getType()).thenReturn(VolumeInfo.TYPE_PRIVATE);
@@ -173,17 +171,16 @@ public class VolumeOptionMenuControllerTest {
when(mExternalVolumeInfo.getState()).thenReturn(VolumeInfo.STATE_MOUNTED);
when(mExternalVolumeInfo.getDiskId()).thenReturn(DISK_ID);
final DiskInfo externalDiskInfo = mock(DiskInfo.class);
- when(mStorageManager.findDiskById(DISK_ID)).thenReturn(externalDiskInfo);
mController.setSelectedStorageEntry(new StorageEntry(mContext, mExternalVolumeInfo));
mController.onPrepareOptionsMenu(mMenu);
verify(mController.mRename, atLeastOnce()).setVisible(true);
verify(mController.mUnmount, atLeastOnce()).setVisible(true);
- verify(mController.mFormat, atLeastOnce()).setVisible(true);
- verify(mController.mMount, never()).setVisible(true);
+ verify(mController.mFormatAsInternal, atLeastOnce()).setVisible(true);
verify(mController.mFormatAsPortable, never()).setVisible(true);
- verify(mController.mFormatAsInternal, never()).setVisible(true);
+ verify(mController.mFormat, never()).setVisible(true);
+ verify(mController.mMount, never()).setVisible(true);
verify(mController.mFree, never()).setVisible(true);
verify(mController.mForget, never()).setVisible(true);
}
diff --git a/tests/unit/src/com/android/settings/sound/MediaControlsLockScreenPreferenceControllerTest.java b/tests/unit/src/com/android/settings/sound/MediaControlsLockScreenPreferenceControllerTest.java
new file mode 100644
index 00000000000..6c1aede4b59
--- /dev/null
+++ b/tests/unit/src/com/android/settings/sound/MediaControlsLockScreenPreferenceControllerTest.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2022 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.sound;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class MediaControlsLockScreenPreferenceControllerTest {
+
+ private static final String KEY = "media_controls_lockscreen";
+ private final Context mContext = ApplicationProvider.getApplicationContext();
+
+ private int mOriginalPreference;
+ private ContentResolver mContentResolver;
+ private MediaControlsLockScreenPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ mContentResolver = mContext.getContentResolver();
+ mOriginalPreference = Settings.Secure.getInt(mContentResolver,
+ Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN, 1);
+ mController = new MediaControlsLockScreenPreferenceController(mContext, KEY);
+ }
+
+ @After
+ public void tearDown() {
+ Settings.Secure.putInt(mContentResolver, Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN,
+ mOriginalPreference);
+ }
+
+ @Test
+ public void getAvailability_returnAvailable() {
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void setChecked_disable_shouldTurnOff() {
+ Settings.Secure.putInt(mContentResolver,
+ Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN, 1);
+
+ assertThat(mController.isChecked()).isTrue();
+
+ mController.setChecked(false);
+
+ assertThat(Settings.Secure.getInt(mContentResolver,
+ Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN, -1)).isEqualTo(0);
+ }
+
+ @Test
+ public void setChecked_enable_shouldTurnOn() {
+ Settings.Secure.putInt(mContentResolver,
+ Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN, 0);
+
+ assertThat(mController.isChecked()).isFalse();
+
+ mController.setChecked(true);
+
+ assertThat(Settings.Secure.getInt(mContentResolver,
+ Settings.Secure.MEDIA_CONTROLS_LOCK_SCREEN, -1)).isEqualTo(1);
+ }
+}