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

Commit 6e150baa authored by Suprabh Shukla's avatar Suprabh Shukla Committed by android-build-merger
Browse files

Merge changes Id876f01f,If7c94cf8 into nyc-mr1-dev am: 634ed6bc

am: a07ed2f3

Change-Id: I795b47e1c7e2c944c0c7525bb108af577546ee53
parents 24ae4b6d a07ed2f3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4384,7 +4384,7 @@
    <!-- Title of the dialog shown when user inactivity times out in retail demo mode [CHAR LIMIT=40] -->
    <string name="demo_user_inactivity_timeout_title">Reset device?</string>
    <!-- Warning message shown when user inactivity times out in retail demo mode [CHAR LIMIT=none] -->
    <string name="demo_user_inactivity_timeout_countdown">You\'ll lose any changes and the demo will start again in <xliff:g id="timeout" example="9">%1$s</xliff:g> seconds\u2026</string>
    <string name="demo_user_inactivity_timeout_countdown">You\u2019ll lose any changes and the demo will start again in <xliff:g id="timeout" example="9">%1$s</xliff:g> seconds\u2026</string>
    <!-- Text of button to allow user to abort countdown and continue current session in retail demo mode [CHAR LIMIT=40] -->
    <string name="demo_user_inactivity_timeout_left_button">Cancel</string>
    <!-- Text of button to allow user to abort countdown and immediately start another session in retail demo mode [CHAR LIMIT=40] -->
+1 −2
Original line number Diff line number Diff line
@@ -456,7 +456,6 @@ public class UserManagerService extends IUserManager.Stub {
            setUserRestriction(UserManager.DISALLOW_CONFIG_WIFI, true, currentGuestUser.id);
        }

        maybeInitializeDemoMode(UserHandle.USER_SYSTEM);
        mContext.registerReceiver(mDisableQuietModeCallback,
                new IntentFilter(ACTION_DISABLE_QUIET_MODE_AFTER_UNLOCK),
                null, mHandler);
