am c6e570db: Merge "Fix camera disambiguation in secure keyguard" into jb-mr1-dev

* commit 'c6e570dbadc3689bc80c0516492a3209d5f6742b':
  Fix camera disambiguation in secure keyguard
This commit is contained in:
Jim Miller
2012-10-02 14:00:28 -07:00
committed by Android Git Automerger
4 changed files with 43 additions and 7 deletions

View File

@@ -125,7 +125,9 @@ 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 = UserHandle.USER_NULL;
// The current user is set by KeyguardViewMediator and shared by all LockPatternUtils.
private static volatile int sCurrentUserId = UserHandle.USER_NULL;
public DevicePolicyManager getDevicePolicyManager() { public DevicePolicyManager getDevicePolicyManager() {
if (mDevicePolicyManager == null) { if (mDevicePolicyManager == null) {
@@ -215,13 +217,13 @@ public class LockPatternUtils {
} }
public void setCurrentUser(int userId) { public void setCurrentUser(int userId) {
mCurrentUserId = userId; sCurrentUserId = userId;
} }
public int getCurrentUser() { public int getCurrentUser() {
if (mCurrentUserId != UserHandle.USER_NULL) { if (sCurrentUserId != UserHandle.USER_NULL) {
// Someone is regularly updating using setCurrentUser() use that value. // Someone is regularly updating using setCurrentUser() use that value.
return mCurrentUserId; return sCurrentUserId;
} }
try { try {
return ActivityManagerNative.getDefault().getCurrentUser().id; return ActivityManagerNative.getDefault().getCurrentUser().id;

View File

@@ -153,7 +153,8 @@ public class KeyguardFaceUnlockView extends LinearLayout implements KeyguardSecu
if (mBiometricUnlock != null) { if (mBiometricUnlock != null) {
mBiometricUnlock.stop(); mBiometricUnlock.stop();
} }
mLockPatternUtils.setCurrentUser(userId); // No longer required; static value set by KeyguardViewMediator
// mLockPatternUtils.setCurrentUser(userId);
} }
}; };

View File

@@ -23,6 +23,8 @@ import android.content.ActivityNotFoundException;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.UserHandle; import android.os.UserHandle;
import android.provider.MediaStore; import android.provider.MediaStore;
@@ -38,6 +40,8 @@ import com.android.internal.widget.multiwaveview.GlowPadView;
import com.android.internal.widget.multiwaveview.GlowPadView.OnTriggerListener; import com.android.internal.widget.multiwaveview.GlowPadView.OnTriggerListener;
import com.android.internal.R; import com.android.internal.R;
import java.util.List;
public class KeyguardSelectorView extends LinearLayout implements KeyguardSecurityView { public class KeyguardSelectorView extends LinearLayout implements KeyguardSecurityView {
private static final boolean DEBUG = KeyguardHostView.DEBUG; private static final boolean DEBUG = KeyguardHostView.DEBUG;
private static final String TAG = "SecuritySelectorView"; private static final String TAG = "SecuritySelectorView";
@@ -118,12 +122,39 @@ public class KeyguardSelectorView extends LinearLayout implements KeyguardSecuri
this(context, null); this(context, null);
} }
private boolean wouldLaunchResolverActivity(Intent intent) {
PackageManager packageManager = mContext.getPackageManager();
ResolveInfo resolved = packageManager.resolveActivityAsUser(intent,
PackageManager.MATCH_DEFAULT_ONLY, mLockPatternUtils.getCurrentUser());
final List<ResolveInfo> appList = packageManager.queryIntentActivitiesAsUser(
intent, PackageManager.MATCH_DEFAULT_ONLY, mLockPatternUtils.getCurrentUser());
// If the list contains the above resolved activity, then it can't be
// ResolverActivity itself.
for (int i = 0; i < appList.size(); i++) {
ResolveInfo tmp = appList.get(i);
if (tmp.activityInfo.name.equals(resolved.activityInfo.name)
&& tmp.activityInfo.packageName.equals(resolved.activityInfo.packageName)) {
return false;
}
}
return true;
}
protected void launchCamera() { protected void launchCamera() {
if (mLockPatternUtils.isSecure()) { if (mLockPatternUtils.isSecure()) {
// Launch the secure version of the camera // Launch the secure version of the camera
Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE); final Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE);
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
launchActivity(intent, true);
if (wouldLaunchResolverActivity(intent)) {
// TODO: Show disambiguation dialog instead.
// For now, we'll treat this like launching any other app from secure keyguard.
// When they do, user sees the system's ResolverActivity which lets them choose
// which secure camera to use.
launchActivity(intent, false);
} else {
launchActivity(intent, true);
}
} else { } else {
// Launch the normal camera // Launch the normal camera
launchActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA), false); launchActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA), false);

View File

@@ -894,6 +894,8 @@ public class KeyguardViewMediator {
/** /**
* Update the newUserId. Call while holding WindowManagerService lock. * Update the newUserId. Call while holding WindowManagerService lock.
* NOTE: Should only be called by KeyguardViewMediator in response to the user id changing.
*
* @param newUserId The id of the incoming user. * @param newUserId The id of the incoming user.
*/ */
public void setCurrentUser(int newUserId) { public void setCurrentUser(int newUserId) {