Snap for 8499686 from 0a41ad016f to tm-qpr1-release

Change-Id: I851293c79caad6af33f095e24f13859827d4213e
This commit is contained in:
Android Build Coastguard Worker
2022-04-26 03:18:33 +00:00
23 changed files with 249 additions and 73 deletions

View File

@@ -1789,6 +1789,18 @@
android:value="true" /> android:value="true" />
</activity> </activity>
<activity android:name="Settings$PrivacyControlsActivity"
android:label="@string/privacy_controls_title"
android:exported="true"
android:icon="@drawable/ic_settings_privacy">
<intent-filter android:priority="1">
<action android:name="android.settings.PRIVACY_CONTROLS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.privacy.PrivacyControlsFragment" />
</activity>
<activity android:name=".development.tare.TareHomePage" <activity android:name=".development.tare.TareHomePage"
android:label="@string/tare_settings" android:label="@string/tare_settings"
android:exported="false" /> android:exported="false" />

View File

@@ -579,6 +579,9 @@
<!-- Padding for indeterminate progress bar --> <!-- Padding for indeterminate progress bar -->
<item name="progressBarStartPadding">12dp</item> <item name="progressBarStartPadding">12dp</item>
<item name="progressBarEndPadding">16dp</item> <item name="progressBarEndPadding">16dp</item>
<!-- Title icon size -->
<item name="iconSize">25dp</item>
</style> </style>
<style name="SliceRow.Slider.LargeIcon"> <style name="SliceRow.Slider.LargeIcon">

View File

