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

Commit 4786223a authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android Git Automerger
Browse files

am 7788b759: am 52716deb: Merge "Fix deadlock in LockPatternUtils by using...

am 7788b759: am 52716deb: Merge "Fix deadlock in LockPatternUtils by using local id." into jb-mr1-dev

* commit '7788b759':
  Fix deadlock in LockPatternUtils by using local id.
parents b74d9f82 7788b759
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -1111,7 +1111,15 @@ public interface WindowManagerPolicy {
     * @param attrs The window's LayoutParams.
     * @param attrs The window's LayoutParams.
     * @return Whether magnification can be applied.
     * @return Whether magnification can be applied.
     */
     */
    public boolean canMagnifyWindow(WindowManager.LayoutParams attrs);
    public boolean canMagnifyWindowLw(WindowManager.LayoutParams attrs);

    /**
     * Called when the current user changes. Guaranteed to be called before the broadcast
     * of the new user id is made to all listeners.
     *
     * @param newUserId The id of the incoming user.
     */
    public void setCurrentUserLw(int newUserId);


    /**
    /**
     * Print the WindowManagerPolicy's state into the given stream.
     * Print the WindowManagerPolicy's state into the given stream.
+6 −11
Original line number Original line Diff line number Diff line
@@ -22,14 +22,11 @@ import com.google.android.collect.Lists;


import android.app.ActivityManagerNative;
import android.app.ActivityManagerNative;
import android.app.admin.DevicePolicyManager;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.os.Binder;
import android.os.Binder;
import android.os.FileObserver;
import android.os.IBinder;
import android.os.IBinder;
import android.os.Process;
import android.os.Process;
import android.os.RemoteException;
import android.os.RemoteException;
@@ -45,16 +42,10 @@ import android.util.Log;
import android.view.View;
import android.view.View;
import android.widget.Button;
import android.widget.Button;


import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.security.MessageDigest;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.List;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;


/**
/**
 * Utilities for the lock pattern and its settings.
 * Utilities for the lock pattern and its settings.
@@ -134,7 +125,7 @@ public class LockPatternUtils {
    private final ContentResolver mContentResolver;
    private final ContentResolver mContentResolver;
    private DevicePolicyManager mDevicePolicyManager;
    private DevicePolicyManager mDevicePolicyManager;
    private ILockSettings mLockSettingsService;
    private ILockSettings mLockSettingsService;
    private int mCurrentUserId = 0;
    private int mCurrentUserId = UserHandle.USER_NULL;


    public DevicePolicyManager getDevicePolicyManager() {
    public DevicePolicyManager getDevicePolicyManager() {
        if (mDevicePolicyManager == null) {
        if (mDevicePolicyManager == null) {
@@ -233,10 +224,14 @@ public class LockPatternUtils {


    public int getCurrentUser() {
    public int getCurrentUser() {
        if (Process.myUid() == Process.SYSTEM_UID) {
        if (Process.myUid() == Process.SYSTEM_UID) {
            if (mCurrentUserId != UserHandle.USER_NULL) {
                // Someone is regularly updating using setCurrentUser() use that value.
                return mCurrentUserId;
            }
            try {
            try {
                return ActivityManagerNative.getDefault().getCurrentUser().id;
                return ActivityManagerNative.getDefault().getCurrentUser().id;
            } catch (RemoteException re) {
            } catch (RemoteException re) {
                return mCurrentUserId;
                return UserHandle.USER_OWNER;
            }
            }
        } else {
        } else {
            throw new SecurityException("Only the system process can get the current user");
            throw new SecurityException("Only the system process can get the current user");
+11 −2
Original line number Original line Diff line number Diff line
@@ -71,7 +71,6 @@ import android.util.EventLog;
import android.util.Log;
import android.util.Log;
import android.util.Slog;
import android.util.Slog;
import android.util.SparseArray;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.Display;
import android.view.Display;
import android.view.Gravity;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.HapticFeedbackConstants;
@@ -722,6 +721,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }
    }


    private final Runnable mPowerLongPress = new Runnable() {
    private final Runnable mPowerLongPress = new Runnable() {
        @Override
        public void run() {
        public void run() {
            // The context isn't read
            // The context isn't read
            if (mLongPressOnPowerBehavior < 0) {
            if (mLongPressOnPowerBehavior < 0) {
@@ -4316,7 +4316,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mLastInputMethodTargetWindow = target;
        mLastInputMethodTargetWindow = target;
    }
    }


    public boolean canMagnifyWindow(WindowManager.LayoutParams attrs) {
    @Override
    public boolean canMagnifyWindowLw(WindowManager.LayoutParams attrs) {
        switch (attrs.type) {
        switch (attrs.type) {
            case WindowManager.LayoutParams.TYPE_INPUT_METHOD:
            case WindowManager.LayoutParams.TYPE_INPUT_METHOD:
            case WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG:
            case WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG:
@@ -4328,6 +4329,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        return true;
        return true;
    }
    }


    @Override
    public void setCurrentUserLw(int newUserId) {
        if (mKeyguardMediator != null) {
            mKeyguardMediator.setCurrentUser(newUserId);
        }
    }

    @Override
    public void dump(String prefix, PrintWriter pw, String[] args) {
    public void dump(String prefix, PrintWriter pw, String[] args) {
        pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode);
        pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode);
                pw.print(" mSystemReady="); pw.print(mSystemReady);
                pw.print(" mSystemReady="); pw.print(mSystemReady);
+11 −2
Original line number Original line Diff line number Diff line
@@ -131,7 +131,7 @@ public class KeyguardViewMediator {
    private static final int KEYGUARD_LOCK_AFTER_DELAY_DEFAULT = 5000;
    private static final int KEYGUARD_LOCK_AFTER_DELAY_DEFAULT = 5000;


    /**
    /**
     * How long we'll wait for the {@link KeyguardViewCallback#keyguardDoneDrawing()}
     * How long we'll wait for the {@link ViewMediatorCallback#keyguardDoneDrawing()}
     * callback before unblocking a call to {@link #setKeyguardEnabled(boolean)}
     * callback before unblocking a call to {@link #setKeyguardEnabled(boolean)}
     * that is reenabling the keyguard.
     * that is reenabling the keyguard.
     */
     */
@@ -297,7 +297,7 @@ public class KeyguardViewMediator {


        @Override
        @Override
        public void onUserSwitched(int userId) {
        public void onUserSwitched(int userId) {
            mLockPatternUtils.setCurrentUser(userId);
            // Note that the mLockPatternUtils user has already been updated from setCurrentUser.
            synchronized (KeyguardViewMediator.this) {
            synchronized (KeyguardViewMediator.this) {
                resetStateLocked();
                resetStateLocked();
            }
            }
@@ -465,6 +465,7 @@ public class KeyguardViewMediator {


        mLockPatternUtils = lockPatternUtils != null
        mLockPatternUtils = lockPatternUtils != null
                ? lockPatternUtils : new LockPatternUtils(mContext);
                ? lockPatternUtils : new LockPatternUtils(mContext);
        mLockPatternUtils.setCurrentUser(UserHandle.USER_OWNER);


        WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
        WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);


@@ -890,6 +891,14 @@ public class KeyguardViewMediator {
            || KeyguardUpdateMonitor.getInstance(mContext).isSimPinSecure();
            || KeyguardUpdateMonitor.getInstance(mContext).isSimPinSecure();
    }
    }


    /**
     * Update the newUserId. Call while holding WindowManagerService lock.
     * @param newUserId The id of the incoming user.
     */
    public void setCurrentUser(int newUserId) {
        mLockPatternUtils.setCurrentUser(newUserId);
    }

    private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
    private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
        @Override
        @Override
        public void onReceive(Context context, Intent intent) {
        public void onReceive(Context context, Intent intent) {
+3 −1
Original line number Original line Diff line number Diff line
@@ -13984,6 +13984,8 @@ public final class ActivityManagerService extends ActivityManagerNative
                mUserLru.remove(userIdInt);
                mUserLru.remove(userIdInt);
                mUserLru.add(userIdInt);
                mUserLru.add(userIdInt);
                mWindowManager.setCurrentUser(userId);
                final UserStartedState uss = mStartedUsers.get(userId);
                final UserStartedState uss = mStartedUsers.get(userId);
                mHandler.removeMessages(REPORT_USER_SWITCH_MSG);
                mHandler.removeMessages(REPORT_USER_SWITCH_MSG);
Loading