Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01c5895d authored by Kholoud Mohamed's avatar Kholoud Mohamed Committed by Android (Google) Code Review
Browse files

Merge "allow updating enterprise strings in sysUI"

parents f3563df9 9130147d
Loading
Loading
Loading
Loading
+79 −22
Original line number Diff line number Diff line
@@ -16,6 +16,12 @@

package com.android.systemui.biometrics;

import static android.app.admin.DevicePolicyResources.Strings.SystemUi.BIOMETRIC_DIALOG_WORK_LOCK_FAILED_ATTEMPTS;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.BIOMETRIC_DIALOG_WORK_PASSWORD_LAST_ATTEMPT;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.BIOMETRIC_DIALOG_WORK_PATTERN_LAST_ATTEMPT;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.BIOMETRIC_DIALOG_WORK_PIN_LAST_ATTEMPT;
import static android.app.admin.DevicePolicyResources.Strings.UNDEFINED;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -374,7 +380,7 @@ public abstract class AuthCredentialView extends LinearLayout {
        final AlertDialog alertDialog = new AlertDialog.Builder(mContext)
                .setTitle(R.string.biometric_dialog_last_attempt_before_wipe_dialog_title)
                .setMessage(
                        getLastAttemptBeforeWipeMessageRes(getUserTypeForWipe(), mCredentialType))
                        getLastAttemptBeforeWipeMessage(getUserTypeForWipe(), mCredentialType))
                .setPositiveButton(android.R.string.ok, null)
                .create();
        alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL);
