Snap for 8555638 from a9b22228bf to tm-qpr1-release

Change-Id: I0d2b9ca52bd3cb368da8376edb6882192489439a
This commit is contained in:
Android Build Coastguard Worker
2022-05-07 05:14:22 +00:00
8 changed files with 189 additions and 58 deletions

View File

@@ -1452,8 +1452,7 @@
<activity <activity
android:name=".datausage.AppDataUsageActivity" android:name=".datausage.AppDataUsageActivity"
android:exported="true" android:exported="true"
android:noHistory="true" android:noHistory="true">
android:permission="android.permission.QUERY_ALL_PACKAGES">
<intent-filter android:priority="1"> <intent-filter android:priority="1">
<action android:name="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS" /> <action android:name="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
@@ -1523,7 +1522,6 @@
<activity-alias android:name=".applications.InstalledAppDetails" <activity-alias android:name=".applications.InstalledAppDetails"
android:label="@string/application_info_label" android:label="@string/application_info_label"
android:exported="true" android:exported="true"
android:permission="android.permission.QUERY_ALL_PACKAGES"
android:targetActivity=".applications.InstalledAppDetailsTop"> android:targetActivity=".applications.InstalledAppDetailsTop">
<intent-filter android:priority="1"> <intent-filter android:priority="1">
<action android:name="android.settings.APPLICATION_DETAILS_SETTINGS" /> <action android:name="android.settings.APPLICATION_DETAILS_SETTINGS" />
@@ -1537,8 +1535,7 @@
<activity android:name=".applications.InstalledAppOpenByDefaultActivity" <activity android:name=".applications.InstalledAppOpenByDefaultActivity"
android:label="@string/application_info_label" android:label="@string/application_info_label"
android:exported="true" android:exported="true">
android:permission="android.permission.QUERY_ALL_PACKAGES">
<intent-filter android:priority="1"> <intent-filter android:priority="1">
<action android:name="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS" /> <action android:name="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS" />
<!-- Also catch legacy "com." prefixed action. --> <!-- Also catch legacy "com." prefixed action. -->
@@ -1913,8 +1910,7 @@
<activity <activity
android:name="Settings$AppUsageAccessSettingsActivity" android:name="Settings$AppUsageAccessSettingsActivity"
android:exported="true" android:exported="true"
android:label="@string/usage_access_title" android:label="@string/usage_access_title">
android:permission="android.permission.QUERY_ALL_PACKAGES">
<intent-filter> <intent-filter>
<action android:name="android.settings.USAGE_ACCESS_SETTINGS"/> <action android:name="android.settings.USAGE_ACCESS_SETTINGS"/>
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT"/>

View File