@@ -224,6 +224,7 @@ public class Settings extends SettingsActivity {
} }
} }
} }
public static class PrivacyControlsActivity extends SettingsActivity { /* empty */ }
public static class PrivacySettingsActivity extends SettingsActivity { /* empty */ } public static class PrivacySettingsActivity extends SettingsActivity { /* empty */ }
public static class FactoryResetActivity extends SettingsActivity { public static class FactoryResetActivity extends SettingsActivity {
@Override @Override

View File

@@ -623,6 +623,12 @@ public class AccountPreferenceController extends AbstractPreferenceController
if (action.equals(Intent.ACTION_MANAGED_PROFILE_REMOVED) if (action.equals(Intent.ACTION_MANAGED_PROFILE_REMOVED)
|| action.equals(Intent.ACTION_MANAGED_PROFILE_ADDED)) { || action.equals(Intent.ACTION_MANAGED_PROFILE_ADDED)) {
if (mFragment instanceof AccountWorkProfileDashboardFragment) { if (mFragment instanceof AccountWorkProfileDashboardFragment) {
new SubSettingLauncher(context)
.setDestination(AccountDashboardFragment.class.getName())
.setSourceMetricsCategory(mFragment.getMetricsCategory())
.setTitleRes(-1)
.setIsSecondLayerPage(true)
.launch();
mFragment.getActivity().finish(); mFragment.getActivity().finish();
} else { } else {
// Clean old state // Clean old state

View File

@@ -60,6 +60,8 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
public static final String EXTRA_KEY_SENSOR_ID = "sensor_id"; public static final String EXTRA_KEY_SENSOR_ID = "sensor_id";
public static final String EXTRA_KEY_CHALLENGE = "challenge"; public static final String EXTRA_KEY_CHALLENGE = "challenge";
public static final String EXTRA_KEY_MODALITY = "sensor_modality"; public static final String EXTRA_KEY_MODALITY = "sensor_modality";
public static final String EXTRA_FINISHED_ENROLL_FACE = "finished_enrolling_face";
public static final String EXTRA_FINISHED_ENROLL_FINGERPRINT = "finished_enrolling_fingerprint";
/** /**
* Used by the choose fingerprint wizard to indicate the wizard is * Used by the choose fingerprint wizard to indicate the wizard is

View File

@@ -302,6 +302,7 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO(b/229924331): Add tests for the enrollment flows.
final boolean cameFromMultiBioFpAuthAddAnother = final boolean cameFromMultiBioFpAuthAddAnother =
requestCode == BiometricUtils.REQUEST_ADD_ANOTHER requestCode == BiometricUtils.REQUEST_ADD_ANOTHER
&& BiometricUtils.isMultiBiometricFingerprintEnrollmentFlow(this); && BiometricUtils.isMultiBiometricFingerprintEnrollmentFlow(this);
@@ -397,14 +398,20 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
return isResultSkipped(resultCode) || isResultFinished(resultCode); return isResultSkipped(resultCode) || isResultFinished(resultCode);
} }
private void handleBiometricResultSkipOrFinished(int resultCode, @Nullable Intent data) { protected void removeEnrollNextBiometric() {
if (data != null
&& data.getBooleanExtra(
MultiBiometricEnrollHelper.EXTRA_SKIP_PENDING_ENROLL, false)) {
getIntent().removeExtra(MultiBiometricEnrollHelper.EXTRA_ENROLL_AFTER_FACE); getIntent().removeExtra(MultiBiometricEnrollHelper.EXTRA_ENROLL_AFTER_FACE);
getIntent().removeExtra(MultiBiometricEnrollHelper.EXTRA_ENROLL_AFTER_FINGERPRINT); getIntent().removeExtra(MultiBiometricEnrollHelper.EXTRA_ENROLL_AFTER_FINGERPRINT);
} }
protected void removeEnrollNextBiometricIfSkipEnroll(@Nullable Intent data) {
if (data != null
&& data.getBooleanExtra(
MultiBiometricEnrollHelper.EXTRA_SKIP_PENDING_ENROLL, false)) {
removeEnrollNextBiometric();
}
}
protected void handleBiometricResultSkipOrFinished(int resultCode, @Nullable Intent data) {
removeEnrollNextBiometricIfSkipEnroll(data);
if (resultCode == RESULT_SKIP) { if (resultCode == RESULT_SKIP) {
onEnrollmentSkipped(data); onEnrollmentSkipped(data);
} else if (resultCode == RESULT_FINISHED) { } else if (resultCode == RESULT_FINISHED) {

View File

@@ -227,6 +227,10 @@ public class FaceEnrollEducation extends BiometricEnrollBase {
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
mResultIntent = data; mResultIntent = data;
boolean hasEnrolledFace = false;
if (data != null) {
hasEnrolledFace = data.getBooleanExtra(EXTRA_FINISHED_ENROLL_FACE, false);
}
if (resultCode == RESULT_TIMEOUT) { if (resultCode == RESULT_TIMEOUT) {
setResult(resultCode, data); setResult(resultCode, data);
finish(); finish();
@@ -234,7 +238,7 @@ public class FaceEnrollEducation extends BiometricEnrollBase {
|| requestCode == ENROLL_NEXT_BIOMETRIC_REQUEST) { || requestCode == ENROLL_NEXT_BIOMETRIC_REQUEST) {
// If the user finished or skipped enrollment, finish this activity // If the user finished or skipped enrollment, finish this activity
if (resultCode == RESULT_SKIP || resultCode == RESULT_FINISHED if (resultCode == RESULT_SKIP || resultCode == RESULT_FINISHED
|| resultCode == SetupSkipDialog.RESULT_SKIP) { || resultCode == SetupSkipDialog.RESULT_SKIP || hasEnrolledFace) {
setResult(resultCode, data); setResult(resultCode, data);
finish(); finish();
} }

View File

@@ -176,7 +176,18 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
|| requestCode == ENROLL_NEXT_BIOMETRIC_REQUEST; || requestCode == ENROLL_NEXT_BIOMETRIC_REQUEST;
final boolean isResultSkipOrFinished = resultCode == RESULT_SKIP final boolean isResultSkipOrFinished = resultCode == RESULT_SKIP
|| resultCode == SetupSkipDialog.RESULT_SKIP || resultCode == RESULT_FINISHED; || resultCode == SetupSkipDialog.RESULT_SKIP || resultCode == RESULT_FINISHED;
if (isEnrollRequest && isResultSkipOrFinished) { boolean hasEnrolledFace = false;
if (data != null) {
hasEnrolledFace = data.getBooleanExtra(EXTRA_FINISHED_ENROLL_FACE, false);
}
if (resultCode == RESULT_CANCELED && hasEnrolledFace) {
setResult(resultCode, data);
finish();
return;
}
if (isEnrollRequest && isResultSkipOrFinished || hasEnrolledFace) {
data = setSkipPendingEnroll(data); data = setSkipPendingEnroll(data);
} }
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);

View File

@@ -289,6 +289,17 @@ public class FingerprintEnrollFindSensor extends BiometricEnrollBase implements
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
boolean enrolledFingerprint = false;
if (data != null) {
enrolledFingerprint = data.getBooleanExtra(EXTRA_FINISHED_ENROLL_FINGERPRINT, false);
}
if (resultCode == RESULT_CANCELED && enrolledFingerprint) {
setResult(resultCode, data);
finish();
return;
}
if (requestCode == CONFIRM_REQUEST) { if (requestCode == CONFIRM_REQUEST) {
if (resultCode == RESULT_OK && data != null) { if (resultCode == RESULT_OK && data != null) {
throw new IllegalStateException("Pretty sure this is dead code"); throw new IllegalStateException("Pretty sure this is dead code");

View File

@@ -79,9 +79,10 @@ public class FingerprintEnrollFinish extends BiometricEnrollBase {
@Override @Override
public void onBackPressed() { public void onBackPressed() {
super.onBackPressed();
updateFingerprintSuggestionEnableState(); updateFingerprintSuggestionEnableState();
Intent intent = getIntent().putExtra(EXTRA_FINISHED_ENROLL_FINGERPRINT, true);
setResult(RESULT_CANCELED, intent);
finish();
} }
@Override @Override

View File

@@ -74,6 +74,16 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
boolean hasEnrolledFace = false;
boolean hasEnrolledFingerprint = false;
if (data != null) {
hasEnrolledFace = data.getBooleanExtra(EXTRA_FINISHED_ENROLL_FACE, false);
hasEnrolledFingerprint = data.getBooleanExtra(EXTRA_FINISHED_ENROLL_FINGERPRINT, false);
// If we've enrolled a face, we can remove the pending intent to launch FaceEnrollIntro.
if (hasEnrolledFace) {
removeEnrollNextBiometric();
}
}
if (requestCode == BIOMETRIC_FIND_SENSOR_REQUEST && isKeyguardSecure()) { if (requestCode == BIOMETRIC_FIND_SENSOR_REQUEST && isKeyguardSecure()) {
// if lock was already present, do not return intent data since it must have been // if lock was already present, do not return intent data since it must have been
// reported in previous attempts // reported in previous attempts
@@ -85,6 +95,34 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu
if (resultCode == RESULT_FINISHED) { if (resultCode == RESULT_FINISHED) {
data = setFingerprintCount(data); data = setFingerprintCount(data);
} }
if (resultCode == RESULT_CANCELED && hasEnrolledFingerprint) {
// If we are coming from a back press from an already enrolled fingerprint,
// we can finish this activity.
setResult(resultCode, data);
finish();
return;
}
} else if (requestCode == ENROLL_NEXT_BIOMETRIC_REQUEST) {
// See if we can still enroll a fingerprint
boolean canEnrollFinger = checkMaxEnrolled() == 0;
// If we came from the next biometric flow and a user has either
// finished or skipped, we will also finish.
if (resultCode == RESULT_SKIP || resultCode == RESULT_FINISHED) {
// If user skips the enroll next biometric, we will also finish
setResult(RESULT_FINISHED, data);
finish();
} else if (resultCode == RESULT_CANCELED) {
// Note that result_canceled comes from onBackPressed.
// If we can enroll a finger, Stay on this page, else we cannot,
// and finish entirely.
if (!canEnrollFinger) {
finish();
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
return;
} }
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
} }

View File

@@ -17,6 +17,7 @@ package com.android.settings.core;
import android.content.Context; import android.content.Context;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.slice.builders.SliceAction;
import com.android.settings.slices.SliceData; import com.android.settings.slices.SliceData;
@@ -70,4 +71,11 @@ public abstract class SliderPreferenceController extends BasePreferenceControlle
public int getSliceType() { public int getSliceType() {
return SliceData.SliceType.SLIDER; return SliceData.SliceType.SLIDER;
} }
/**
* @return the SliceAction for the end item of the slice.
*/
public SliceAction getSliceEndItem(Context context) {
return null;
}
} }

View File

@@ -152,6 +152,7 @@ import com.android.settings.password.ChooseLockPassword;
import com.android.settings.password.ChooseLockPattern; import com.android.settings.password.ChooseLockPattern;
import com.android.settings.print.PrintJobSettingsFragment; import com.android.settings.print.PrintJobSettingsFragment;
import com.android.settings.print.PrintSettingsFragment; import com.android.settings.print.PrintSettingsFragment;
import com.android.settings.privacy.PrivacyControlsFragment;
import com.android.settings.privacy.PrivacyDashboardFragment; import com.android.settings.privacy.PrivacyDashboardFragment;
import com.android.settings.security.LockscreenDashboardFragment; import com.android.settings.security.LockscreenDashboardFragment;
import com.android.settings.security.SecurityAdvancedSettings; import com.android.settings.security.SecurityAdvancedSettings;
@@ -218,6 +219,7 @@ public class SettingsGateway {
LocationSettings.class.getName(), LocationSettings.class.getName(),
WifiScanningFragment.class.getName(), WifiScanningFragment.class.getName(),
PrivacyDashboardFragment.class.getName(), PrivacyDashboardFragment.class.getName(),
PrivacyControlsFragment.class.getName(),
LocationServices.class.getName(), LocationServices.class.getName(),
SecuritySettings.class.getName(), SecuritySettings.class.getName(),
SecurityAdvancedSettings.class.getName(), SecurityAdvancedSettings.class.getName(),

View File

@@ -234,7 +234,9 @@ public class StorageItemPreferenceController extends AbstractPreferenceControlle
// If isValidPrivateVolume() is true, these preferences will become visible at // If isValidPrivateVolume() is true, these preferences will become visible at
// onLoadFinished. // onLoadFinished.
if (!isValidPrivateVolume()) { if (isValidPrivateVolume()) {
mIsDocumentsPrefShown = isDocumentsPrefShown();
} else {
setPrivateStorageCategoryPreferencesVisibility(false); setPrivateStorageCategoryPreferencesVisibility(false);
} }
} }

View File

@@ -38,6 +38,7 @@ import android.view.View;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.vpn2.VpnUtils; import com.android.settings.vpn2.VpnUtils;
import com.android.settingslib.utils.WorkPolicyUtils;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -54,6 +55,7 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
private final ConnectivityManager mCm; private final ConnectivityManager mCm;
private final VpnManager mVm; private final VpnManager mVm;
private final Resources mResources; private final Resources mResources;
private final WorkPolicyUtils mWorkPolicyUtils;
private static final int MY_USER_ID = UserHandle.myUserId(); private static final int MY_USER_ID = UserHandle.myUserId();
@@ -67,6 +69,7 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
mCm = cm; mCm = cm;
mVm = vm; mVm = vm;
mResources = resources; mResources = resources;
mWorkPolicyUtils = new WorkPolicyUtils(mContext, mPm, mUm, mDpm);
} }
@Override @Override
@@ -228,25 +231,12 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
@Override @Override
public boolean hasWorkPolicyInfo() { public boolean hasWorkPolicyInfo() {
return (getWorkPolicyInfoIntentDO() != null) || (getWorkPolicyInfoIntentPO() != null); return mWorkPolicyUtils.hasWorkPolicy();
} }
@Override @Override
public boolean showWorkPolicyInfo(Context activityContext) { public boolean showWorkPolicyInfo(Context activityContext) {
Intent intent = getWorkPolicyInfoIntentDO(); return mWorkPolicyUtils.showWorkPolicyInfo(activityContext);
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;
} }
@Override @Override
@@ -301,47 +291,6 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe
return UserHandle.USER_NULL; 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 { protected static class EnterprisePrivacySpan extends ClickableSpan {
private final Context mContext; private final Context mContext;

View File

@@ -34,6 +34,7 @@ import androidx.annotation.Nullable;
import com.android.settings.bluetooth.Utils; import com.android.settings.bluetooth.Utils;
import com.android.settings.slices.SliceBackgroundWorker; import com.android.settings.slices.SliceBackgroundWorker;
import com.android.settingslib.bluetooth.BluetoothCallback; import com.android.settingslib.bluetooth.BluetoothCallback;
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
import com.android.settingslib.bluetooth.LocalBluetoothManager; import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.media.LocalMediaManager; import com.android.settingslib.media.LocalMediaManager;
import com.android.settingslib.media.MediaDevice; import com.android.settingslib.media.MediaDevice;
@@ -126,7 +127,7 @@ public class MediaOutputIndicatorWorker extends SliceBackgroundWorker implements
} }
@Nullable @Nullable
MediaController getActiveLocalMediaController() { public MediaController getActiveLocalMediaController() {
return MediaOutputUtils.getActiveLocalMediaController(mContext.getSystemService( return MediaOutputUtils.getActiveLocalMediaController(mContext.getSystemService(
MediaSessionManager.class)); MediaSessionManager.class));
} }
@@ -156,7 +157,7 @@ public class MediaOutputIndicatorWorker extends SliceBackgroundWorker implements
return mMediaDevices; return mMediaDevices;
} }
MediaDevice getCurrentConnectedMediaDevice() { public MediaDevice getCurrentConnectedMediaDevice() {
return mLocalMediaManager.getCurrentConnectedDevice(); return mLocalMediaManager.getCurrentConnectedDevice();
} }
@@ -164,6 +165,15 @@ public class MediaOutputIndicatorWorker extends SliceBackgroundWorker implements
return mPackageName; return mPackageName;
} }
public boolean isDeviceBroadcasting() {
LocalBluetoothLeBroadcast broadcast =
mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastProfile();
if (broadcast == null) {
return false;
}
return broadcast.isEnabled(null);
}
private class DevicesChangedBroadcastReceiver extends BroadcastReceiver { private class DevicesChangedBroadcastReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {

View File

@@ -87,7 +87,8 @@ public class EnabledNetworkModePreferenceController extends
final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId); final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(subId);
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
visible = false; visible = false;
} else if (carrierConfig == null) { } else if (carrierConfig == null
|| !CarrierConfigManager.isConfigForIdentifiedCarrier(carrierConfig)) {
visible = false; visible = false;
} else if (carrierConfig.getBoolean( } else if (carrierConfig.getBoolean(
CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL) CarrierConfigManager.KEY_HIDE_CARRIER_NETWORK_SETTINGS_BOOL)

View File

@@ -16,16 +16,32 @@
package com.android.settings.notification; package com.android.settings.notification;
import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.media.AudioManager; import android.media.AudioManager;
import android.net.Uri;
import android.text.TextUtils; 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.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 { public class MediaVolumePreferenceController extends VolumeSeekBarPreferenceController {
private static final String TAG = "MediaVolumePreCtrl";
private static final String KEY_MEDIA_VOLUME = "media_volume"; private static final String KEY_MEDIA_VOLUME = "media_volume";
private MediaOutputIndicatorWorker mWorker;
public MediaVolumePreferenceController(Context context) { public MediaVolumePreferenceController(Context context) {
super(context, KEY_MEDIA_VOLUME); super(context, KEY_MEDIA_VOLUME);
} }
@@ -66,4 +82,66 @@ public class MediaVolumePreferenceController extends VolumeSeekBarPreferenceCont
public int getMuteIcon() { public int getMuteIcon() {
return R.drawable.ic_media_stream_off; 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;
}
} }

View File

@@ -143,6 +143,9 @@ public class PanelSlicesAdapter
sliceView.setVisibility(View.GONE); sliceView.setVisibility(View.GONE);
} }
// Add divider for the end icon
sliceView.setShowActionDividers(true);
// Log Panel interaction // Log Panel interaction
sliceView.setOnSliceActionListener( sliceView.setOnSliceActionListener(
((eventInfo, sliceItem) -> { ((eventInfo, sliceItem) -> {

View File

@@ -58,6 +58,7 @@ public class TopLevelSecurityEntryPreferenceController extends BasePreferenceCon
new SubSettingLauncher(mContext) new SubSettingLauncher(mContext)
.setDestination(alternativeFragmentClassname) .setDestination(alternativeFragmentClassname)
.setSourceMetricsCategory(getMetricsCategory()) .setSourceMetricsCategory(getMetricsCategory())
.setIsSecondLayerPage(true)
.launch(); .launch();
return true; return true;
} }

View File

@@ -339,6 +339,11 @@ public class SliceBuilderUtils {
inputRangeBuilder.setSubtitle(subtitleText); inputRangeBuilder.setSubtitle(subtitleText);
} }
SliceAction endItemAction = sliderController.getSliceEndItem(context);
if (endItemAction != null) {
inputRangeBuilder.addEndItem(endItemAction);
}
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY) return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY)
.setAccentColor(color) .setAccentColor(color)
.addInputRange(inputRangeBuilder) .addInputRange(inputRangeBuilder)

View File

@@ -377,10 +377,22 @@ public class EnterprisePrivacyFeatureProviderImplTest {
} }
@Test @Test
public void workPolicyInfo_profileOwner_shouldResolveIntent() { public void workPolicyInfo_profileOwner_shouldResolveIntent()
throws PackageManager.NameNotFoundException {
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(null); when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(null);
mProfiles.add(new UserInfo(mManagedProfileUserId, "", "", UserInfo.FLAG_MANAGED_PROFILE)); List<UserHandle> mAllProfiles = new ArrayList<>();
when(mDevicePolicyManager.getProfileOwnerAsUser(mManagedProfileUserId)).thenReturn(mOwner); 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 // If the intent is not resolved, then there's no info to show for PO
assertThat(mProvider.hasWorkPolicyInfo()).isFalse(); assertThat(mProvider.hasWorkPolicyInfo()).isFalse();
@@ -441,7 +453,7 @@ public class EnterprisePrivacyFeatureProviderImplTest {
} }
if (profileOwner) { if (profileOwner) {
when(mPackageManager.queryIntentActivitiesAsUser( when(mPackageManager.queryIntentActivitiesAsUser(
intentEquals(intent), anyInt(), eq(mManagedProfileUserId))) intentEquals(intent), anyInt(), eq(UserHandle.of(mManagedProfileUserId))))
.thenReturn(activities); .thenReturn(activities);
} }

View File

@@ -106,6 +106,7 @@ public class EnabledNetworkModePreferenceControllerTest {
mPersistableBundle = new PersistableBundle(); mPersistableBundle = new PersistableBundle();
doReturn(mPersistableBundle).when(mCarrierConfigCache).getConfig(); doReturn(mPersistableBundle).when(mCarrierConfigCache).getConfig();
doReturn(mPersistableBundle).when(mCarrierConfigCache).getConfigForSubId(SUB_ID); doReturn(mPersistableBundle).when(mCarrierConfigCache).getConfigForSubId(SUB_ID);
mPersistableBundle.putBoolean(CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, true);
mPreference = new ListPreference(mContext); mPreference = new ListPreference(mContext);
mController = new EnabledNetworkModePreferenceController(mContext, KEY); mController = new EnabledNetworkModePreferenceController(mContext, KEY);
mockAllowedNetworkTypes(ALLOWED_ALL_NETWORK_TYPE); mockAllowedNetworkTypes(ALLOWED_ALL_NETWORK_TYPE);
@@ -145,6 +146,14 @@ public class EnabledNetworkModePreferenceControllerTest {
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE); assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
} }
@UiThreadTest
@Test
public void getAvailabilityStatus_carrierConfigNotReady_returnUnavailable() {
mPersistableBundle.putBoolean(CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, false);
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
}
@UiThreadTest @UiThreadTest
@Test @Test
public void getAvailabilityStatus_notWorldPhone_returnAvailable() { public void getAvailabilityStatus_notWorldPhone_returnAvailable() {