diff --git a/src/com/android/settings/MainClear.java b/src/com/android/settings/MainClear.java index 62462b3492a..1e8b47b4cb1 100644 --- a/src/com/android/settings/MainClear.java +++ b/src/com/android/settings/MainClear.java @@ -44,7 +44,6 @@ import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; -import android.sysprop.VoldProperties; import android.telephony.euicc.EuiccManager; import android.text.TextUtils; import android.util.Log; @@ -309,12 +308,9 @@ public class MainClear extends InstrumentedFragment implements OnGlobalLayoutLis * If the external storage is emulated, it will be erased with a factory * reset at any rate. There is no need to have a separate option until * we have a factory reset that only erases some directories and not - * others. Likewise, if it's non-removable storage, it could potentially have been - * encrypted, and will also need to be wiped. + * others. */ - boolean isExtStorageEmulated = Environment.isExternalStorageEmulated(); - if (isExtStorageEmulated - || (!Environment.isExternalStorageRemovable() && isExtStorageEncrypted())) { + if (Environment.isExternalStorageEmulated()) { mExternalStorageContainer.setVisibility(View.GONE); final View externalOption = mContentView.findViewById(R.id.erase_external_option_text); @@ -323,9 +319,7 @@ public class MainClear extends InstrumentedFragment implements OnGlobalLayoutLis final View externalAlsoErased = mContentView.findViewById(R.id.also_erases_external); externalAlsoErased.setVisibility(View.VISIBLE); - // If it's not emulated, it is on a separate partition but it means we're doing - // a force wipe due to encryption. - mExternalStorage.setChecked(!isExtStorageEmulated); + mExternalStorage.setChecked(false); } else { mExternalStorageContainer.setOnClickListener(new View.OnClickListener() { @@ -457,11 +451,6 @@ public class MainClear extends InstrumentedFragment implements OnGlobalLayoutLis } } - private boolean isExtStorageEncrypted() { - String state = VoldProperties.decrypt().orElse(""); - return !"".equals(state); - } - private void loadAccountList(final UserManager um) { View accountsLabel = mContentView.findViewById(R.id.accounts_label); LinearLayout contents = (LinearLayout) mContentView.findViewById(R.id.accounts); diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java index b7f89095755..9069feabb82 100644 --- a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java +++ b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java @@ -479,7 +479,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll @Override protected void refresh() { for (LocalBluetoothProfile profile : getProfiles()) { - if (profile != null && !profile.isProfileReady()) { + if (profile == null || !profile.isProfileReady()) { continue; } SwitchPreference pref = mProfilesContainer.findPreference( diff --git a/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java b/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java index 29004c8f1fd..6aac7723435 100644 --- a/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java +++ b/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java @@ -17,17 +17,29 @@ package com.android.settings.gestures; import android.content.Context; +import android.net.Uri; + +import androidx.preference.Preference; +import androidx.preference.PreferenceScreen; import com.android.settings.R; import com.android.settings.core.BasePreferenceController; +import com.android.settingslib.core.lifecycle.LifecycleObserver; +import com.android.settingslib.core.lifecycle.events.OnStart; +import com.android.settingslib.core.lifecycle.events.OnStop; /** * Preference controller for One-handed mode shortcut settings */ -public class OneHandedEnablePreferenceController extends BasePreferenceController { +public class OneHandedEnablePreferenceController extends BasePreferenceController + implements OneHandedSettingsUtils.TogglesCallback, LifecycleObserver, OnStart, OnStop { + + private final OneHandedSettingsUtils mUtils; + private Preference mPreference; public OneHandedEnablePreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); + mUtils = new OneHandedSettingsUtils(context); } @Override @@ -41,4 +53,30 @@ public class OneHandedEnablePreferenceController extends BasePreferenceControlle OneHandedSettingsUtils.isOneHandedModeEnabled(mContext) ? R.string.gesture_setting_on : R.string.gesture_setting_off); } + + @Override + public void displayPreference(PreferenceScreen screen) { + super.displayPreference(screen); + mPreference = screen.findPreference(getPreferenceKey()); + } + + @Override + public void onStart() { + mUtils.registerToggleAwareObserver(this); + } + + @Override + public void onStop() { + mUtils.unregisterToggleAwareObserver(); + } + + @Override + public void onChange(Uri uri) { + if (mPreference == null) { + return; + } + if (uri.equals(OneHandedSettingsUtils.ONE_HANDED_MODE_ENABLED_URI)) { + refreshSummary(mPreference); + } + } }