Snap for 8572535 from 695a47e469 to tm-release

Change-Id: I27fc4000cff94eedae98b2227000dddf168165fa
This commit is contained in:
Android Build Coastguard Worker
2022-05-11 23:09:11 +00:00
8 changed files with 129 additions and 25 deletions

View File

@@ -1411,8 +1411,10 @@
<!-- Message shown in screen lock picker while setting up the backup/fallback screen lock method for biometrics. Users can choose to use this method to unlock the screen instead of biometrics, or when biometrics are not accepted. [CHAR LIMIT=80] [BACKUP_MESSAGE_ID=2799884038398627882] --> <!-- Message shown in screen lock picker while setting up the backup/fallback screen lock method for biometrics. Users can choose to use this method to unlock the screen instead of biometrics, or when biometrics are not accepted. [CHAR LIMIT=80] [BACKUP_MESSAGE_ID=2799884038398627882] -->
<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. [CHAR LIMIT=100] -->
<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> <string name="lock_settings_picker_admin_restricted_personal_message">If you forget your screen lock, your IT admin can\u2019t reset it.</string>
<!-- Text shown on the screen lock menu. This text is letting the user know that they can choose to set another lock that would be specifically for their work apps. [CHAR LIMIT=100] -->
<string name="lock_settings_picker_admin_restricted_personal_message_action">Set a separate work lock</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

