summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Wang <jaywang@codeaurora.org>2016-07-21 01:22:27 (GMT)
committerSteve Kondik <steve@cyngn.com>2016-08-18 22:10:11 (GMT)
commita780bd9965eb4adbcf14e5162c5b6f9a2a92ea97 (patch)
tree957d4459dc8e621f453bf18a2c520f31d65dba9d
parentf41b627e549a9ab705cc51e7d85ffe14a12a85d0 (diff)
downloadandroid_packages_apps_Snap-a780bd9965eb4adbcf14e5162c5b6f9a2a92ea97.zip
android_packages_apps_Snap-a780bd9965eb4adbcf14e5162c5b6f9a2a92ea97.tar.gz
android_packages_apps_Snap-a780bd9965eb4adbcf14e5162c5b6f9a2a92ea97.tar.bz2
SnapdragonCamera: Fix NPE caused by empty permission result
When request permission is cancelled, it returns empty result. Making change to check the length of result before accessing the result. Change-Id: Ic3e35c822e053fac7786d5e924ead8935feb1794 CRs-Fixed: 1041464
-rw-r--r--src/com/android/camera/PermissionsActivity.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/com/android/camera/PermissionsActivity.java b/src/com/android/camera/PermissionsActivity.java
index 27a3c36..f47d826 100644
--- a/src/com/android/camera/PermissionsActivity.java
+++ b/src/com/android/camera/PermissionsActivity.java
@@ -119,24 +119,27 @@ public class PermissionsActivity extends Activity {
String permissions[], int[] grantResults) {
if (mShouldRequestCameraPermission) {
- if (grantResults[mIndexPermissionRequestCamera] ==
- PackageManager.PERMISSION_GRANTED) {
+ if ((grantResults.length >= mIndexPermissionRequestCamera + 1) &&
+ (grantResults[mIndexPermissionRequestCamera] ==
+ PackageManager.PERMISSION_GRANTED)) {
mFlagHasCameraPermission = true;
} else {
mCriticalPermissionDenied = true;
}
}
if (mShouldRequestMicrophonePermission) {
- if (grantResults[mIndexPermissionRequestMicrophone] ==
- PackageManager.PERMISSION_GRANTED) {
+ if ((grantResults.length >= mIndexPermissionRequestMicrophone + 1) &&
+ (grantResults[mIndexPermissionRequestMicrophone] ==
+ PackageManager.PERMISSION_GRANTED)) {
mFlagHasMicrophonePermission = true;
} else {
mCriticalPermissionDenied = true;
}
}
if (mShouldRequestStoragePermission) {
- if (grantResults[mIndexPermissionRequestStorage] ==
- PackageManager.PERMISSION_GRANTED) {
+ if ((grantResults.length >= mIndexPermissionRequestStorage + 1) &&
+ (grantResults[mIndexPermissionRequestStorage] ==
+ PackageManager.PERMISSION_GRANTED)) {
mFlagHasStoragePermission = true;
} else {
mCriticalPermissionDenied = true;
@@ -144,8 +147,9 @@ public class PermissionsActivity extends Activity {
}
if (mShouldRequestLocationPermission) {
- if (grantResults[mIndexPermissionRequestLocation] ==
- PackageManager.PERMISSION_GRANTED) {
+ if ((grantResults.length >= mIndexPermissionRequestLocation + 1) &&
+ (grantResults[mIndexPermissionRequestLocation] ==
+ PackageManager.PERMISSION_GRANTED)) {
// Do nothing
} else {
// Do nothing