Snap for 8009678 from 1511407370 to tm-release
Change-Id: I9cd8f4a371c9cb0b86efb5809b2ff71c29385bc2
This commit is contained in:
@@ -59,7 +59,6 @@ android_library {
|
|||||||
"com.google.android.material_material",
|
"com.google.android.material_material",
|
||||||
"setupcompat",
|
"setupcompat",
|
||||||
"setupdesign",
|
"setupdesign",
|
||||||
"androidx-constraintlayout_constraintlayout-solver",
|
|
||||||
"androidx.lifecycle_lifecycle-runtime",
|
"androidx.lifecycle_lifecycle-runtime",
|
||||||
"androidx.lifecycle_lifecycle-extensions",
|
"androidx.lifecycle_lifecycle-extensions",
|
||||||
"guava",
|
"guava",
|
||||||
|
|||||||
@@ -2973,6 +2973,12 @@
|
|||||||
android:value="true" />
|
android:value="true" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".users.AddSupervisedUserActivity"
|
||||||
|
android:label="@*android:string/supervised_user_creation_label"
|
||||||
|
android:icon="@drawable/ic_settings_multiuser">
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="Settings$PaymentSettingsActivity"
|
android:name="Settings$PaymentSettingsActivity"
|
||||||
android:label="@string/nfc_payment_settings_title"
|
android:label="@string/nfc_payment_settings_title"
|
||||||
|
|||||||
26
res/layout/add_supervised_user.xml
Normal file
26
res/layout/add_supervised_user.xml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (C) 2021 The Android Open Source Project
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<Button
|
||||||
|
android:id="@+id/createSupervisedUser"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:text="@*android:string/supervised_user_creation_label" />
|
||||||
|
</FrameLayout>
|
||||||
@@ -13351,9 +13351,9 @@
|
|||||||
<string name="lockscreen_privacy_wallet_summary">Allow access to wallet from lock screen and quick settings</string>
|
<string name="lockscreen_privacy_wallet_summary">Allow access to wallet from lock screen and quick settings</string>
|
||||||
|
|
||||||
<!-- QR Code Scanner toggle name [CHAR LIMIT=60] -->
|
<!-- QR Code Scanner toggle name [CHAR LIMIT=60] -->
|
||||||
<string name="lockscreen_privacy_qr_code_scanner_setting_toggle">Show QR Code Scanner</string>
|
<string name="lockscreen_privacy_qr_code_scanner_setting_toggle">Show QR Scanner</string>
|
||||||
<!-- QR Code Scanner summary [CHAR LIMIT=NONE] -->
|
<!-- QR Code Scanner summary [CHAR LIMIT=NONE] -->
|
||||||
<string name="lockscreen_privacy_qr_code_scanner_summary">Allow access to QR code scanner from lock screen</string>
|
<string name="lockscreen_privacy_qr_code_scanner_summary">Allow access to QR scanner from lock screen</string>
|
||||||
|
|
||||||
<!-- Device controls toggle name [CHAR LIMIT=60] -->
|
<!-- Device controls toggle name [CHAR LIMIT=60] -->
|
||||||
<string name="lockscreen_privacy_controls_setting_toggle">Show device controls</string>
|
<string name="lockscreen_privacy_controls_setting_toggle">Show device controls</string>
|
||||||
|
|||||||
@@ -43,6 +43,12 @@
|
|||||||
android:icon="@drawable/ic_add_40dp"
|
android:icon="@drawable/ic_add_40dp"
|
||||||
android:order="20"/>
|
android:order="20"/>
|
||||||
|
|
||||||
|
<com.android.settingslib.RestrictedPreference
|
||||||
|
android:key="supervised_user_add"
|
||||||
|
android:title="@*android:string/supervised_user_creation_label"
|
||||||
|
android:icon="@*android:drawable/ic_add_supervised_user"
|
||||||
|
android:order="25"/>
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedSwitchPreference
|
<com.android.settingslib.RestrictedSwitchPreference
|
||||||
android:key="user_settings_add_users_when_locked"
|
android:key="user_settings_add_users_when_locked"
|
||||||
android:title="@string/user_add_on_lockscreen_menu"
|
android:title="@string/user_add_on_lockscreen_menu"
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.users;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.ActivityManager;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.os.NewUserRequest;
|
||||||
|
import android.os.NewUserResponse;
|
||||||
|
import android.os.UserManager;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fallback activity for supervised user creation.
|
||||||
|
* Built to test {@link UserManager#createUser(NewUserRequest)} API.
|
||||||
|
*/
|
||||||
|
// TODO(b/209659998): [to-be-removed] fallback activity for supervised user creation.
|
||||||
|
public class AddSupervisedUserActivity extends Activity {
|
||||||
|
|
||||||
|
private UserManager mUserManager;
|
||||||
|
private ActivityManager mActivityManager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
mUserManager = getSystemService(UserManager.class);
|
||||||
|
mActivityManager = getSystemService(ActivityManager.class);
|
||||||
|
setContentView(R.layout.add_supervised_user);
|
||||||
|
findViewById(R.id.createSupervisedUser).setOnClickListener(v -> createUser());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createUserAsync(final NewUserRequest request,
|
||||||
|
final Consumer<NewUserResponse> onResponse) {
|
||||||
|
Objects.requireNonNull(onResponse);
|
||||||
|
|
||||||
|
final Handler mMainThread = new Handler(Looper.getMainLooper());
|
||||||
|
Executors.newSingleThreadExecutor().execute(() -> {
|
||||||
|
final NewUserResponse response = mUserManager.createUser(request);
|
||||||
|
mMainThread.post(() -> onResponse.accept(response));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createUser() {
|
||||||
|
final NewUserRequest request = new NewUserRequest.Builder().build();
|
||||||
|
|
||||||
|
final AlertDialog pleaseWaitDialog = new AlertDialog.Builder(this)
|
||||||
|
.setMessage(getString(R.string.creating_new_user_dialog_message))
|
||||||
|
.setCancelable(false)
|
||||||
|
.create();
|
||||||
|
|
||||||
|
pleaseWaitDialog.show();
|
||||||
|
createUserAsync(request, response -> {
|
||||||
|
pleaseWaitDialog.dismiss();
|
||||||
|
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
mActivityManager.switchUser(response.getUser());
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
new AlertDialog.Builder(this)
|
||||||
|
.setTitle(getString(R.string.add_user_failed))
|
||||||
|
.setMessage(UserManager.UserOperationResult.class.getName()
|
||||||
|
+ " = " + response.getOperationResult())
|
||||||
|
.setNeutralButton(getString(R.string.okay), null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -115,6 +115,7 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
private static final String KEY_USER_GUEST = "user_guest";
|
private static final String KEY_USER_GUEST = "user_guest";
|
||||||
private static final String KEY_ADD_GUEST = "guest_add";
|
private static final String KEY_ADD_GUEST = "guest_add";
|
||||||
private static final String KEY_ADD_USER = "user_add";
|
private static final String KEY_ADD_USER = "user_add";
|
||||||
|
private static final String KEY_ADD_SUPERVISED_USER = "supervised_user_add";
|
||||||
private static final String KEY_ADD_USER_WHEN_LOCKED = "user_settings_add_users_when_locked";
|
private static final String KEY_ADD_USER_WHEN_LOCKED = "user_settings_add_users_when_locked";
|
||||||
private static final String KEY_MULTIUSER_TOP_INTRO = "multiuser_top_intro";
|
private static final String KEY_MULTIUSER_TOP_INTRO = "multiuser_top_intro";
|
||||||
|
|
||||||
@@ -165,10 +166,13 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
RestrictedPreference mAddUser;
|
RestrictedPreference mAddUser;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
RestrictedPreference mAddSupervisedUser;
|
||||||
|
@VisibleForTesting
|
||||||
SparseArray<Bitmap> mUserIcons = new SparseArray<>();
|
SparseArray<Bitmap> mUserIcons = new SparseArray<>();
|
||||||
private int mRemovingUserId = -1;
|
private int mRemovingUserId = -1;
|
||||||
private boolean mAddingUser;
|
private boolean mAddingUser;
|
||||||
private boolean mGuestUserAutoCreated;
|
private boolean mGuestUserAutoCreated;
|
||||||
|
private String mConfigSupervisedUserCreationPackage;
|
||||||
private String mAddingUserName;
|
private String mAddingUserName;
|
||||||
private UserCapabilities mUserCaps;
|
private UserCapabilities mUserCaps;
|
||||||
private boolean mShouldUpdateUserList = true;
|
private boolean mShouldUpdateUserList = true;
|
||||||
@@ -300,6 +304,10 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
mAddUser.setOnPreferenceClickListener(this);
|
mAddUser.setOnPreferenceClickListener(this);
|
||||||
|
|
||||||
|
setConfigSupervisedUserCreationPackage();
|
||||||
|
mAddSupervisedUser = findPreference(KEY_ADD_SUPERVISED_USER);
|
||||||
|
mAddSupervisedUser.setOnPreferenceClickListener(this);
|
||||||
|
|
||||||
activity.registerReceiverAsUser(
|
activity.registerReceiverAsUser(
|
||||||
mUserChangeReceiver, UserHandle.ALL, USER_REMOVED_INTENT_FILTER, null, mHandler);
|
mUserChangeReceiver, UserHandle.ALL, USER_REMOVED_INTENT_FILTER, null, mHandler);
|
||||||
|
|
||||||
@@ -491,6 +499,21 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onAddSupervisedUserClicked() {
|
||||||
|
final Intent intent = new Intent()
|
||||||
|
.setAction(UserManager.ACTION_CREATE_SUPERVISED_USER)
|
||||||
|
.setPackage(mConfigSupervisedUserCreationPackage);
|
||||||
|
|
||||||
|
// TODO(b/209659998): [to-be-removed] fallback activity for supervised user creation.
|
||||||
|
if (getActivity().getPackageManager().resolveActivity(intent, 0) == null) {
|
||||||
|
intent
|
||||||
|
.setClass(getContext(), AddSupervisedUserActivity.class)
|
||||||
|
.setPackage(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
private void onRemoveUserClicked(int userId) {
|
private void onRemoveUserClicked(int userId) {
|
||||||
synchronized (mUserLock) {
|
synchronized (mUserLock) {
|
||||||
if (mRemovingUserId == -1 && !mAddingUser) {
|
if (mRemovingUserId == -1 && !mAddingUser) {
|
||||||
@@ -1058,6 +1081,7 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
updateAddGuest(context, users.stream().anyMatch(UserInfo::isGuest));
|
updateAddGuest(context, users.stream().anyMatch(UserInfo::isGuest));
|
||||||
updateAddUser(context);
|
updateAddUser(context);
|
||||||
|
updateAddSupervisedUser(context);
|
||||||
|
|
||||||
if (!mUserCaps.mUserSwitcherEnabled) {
|
if (!mUserCaps.mUserSwitcherEnabled) {
|
||||||
return;
|
return;
|
||||||
@@ -1070,6 +1094,12 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void setConfigSupervisedUserCreationPackage() {
|
||||||
|
mConfigSupervisedUserCreationPackage = getPrefContext().getString(
|
||||||
|
com.android.internal.R.string.config_supervisedUserCreationPackage);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isCurrentUserGuest() {
|
private boolean isCurrentUserGuest() {
|
||||||
return mUserCaps.mIsGuest;
|
return mUserCaps.mIsGuest;
|
||||||
}
|
}
|
||||||
@@ -1100,28 +1130,41 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateAddUser(Context context) {
|
private void updateAddUser(Context context) {
|
||||||
|
updateAddUserCommon(context, mAddUser, mUserCaps.mCanAddRestrictedProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateAddSupervisedUser(Context context) {
|
||||||
|
if (!TextUtils.isEmpty(mConfigSupervisedUserCreationPackage)) {
|
||||||
|
updateAddUserCommon(context, mAddSupervisedUser, false);
|
||||||
|
} else {
|
||||||
|
mAddSupervisedUser.setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateAddUserCommon(Context context, RestrictedPreference addUser,
|
||||||
|
boolean canAddRestrictedProfile) {
|
||||||
if ((mUserCaps.mCanAddUser || mUserCaps.mDisallowAddUserSetByAdmin)
|
if ((mUserCaps.mCanAddUser || mUserCaps.mDisallowAddUserSetByAdmin)
|
||||||
&& WizardManagerHelper.isDeviceProvisioned(context)
|
&& WizardManagerHelper.isDeviceProvisioned(context)
|
||||||
&& mUserCaps.mUserSwitcherEnabled) {
|
&& mUserCaps.mUserSwitcherEnabled) {
|
||||||
mAddUser.setVisible(true);
|
addUser.setVisible(true);
|
||||||
mAddUser.setSelectable(true);
|
addUser.setSelectable(true);
|
||||||
final boolean canAddMoreUsers =
|
final boolean canAddMoreUsers =
|
||||||
mUserManager.canAddMoreUsers(UserManager.USER_TYPE_FULL_SECONDARY)
|
mUserManager.canAddMoreUsers(UserManager.USER_TYPE_FULL_SECONDARY)
|
||||||
|| (mUserCaps.mCanAddRestrictedProfile
|
|| (canAddRestrictedProfile
|
||||||
&& mUserManager.canAddMoreUsers(UserManager.USER_TYPE_FULL_RESTRICTED));
|
&& mUserManager.canAddMoreUsers(UserManager.USER_TYPE_FULL_RESTRICTED));
|
||||||
mAddUser.setEnabled(canAddMoreUsers && !mAddingUser && canSwitchUserNow());
|
addUser.setEnabled(canAddMoreUsers && !mAddingUser && canSwitchUserNow());
|
||||||
if (!canAddMoreUsers) {
|
if (!canAddMoreUsers) {
|
||||||
mAddUser.setSummary(
|
addUser.setSummary(
|
||||||
getString(R.string.user_add_max_count, getRealUsersCount()));
|
getString(R.string.user_add_max_count, getRealUsersCount()));
|
||||||
} else {
|
} else {
|
||||||
mAddUser.setSummary(null);
|
addUser.setSummary(null);
|
||||||
}
|
}
|
||||||
if (mAddUser.isEnabled()) {
|
if (addUser.isEnabled()) {
|
||||||
mAddUser.setDisabledByAdmin(
|
addUser.setDisabledByAdmin(
|
||||||
mUserCaps.mDisallowAddUser ? mUserCaps.mEnforcedAdmin : null);
|
mUserCaps.mDisallowAddUser ? mUserCaps.mEnforcedAdmin : null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mAddUser.setVisible(false);
|
addUser.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1206,6 +1249,9 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
onAddUserClicked(USER_TYPE_USER);
|
onAddUserClicked(USER_TYPE_USER);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
} else if (pref == mAddSupervisedUser) {
|
||||||
|
onAddSupervisedUserClicked();
|
||||||
|
return true;
|
||||||
} else if (pref == mAddGuest) {
|
} else if (pref == mAddGuest) {
|
||||||
mAddGuest.setEnabled(false); // prevent multiple tap issue
|
mAddGuest.setEnabled(false); // prevent multiple tap issue
|
||||||
mMetricsFeatureProvider.action(getActivity(), SettingsEnums.ACTION_USER_GUEST_ADD);
|
mMetricsFeatureProvider.action(getActivity(), SettingsEnums.ACTION_USER_GUEST_ADD);
|
||||||
|
|||||||
@@ -179,7 +179,8 @@ public class WifiCallingSliceHelper {
|
|||||||
.setTitle(res.getText(R.string.wifi_calling_settings_title))
|
.setTitle(res.getText(R.string.wifi_calling_settings_title))
|
||||||
.addEndItem(
|
.addEndItem(
|
||||||
SliceAction.createToggle(
|
SliceAction.createToggle(
|
||||||
getBroadcastIntent(ACTION_WIFI_CALLING_CHANGED),
|
getBroadcastIntent(ACTION_WIFI_CALLING_CHANGED,
|
||||||
|
isWifiCallingEnabled),
|
||||||
null /* actionTitle */, isWifiCallingEnabled))
|
null /* actionTitle */, isWifiCallingEnabled))
|
||||||
.setPrimaryAction(SliceAction.createDeeplink(
|
.setPrimaryAction(SliceAction.createDeeplink(
|
||||||
getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY),
|
getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY),
|
||||||
@@ -316,7 +317,7 @@ public class WifiCallingSliceHelper {
|
|||||||
final Resources res = getResourcesForSubId(subId);
|
final Resources res = getResourcesForSubId(subId);
|
||||||
return new RowBuilder()
|
return new RowBuilder()
|
||||||
.setTitle(res.getText(preferenceTitleResId))
|
.setTitle(res.getText(preferenceTitleResId))
|
||||||
.setTitleItem(SliceAction.createToggle(getBroadcastIntent(action),
|
.setTitleItem(SliceAction.createToggle(getBroadcastIntent(action, checked),
|
||||||
icon, res.getText(preferenceTitleResId), checked));
|
icon, res.getText(preferenceTitleResId), checked));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,25 +371,31 @@ public class WifiCallingSliceHelper {
|
|||||||
public void handleWifiCallingChanged(Intent intent) {
|
public void handleWifiCallingChanged(Intent intent) {
|
||||||
final int subId = getDefaultVoiceSubId();
|
final int subId = getDefaultVoiceSubId();
|
||||||
|
|
||||||
if (SubscriptionManager.isValidSubscriptionId(subId)) {
|
if (SubscriptionManager.isValidSubscriptionId(subId)
|
||||||
|
&& intent.hasExtra(EXTRA_TOGGLE_STATE)) {
|
||||||
final WifiCallingQueryImsState queryState = queryImsState(subId);
|
final WifiCallingQueryImsState queryState = queryImsState(subId);
|
||||||
if (queryState.isWifiCallingProvisioned()) {
|
if (queryState.isWifiCallingProvisioned()) {
|
||||||
final boolean currentValue = queryState.isEnabledByUser()
|
final boolean currentValue = isWifiCallingEnabled();
|
||||||
&& queryState.isAllowUserControl();
|
|
||||||
final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
|
final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
|
||||||
currentValue);
|
currentValue);
|
||||||
final Intent activationAppIntent =
|
final Intent activationAppIntent =
|
||||||
getWifiCallingCarrierActivityIntent(subId);
|
getWifiCallingCarrierActivityIntent(subId);
|
||||||
if (!newValue || activationAppIntent == null) {
|
if ((newValue == currentValue) && activationAppIntent == null) {
|
||||||
// If either the action is to turn off wifi calling setting
|
// If either the action is to turn off wifi calling setting
|
||||||
// or there is no activation involved - Update the setting
|
// or there is no activation involved - Update the setting
|
||||||
if (newValue != currentValue) {
|
|
||||||
final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
|
final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
|
||||||
imsMmTelManager.setVoWiFiSettingEnabled(newValue);
|
imsMmTelManager.setVoWiFiSettingEnabled(!newValue);
|
||||||
}
|
} else {
|
||||||
|
Log.w(TAG, "action not taken: subId " + subId
|
||||||
|
+ " from " + currentValue + " to " + newValue);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "action not taken: subId " + subId + " needs provision");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "action not taken: subId " + subId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify change in slice in any case to get re-queried. This would result in displaying
|
// notify change in slice in any case to get re-queried. This would result in displaying
|
||||||
// appropriate message with the updated setting.
|
// appropriate message with the updated setting.
|
||||||
mContext.getContentResolver().notifyChange(WIFI_CALLING_URI, null);
|
mContext.getContentResolver().notifyChange(WIFI_CALLING_URI, null);
|
||||||
@@ -541,10 +548,20 @@ public class WifiCallingSliceHelper {
|
|||||||
PendingIntent.FLAG_IMMUTABLE);
|
PendingIntent.FLAG_IMMUTABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PendingIntent getBroadcastIntent(String action) {
|
/**
|
||||||
|
* Create PendingIntent for Slice.
|
||||||
|
* Note: SliceAction#createDeeplink() didn't support toggle status so far,
|
||||||
|
* therefore, embedding toggle status within PendingIntent.
|
||||||
|
*
|
||||||
|
* @param action Slice action
|
||||||
|
* @param isChecked Status when Slice created.
|
||||||
|
* @return PendingIntent
|
||||||
|
*/
|
||||||
|
private PendingIntent getBroadcastIntent(String action, boolean isChecked) {
|
||||||
final Intent intent = new Intent(action);
|
final Intent intent = new Intent(action);
|
||||||
intent.setClass(mContext, SliceBroadcastReceiver.class);
|
intent.setClass(mContext, SliceBroadcastReceiver.class);
|
||||||
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
||||||
|
intent.putExtra(EXTRA_TOGGLE_STATE, isChecked);
|
||||||
return PendingIntent.getBroadcast(mContext, 0 /* requestCode */, intent,
|
return PendingIntent.getBroadcast(mContext, 0 /* requestCode */, intent,
|
||||||
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ android_app {
|
|||||||
"com.google.android.material_material",
|
"com.google.android.material_material",
|
||||||
"setupcompat",
|
"setupcompat",
|
||||||
"setupdesign",
|
"setupdesign",
|
||||||
"androidx-constraintlayout_constraintlayout-solver",
|
|
||||||
"androidx.lifecycle_lifecycle-runtime",
|
"androidx.lifecycle_lifecycle-runtime",
|
||||||
"androidx.lifecycle_lifecycle-extensions",
|
"androidx.lifecycle_lifecycle-extensions",
|
||||||
"androidx.test.core",
|
"androidx.test.core",
|
||||||
|
|||||||
@@ -212,86 +212,6 @@ public class MobileNetworkSummaryControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void getSummary_twoSubscriptions_correctSummaryAndFragment() {
|
|
||||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
|
|
||||||
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
|
|
||||||
final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
|
|
||||||
when(sub1.getSubscriptionId()).thenReturn(1);
|
|
||||||
when(sub2.getSubscriptionId()).thenReturn(2);
|
|
||||||
|
|
||||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
|
||||||
mController.displayPreference(mPreferenceScreen);
|
|
||||||
mController.onResume();
|
|
||||||
assertThat(mController.getSummary()).isEqualTo("2 SIMs");
|
|
||||||
assertThat(mPreference.getFragment()).isEqualTo(MobileNetworkListFragment.class.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Ignore
|
|
||||||
public void getSummaryAfterUpdate_twoSubscriptionsBecomesOne_correctSummaryAndFragment() {
|
|
||||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
|
|
||||||
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
|
|
||||||
final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
|
|
||||||
when(sub1.getSubscriptionId()).thenReturn(1);
|
|
||||||
when(sub2.getSubscriptionId()).thenReturn(2);
|
|
||||||
when(sub1.getDisplayName()).thenReturn("sub1");
|
|
||||||
when(sub2.getDisplayName()).thenReturn("sub2");
|
|
||||||
|
|
||||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
|
||||||
SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
|
||||||
mController.displayPreference(mPreferenceScreen);
|
|
||||||
mController.onResume();
|
|
||||||
assertThat(mController.getSummary()).isEqualTo("2 SIMs");
|
|
||||||
assertThat(mPreference.getFragment()).isEqualTo(MobileNetworkListFragment.class.getName());
|
|
||||||
|
|
||||||
// Simulate sub2 having disappeared - the end result should change to be the same as
|
|
||||||
// if there were just one subscription.
|
|
||||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
|
|
||||||
mController.onSubscriptionsChanged();
|
|
||||||
assertThat(mController.getSummary()).isEqualTo("sub1");
|
|
||||||
assertThat(mPreference.getFragment()).isNull();
|
|
||||||
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
|
||||||
doNothing().when(mContext).startActivity(intentCaptor.capture());
|
|
||||||
mPreference.getOnPreferenceClickListener().onPreferenceClick(mPreference);
|
|
||||||
assertThat(intentCaptor.getValue().getComponent().getClassName()).isEqualTo(
|
|
||||||
MobileNetworkActivity.class.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Ignore
|
|
||||||
public void getSummaryAfterUpdate_oneSubscriptionBecomesTwo_correctSummaryAndFragment() {
|
|
||||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
|
|
||||||
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
|
|
||||||
final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
|
|
||||||
when(sub1.getSubscriptionId()).thenReturn(1);
|
|
||||||
when(sub2.getSubscriptionId()).thenReturn(2);
|
|
||||||
when(sub1.getDisplayName()).thenReturn("sub1");
|
|
||||||
when(sub2.getDisplayName()).thenReturn("sub2");
|
|
||||||
|
|
||||||
when(mSubscriptionManager.getAvailableSubscriptionInfoList()).thenReturn(
|
|
||||||
Arrays.asList(sub1));
|
|
||||||
SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1));
|
|
||||||
mController.displayPreference(mPreferenceScreen);
|
|
||||||
mController.onResume();
|
|
||||||
assertThat(mController.getSummary()).isEqualTo("sub1");
|
|
||||||
assertThat(mPreference.getFragment()).isNull();
|
|
||||||
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
|
||||||
doNothing().when(mContext).startActivity(intentCaptor.capture());
|
|
||||||
mPreference.getOnPreferenceClickListener().onPreferenceClick(mPreference);
|
|
||||||
assertThat(intentCaptor.getValue().getComponent().getClassName()).isEqualTo(
|
|
||||||
MobileNetworkActivity.class.getName());
|
|
||||||
|
|
||||||
// Simulate sub2 appearing in the list of subscriptions and check the results.
|
|
||||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
|
||||||
mController.displayPreference(mPreferenceScreen);
|
|
||||||
mController.onResume();
|
|
||||||
assertThat(mController.getSummary()).isEqualTo("2 SIMs");
|
|
||||||
assertThat(mPreference.getFragment()).isEqualTo(MobileNetworkListFragment.class.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Ignore
|
|
||||||
public void getSummary_providerModel_Enabled() {
|
public void getSummary_providerModel_Enabled() {
|
||||||
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
|
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
|
||||||
final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
|
final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
|
||||||
@@ -302,15 +222,9 @@ public class MobileNetworkSummaryControllerTest {
|
|||||||
|
|
||||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
||||||
SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
||||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
|
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
assertThat(mController.getSummary()).isEqualTo("sub1, sub2");
|
assertThat(mController.getSummary()).isEqualTo("sub1, sub2");
|
||||||
|
|
||||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
|
|
||||||
mController.displayPreference(mPreferenceScreen);
|
|
||||||
mController.onResume();
|
|
||||||
assertThat(mController.getSummary()).isEqualTo("2 SIMs");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ import androidx.preference.PreferenceScreen;
|
|||||||
|
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.SubSettings;
|
import com.android.settings.SubSettings;
|
||||||
|
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||||
import com.android.settings.testutils.shadow.ShadowDevicePolicyManager;
|
import com.android.settings.testutils.shadow.ShadowDevicePolicyManager;
|
||||||
import com.android.settings.testutils.shadow.ShadowUserManager;
|
import com.android.settings.testutils.shadow.ShadowUserManager;
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
@@ -85,7 +86,11 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = {ShadowUserManager.class, ShadowDevicePolicyManager.class})
|
@Config(shadows = {
|
||||||
|
ShadowUserManager.class,
|
||||||
|
ShadowDevicePolicyManager.class,
|
||||||
|
SettingsShadowResources.class,
|
||||||
|
})
|
||||||
public class UserSettingsTest {
|
public class UserSettingsTest {
|
||||||
|
|
||||||
private static final String KEY_USER_GUEST = "user_guest";
|
private static final String KEY_USER_GUEST = "user_guest";
|
||||||
@@ -111,6 +116,8 @@ public class UserSettingsTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private RestrictedPreference mAddUserPreference;
|
private RestrictedPreference mAddUserPreference;
|
||||||
@Mock
|
@Mock
|
||||||
|
private RestrictedPreference mAddSupervisedUserPreference;
|
||||||
|
@Mock
|
||||||
private RestrictedPreference mAddGuestPreference;
|
private RestrictedPreference mAddGuestPreference;
|
||||||
@Mock
|
@Mock
|
||||||
private UserManager mUserManager;
|
private UserManager mUserManager;
|
||||||
@@ -161,6 +168,7 @@ public class UserSettingsTest {
|
|||||||
|
|
||||||
mFragment.mMePreference = mMePreference;
|
mFragment.mMePreference = mMePreference;
|
||||||
mFragment.mAddUser = mAddUserPreference;
|
mFragment.mAddUser = mAddUserPreference;
|
||||||
|
mFragment.mAddSupervisedUser = mAddSupervisedUserPreference;
|
||||||
mFragment.mAddGuest = mAddGuestPreference;
|
mFragment.mAddGuest = mAddGuestPreference;
|
||||||
mFragment.mUserListCategory = mock(PreferenceCategory.class);
|
mFragment.mUserListCategory = mock(PreferenceCategory.class);
|
||||||
}
|
}
|
||||||
@@ -169,6 +177,7 @@ public class UserSettingsTest {
|
|||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
Settings.Global.putInt(mContext.getContentResolver(),
|
Settings.Global.putInt(mContext.getContentResolver(),
|
||||||
Settings.Global.DEVICE_PROVISIONED, mProvisionedBackupValue);
|
Settings.Global.DEVICE_PROVISIONED, mProvisionedBackupValue);
|
||||||
|
SettingsShadowResources.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -694,6 +703,36 @@ public class UserSettingsTest {
|
|||||||
verify(mUserManager).getUsers();
|
verify(mUserManager).getUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setConfigSupervisedUserCreationPackage(String value) {
|
||||||
|
SettingsShadowResources.overrideResource(
|
||||||
|
com.android.internal.R.string.config_supervisedUserCreationPackage,
|
||||||
|
value
|
||||||
|
);
|
||||||
|
mFragment.setConfigSupervisedUserCreationPackage();
|
||||||
|
mUserCapabilities.mCanAddUser = true;
|
||||||
|
mFragment.updateUserList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addSupervisedUserOption_resourceIsDefined_shouldBeDisplayed() {
|
||||||
|
try {
|
||||||
|
setConfigSupervisedUserCreationPackage("test");
|
||||||
|
verify(mAddSupervisedUserPreference).setVisible(true);
|
||||||
|
} finally {
|
||||||
|
SettingsShadowResources.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addSupervisedUserOption_resourceIsNotDefined_shouldBeHidden() {
|
||||||
|
try {
|
||||||
|
setConfigSupervisedUserCreationPackage("");
|
||||||
|
verify(mAddSupervisedUserPreference).setVisible(false);
|
||||||
|
} finally {
|
||||||
|
SettingsShadowResources.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void givenUsers(UserInfo... userInfo) {
|
private void givenUsers(UserInfo... userInfo) {
|
||||||
List<UserInfo> users = Arrays.asList(userInfo);
|
List<UserInfo> users = Arrays.asList(userInfo);
|
||||||
doReturn(users).when(mUserManager).getUsers();
|
doReturn(users).when(mUserManager).getUsers();
|
||||||
|
|||||||
@@ -153,7 +153,6 @@ public class NetworkProviderBackupCallingGroupTest {
|
|||||||
@Test
|
@Test
|
||||||
public void
|
public void
|
||||||
shouldShowBackupCallingForSub_crossSimDisabled_returnFalse() {
|
shouldShowBackupCallingForSub_crossSimDisabled_returnFalse() {
|
||||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
|
|
||||||
doReturn(false).when(mNetworkProviderBackupCallingGroup).isCrossSimEnabledByPlatform(
|
doReturn(false).when(mNetworkProviderBackupCallingGroup).isCrossSimEnabledByPlatform(
|
||||||
mContext, SUB_ID_1);
|
mContext, SUB_ID_1);
|
||||||
|
|
||||||
@@ -163,7 +162,6 @@ public class NetworkProviderBackupCallingGroupTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldBackupCallingForSub_crossSimEnabled_returnTrue() {
|
public void shouldBackupCallingForSub_crossSimEnabled_returnTrue() {
|
||||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
|
|
||||||
doReturn(true).when(mNetworkProviderBackupCallingGroup).isCrossSimEnabledByPlatform(
|
doReturn(true).when(mNetworkProviderBackupCallingGroup).isCrossSimEnabledByPlatform(
|
||||||
mContext, SUB_ID_1);
|
mContext, SUB_ID_1);
|
||||||
|
|
||||||
|
|||||||
@@ -147,7 +147,6 @@ public class NetworkProviderWifiCallingGroupTest {
|
|||||||
@Test
|
@Test
|
||||||
public void
|
public void
|
||||||
shouldShowWifiCallingForSub_wifiCallingDisabledWithWifiCallingNotReady_returnFalse() {
|
shouldShowWifiCallingForSub_wifiCallingDisabledWithWifiCallingNotReady_returnFalse() {
|
||||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
|
|
||||||
setWifiCallingEnabled(false);
|
setWifiCallingEnabled(false);
|
||||||
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
|
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
|
||||||
|
|
||||||
@@ -157,7 +156,6 @@ public class NetworkProviderWifiCallingGroupTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldShowWifiCallingForSub_wifiCallingEnabledWithWifiCallingIsReady_returnTrue() {
|
public void shouldShowWifiCallingForSub_wifiCallingEnabledWithWifiCallingIsReady_returnTrue() {
|
||||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
|
|
||||||
setWifiCallingEnabled(true);
|
setWifiCallingEnabled(true);
|
||||||
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
|
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
|
||||||
|
|
||||||
@@ -168,7 +166,6 @@ public class NetworkProviderWifiCallingGroupTest {
|
|||||||
@Test
|
@Test
|
||||||
public void
|
public void
|
||||||
shouldShowWifiCallingForSub_wifiCallingDisabledWithNoActivityHandleIntent_returnFalse() {
|
shouldShowWifiCallingForSub_wifiCallingDisabledWithNoActivityHandleIntent_returnFalse() {
|
||||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
|
|
||||||
buildPhoneAccountConfigureIntent(false);
|
buildPhoneAccountConfigureIntent(false);
|
||||||
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
|
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
|
||||||
doReturn(mPhoneAccountHandle).when(mNetworkProviderWifiCallingGroup)
|
doReturn(mPhoneAccountHandle).when(mNetworkProviderWifiCallingGroup)
|
||||||
@@ -181,7 +178,6 @@ public class NetworkProviderWifiCallingGroupTest {
|
|||||||
@Test
|
@Test
|
||||||
public void
|
public void
|
||||||
shouldShowWifiCallingForSub_wifiCallingEnabledWithActivityHandleIntent_returnTrue() {
|
shouldShowWifiCallingForSub_wifiCallingEnabledWithActivityHandleIntent_returnTrue() {
|
||||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
|
|
||||||
buildPhoneAccountConfigureIntent(true);
|
buildPhoneAccountConfigureIntent(true);
|
||||||
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
|
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
|
||||||
doReturn(mPhoneAccountHandle).when(mNetworkProviderWifiCallingGroup)
|
doReturn(mPhoneAccountHandle).when(mNetworkProviderWifiCallingGroup)
|
||||||
|
|||||||
Reference in New Issue
Block a user