Merge "add settings log to remove and switch user"
This commit is contained in:
@@ -127,7 +127,12 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (preference != null && preference.getKey() != null) {
|
||||
mMetricsFeatureProvider.logSettingsTileClick(preference.getKey(), getMetricsCategory());
|
||||
}
|
||||
if (preference == mRemoveUserPref) {
|
||||
mMetricsFeatureProvider.action(getActivity(),
|
||||
UserMetricsUtils.getRemoveUserMetricCategory(mUserInfo));
|
||||
if (canDeleteUser()) {
|
||||
if (mUserInfo.isGuest()) {
|
||||
showDialog(DIALOG_CONFIRM_RESET_GUEST);
|
||||
@@ -137,6 +142,8 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
|
||||
return true;
|
||||
}
|
||||
} else if (preference == mSwitchUserPref) {
|
||||
mMetricsFeatureProvider.action(getActivity(),
|
||||
UserMetricsUtils.getSwitchUserMetricCategory(mUserInfo));
|
||||
if (canSwitchUserNow()) {
|
||||
if (shouldShowSetupPromptDialog()) {
|
||||
showDialog(DIALOG_SETUP_USER);
|
||||
@@ -164,9 +171,13 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (preference == mPhonePref) {
|
||||
if (Boolean.TRUE.equals(newValue)) {
|
||||
mMetricsFeatureProvider.action(getActivity(),
|
||||
SettingsEnums.ACTION_ENABLE_USER_CALL);
|
||||
showDialog(DIALOG_CONFIRM_ENABLE_CALLING_AND_SMS);
|
||||
return false;
|
||||
}
|
||||
mMetricsFeatureProvider.action(getActivity(),
|
||||
SettingsEnums.ACTION_DISABLE_USER_CALL);
|
||||
enableCallsAndSms(false);
|
||||
}
|
||||
return true;
|
||||
@@ -364,9 +375,6 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
|
||||
void switchUser() {
|
||||
Trace.beginSection("UserDetailSettings.switchUser");
|
||||
try {
|
||||
if (mUserInfo.isGuest()) {
|
||||
mMetricsFeatureProvider.action(getActivity(), SettingsEnums.ACTION_SWITCH_TO_GUEST);
|
||||
}
|
||||
if (mUserCaps.mIsGuest && mUserCaps.mIsEphemeral) {
|
||||
int guestUserId = UserHandle.myUserId();
|
||||
// Using markGuestForDeletion allows us to create a new guest before this one is
|
||||
|
56
src/com/android/settings/users/UserMetricsUtils.java
Normal file
56
src/com/android/settings/users/UserMetricsUtils.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.settings.SettingsEnums;
|
||||
import android.content.pm.UserInfo;
|
||||
|
||||
/**
|
||||
* Utils class for metrics to avoid user characteristics checks in code
|
||||
*/
|
||||
public class UserMetricsUtils {
|
||||
|
||||
/**
|
||||
* Returns relevant remove SettingsEnum key depending on UserInfo
|
||||
* @param userInfo information about user
|
||||
* @return list of RestrictionEntry objects with user-visible text.
|
||||
*/
|
||||
public static int getRemoveUserMetricCategory(UserInfo userInfo) {
|
||||
if (userInfo.isGuest()) {
|
||||
return SettingsEnums.ACTION_REMOVE_GUEST_USER;
|
||||
}
|
||||
if (userInfo.isRestricted()) {
|
||||
return SettingsEnums.ACTION_REMOVE_RESTRICTED_USER;
|
||||
}
|
||||
return SettingsEnums.ACTION_REMOVE_USER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns relevant switch user SettingsEnum key depending on UserInfo
|
||||
* @param userInfo information about user
|
||||
* @return SettingsEnums.
|
||||
*/
|
||||
public static int getSwitchUserMetricCategory(UserInfo userInfo) {
|
||||
if (userInfo.isGuest()) {
|
||||
return SettingsEnums.ACTION_SWITCH_TO_GUEST;
|
||||
}
|
||||
if (userInfo.isRestricted()) {
|
||||
return SettingsEnums.ACTION_SWITCH_TO_RESTRICTED_USER;
|
||||
}
|
||||
return SettingsEnums.ACTION_SWITCH_TO_USER;
|
||||
}
|
||||
}
|
@@ -1568,6 +1568,7 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference pref) {
|
||||
mMetricsFeatureProvider.logSettingsTileClick(pref.getKey(), getMetricsCategory());
|
||||
if (isCurrentUserGuest()) {
|
||||
if (mGuestResetPreference != null && pref == mGuestResetPreference) {
|
||||
showDialog(DIALOG_CONFIRM_RESET_AND_RESTART_GUEST);
|
||||
|
Reference in New Issue
Block a user