@@ -1044,8 +1044,12 @@
<!-- Acquire message received during fingerprint enrollment to inform the user they've reached the maximum number of enrollments. [CHAR LIMIT=NONE]--> <!-- Acquire message received during fingerprint enrollment to inform the user they've reached the maximum number of enrollments. [CHAR LIMIT=NONE]-->
<string name="security_settings_fingerprint_v2_enroll_error_max_attempts">You\u2019ve reached the maximum number of attempts</string> <string name="security_settings_fingerprint_v2_enroll_error_max_attempts">You\u2019ve reached the maximum number of attempts</string>
<!-- Message shown in fingerprint security settings home screen. [CHAR LIMIT=NONE]--> <!-- Message text only shown in fingerprint security settings home screen. (tablet) [CHAR LIMIT=NONE]-->
<string name="security_settings_fingerprint_v2_home_screen">Use your fingerprint to unlock your phone or verify it\u2019s you, like when you sign in to apps\n\n<annotation id="url">Learn more</annotation></string> <string name="security_settings_fingerprint_v2_home_screen_text" product="tablet">Use your fingerprint to unlock your tablet or verify it\u2019s you, like when you sign in to apps</string>
<!-- Message text only shown in fingerprint security settings home screen. (device) [CHAR LIMIT=NONE]-->
<string name="security_settings_fingerprint_v2_home_screen_text" product="device">Use your fingerprint to unlock your device or verify it\u2019s you, like when you sign in to apps</string>
<!-- Message text only shown in fingerprint security settings home screen. (phone) [CHAR LIMIT=NONE]-->
<string name="security_settings_fingerprint_v2_home_screen_text" product="default">Use your fingerprint to unlock your phone or verify it\u2019s you, like when you sign in to apps</string>
<!-- Biometric settings --><skip /> <!-- Biometric settings --><skip />
<!-- Title shown for menu item that launches biometric settings. [CHAR LIMIT=66] --> <!-- Title shown for menu item that launches biometric settings. [CHAR LIMIT=66] -->
@@ -1402,7 +1406,7 @@
<string name="lock_settings_picker_biometric_message">Choose your backup screen lock method</string> <string name="lock_settings_picker_biometric_message">Choose your backup screen lock method</string>
<!-- Text shown on the screen lock menu. This text is letting the user know that their IT admin can't reset their screen lock if they forget it, and they can choose to set another lock that would be specifically for their work apps. The place-holders "LINK_BEGIN" and "LINK_END" must NOT be translated. They mark a link to bring the user to enroll a work profile screen lock instead. [CHAR LIMIT=100] --> <!-- Text shown on the screen lock menu. This text is letting the user know that their IT admin can't reset their screen lock if they forget it, and they can choose to set another lock that would be specifically for their work apps. The place-holders "LINK_BEGIN" and "LINK_END" must NOT be translated. They mark a link to bring the user to enroll a work profile screen lock instead. [CHAR LIMIT=100] -->
<string name="lock_settings_picker_admin_restricted_personal_message">This lock can\u2019t be reset by your IT admin. <xliff:g id="link_begin" example="">LINK_BEGIN</xliff:g>Set a separate work lock instead<xliff:g id="link_end" example="">LINK_END</xliff:g></string> <string name="lock_settings_picker_admin_restricted_personal_message">If you forget your screen lock, your IT admin can\u2019t reset it. <annotation id="link">Set a separate work lock</annotation></string>
<!-- Message shown in screen lock picker for setting up a work profile screen lock. [CHAR LIMIT=80] --> <!-- Message shown in screen lock picker for setting up a work profile screen lock. [CHAR LIMIT=80] -->
<string name="lock_settings_picker_profile_message">If you forget this lock, ask your IT admin to reset it</string> <string name="lock_settings_picker_profile_message">If you forget this lock, ask your IT admin to reset it</string>

View File

@@ -173,6 +173,8 @@ public class ManageApplications extends InstrumentedFragment
private static final String EXTRA_HAS_BRIDGE = "hasBridge"; private static final String EXTRA_HAS_BRIDGE = "hasBridge";
private static final String EXTRA_FILTER_TYPE = "filterType"; private static final String EXTRA_FILTER_TYPE = "filterType";
@VisibleForTesting @VisibleForTesting
static final String EXTRA_SEARCH_QUERY = "search_query";
@VisibleForTesting
static final String EXTRA_EXPAND_SEARCH_VIEW = "expand_search_view"; static final String EXTRA_EXPAND_SEARCH_VIEW = "expand_search_view";
// attributes used as keys when passing values to AppInfoDashboardFragment activity // attributes used as keys when passing values to AppInfoDashboardFragment activity
@@ -253,6 +255,8 @@ public class ManageApplications extends InstrumentedFragment
// Whether or not search view is expanded. // Whether or not search view is expanded.
@VisibleForTesting @VisibleForTesting
boolean mExpandSearch; boolean mExpandSearch;
@VisibleForTesting
CharSequence mPreQuery;
private View mRootView; private View mRootView;
private Spinner mFilterSpinner; private Spinner mFilterSpinner;
@@ -358,6 +362,7 @@ public class ManageApplications extends InstrumentedFragment
mFilterType = mFilterType =
savedInstanceState.getInt(EXTRA_FILTER_TYPE, AppFilterRegistry.FILTER_APPS_ALL); savedInstanceState.getInt(EXTRA_FILTER_TYPE, AppFilterRegistry.FILTER_APPS_ALL);
mExpandSearch = savedInstanceState.getBoolean(EXTRA_EXPAND_SEARCH_VIEW); mExpandSearch = savedInstanceState.getBoolean(EXTRA_EXPAND_SEARCH_VIEW);
mPreQuery = savedInstanceState.getCharSequence(EXTRA_SEARCH_QUERY);
} }
mInvalidSizeStr = activity.getText(R.string.invalid_size_value); mInvalidSizeStr = activity.getText(R.string.invalid_size_value);
@@ -544,6 +549,7 @@ public class ManageApplications extends InstrumentedFragment
outState.putBoolean(EXTRA_SHOW_SYSTEM, mShowSystem); outState.putBoolean(EXTRA_SHOW_SYSTEM, mShowSystem);
if (mSearchView != null) { if (mSearchView != null) {
outState.putBoolean(EXTRA_EXPAND_SEARCH_VIEW, !mSearchView.isIconified()); outState.putBoolean(EXTRA_EXPAND_SEARCH_VIEW, !mSearchView.isIconified());
outState.putCharSequence(EXTRA_SEARCH_QUERY, mSearchView.getQuery());
} }
if (mApplications != null) { if (mApplications != null) {
outState.putBoolean(EXTRA_HAS_ENTRIES, mApplications.mHasReceivedLoadEntries); outState.putBoolean(EXTRA_HAS_ENTRIES, mApplications.mHasReceivedLoadEntries);
@@ -683,6 +689,9 @@ public class ManageApplications extends InstrumentedFragment
if (mExpandSearch) { if (mExpandSearch) {
searchMenuItem.expandActionView(); searchMenuItem.expandActionView();
} }
if (!TextUtils.isEmpty(mPreQuery)) {
mSearchView.setQuery(mPreQuery, true);
}
} }
updateOptionsMenu(); updateOptionsMenu();