@@ -383,7 +389,7 @@ public abstract class AuthCredentialView extends LinearLayout {

    private void showNowWipingDialog() {
        final AlertDialog alertDialog = new AlertDialog.Builder(mContext)
                .setMessage(getNowWipingMessageRes(getUserTypeForWipe()))
                .setMessage(getNowWipingMessage(getUserTypeForWipe()))
                .setPositiveButton(R.string.biometric_dialog_now_wiping_dialog_dismiss, null)
                .setOnDismissListener(
                        dialog -> mContainerView.animateAway(AuthDialogCallback.DISMISSED_ERROR))
@@ -404,70 +410,121 @@ public abstract class AuthCredentialView extends LinearLayout {
        }
    }

    private static @StringRes int getLastAttemptBeforeWipeMessageRes(
    private String getLastAttemptBeforeWipeMessage(
            @UserType int userType, @Utils.CredentialType int credentialType) {
        switch (userType) {
            case USER_TYPE_PRIMARY:
                return getLastAttemptBeforeWipeDeviceMessageRes(credentialType);
                return getLastAttemptBeforeWipeDeviceMessage(credentialType);
            case USER_TYPE_MANAGED_PROFILE:
                return getLastAttemptBeforeWipeProfileMessageRes(credentialType);
                return getLastAttemptBeforeWipeProfileMessage(credentialType);
            case USER_TYPE_SECONDARY:
                return getLastAttemptBeforeWipeUserMessageRes(credentialType);
                return getLastAttemptBeforeWipeUserMessage(credentialType);
            default:
                throw new IllegalArgumentException("Unrecognized user type:" + userType);
        }
    }

    private static @StringRes int getLastAttemptBeforeWipeDeviceMessageRes(
    private String getLastAttemptBeforeWipeDeviceMessage(
            @Utils.CredentialType int credentialType) {
        switch (credentialType) {
            case Utils.CREDENTIAL_PIN:
                return mContext.getString(
                        R.string.biometric_dialog_last_pin_attempt_before_wipe_device);
            case Utils.CREDENTIAL_PATTERN:
                return mContext.getString(
                        R.string.biometric_dialog_last_pattern_attempt_before_wipe_device);
            case Utils.CREDENTIAL_PASSWORD:
            default:
                return mContext.getString(
                        R.string.biometric_dialog_last_password_attempt_before_wipe_device);
        }
    }

    private String getLastAttemptBeforeWipeProfileMessage(
            @Utils.CredentialType int credentialType) {
        return mDevicePolicyManager.getString(
                getLastAttemptBeforeWipeProfileUpdatableStringId(credentialType),
                () -> getLastAttemptBeforeWipeProfileDefaultMessage(credentialType));
    }

    private static String getLastAttemptBeforeWipeProfileUpdatableStringId(
            @Utils.CredentialType int credentialType) {
        switch (credentialType) {
            case Utils.CREDENTIAL_PIN:
                return R.string.biometric_dialog_last_pin_attempt_before_wipe_device;
                return BIOMETRIC_DIALOG_WORK_PIN_LAST_ATTEMPT;
            case Utils.CREDENTIAL_PATTERN:
                return R.string.biometric_dialog_last_pattern_attempt_before_wipe_device;
                return BIOMETRIC_DIALOG_WORK_PATTERN_LAST_ATTEMPT;
            case Utils.CREDENTIAL_PASSWORD:
            default:
                return R.string.biometric_dialog_last_password_attempt_before_wipe_device;
                return BIOMETRIC_DIALOG_WORK_PASSWORD_LAST_ATTEMPT;
        }
    }

    private static @StringRes int getLastAttemptBeforeWipeProfileMessageRes(
    private String getLastAttemptBeforeWipeProfileDefaultMessage(
            @Utils.CredentialType int credentialType) {
        int resId;
        switch (credentialType) {
            case Utils.CREDENTIAL_PIN:
                return R.string.biometric_dialog_last_pin_attempt_before_wipe_profile;
                resId = R.string.biometric_dialog_last_pin_attempt_before_wipe_profile;
                break;
            case Utils.CREDENTIAL_PATTERN:
                return R.string.biometric_dialog_last_pattern_attempt_before_wipe_profile;
                resId = R.string.biometric_dialog_last_pattern_attempt_before_wipe_profile;
                break;
            case Utils.CREDENTIAL_PASSWORD:
            default:
                return R.string.biometric_dialog_last_password_attempt_before_wipe_profile;
                resId = R.string.biometric_dialog_last_password_attempt_before_wipe_profile;
        }
        return mContext.getString(resId);
    }

    private static @StringRes int getLastAttemptBeforeWipeUserMessageRes(
    private String getLastAttemptBeforeWipeUserMessage(
            @Utils.CredentialType int credentialType) {
        int resId;
        switch (credentialType) {
            case Utils.CREDENTIAL_PIN:
                return R.string.biometric_dialog_last_pin_attempt_before_wipe_user;
                resId = R.string.biometric_dialog_last_pin_attempt_before_wipe_user;
                break;
            case Utils.CREDENTIAL_PATTERN:
                return R.string.biometric_dialog_last_pattern_attempt_before_wipe_user;
                resId = R.string.biometric_dialog_last_pattern_attempt_before_wipe_user;
                break;
            case Utils.CREDENTIAL_PASSWORD:
            default:
                return R.string.biometric_dialog_last_password_attempt_before_wipe_user;
                resId = R.string.biometric_dialog_last_password_attempt_before_wipe_user;
        }
        return mContext.getString(resId);
    }

    private String getNowWipingMessage(@UserType int userType) {
        return mDevicePolicyManager.getString(
                getNowWipingUpdatableStringId(userType),
                () -> getNowWipingDefaultMessage(userType));
    }

    private String getNowWipingUpdatableStringId(@UserType int userType) {
        switch (userType) {
            case USER_TYPE_MANAGED_PROFILE:
                return BIOMETRIC_DIALOG_WORK_LOCK_FAILED_ATTEMPTS;
            default:
                return UNDEFINED;
        }
    }

    private static @StringRes int getNowWipingMessageRes(@UserType int userType) {
    private String getNowWipingDefaultMessage(@UserType int userType) {
        int resId;
        switch (userType) {
            case USER_TYPE_PRIMARY:
                return R.string.biometric_dialog_failed_attempts_now_wiping_device;
                resId = R.string.biometric_dialog_failed_attempts_now_wiping_device;
                break;
            case USER_TYPE_MANAGED_PROFILE:
                return R.string.biometric_dialog_failed_attempts_now_wiping_profile;
                resId = R.string.biometric_dialog_failed_attempts_now_wiping_profile;
                break;
            case USER_TYPE_SECONDARY:
                return R.string.biometric_dialog_failed_attempts_now_wiping_user;
                resId = R.string.biometric_dialog_failed_attempts_now_wiping_user;
                break;
            default:
                throw new IllegalArgumentException("Unrecognized user type:" + userType);
        }
        return mContext.getString(resId);
    }

    @Nullable
+5 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.keyguard;

import static android.app.ActivityManager.TaskDescription;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.WORK_LOCK_ACCESSIBILITY;

import android.annotation.ColorInt;
import android.annotation.UserIdInt;
@@ -92,8 +93,11 @@ public class WorkLockActivity extends Activity {

        // Blank out the activity. When it is on-screen it will look like a Recents thumbnail with
        // redaction switched on.
        final DevicePolicyManager dpm = getSystemService(DevicePolicyManager.class);
        String contentDescription = dpm.getString(
                WORK_LOCK_ACCESSIBILITY, () -> getString(R.string.accessibility_desc_work_lock));
        final View blankView = new View(this);
        blankView.setContentDescription(getString(R.string.accessibility_desc_work_lock));
        blankView.setContentDescription(contentDescription);
        blankView.setBackgroundColor(getPrimaryColor());
        setContentView(blankView);
    }
+233 −74

File changed.

Preview size limit exceeded, changes collapsed.

+6 −1
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package com.android.systemui.qs.tiles;

import static android.app.admin.DevicePolicyResources.Strings.SystemUi.QS_WORK_PROFILE_LABEL;

import android.app.admin.DevicePolicyManager;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
@@ -100,7 +103,9 @@ public class WorkModeTile extends QSTileImpl<BooleanState> implements

    @Override
    public CharSequence getTileLabel() {
        return mContext.getString(R.string.quick_settings_work_mode_label);
        DevicePolicyManager dpm = mContext.getSystemService(DevicePolicyManager.class);
        return dpm.getString(QS_WORK_PROFILE_LABEL,
                () -> mContext.getString(R.string.quick_settings_work_mode_label));
    }

    @Override
+8 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar;

import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.KEYGUARD_MANAGEMENT_DISCLOSURE;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;

@@ -343,7 +344,9 @@ public class KeyguardIndicationController {
    private CharSequence getDisclosureText(@Nullable CharSequence organizationName) {
        final Resources packageResources = mContext.getResources();
        if (organizationName == null) {
            return packageResources.getText(R.string.do_disclosure_generic);
            return mDevicePolicyManager.getString(
                    KEYGUARD_MANAGEMENT_DISCLOSURE,
                    () -> packageResources.getString(R.string.do_disclosure_generic));
        } else if (mDevicePolicyManager.isDeviceManaged()
                && mDevicePolicyManager.getDeviceOwnerType(
                mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser())
@@ -351,7 +354,10 @@ public class KeyguardIndicationController {
            return packageResources.getString(R.string.do_financed_disclosure_with_name,
                    organizationName);
        } else {
            return packageResources.getString(R.string.do_disclosure_with_name,
            return mDevicePolicyManager.getString(
                    KEYGUARD_MANAGEMENT_DISCLOSURE,
                    () -> packageResources.getString(
                            R.string.do_disclosure_with_name, organizationName),
                    organizationName);
        }
    }
Loading