OSDN Git Service

am cf911d10: Merge "Check for DeviceAdminInfo type before casting" into lmp-dev
authorZoltan Szatmary-Ban <szatmz@google.com>
Thu, 11 Sep 2014 16:01:24 +0000 (16:01 +0000)
committerAndroid Git Automerger <android-git-automerger@android.com>
Thu, 11 Sep 2014 16:01:24 +0000 (16:01 +0000)
* commit 'cf911d107ac931306af80fd02eb696410bb2aaad':
  Check for DeviceAdminInfo type before casting

src/com/android/settings/DeviceAdminSettings.java

index 6ac0974..bc22637 100644 (file)
@@ -126,7 +126,12 @@ public class DeviceAdminSettings extends ListFragment {
 
     @Override
     public void onListItemClick(ListView l, View v, int position, long id) {
-        DeviceAdminInfo dpi = (DeviceAdminInfo) l.getAdapter().getItem(position);
+        Object o = l.getAdapter().getItem(position);
+        if (!(o instanceof DeviceAdminInfo)) {
+            // race conditions may cause this
+            return;
+        }
+        DeviceAdminInfo dpi = (DeviceAdminInfo) o;
         final Activity activity = getActivity();
         final int userId = getUserId(dpi);
         if (userId == UserHandle.myUserId() || !isProfileOwner(dpi)) {