View File

@@ -145,6 +145,7 @@ public class FingerprintSettings extends SubSettings {
private Drawable mHighlightDrawable; private Drawable mHighlightDrawable;
private int mUserId; private int mUserId;
private CharSequence mFooterTitle; private CharSequence mFooterTitle;
private View.OnClickListener mLearnMoreListener = null;
private boolean mEnrollClicked; private boolean mEnrollClicked;
private long mChallenge; private long mChallenge;
@@ -372,9 +373,8 @@ public class FingerprintSettings extends SubSettings {
mFooterTitle = AnnotationSpan.linkify(footerText, linkInfo, adminLinkInfo); mFooterTitle = AnnotationSpan.linkify(footerText, linkInfo, adminLinkInfo);
} else { } else {
mFooterTitle = AnnotationSpan.linkify( mFooterTitle = getText(R.string.security_settings_fingerprint_v2_home_screen_text);
getText(R.string.security_settings_fingerprint_v2_home_screen), mLearnMoreListener = (v) -> activity.startActivityForResult(helpIntent, 0);
linkInfo, adminLinkInfo);
} }
@@ -474,8 +474,12 @@ public class FingerprintSettings extends SubSettings {
if (context == null) { if (context == null) {
return; return;
} }
root.addPreference(new FooterPreference.Builder(context).setTitle( final FooterPreference footer = new FooterPreference.Builder(context)
mFooterTitle).build()); .setTitle(mFooterTitle).build();
if (mLearnMoreListener != null) {
footer.setLearnMoreAction(mLearnMoreListener);
}
root.addPreference(footer);
} }
private static String genKey(int id) { private static String genKey(int id) {

View File

@@ -75,6 +75,7 @@ public class BluetoothFindBroadcastsFragment extends RestrictedDashboardFragment
CachedBluetoothDevice mCachedDevice; CachedBluetoothDevice mCachedDevice;
@VisibleForTesting @VisibleForTesting
PreferenceCategory mBroadcastSourceListCategory; PreferenceCategory mBroadcastSourceListCategory;
BluetoothFindBroadcastsHeaderController mBluetoothFindBroadcastsHeaderController;
private LocalBluetoothLeBroadcastAssistant mLeBroadcastAssistant; private LocalBluetoothLeBroadcastAssistant mLeBroadcastAssistant;
private BluetoothBroadcastSourcePreference mSelectedPreference; private BluetoothBroadcastSourcePreference mSelectedPreference;
private Executor mExecutor; private Executor mExecutor;
@@ -93,7 +94,6 @@ public class BluetoothFindBroadcastsFragment extends RestrictedDashboardFragment
@Override @Override
public void onSearchStartFailed(int reason) { public void onSearchStartFailed(int reason) {
Log.d(TAG, "onSearchStartFailed: " + reason); Log.d(TAG, "onSearchStartFailed: " + reason);
} }
@Override @Override
@@ -240,6 +240,28 @@ public class BluetoothFindBroadcastsFragment extends RestrictedDashboardFragment
return SettingsEnums.PAGE_UNKNOWN; return SettingsEnums.PAGE_UNKNOWN;
} }
/**
* Starts to scan broadcast source by the BluetoothLeBroadcastAssistant.
*/
public void scanBroadcastSource() {
if (mLeBroadcastAssistant == null) {
Log.w(TAG, "scanBroadcastSource: LeBroadcastAssistant is null!");
return;
}
mLeBroadcastAssistant.startSearchingForSources(getScanFilter());
}
/**
* Leaves the broadcast source by the BluetoothLeBroadcastAssistant.
*/
public void leaveBroadcastSession() {
if (mLeBroadcastAssistant == null || mCachedDevice == null) {
Log.w(TAG, "leaveBroadcastSession: LeBroadcastAssistant or CachedDevice is null!");
return;
}
mLeBroadcastAssistant.removeSource(mCachedDevice.getDevice(), getSourceId());
}
@Override @Override
protected String getLogTag() { protected String getLogTag() {
return TAG; return TAG;
@@ -256,13 +278,18 @@ public class BluetoothFindBroadcastsFragment extends RestrictedDashboardFragment
if (mCachedDevice != null) { if (mCachedDevice != null) {
Lifecycle lifecycle = getSettingsLifecycle(); Lifecycle lifecycle = getSettingsLifecycle();
controllers.add(new BluetoothFindBroadcastsHeaderController(context, this, mBluetoothFindBroadcastsHeaderController = new BluetoothFindBroadcastsHeaderController(
mCachedDevice, lifecycle, mManager)); context, this, mCachedDevice, lifecycle, mManager);
controllers.add(mBluetoothFindBroadcastsHeaderController);
} }
return controllers; return controllers;
} }
private LocalBluetoothLeBroadcastAssistant getLeBroadcastAssistant() { /**
* Gets the LocalBluetoothLeBroadcastAssistant
* @return the LocalBluetoothLeBroadcastAssistant
*/
public LocalBluetoothLeBroadcastAssistant getLeBroadcastAssistant() {
if (mManager == null) { if (mManager == null) {
Log.w(TAG, "getLeBroadcastAssistant: LocalBluetoothManager is null!"); Log.w(TAG, "getLeBroadcastAssistant: LocalBluetoothManager is null!");
return null; return null;
@@ -292,6 +319,11 @@ public class BluetoothFindBroadcastsFragment extends RestrictedDashboardFragment
} }
item.updateMetadataAndRefreshUi(source, isConnected); item.updateMetadataAndRefreshUi(source, isConnected);
item.setOrder(isConnected ? 0 : 1); item.setOrder(isConnected ? 0 : 1);
//refresh the header
if (mBluetoothFindBroadcastsHeaderController != null) {
mBluetoothFindBroadcastsHeaderController.refreshUi();
}
} }
private BluetoothBroadcastSourcePreference createBluetoothBroadcastSourcePreference( private BluetoothBroadcastSourcePreference createBluetoothBroadcastSourcePreference(

View File

@@ -16,22 +16,24 @@
package com.android.settings.bluetooth; package com.android.settings.bluetooth;
import android.bluetooth.BluetoothProfile;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.content.Intent;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.preference.PreferenceCategory; import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.settings.R; import com.android.settings.R;
import com.android.settingslib.bluetooth.BluetoothBroadcastUtils;
import com.android.settingslib.bluetooth.CachedBluetoothDevice; import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant;
import com.android.settingslib.bluetooth.LocalBluetoothManager; import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.qrcode.QrCodeScanModeActivity;
import com.android.settingslib.widget.LayoutPreference; import com.android.settingslib.widget.LayoutPreference;
/** /**
@@ -52,11 +54,12 @@ public class BluetoothFindBroadcastsHeaderController extends BluetoothDetailsCon
LinearLayout mBtnBroadcastLayout; LinearLayout mBtnBroadcastLayout;
Button mBtnLeaveBroadcast; Button mBtnLeaveBroadcast;
Button mBtnScanQrCode; Button mBtnScanQrCode;
BluetoothFindBroadcastsFragment mBluetoothFindBroadcastsFragment;
public BluetoothFindBroadcastsHeaderController(Context context, public BluetoothFindBroadcastsHeaderController(Context context,
PreferenceFragmentCompat fragment, CachedBluetoothDevice device, Lifecycle lifecycle, BluetoothFindBroadcastsFragment fragment, CachedBluetoothDevice device,
LocalBluetoothManager bluetoothManager) { Lifecycle lifecycle, LocalBluetoothManager bluetoothManager) {
super(context, fragment, device, lifecycle); super(context, fragment, device, lifecycle);
mBluetoothFindBroadcastsFragment = fragment;
} }
@Override @Override
@@ -101,20 +104,41 @@ public class BluetoothFindBroadcastsHeaderController extends BluetoothDetailsCon
mBtnFindBroadcast.setVisibility(View.VISIBLE); mBtnFindBroadcast.setVisibility(View.VISIBLE);
mBtnBroadcastLayout.setVisibility(View.GONE); mBtnBroadcastLayout.setVisibility(View.GONE);
} }
mBtnLeaveBroadcast.setEnabled(false);
if (mBluetoothFindBroadcastsFragment != null && mCachedDevice != null) {
LocalBluetoothLeBroadcastAssistant broadcastAssistant =
mBluetoothFindBroadcastsFragment.getLeBroadcastAssistant();
if (broadcastAssistant != null
&& broadcastAssistant.getConnectionStatus(mCachedDevice.getDevice())
== BluetoothProfile.STATE_CONNECTED) {
mBtnLeaveBroadcast.setEnabled(true);
}
}
} }
private void scanBroadcastSource() { private void scanBroadcastSource() {
// TODO(b/228258236) : Call the LocalBluetoothLeBroadcastAssistant // TODO(b/231543455) : Using the BluetoothDeviceUpdater to refactor it.
// to start searching for source if (mBluetoothFindBroadcastsFragment == null) {
return;
}
mBluetoothFindBroadcastsFragment.scanBroadcastSource();
} }
private void leaveBroadcastSession() { private void leaveBroadcastSession() {
// TODO(b/228258236) : Call the LocalBluetoothLeBroadcastAssistant if (mBluetoothFindBroadcastsFragment == null) {
// to leave the broadcast session return;
}
mBluetoothFindBroadcastsFragment.leaveBroadcastSession();
} }
private void launchQrCodeScanner() { private void launchQrCodeScanner() {
// TODO(b/228259065) : Launch the QR code scanner page by intent final Intent intent = new Intent(mContext, QrCodeScanModeActivity.class);
intent.setAction(BluetoothBroadcastUtils.ACTION_BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER)
.putExtra(BluetoothBroadcastUtils.EXTRA_BLUETOOTH_SINK_IS_GROUP, false)
.putExtra(BluetoothBroadcastUtils.EXTRA_BLUETOOTH_DEVICE_SINK,
mCachedDevice.getDevice());
mContext.startActivity(intent);
} }
@Override @Override
@@ -128,4 +152,11 @@ public class BluetoothFindBroadcastsHeaderController extends BluetoothDetailsCon
public String getPreferenceKey() { public String getPreferenceKey() {
return KEY_BROADCAST_HEADER; return KEY_BROADCAST_HEADER;
} }
/**
* Updates the UI
*/
public void refreshUi() {
updateHeaderLayout();
}
} }