@@ -55,6 +55,7 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
private BluetoothPairingController mPairingController; private BluetoothPairingController mPairingController;
private BluetoothPairingDialog mPairingDialogActivity; private BluetoothPairingDialog mPairingDialogActivity;
private EditText mPairingView; private EditText mPairingView;
private boolean mPositiveClicked = false;
/** /**
* The interface we expect a listener to implement. Typically this should be done by * The interface we expect a listener to implement. Typically this should be done by
* the controller. * the controller.
@@ -85,7 +86,9 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
mPairingController.onCancel(); if (!mPositiveClicked) {
mPairingController.onCancel();
}
} }
@Override @Override
@@ -110,6 +113,7 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_POSITIVE) { if (which == DialogInterface.BUTTON_POSITIVE) {
mPositiveClicked = true;
mPairingController.onDialogPositiveClick(this); mPairingController.onDialogPositiveClick(this);
} else if (which == DialogInterface.BUTTON_NEGATIVE) { } else if (which == DialogInterface.BUTTON_NEGATIVE) {
mPairingController.onDialogNegativeClick(this); mPairingController.onDialogNegativeClick(this);

View File

@@ -39,6 +39,7 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
private static final String SETTINGS_PACKAGE_NAME = "com.android.settings"; private static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
private static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui"; private static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private static final String SLICE_ACTION = "com.android.settings.SEARCH_RESULT_TRAMPOLINE";
@VisibleForTesting @VisibleForTesting
static final String KEY_CONNECTED_DEVICES = "connected_device_list"; static final String KEY_CONNECTED_DEVICES = "connected_device_list";
@@ -72,8 +73,10 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
SettingsUIDeviceConfig.BT_NEAR_BY_SUGGESTION_ENABLED, true); SettingsUIDeviceConfig.BT_NEAR_BY_SUGGESTION_ENABLED, true);
String callingAppPackageName = PasswordUtils.getCallingAppPackageName( String callingAppPackageName = PasswordUtils.getCallingAppPackageName(
getActivity().getActivityToken()); getActivity().getActivityToken());
String action = getIntent() != null ? getIntent().getAction() : "";
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "onAttach() calling package name is : " + callingAppPackageName); Log.d(TAG, "onAttach() calling package name is : " + callingAppPackageName
+ ", action : " + action);
} }
use(AvailableMediaDeviceGroupController.class).init(this); use(AvailableMediaDeviceGroupController.class).init(this);
use(ConnectedDeviceGroupController.class).init(this); use(ConnectedDeviceGroupController.class).init(this);
@@ -81,9 +84,15 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
use(SlicePreferenceController.class).setSliceUri(nearbyEnabled use(SlicePreferenceController.class).setSliceUri(nearbyEnabled
? Uri.parse(getString(R.string.config_nearby_devices_slice_uri)) ? Uri.parse(getString(R.string.config_nearby_devices_slice_uri))
: null); : null);
use(DiscoverableFooterPreferenceController.class).setAlwaysDiscoverable( use(DiscoverableFooterPreferenceController.class)
TextUtils.equals(SETTINGS_PACKAGE_NAME, callingAppPackageName) .setAlwaysDiscoverable(isAlwaysDiscoverable(callingAppPackageName, action));
|| TextUtils.equals(SYSTEMUI_PACKAGE_NAME, callingAppPackageName)); }
@VisibleForTesting
boolean isAlwaysDiscoverable(String callingAppPackageName, String action) {
return TextUtils.equals(SLICE_ACTION, action) ? false
: TextUtils.equals(SETTINGS_PACKAGE_NAME, callingAppPackageName)
|| TextUtils.equals(SYSTEMUI_PACKAGE_NAME, callingAppPackageName);
} }
/** /**

View File

@@ -38,7 +38,7 @@ import com.android.settings.applications.appinfo.AppLocaleDetails;
import com.android.settings.core.SettingsBaseActivity; import com.android.settings.core.SettingsBaseActivity;
public class AppLocalePickerActivity extends SettingsBaseActivity public class AppLocalePickerActivity extends SettingsBaseActivity
implements LocalePickerWithRegion.LocaleSelectedListener { implements LocalePickerWithRegion.LocaleSelectedListener, MenuItem.OnActionExpandListener {
private static final String TAG = AppLocalePickerActivity.class.getSimpleName(); private static final String TAG = AppLocalePickerActivity.class.getSimpleName();
private String mPackageName; private String mPackageName;
@@ -75,9 +75,10 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
mLocalePickerWithRegion = LocalePickerWithRegion.createLanguagePicker( mLocalePickerWithRegion = LocalePickerWithRegion.createLanguagePicker(
mContextAsUser, mContextAsUser,
AppLocalePickerActivity.this, this,
false /* translate only */, false /* translate only */,
mPackageName); mPackageName,
this);
mAppLocaleDetails = AppLocaleDetails.newInstance(mPackageName); mAppLocaleDetails = AppLocaleDetails.newInstance(mPackageName);
mAppLocaleDetailContainer = launchAppLocaleDetailsPage(); mAppLocaleDetailContainer = launchAppLocaleDetailsPage();
// Launch Locale picker part. // Launch Locale picker part.
@@ -103,6 +104,18 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
finish(); finish();
} }
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/);
return true;
}
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/);
return true;
}
/** Sets the app's locale to the supplied language tag */ /** Sets the app's locale to the supplied language tag */
private void setAppDefaultLocale(String languageTag) { private void setAppDefaultLocale(String languageTag) {
LocaleManager localeManager = mContextAsUser.getSystemService(LocaleManager.class); LocaleManager localeManager = mContextAsUser.getSystemService(LocaleManager.class);

View File

@@ -16,8 +16,12 @@
package com.android.settings.network.telephony; package com.android.settings.network.telephony;
import static android.content.Context.MODE_PRIVATE;
import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.util.Log;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
@@ -27,14 +31,27 @@ public class SubscriptionActionDialogActivity extends FragmentActivity {
private static final String TAG = "SubscriptionActionDialogActivity"; private static final String TAG = "SubscriptionActionDialogActivity";
// Arguments // Arguments
protected static final String ARG_SUB_ID = "sub_id"; protected static final String ARG_SUB_ID = "sub_id";
protected SubscriptionManager mSubscriptionManager; protected SubscriptionManager mSubscriptionManager;
public static final String SIM_ACTION_DIALOG_PREFS = "sim_action_dialog_prefs";
// Shared preference keys
public static final String KEY_PROGRESS_STATE = "progress_state";
public static final int PROGRESS_IS_NOT_SHOWING = 0;
public static final int PROGRESS_IS_SHOWING = 1;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mSubscriptionManager = getSystemService(SubscriptionManager.class); mSubscriptionManager = getSystemService(SubscriptionManager.class);
setProgressState(PROGRESS_IS_NOT_SHOWING);
}
@Override
public void finish() {
setProgressState(PROGRESS_IS_NOT_SHOWING);
super.finish();
} }
/** /**
@@ -44,11 +61,13 @@ public class SubscriptionActionDialogActivity extends FragmentActivity {
*/ */
protected void showProgressDialog(String message) { protected void showProgressDialog(String message) {
ProgressDialogFragment.show(getFragmentManager(), message, null); ProgressDialogFragment.show(getFragmentManager(), message, null);
setProgressState(PROGRESS_IS_SHOWING);
} }
/** Dismisses the loading dialog. */ /** Dismisses the loading dialog. */
protected void dismissProgressDialog() { protected void dismissProgressDialog() {
ProgressDialogFragment.dismiss(getFragmentManager()); ProgressDialogFragment.dismiss(getFragmentManager());
setProgressState(PROGRESS_IS_NOT_SHOWING);
} }
/** /**
@@ -60,4 +79,10 @@ public class SubscriptionActionDialogActivity extends FragmentActivity {
protected void showErrorDialog(String title, String message) { protected void showErrorDialog(String title, String message) {
AlertDialogFragment.show(this, title, message); AlertDialogFragment.show(this, title, message);
} }
protected void setProgressState(int state) {
final SharedPreferences prefs = getSharedPreferences(SIM_ACTION_DIALOG_PREFS, MODE_PRIVATE);
prefs.edit().putInt(KEY_PROGRESS_STATE, state).apply();
Log.i(TAG, "setProgressState:" + state);
}
} }

View File

@@ -25,6 +25,7 @@ import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_NONE;
import static android.app.admin.DevicePolicyResources.Strings.Settings.LOCK_SETTINGS_NEW_PROFILE_LOCK_TITLE; import static android.app.admin.DevicePolicyResources.Strings.Settings.LOCK_SETTINGS_NEW_PROFILE_LOCK_TITLE;
import static android.app.admin.DevicePolicyResources.Strings.Settings.LOCK_SETTINGS_UPDATE_PROFILE_LOCK_TITLE; import static android.app.admin.DevicePolicyResources.Strings.Settings.LOCK_SETTINGS_UPDATE_PROFILE_LOCK_TITLE;
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_IT_ADMIN_CANT_RESET_SCREEN_LOCK; import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_IT_ADMIN_CANT_RESET_SCREEN_LOCK;
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_IT_ADMIN_CANT_RESET_SCREEN_LOCK_ACTION;
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_SCREEN_LOCK_SETUP_MESSAGE; import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_SCREEN_LOCK_SETUP_MESSAGE;
import static com.android.settings.password.ChooseLockPassword.ChooseLockPasswordFragment.RESULT_FINISHED; import static com.android.settings.password.ChooseLockPassword.ChooseLockPasswordFragment.RESULT_FINISHED;
@@ -78,7 +79,6 @@ 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.android.settingslib.widget.FooterPreference;
@@ -621,15 +621,20 @@ public class ChooseLockGeneric extends SettingsActivity {
} else if (!mForFace && !mForBiometrics && !mForFingerprint && !mIsManagedProfile } else if (!mForFace && !mForBiometrics && !mForFingerprint && !mIsManagedProfile
&& mController.isScreenLockRestrictedByAdmin() && mController.isScreenLockRestrictedByAdmin()
&& profileUserId != UserHandle.USER_NULL) { && profileUserId != UserHandle.USER_NULL) {
CharSequence description = final StringBuilder description = new StringBuilder(
mDpm.getResources().getString(WORK_PROFILE_IT_ADMIN_CANT_RESET_SCREEN_LOCK, mDpm.getResources().getString(
() -> null); WORK_PROFILE_IT_ADMIN_CANT_RESET_SCREEN_LOCK,
if (description == null) { () -> getString(
description = getText( R.string.lock_settings_picker_admin_restricted_personal_message)));
R.string.lock_settings_picker_admin_restricted_personal_message); footer.setVisible(true);
} footer.setTitle(description);
final AnnotationSpan.LinkInfo linkInfo = new AnnotationSpan.LinkInfo(
AnnotationSpan.LinkInfo.DEFAULT_ANNOTATION, (view) -> { final StringBuilder setLockText = new StringBuilder(
mDpm.getResources().getString(
WORK_PROFILE_IT_ADMIN_CANT_RESET_SCREEN_LOCK_ACTION,
() -> getString(
R.string.lock_settings_picker_admin_restricted_personal_message_action)));
View.OnClickListener setLockClickListener = (v) -> {
final Bundle extras = new Bundle(); final Bundle extras = new Bundle();
extras.putInt(Intent.EXTRA_USER_ID, profileUserId); extras.putInt(Intent.EXTRA_USER_ID, profileUserId);
if (mUserPassword != null) { if (mUserPassword != null) {
@@ -642,10 +647,9 @@ public class ChooseLockGeneric extends SettingsActivity {
.setArguments(extras) .setArguments(extras)
.launch(); .launch();
finish(); finish();
}); };
CharSequence footerText = AnnotationSpan.linkify(description, linkInfo); footer.setLearnMoreText(setLockText);
footer.setVisible(true); footer.setLearnMoreAction(setLockClickListener);
footer.setTitle(footerText);
} else { } else {
footer.setVisible(false); footer.setVisible(false);
} }

View File

@@ -16,8 +16,11 @@
package com.android.settings.sim; package com.android.settings.sim;
import static android.content.Context.MODE_PRIVATE;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.telecom.PhoneAccountHandle; import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager; import android.telecom.TelecomManager;
@@ -32,6 +35,7 @@ import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.network.telephony.SubscriptionActionDialogActivity;
import java.util.List; import java.util.List;
@@ -60,6 +64,7 @@ public class SimDialogActivity extends FragmentActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getWindow().addSystemFlags( getWindow().addSystemFlags(
WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
showOrUpdateDialog(); showOrUpdateDialog();
@@ -72,6 +77,13 @@ public class SimDialogActivity extends FragmentActivity {
showOrUpdateDialog(); showOrUpdateDialog();
} }
private int getProgressState() {
final SharedPreferences prefs = getSharedPreferences(
SubscriptionActionDialogActivity.SIM_ACTION_DIALOG_PREFS, MODE_PRIVATE);
return prefs.getInt(SubscriptionActionDialogActivity.KEY_PROGRESS_STATE,
SubscriptionActionDialogActivity.PROGRESS_IS_NOT_SHOWING);
}
private void showOrUpdateDialog() { private void showOrUpdateDialog() {
final int dialogType = getIntent().getIntExtra(DIALOG_TYPE_KEY, INVALID_PICK); final int dialogType = getIntent().getIntExtra(DIALOG_TYPE_KEY, INVALID_PICK);
@@ -80,6 +92,13 @@ public class SimDialogActivity extends FragmentActivity {
return; return;
} }
if (dialogType == PREFERRED_PICK
&& getProgressState() == SubscriptionActionDialogActivity.PROGRESS_IS_SHOWING) {
Log.d(TAG, "Finish the sim dialog since the sim action dialog is showing the progress");
finish();
return;
}
final String tag = Integer.toString(dialogType); final String tag = Integer.toString(dialogType);
final FragmentManager fragmentManager = getSupportFragmentManager(); final FragmentManager fragmentManager = getSupportFragmentManager();
SimDialogFragment fragment = (SimDialogFragment) fragmentManager.findFragmentByTag(tag); SimDialogFragment fragment = (SimDialogFragment) fragmentManager.findFragmentByTag(tag);

View File

@@ -54,16 +54,24 @@ public class ConnectedDeviceDashboardFragmentTest {
private static final String KEY_DISCOVERABLE_FOOTER = "discoverable_footer"; private static final String KEY_DISCOVERABLE_FOOTER = "discoverable_footer";
private static final String KEY_SEE_ALL = "previously_connected_devices_see_all"; private static final String KEY_SEE_ALL = "previously_connected_devices_see_all";
private static final String KEY_ADD_BT_DEVICES = "add_bt_devices"; private static final String KEY_ADD_BT_DEVICES = "add_bt_devices";
private static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
private static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui";
private static final String SLICE_ACTION = "com.android.settings.SEARCH_RESULT_TRAMPOLINE";
private static final String TEST_APP_NAME = "com.testapp.settings";
private static final String TEST_ACTION = "com.testapp.settings.ACTION_START";
@Mock @Mock
private PackageManager mPackageManager; private PackageManager mPackageManager;
private Context mContext; private Context mContext;
private ConnectedDeviceDashboardFragment mFragment;
@Before @Before
public void setUp() { public void setUp() {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application); mContext = spy(RuntimeEnvironment.application);
mFragment = new ConnectedDeviceDashboardFragment();
doReturn(mPackageManager).when(mContext).getPackageManager(); doReturn(mPackageManager).when(mContext).getPackageManager();
doReturn(true).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH); doReturn(true).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
} }
@@ -87,6 +95,26 @@ public class ConnectedDeviceDashboardFragmentTest {
KEY_NEARBY_DEVICES, KEY_DISCOVERABLE_FOOTER, KEY_SEE_ALL); KEY_NEARBY_DEVICES, KEY_DISCOVERABLE_FOOTER, KEY_SEE_ALL);
} }
@Test
public void isAlwaysDiscoverable_callingAppIsNotFromSystemApp_returnsFalse() {
assertThat(mFragment.isAlwaysDiscoverable(TEST_APP_NAME, TEST_ACTION)).isFalse();
}
@Test
public void isAlwaysDiscoverable_callingAppIsFromSettings_returnsTrue() {
assertThat(mFragment.isAlwaysDiscoverable(SETTINGS_PACKAGE_NAME, TEST_ACTION)).isTrue();
}
@Test
public void isAlwaysDiscoverable_callingAppIsFromSystemUI_returnsTrue() {
assertThat(mFragment.isAlwaysDiscoverable(SYSTEMUI_PACKAGE_NAME, TEST_ACTION)).isTrue();
}
@Test
public void isAlwaysDiscoverable_actionIsFromSlice_returnsFalse() {
assertThat(mFragment.isAlwaysDiscoverable(SYSTEMUI_PACKAGE_NAME, SLICE_ACTION)).isFalse();
}
@Test @Test
public void getPreferenceControllers_containSlicePrefController() { public void getPreferenceControllers_containSlicePrefController() {
final List<BasePreferenceController> controllers = final List<BasePreferenceController> controllers =