Merge "Don't show back arrow in Security when in split mode." into tm-dev
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 5e4e5a4..e2a8423 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -579,6 +579,9 @@
<!-- Padding for indeterminate progress bar -->
<item name="progressBarStartPadding">12dp</item>
<item name="progressBarEndPadding">16dp</item>
+
+ <!-- Title icon size -->
+ <item name="iconSize">25dp</item>
</style>
<style name="SliceRow.Slider.LargeIcon">
diff --git a/src/com/android/settings/accessibility/AccessibilityDetailsSettingsFragment.java b/src/com/android/settings/accessibility/AccessibilityDetailsSettingsFragment.java
index 911e2fc..c3359e4 100644
--- a/src/com/android/settings/accessibility/AccessibilityDetailsSettingsFragment.java
+++ b/src/com/android/settings/accessibility/AccessibilityDetailsSettingsFragment.java
@@ -163,7 +163,9 @@
try {
final int mode = mAppOps.noteOpNoThrow(AppOpsManager.OP_ACCESS_RESTRICTED_SETTINGS,
uid, packageName);
- return mode != AppOpsManager.MODE_ERRORED && mode != AppOpsManager.MODE_IGNORED;
+ final boolean ecmEnabled = getContext().getResources().getBoolean(
+ com.android.internal.R.bool.config_enhancedConfirmationModeEnabled);
+ return !ecmEnabled || mode == AppOpsManager.MODE_ALLOWED;
} catch (Exception e) {
// Fallback in case if app ops is not available in testing.
return true;
diff --git a/src/com/android/settings/accessibility/RestrictedPreferenceHelper.java b/src/com/android/settings/accessibility/RestrictedPreferenceHelper.java
index 3e42e21..4344acc 100644
--- a/src/com/android/settings/accessibility/RestrictedPreferenceHelper.java
+++ b/src/com/android/settings/accessibility/RestrictedPreferenceHelper.java
@@ -233,7 +233,9 @@
final int mode = mAppOps.noteOpNoThrow(
AppOpsManager.OP_ACCESS_RESTRICTED_SETTINGS,
preference.getUid(), preference.getPackageName());
- appOpsAllowed = mode == AppOpsManager.MODE_ALLOWED;
+ final boolean ecmEnabled = mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_enhancedConfirmationModeEnabled);
+ appOpsAllowed = !ecmEnabled || mode == AppOpsManager.MODE_ALLOWED;
serviceAllowed = appOpsAllowed;
} catch (Exception e) {
// Allow service in case if app ops is not available in testing.
diff --git a/src/com/android/settings/accounts/AccountPreferenceController.java b/src/com/android/settings/accounts/AccountPreferenceController.java
index 29198fb..1458988 100644
--- a/src/com/android/settings/accounts/AccountPreferenceController.java
+++ b/src/com/android/settings/accounts/AccountPreferenceController.java
@@ -623,6 +623,12 @@
if (action.equals(Intent.ACTION_MANAGED_PROFILE_REMOVED)
|| action.equals(Intent.ACTION_MANAGED_PROFILE_ADDED)) {
if (mFragment instanceof AccountWorkProfileDashboardFragment) {
+ new SubSettingLauncher(context)
+ .setDestination(AccountDashboardFragment.class.getName())
+ .setSourceMetricsCategory(mFragment.getMetricsCategory())
+ .setTitleRes(-1)
+ .setIsSecondLayerPage(true)
+ .launch();
mFragment.getActivity().finish();
} else {
// Clean old state
diff --git a/src/com/android/settings/core/SliderPreferenceController.java b/src/com/android/settings/core/SliderPreferenceController.java
index 0a7ece2..8c936f2 100644
--- a/src/com/android/settings/core/SliderPreferenceController.java
+++ b/src/com/android/settings/core/SliderPreferenceController.java
@@ -17,6 +17,7 @@
import android.content.Context;
import androidx.preference.Preference;
+import androidx.slice.builders.SliceAction;
import com.android.settings.slices.SliceData;
@@ -70,4 +71,11 @@
public int getSliceType() {
return SliceData.SliceType.SLIDER;
}
+
+ /**
+ * @return the SliceAction for the end item of the slice.
+ */
+ public SliceAction getSliceEndItem(Context context) {
+ return null;
+ }
}
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index 7e27414..dcd2bd8 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -234,7 +234,9 @@
// If isValidPrivateVolume() is true, these preferences will become visible at
// onLoadFinished.
- if (!isValidPrivateVolume()) {
+ if (isValidPrivateVolume()) {
+ mIsDocumentsPrefShown = isDocumentsPrefShown();
+ } else {
setPrivateStorageCategoryPreferencesVisibility(false);
}
}
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
index 6cadbda..f3085bc 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
@@ -38,6 +38,7 @@
import com.android.settings.R;
import com.android.settings.vpn2.VpnUtils;
+import com.android.settingslib.utils.WorkPolicyUtils;
import java.util.Date;
import java.util.List;
@@ -54,6 +55,7 @@
private final ConnectivityManager mCm;
private final VpnManager mVm;
private final Resources mResources;
+ private final WorkPolicyUtils mWorkPolicyUtils;
private static final int MY_USER_ID = UserHandle.myUserId();
@@ -67,6 +69,7 @@
mCm = cm;
mVm = vm;
mResources = resources;
+ mWorkPolicyUtils = new WorkPolicyUtils(mContext, mPm, mUm, mDpm);
}
@Override
@@ -228,25 +231,12 @@
@Override
public boolean hasWorkPolicyInfo() {
- return (getWorkPolicyInfoIntentDO() != null) || (getWorkPolicyInfoIntentPO() != null);
+ return mWorkPolicyUtils.hasWorkPolicy();
}
@Override
public boolean showWorkPolicyInfo(Context activityContext) {
- Intent intent = getWorkPolicyInfoIntentDO();
- if (intent != null) {
- activityContext.startActivity(intent);
- return true;
- }
-
- intent = getWorkPolicyInfoIntentPO();
- final UserInfo userInfo = getManagedProfileUserInfo();
- if (intent != null && userInfo != null) {
- activityContext.startActivityAsUser(intent, userInfo.getUserHandle());
- return true;
- }
-
- return false;
+ return mWorkPolicyUtils.showWorkPolicyInfo(activityContext);
}
@Override
@@ -301,47 +291,6 @@
return UserHandle.USER_NULL;
}
- private Intent getWorkPolicyInfoIntentDO() {
- final ComponentName ownerComponent = getDeviceOwnerComponent();
- if (ownerComponent == null) {
- return null;
- }
-
- // Only search for the required action in the Device Owner's package
- final Intent intent =
- new Intent(Settings.ACTION_SHOW_WORK_POLICY_INFO)
- .setPackage(ownerComponent.getPackageName());
- final List<ResolveInfo> activities = mPm.queryIntentActivities(intent, 0);
- if (activities.size() != 0) {
- return intent;
- }
-
- return null;
- }
-
- private Intent getWorkPolicyInfoIntentPO() {
- final int userId = getManagedProfileUserId();
- if (userId == UserHandle.USER_NULL) {
- return null;
- }
-
- final ComponentName ownerComponent = mDpm.getProfileOwnerAsUser(userId);
- if (ownerComponent == null) {
- return null;
- }
-
- // Only search for the required action in the Profile Owner's package
- final Intent intent =
- new Intent(Settings.ACTION_SHOW_WORK_POLICY_INFO)
- .setPackage(ownerComponent.getPackageName());
- final List<ResolveInfo> activities = mPm.queryIntentActivitiesAsUser(intent, 0, userId);
- if (activities.size() != 0) {
- return intent;
- }
-
- return null;
- }
-
protected static class EnterprisePrivacySpan extends ClickableSpan {
private final Context mContext;
diff --git a/src/com/android/settings/media/MediaOutputIndicatorWorker.java b/src/com/android/settings/media/MediaOutputIndicatorWorker.java
index ef3a7bc..a87b0ea 100644
--- a/src/com/android/settings/media/MediaOutputIndicatorWorker.java
+++ b/src/com/android/settings/media/MediaOutputIndicatorWorker.java
@@ -34,6 +34,7 @@
import com.android.settings.bluetooth.Utils;
import com.android.settings.slices.SliceBackgroundWorker;
import com.android.settingslib.bluetooth.BluetoothCallback;
+import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.media.LocalMediaManager;
import com.android.settingslib.media.MediaDevice;
@@ -126,7 +127,7 @@
}
@Nullable
- MediaController getActiveLocalMediaController() {
+ public MediaController getActiveLocalMediaController() {
return MediaOutputUtils.getActiveLocalMediaController(mContext.getSystemService(
MediaSessionManager.class));
}
@@ -156,7 +157,7 @@
return mMediaDevices;
}
- MediaDevice getCurrentConnectedMediaDevice() {
+ public MediaDevice getCurrentConnectedMediaDevice() {
return mLocalMediaManager.getCurrentConnectedDevice();
}
@@ -164,6 +165,15 @@
return mPackageName;
}
+ public boolean isDeviceBroadcasting() {
+ LocalBluetoothLeBroadcast broadcast =
+ mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastProfile();
+ if (broadcast == null) {
+ return false;
+ }
+ return broadcast.isEnabled(null);
+ }
+
private class DevicesChangedBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
diff --git a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
index cb5b5d0..919913f 100644
--- a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
@@ -87,7 +87,8 @@
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
visible = false;
- } else if (carrierConfig == null) {
+ } else if (carrierConfig == null
+ || !CarrierConfigManager.isConfigForIdentifiedCarrier(carrierConfig)) {
visible = false;
} else if (carrierConfig.getBoolean(
CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL)
diff --git a/src/com/android/settings/notification/MediaVolumePreferenceController.java b/src/com/android/settings/notification/MediaVolumePreferenceController.java
index e18d2e5..978a4b4 100644
--- a/src/com/android/settings/notification/MediaVolumePreferenceController.java
+++ b/src/com/android/settings/notification/MediaVolumePreferenceController.java
@@ -16,16 +16,32 @@
package com.android.settings.notification;
+import android.app.PendingIntent;
import android.content.Context;
+import android.content.Intent;
+import android.graphics.drawable.Drawable;
import android.media.AudioManager;
+import android.net.Uri;
import android.text.TextUtils;
+import android.util.Log;
+
+import androidx.core.graphics.drawable.IconCompat;
+import androidx.slice.builders.ListBuilder;
+import androidx.slice.builders.SliceAction;
import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.media.MediaOutputIndicatorWorker;
+import com.android.settings.slices.CustomSliceRegistry;
+import com.android.settings.slices.SliceBackgroundWorker;
+import com.android.settingslib.media.MediaDevice;
public class MediaVolumePreferenceController extends VolumeSeekBarPreferenceController {
-
+ private static final String TAG = "MediaVolumePreCtrl";
private static final String KEY_MEDIA_VOLUME = "media_volume";
+ private MediaOutputIndicatorWorker mWorker;
+
public MediaVolumePreferenceController(Context context) {
super(context, KEY_MEDIA_VOLUME);
}
@@ -66,4 +82,66 @@
public int getMuteIcon() {
return R.drawable.ic_media_stream_off;
}
+
+ private boolean isSupportEndItem() {
+ return getWorker() != null
+ && getWorker().getActiveLocalMediaController() != null
+ && isConnectedBLEDevice();
+ }
+
+ private boolean isConnectedBLEDevice() {
+ final MediaDevice device = getWorker().getCurrentConnectedMediaDevice();
+ if (device != null) {
+ return device.isBLEDevice();
+ }
+ return false;
+ }
+
+ @Override
+ public SliceAction getSliceEndItem(Context context) {
+ if (!isSupportEndItem()) {
+ Log.d(TAG, "The slice doesn't support end item");
+ return null;
+ }
+
+ final Intent intent = new Intent();
+ if (getWorker().isDeviceBroadcasting()) {
+ // TODO(b/229577323) : Get the intent action for the Media Output Broadcast Dialog
+ // in SystemUI
+ } else {
+ // TODO(b/229577518) : Get the intent action of the Bluetooth Broadcast Dialog
+ // for user to choose the action
+ }
+ final PendingIntent pi = PendingIntent.getBroadcast(context, 0 /* requestCode */, intent,
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
+ final IconCompat icon = getBroadcastIcon(context);
+
+ return SliceAction.createDeeplink(pi, icon, ListBuilder.ICON_IMAGE, getPreferenceKey());
+ }
+
+ private IconCompat getBroadcastIcon(Context context) {
+ final Drawable drawable = context.getDrawable(
+ com.android.settingslib.R.drawable.settings_input_antenna);
+ if (drawable != null) {
+ drawable.setTint(Utils.getColorAccentDefaultColor(context));
+ return Utils.createIconWithDrawable(drawable);
+ }
+ return null;
+ }
+
+ private MediaOutputIndicatorWorker getWorker() {
+ if (mWorker == null) {
+ mWorker = SliceBackgroundWorker.getInstance(getUri());
+ }
+ return mWorker;
+ }
+
+ private Uri getUri() {
+ return CustomSliceRegistry.VOLUME_MEDIA_URI;
+ }
+
+ @Override
+ public Class<? extends SliceBackgroundWorker> getBackgroundWorkerClass() {
+ return MediaOutputIndicatorWorker.class;
+ }
}
diff --git a/src/com/android/settings/panel/PanelSlicesAdapter.java b/src/com/android/settings/panel/PanelSlicesAdapter.java
index 2486361..9f5ffe9 100644
--- a/src/com/android/settings/panel/PanelSlicesAdapter.java
+++ b/src/com/android/settings/panel/PanelSlicesAdapter.java
@@ -143,6 +143,9 @@
sliceView.setVisibility(View.GONE);
}
+ // Add divider for the end icon
+ sliceView.setShowActionDividers(true);
+
// Log Panel interaction
sliceView.setOnSliceActionListener(
((eventInfo, sliceItem) -> {
diff --git a/src/com/android/settings/slices/SliceBuilderUtils.java b/src/com/android/settings/slices/SliceBuilderUtils.java
index ce5384f..8d5a0b4 100644
--- a/src/com/android/settings/slices/SliceBuilderUtils.java
+++ b/src/com/android/settings/slices/SliceBuilderUtils.java
@@ -339,6 +339,11 @@
inputRangeBuilder.setSubtitle(subtitleText);
}
+ SliceAction endItemAction = sliderController.getSliceEndItem(context);
+ if (endItemAction != null) {
+ inputRangeBuilder.addEndItem(endItemAction);
+ }
+
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY)
.setAccentColor(color)
.addInputRange(inputRangeBuilder)
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
index 2b64c19..0005e71 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
@@ -377,10 +377,22 @@
}
@Test
- public void workPolicyInfo_profileOwner_shouldResolveIntent() {
+ public void workPolicyInfo_profileOwner_shouldResolveIntent()
+ throws PackageManager.NameNotFoundException {
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(null);
- mProfiles.add(new UserInfo(mManagedProfileUserId, "", "", UserInfo.FLAG_MANAGED_PROFILE));
- when(mDevicePolicyManager.getProfileOwnerAsUser(mManagedProfileUserId)).thenReturn(mOwner);
+ List<UserHandle> mAllProfiles = new ArrayList<>();
+ mAllProfiles.add(new UserHandle(mManagedProfileUserId));
+ when(mUserManager.getAllProfiles()).thenReturn(mAllProfiles);
+ when(mUserManager.isManagedProfile(mManagedProfileUserId)).thenReturn(true);
+ when(mContext.getPackageName()).thenReturn("somePackageName");
+ when(mContext.createPackageContextAsUser(
+ eq(mContext.getPackageName()),
+ anyInt(),
+ any(UserHandle.class))
+ ).thenReturn(mContext);
+ when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
+ .thenReturn(mDevicePolicyManager);
+ when(mDevicePolicyManager.getProfileOwner()).thenReturn(mOwner);
// If the intent is not resolved, then there's no info to show for PO
assertThat(mProvider.hasWorkPolicyInfo()).isFalse();
@@ -441,7 +453,7 @@
}
if (profileOwner) {
when(mPackageManager.queryIntentActivitiesAsUser(
- intentEquals(intent), anyInt(), eq(mManagedProfileUserId)))
+ intentEquals(intent), anyInt(), eq(UserHandle.of(mManagedProfileUserId))))
.thenReturn(activities);
}
diff --git a/tests/unit/src/com/android/settings/network/EnabledNetworkModePreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/EnabledNetworkModePreferenceControllerTest.java
index 5672df7..c945206 100644
--- a/tests/unit/src/com/android/settings/network/EnabledNetworkModePreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/EnabledNetworkModePreferenceControllerTest.java
@@ -106,6 +106,7 @@
mPersistableBundle = new PersistableBundle();
doReturn(mPersistableBundle).when(mCarrierConfigCache).getConfig();
doReturn(mPersistableBundle).when(mCarrierConfigCache).getConfigForSubId(SUB_ID);
+ mPersistableBundle.putBoolean(CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, true);
mPreference = new ListPreference(mContext);
mController = new EnabledNetworkModePreferenceController(mContext, KEY);
mockAllowedNetworkTypes(ALLOWED_ALL_NETWORK_TYPE);
@@ -147,6 +148,14 @@
@UiThreadTest
@Test
+ public void getAvailabilityStatus_carrierConfigNotReady_returnUnavailable() {
+ mPersistableBundle.putBoolean(CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, false);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+ }
+
+ @UiThreadTest
+ @Test
public void getAvailabilityStatus_notWorldPhone_returnAvailable() {
mPersistableBundle.putBoolean(CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL,
false);