View File

@@ -67,7 +67,6 @@ import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockscreenCredential; import com.android.internal.widget.LockscreenCredential;
import com.android.settings.EncryptionInterstitial; import com.android.settings.EncryptionInterstitial;
import com.android.settings.EventLogTags; import com.android.settings.EventLogTags;
import com.android.settings.LinkifyUtils;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.SettingsActivity; import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment; import com.android.settings.SettingsPreferenceFragment;
@@ -78,7 +77,9 @@ import com.android.settings.core.SubSettingLauncher;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment; import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.safetycenter.LockScreenSafetySource; import com.android.settings.safetycenter.LockScreenSafetySource;
import com.android.settings.search.SearchFeatureProvider; import com.android.settings.search.SearchFeatureProvider;
import com.android.settings.utils.AnnotationSpan;
import com.android.settingslib.RestrictedPreference; import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.widget.FooterPreference;
import com.google.android.setupcompat.util.WizardManagerHelper; import com.google.android.setupcompat.util.WizardManagerHelper;
@@ -403,32 +404,7 @@ public class ChooseLockGeneric extends SettingsActivity {
WORK_PROFILE_SCREEN_LOCK_SETUP_MESSAGE, WORK_PROFILE_SCREEN_LOCK_SETUP_MESSAGE,
() -> getString(R.string.lock_settings_picker_profile_message))); () -> getString(R.string.lock_settings_picker_profile_message)));
} else { } else {
int profileUserId = Utils.getManagedProfileId(mUserManager, mUserId); textView.setText("");
if (mController.isScreenLockRestrictedByAdmin()
&& profileUserId != UserHandle.USER_NULL) {
final StringBuilder description = new StringBuilder(
mDpm.getResources().getString(
WORK_PROFILE_IT_ADMIN_CANT_RESET_SCREEN_LOCK,
() -> getString(
R.string.lock_settings_picker_admin_restricted_personal_message)));
final LinkifyUtils.OnClickListener clickListener = () -> {
final Bundle extras = new Bundle();
extras.putInt(Intent.EXTRA_USER_ID, profileUserId);
if (mUserPassword != null) {
extras.putParcelable(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
mUserPassword);
}
new SubSettingLauncher(getActivity())
.setDestination(ChooseLockGenericFragment.class.getName())
.setSourceMetricsCategory(getMetricsCategory())
.setArguments(extras)
.launch();
finish();
};
LinkifyUtils.linkify(textView, description, clickListener);
} else {
textView.setText("");
}
} }
} }
} }
@@ -633,10 +609,39 @@ public class ChooseLockGeneric extends SettingsActivity {
protected void addPreferences() { protected void addPreferences() {
addPreferencesFromResource(R.xml.security_settings_picker); addPreferencesFromResource(R.xml.security_settings_picker);
final Preference footer = findPreference(KEY_LOCK_SETTINGS_FOOTER); int profileUserId = Utils.getManagedProfileId(mUserManager, mUserId);
final FooterPreference footer = findPreference(KEY_LOCK_SETTINGS_FOOTER);
if (!TextUtils.isEmpty(mCallerAppName) && !mIsCallingAppAdmin) { if (!TextUtils.isEmpty(mCallerAppName) && !mIsCallingAppAdmin) {
footer.setVisible(true); footer.setVisible(true);
footer.setTitle(getFooterString()); footer.setTitle(getFooterString());
} else if (!mForFace && !mForBiometrics && !mForFingerprint && !mIsManagedProfile
&& mController.isScreenLockRestrictedByAdmin()
&& profileUserId != UserHandle.USER_NULL) {
CharSequence description =
mDpm.getResources().getString(WORK_PROFILE_IT_ADMIN_CANT_RESET_SCREEN_LOCK,
() -> null);
if (description == null) {
description = getText(
R.string.lock_settings_picker_admin_restricted_personal_message);
}
final AnnotationSpan.LinkInfo linkInfo = new AnnotationSpan.LinkInfo(
AnnotationSpan.LinkInfo.DEFAULT_ANNOTATION, (view) -> {
final Bundle extras = new Bundle();
extras.putInt(Intent.EXTRA_USER_ID, profileUserId);
if (mUserPassword != null) {
extras.putParcelable(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
mUserPassword);
}
new SubSettingLauncher(getActivity())
.setDestination(ChooseLockGenericFragment.class.getName())
.setSourceMetricsCategory(getMetricsCategory())
.setArguments(extras)
.launch();
finish();
});
CharSequence footerText = AnnotationSpan.linkify(description, linkInfo);
footer.setVisible(true);
footer.setTitle(footerText);
} else { } else {
footer.setVisible(false); footer.setVisible(false);
} }

View File

@@ -188,6 +188,24 @@ public class ManageApplicationsTest {
verify(searchMenu).expandActionView(); verify(searchMenu).expandActionView();
} }
@Test
public void onCreateOptionsMenu_hasPreQuery_shouldSetQuery() {
final SearchView searchView = mock(SearchView.class);
final MenuItem searchMenu = mock(MenuItem.class);
final MenuItem helpMenu = mock(MenuItem.class);
when(searchMenu.getActionView()).thenReturn(searchView);
when(mMenu.findItem(R.id.search_app_list_menu)).thenReturn(searchMenu);
when(mMenu.add(anyInt() /* groupId */, anyInt() /* itemId */, anyInt() /* order */,
anyInt() /* titleRes */)).thenReturn(helpMenu);
doReturn("Test").when(mFragment).getText(anyInt() /* resId */);
doNothing().when(mFragment).updateOptionsMenu();
mFragment.mPreQuery = "test";
mFragment.onCreateOptionsMenu(mMenu, mock(MenuInflater.class));
verify(searchView).setQuery("test", true);
}
@Test @Test
public void onQueryTextChange_shouldFilterSearchInApplicationsAdapter() { public void onQueryTextChange_shouldFilterSearchInApplicationsAdapter() {
final ManageApplications.ApplicationsAdapter adapter = final ManageApplications.ApplicationsAdapter adapter =
@@ -518,6 +536,38 @@ public class ManageApplicationsTest {
assertThat(bundle.getBoolean(ManageApplications.EXTRA_EXPAND_SEARCH_VIEW)).isFalse(); assertThat(bundle.getBoolean(ManageApplications.EXTRA_EXPAND_SEARCH_VIEW)).isFalse();
} }
@Test
public void onSaveInstanceState_noSearchView_shouldNotSaveQuery() {
final Bundle bundle = new Bundle();
ReflectionHelpers.setField(mFragment, "mResetAppsHelper", mock(ResetAppsHelper.class));
ReflectionHelpers.setField(mFragment, "mFilter", mock(AppFilterItem.class));
ReflectionHelpers.setField(mFragment, "mApplications",
mock(ManageApplications.ApplicationsAdapter.class));
mFragment.onSaveInstanceState(bundle);
assertThat(bundle.containsKey(ManageApplications.EXTRA_SEARCH_QUERY)).isFalse();
}
@Test
public void onSaveInstanceState_searchViewSet_shouldSaveQuery() {
final SearchView searchView = mock(SearchView.class);
final Bundle bundle = new Bundle();
ReflectionHelpers.setField(mFragment, "mResetAppsHelper", mock(ResetAppsHelper.class));
ReflectionHelpers.setField(mFragment, "mFilter", mock(AppFilterItem.class));
ReflectionHelpers.setField(mFragment, "mApplications",
mock(ManageApplications.ApplicationsAdapter.class));
ReflectionHelpers.setField(mFragment, "mSearchView", searchView);
when(searchView.isIconified()).thenReturn(true);
when(searchView.getQuery()).thenReturn("test");
mFragment.onSaveInstanceState(bundle);
assertThat(bundle.containsKey(ManageApplications.EXTRA_SEARCH_QUERY)).isTrue();
assertThat(bundle.getCharSequence(ManageApplications.EXTRA_SEARCH_QUERY))
.isEqualTo("test");
}
@Test @Test
public void createHeader_batteryListType_hasCorrectItems() { public void createHeader_batteryListType_hasCorrectItems() {
ReflectionHelpers.setField(mFragment, "mListType", ManageApplications.LIST_TYPE_HIGH_POWER); ReflectionHelpers.setField(mFragment, "mListType", ManageApplications.LIST_TYPE_HIGH_POWER);