@@ -2901,7 +2900,7 @@ public class UserManagerService extends IUserManager.Stub {
    }

    private void maybeInitializeDemoMode(int userId) {
        if (UserManager.isDeviceInDemoMode(mContext)) {
        if (UserManager.isDeviceInDemoMode(mContext) && userId != UserHandle.USER_SYSTEM) {
            String demoLauncher =
                    mContext.getResources().getString(
                            com.android.internal.R.string.config_demoModeLauncherComponent);
+6 −0
Original line number Diff line number Diff line
@@ -8250,6 +8250,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {

    @Override
    public SystemUpdatePolicy getSystemUpdatePolicy() {
        if (UserManager.isDeviceInDemoMode(mContext)) {
            // Pretending to have an automatic update policy when the device is in retail demo
            // mode. This will allow the device to download and install an ota without
            // any user interaction.
            return SystemUpdatePolicy.createAutomaticInstallPolicy();
        }
        synchronized (this) {
            SystemUpdatePolicy policy =  mOwners.getSystemUpdatePolicy();
            if (policy != null && !policy.isValid()) {
+10 −9
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ public class RetailDemoModeService extends SystemService {
    private PendingIntent mResetDemoPendingIntent;
    private CameraManager mCameraManager;
    private String[] mCameraIdsWithFlash;
    private Configuration mPrimaryUserConfiguration;
    private Configuration mSystemUserConfiguration;

    final Object mActivityLock = new Object();
    // Whether the newly created demo user has interacted with the screen yet
@@ -179,8 +179,8 @@ public class RetailDemoModeService extends SystemService {
    private void showInactivityCountdownDialog() {
        UserInactivityCountdownDialog dialog = new UserInactivityCountdownDialog(getContext(),
                WARNING_DIALOG_TIMEOUT, MILLIS_PER_SECOND);
        dialog.setPositiveButtonClickListener(null);
        dialog.setNegativeButtonClickListener(new DialogInterface.OnClickListener() {
        dialog.setNegativeButtonClickListener(null);
        dialog.setPositiveButtonClickListener(new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                mHandler.sendEmptyMessage(MSG_START_NEW_SESSION);
@@ -366,12 +366,12 @@ public class RetailDemoModeService extends SystemService {
        }
    }

    private Configuration getPrimaryUsersConfiguration() {
        if (mPrimaryUserConfiguration == null) {
    private Configuration getSystemUsersConfiguration() {
        if (mSystemUserConfiguration == null) {
            Settings.System.getConfiguration(getContext().getContentResolver(),
                    mPrimaryUserConfiguration = new Configuration());
                    mSystemUserConfiguration = new Configuration());
        }
        return mPrimaryUserConfiguration;
        return mSystemUserConfiguration;
    }

    @Override
@@ -424,10 +424,11 @@ public class RetailDemoModeService extends SystemService {
            mWakeLock.acquire();
        }
        mCurrentUserId = userId;
        mNm.notifyAsUser(TAG, 1, createResetNotification(), UserHandle.of(userId));
        mAmi.updatePersistentConfigurationForUser(getSystemUsersConfiguration(), userId);
        turnOffAllFlashLights();
        muteVolumeStreams();
        mAmi.updatePersistentConfigurationForUser(getPrimaryUsersConfiguration(), userId);
        mNm.notifyAsUser(TAG, 1, createResetNotification(), UserHandle.of(userId));

        synchronized (mActivityLock) {
            mUserUntouched = true;
        }
+12 −16
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@ import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.os.CountDownTimer;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

@@ -30,25 +28,23 @@ import com.android.internal.R;
public class UserInactivityCountdownDialog extends AlertDialog {

    private OnCountDownExpiredListener mOnCountDownExpiredListener;
    private View mDialogView;
    private CountDownTimer mCountDownTimer;
    private long mCountDownDuration;
    private long mRefreshInterval;

    UserInactivityCountdownDialog(Context context, long duration, long refreshInterval) {
        super(context);

        mCountDownDuration = duration;
        mRefreshInterval = refreshInterval;
        mDialogView = LayoutInflater.from(context).inflate(R.layout.alert_dialog, null);
        String msg = context.getString(R.string.demo_user_inactivity_timeout_countdown, duration);
        getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);

        getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
        WindowManager.LayoutParams attrs = getWindow().getAttributes();
        attrs.privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
        getWindow().setAttributes(attrs);

        setTitle(R.string.demo_user_inactivity_timeout_title);
        setView(mDialogView);
        setMessage(msg);
        setMessage(getContext().getString(R.string.demo_user_inactivity_timeout_countdown,
                duration));
    }

    public void setOnCountDownExpiredListener(
@@ -58,30 +54,31 @@ public class UserInactivityCountdownDialog extends AlertDialog {

    public void setPositiveButtonClickListener(OnClickListener onClickListener) {
        setButton(Dialog.BUTTON_POSITIVE,
                getContext().getString(R.string.demo_user_inactivity_timeout_left_button),
                getContext().getString(R.string.demo_user_inactivity_timeout_right_button),
                onClickListener);
    }

    public void setNegativeButtonClickListener(OnClickListener onClickListener) {
        setButton(Dialog.BUTTON_NEGATIVE,
                getContext().getString(R.string.demo_user_inactivity_timeout_right_button),
                getContext().getString(R.string.demo_user_inactivity_timeout_left_button),
                onClickListener);
    }

    @Override
    public void show() {
        super.show();
        mDialogView.post(new Runnable() {
        final TextView messageView = (TextView) findViewById(R.id.message);
        messageView.post(new Runnable() {
            @Override
            public void run() {
                mCountDownTimer = new CountDownTimer(mCountDownDuration, mRefreshInterval) {

                    @Override
                    public void onTick(long millisUntilFinished) {
                        String msg = getContext().getResources().getString(
                        String msg = getContext().getString(
                                R.string.demo_user_inactivity_timeout_countdown,
                                millisUntilFinished / 1000);
                        ((TextView) mDialogView.findViewById(R.id.message)).setText(msg);
                        messageView.setText(msg);
                    }

                    @Override
@@ -96,8 +93,7 @@ public class UserInactivityCountdownDialog extends AlertDialog {
    }

    @Override
    public void dismiss() {
        super.dismiss();
    public void onStop() {
        if (mCountDownTimer != null) {
            mCountDownTimer.cancel();
        }