Snap for 8572535 from 695a47e469
to tm-release
Change-Id: I27fc4000cff94eedae98b2227000dddf168165fa
This commit is contained in:
@@ -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] -->
|
||||
<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] -->
|
||||
<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>
|
||||
<!-- 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.</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] -->
|
||||
<string name="lock_settings_picker_profile_message">If you forget this lock, ask your IT admin to reset it</string>
|
||||
|
@@ -55,6 +55,7 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
|
||||
private BluetoothPairingController mPairingController;
|
||||
private BluetoothPairingDialog mPairingDialogActivity;
|
||||
private EditText mPairingView;
|
||||
private boolean mPositiveClicked = false;
|
||||
/**
|
||||
* The interface we expect a listener to implement. Typically this should be done by
|
||||
* the controller.
|
||||
@@ -85,7 +86,9 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mPairingController.onCancel();
|
||||
if (!mPositiveClicked) {
|
||||
mPairingController.onCancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,6 +113,7 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||
mPositiveClicked = true;
|
||||
mPairingController.onDialogPositiveClick(this);
|
||||
} else if (which == DialogInterface.BUTTON_NEGATIVE) {
|
||||
mPairingController.onDialogNegativeClick(this);
|
||||
|
@@ -39,6 +39,7 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
|
||||
private static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
|
||||
private static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui";
|
||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
private static final String SLICE_ACTION = "com.android.settings.SEARCH_RESULT_TRAMPOLINE";
|
||||
|
||||
@VisibleForTesting
|
||||
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);
|
||||
String callingAppPackageName = PasswordUtils.getCallingAppPackageName(
|
||||
getActivity().getActivityToken());
|
||||
String action = getIntent() != null ? getIntent().getAction() : "";
|
||||
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(ConnectedDeviceGroupController.class).init(this);
|
||||
@@ -81,9 +84,15 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
|
||||
use(SlicePreferenceController.class).setSliceUri(nearbyEnabled
|
||||
? Uri.parse(getString(R.string.config_nearby_devices_slice_uri))
|
||||
: null);
|
||||
use(DiscoverableFooterPreferenceController.class).setAlwaysDiscoverable(
|
||||
TextUtils.equals(SETTINGS_PACKAGE_NAME, callingAppPackageName)
|
||||
|| TextUtils.equals(SYSTEMUI_PACKAGE_NAME, callingAppPackageName));
|
||||
use(DiscoverableFooterPreferenceController.class)
|
||||
.setAlwaysDiscoverable(isAlwaysDiscoverable(callingAppPackageName, action));
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -38,7 +38,7 @@ import com.android.settings.applications.appinfo.AppLocaleDetails;
|
||||
import com.android.settings.core.SettingsBaseActivity;
|
||||
|
||||
public class AppLocalePickerActivity extends SettingsBaseActivity
|
||||
implements LocalePickerWithRegion.LocaleSelectedListener {
|
||||
implements LocalePickerWithRegion.LocaleSelectedListener, MenuItem.OnActionExpandListener {
|
||||
private static final String TAG = AppLocalePickerActivity.class.getSimpleName();
|
||||
|
||||
private String mPackageName;
|
||||
@@ -75,9 +75,10 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
|
||||
|
||||
mLocalePickerWithRegion = LocalePickerWithRegion.createLanguagePicker(
|
||||
mContextAsUser,
|
||||
AppLocalePickerActivity.this,
|
||||
this,
|
||||
false /* translate only */,
|
||||
mPackageName);
|
||||
mPackageName,
|
||||
this);
|
||||
mAppLocaleDetails = AppLocaleDetails.newInstance(mPackageName);
|
||||
mAppLocaleDetailContainer = launchAppLocaleDetailsPage();
|
||||
// Launch Locale picker part.
|
||||
@@ -103,6 +104,18 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
|
||||
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 */
|
||||
private void setAppDefaultLocale(String languageTag) {
|
||||
LocaleManager localeManager = mContextAsUser.getSystemService(LocaleManager.class);
|
||||
|
@@ -16,8 +16,12 @@
|
||||
|
||||
package com.android.settings.network.telephony;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
@@ -27,14 +31,27 @@ public class SubscriptionActionDialogActivity extends FragmentActivity {
|
||||
private static final String TAG = "SubscriptionActionDialogActivity";
|
||||
// Arguments
|
||||
protected static final String ARG_SUB_ID = "sub_id";
|
||||
|
||||
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
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
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) {
|
||||
ProgressDialogFragment.show(getFragmentManager(), message, null);
|
||||
setProgressState(PROGRESS_IS_SHOWING);
|
||||
}
|
||||
|
||||
/** Dismisses the loading dialog. */
|
||||
protected void dismissProgressDialog() {
|
||||
ProgressDialogFragment.dismiss(getFragmentManager());
|
||||
setProgressState(PROGRESS_IS_NOT_SHOWING);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,4 +79,10 @@ public class SubscriptionActionDialogActivity extends FragmentActivity {
|
||||
protected void showErrorDialog(String title, String 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);
|
||||
}
|
||||
}
|
||||
|
@@ -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_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_ACTION;
|
||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_SCREEN_LOCK_SETUP_MESSAGE;
|
||||
|
||||
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.safetycenter.LockScreenSafetySource;
|
||||
import com.android.settings.search.SearchFeatureProvider;
|
||||
import com.android.settings.utils.AnnotationSpan;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
|
||||
@@ -621,15 +621,20 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
} 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 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)));
|
||||
footer.setVisible(true);
|
||||
footer.setTitle(description);
|
||||
|
||||
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();
|
||||
extras.putInt(Intent.EXTRA_USER_ID, profileUserId);
|
||||
if (mUserPassword != null) {
|
||||
@@ -642,10 +647,9 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
.setArguments(extras)
|
||||
.launch();
|
||||
finish();
|
||||
});
|
||||
CharSequence footerText = AnnotationSpan.linkify(description, linkInfo);
|
||||
footer.setVisible(true);
|
||||
footer.setTitle(footerText);
|
||||
};
|
||||
footer.setLearnMoreText(setLockText);
|
||||
footer.setLearnMoreAction(setLockClickListener);
|
||||
} else {
|
||||
footer.setVisible(false);
|
||||
}
|
||||
|
@@ -16,8 +16,11 @@
|
||||
|
||||
package com.android.settings.sim;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.telecom.PhoneAccountHandle;
|
||||
import android.telecom.TelecomManager;
|
||||
@@ -32,6 +35,7 @@ import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.network.telephony.SubscriptionActionDialogActivity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -60,6 +64,7 @@ public class SimDialogActivity extends FragmentActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getWindow().addSystemFlags(
|
||||
WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
|
||||
showOrUpdateDialog();
|
||||
@@ -72,6 +77,13 @@ public class SimDialogActivity extends FragmentActivity {
|
||||
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() {
|
||||
final int dialogType = getIntent().getIntExtra(DIALOG_TYPE_KEY, INVALID_PICK);
|
||||
|
||||
@@ -80,6 +92,13 @@ public class SimDialogActivity extends FragmentActivity {
|
||||
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 FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
SimDialogFragment fragment = (SimDialogFragment) fragmentManager.findFragmentByTag(tag);
|
||||
|
@@ -54,16 +54,24 @@ public class ConnectedDeviceDashboardFragmentTest {
|
||||
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_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
|
||||
private PackageManager mPackageManager;
|
||||
private Context mContext;
|
||||
private ConnectedDeviceDashboardFragment mFragment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mFragment = new ConnectedDeviceDashboardFragment();
|
||||
doReturn(mPackageManager).when(mContext).getPackageManager();
|
||||
doReturn(true).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_BLUETOOTH);
|
||||
}
|
||||
@@ -87,6 +95,26 @@ public class ConnectedDeviceDashboardFragmentTest {
|
||||
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
|
||||
public void getPreferenceControllers_containSlicePrefController() {
|
||||
final List<BasePreferenceController> controllers =
|
||||
|
Reference in New Issue
Block a user