|
23 | 23 | import android.content.ComponentName; |
24 | 24 | import android.content.Context; |
25 | 25 | import android.content.Intent; |
| 26 | +import android.content.pm.PackageManager; |
| 27 | +import android.content.pm.ResolveInfo; |
26 | 28 | import android.os.RemoteException; |
27 | 29 | import android.os.UserHandle; |
28 | 30 | import android.provider.MediaStore; |
|
38 | 40 | import com.android.internal.widget.multiwaveview.GlowPadView.OnTriggerListener; |
39 | 41 | import com.android.internal.R; |
40 | 42 |
|
| 43 | +import java.util.List; |
| 44 | + |
41 | 45 | public class KeyguardSelectorView extends LinearLayout implements KeyguardSecurityView { |
42 | 46 | private static final boolean DEBUG = KeyguardHostView.DEBUG; |
43 | 47 | private static final String TAG = "SecuritySelectorView"; |
@@ -118,12 +122,39 @@ public KeyguardSelectorView(Context context) { |
118 | 122 | this(context, null); |
119 | 123 | } |
120 | 124 |
|
| 125 | + private boolean wouldLaunchResolverActivity(Intent intent) { |
| 126 | + PackageManager packageManager = mContext.getPackageManager(); |
| 127 | + ResolveInfo resolved = packageManager.resolveActivityAsUser(intent, |
| 128 | + PackageManager.MATCH_DEFAULT_ONLY, mLockPatternUtils.getCurrentUser()); |
| 129 | + final List<ResolveInfo> appList = packageManager.queryIntentActivitiesAsUser( |
| 130 | + intent, PackageManager.MATCH_DEFAULT_ONLY, mLockPatternUtils.getCurrentUser()); |
| 131 | + // If the list contains the above resolved activity, then it can't be |
| 132 | + // ResolverActivity itself. |
| 133 | + for (int i = 0; i < appList.size(); i++) { |
| 134 | + ResolveInfo tmp = appList.get(i); |
| 135 | + if (tmp.activityInfo.name.equals(resolved.activityInfo.name) |
| 136 | + && tmp.activityInfo.packageName.equals(resolved.activityInfo.packageName)) { |
| 137 | + return false; |
| 138 | + } |
| 139 | + } |
| 140 | + return true; |
| 141 | + } |
| 142 | + |
121 | 143 | protected void launchCamera() { |
122 | 144 | if (mLockPatternUtils.isSecure()) { |
123 | 145 | // Launch the secure version of the camera |
124 | | - Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE); |
| 146 | + final Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE); |
125 | 147 | intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); |
126 | | - launchActivity(intent, true); |
| 148 | + |
| 149 | + if (wouldLaunchResolverActivity(intent)) { |
| 150 | + // TODO: Show disambiguation dialog instead. |
| 151 | + // For now, we'll treat this like launching any other app from secure keyguard. |
| 152 | + // When they do, user sees the system's ResolverActivity which lets them choose |
| 153 | + // which secure camera to use. |
| 154 | + launchActivity(intent, false); |
| 155 | + } else { |
| 156 | + launchActivity(intent, true); |
| 157 | + } |
127 | 158 | } else { |
128 | 159 | // Launch the normal camera |
129 | 160 | launchActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA), false); |
|
0 commit comments