Update description when device allows guest user

If device supports guest user mode, app pinning
recommends guest feature to user.

Test: Rebuilt rom and see correct string in app pinning.
Fix: 151332926
Change-Id: I6c03ecfe075fba2f4dedca18f65893f328e680aa
This commit is contained in:
Tsung-Mao Fang
2020-04-30 21:51:32 +08:00
parent cdab906c45
commit 4cca8db28c
2 changed files with 17 additions and 2 deletions

View File

@@ -9242,10 +9242,10 @@
\t\n3.\tTap the app icon at the top of the screen, then tap Pin
</string>
<!-- [CHAR LIMIT=none] Screen pinning description -->
<string name="screen_pinning_guest_mode_description">
<string name="screen_pinning_guest_user_description">
App pinning allows you to keep the current app in view until you unpin it. This feature can be used, for example, to let a trusted friend play a specific game.
\n\nWhen an app is pinned, the pinned app may open other apps and personal data may be accessible.
\n\nIf you want to securely share your device with someone, try using a guest profile instead.
\n\nIf you want to securely share your device with someone, try using a guest user instead.
\n\nTo use app pinning:
\t\n1.\tTurn on app pinning
\t\n2.\tOpen Overview

View File

@@ -22,6 +22,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.widget.Switch;
@@ -61,6 +62,7 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
private SwitchPreference mUseScreenLock;
private FooterPreference mFooterPreference;
private LockPatternUtils mLockPatternUtils;
private UserManager mUserManager;
@Override
public int getMetricsCategory() {
@@ -74,6 +76,7 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
final SettingsActivity activity = (SettingsActivity) getActivity();
activity.setTitle(R.string.screen_pinning_title);
mLockPatternUtils = new LockPatternUtils(activity);
mUserManager = activity.getSystemService(UserManager.class);
addPreferencesFromResource(R.xml.screen_pinning_settings);
final PreferenceScreen root = getPreferenceScreen();
@@ -224,10 +227,22 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
mUseScreenLock.setTitle(getCurrentSecurityTitle());
} else {
mFooterPreference.setVisible(true);
mFooterPreference.setSummary(getAppPinningContent());
mUseScreenLock.setVisible(false);
}
}
private boolean isGuestModeSupported() {
return UserManager.supportsMultipleUsers()
&& !mUserManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH);
}
private CharSequence getAppPinningContent() {
return isGuestModeSupported()
? getActivity().getText(R.string.screen_pinning_guest_user_description)
: getActivity().getText(R.string.screen_pinning_description);
}
/**
* For search
*/