summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Hugh <ahugh@google.com>2015-10-30 19:57:21 (GMT)
committerandroid-build-merger <android-build-merger@google.com>2015-10-30 19:57:21 (GMT)
commita7bd3497cb1649c3b7f8bce5333509aa8d83c581 (patch)
tree7b7b7f53a713e66512256583475b09c47f1d555e
parentc2f76914cbe000ad10ff56c08fb2e969c7af0877 (diff)
parente18bfc22019f44ae60674fc6d34616ce097e05f4 (diff)
downloadandroid_packages_apps_PackageInstaller-a7bd3497cb1649c3b7f8bce5333509aa8d83c581.zip
android_packages_apps_PackageInstaller-a7bd3497cb1649c3b7f8bce5333509aa8d83c581.tar.gz
android_packages_apps_PackageInstaller-a7bd3497cb1649c3b7f8bce5333509aa8d83c581.tar.bz2
Fix out of bounds exception
am: e18bfc2201 * commit 'e18bfc22019f44ae60674fc6d34616ce097e05f4': Fix out of bounds exception
-rw-r--r--src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java16
-rw-r--r--src/com/android/packageinstaller/permission/ui/wear/WarningConfirmationActivity.java16
2 files changed, 21 insertions, 11 deletions
diff --git a/src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java b/src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java
index 18db94c..aba97fc 100644
--- a/src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java
+++ b/src/com/android/packageinstaller/permission/ui/wear/AppPermissionsFragmentWear.java
@@ -55,7 +55,6 @@ public final class AppPermissionsFragmentWear extends TitledSettingsFragment {
private PermissionsSettingsAdapter mAdapter;
private boolean mHasConfirmedRevoke;
- private int mPendingPermGroupIndex = -1;
public static AppPermissionsFragmentWear newInstance(String packageName) {
return setPackageName(new AppPermissionsFragmentWear(), packageName);
@@ -216,11 +215,11 @@ public final class AppPermissionsFragmentWear extends TitledSettingsFragment {
} else {
final boolean grantedByDefault = group.hasGrantedByDefaultPermission();
if (grantedByDefault || (!group.hasRuntimePermission() && !mHasConfirmedRevoke)) {
- mPendingPermGroupIndex = index;
Intent intent = new Intent(getActivity(), WarningConfirmationActivity.class);
intent.putExtra(WarningConfirmationActivity.EXTRA_WARNING_MESSAGE,
getString(grantedByDefault ?
R.string.system_warning : R.string.old_sdk_deny_warning));
+ intent.putExtra(WarningConfirmationActivity.EXTRA_INDEX, index);
startActivityForResult(intent, WARNING_CONFIRMATION_REQUEST);
} else {
group.revokeRuntimePermissions(false);
@@ -234,18 +233,21 @@ public final class AppPermissionsFragmentWear extends TitledSettingsFragment {
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == WARNING_CONFIRMATION_REQUEST) {
if (resultCode == Activity.RESULT_OK) {
- SettingsAdapter.Setting<AppPermissionGroup> setting =
- mAdapter.get(mPendingPermGroupIndex);
+ int index = data.getIntExtra(WarningConfirmationActivity.EXTRA_INDEX, -1);
+ if (index == -1) {
+ Log.e(LOG_TAG, "Warning confirmation request came back with no index.");
+ return;
+ }
+
+ SettingsAdapter.Setting<AppPermissionGroup> setting = mAdapter.get(index);
final AppPermissionGroup group = setting.data;
group.revokeRuntimePermissions(false);
if (!group.hasGrantedByDefaultPermission()) {
mHasConfirmedRevoke = true;
}
- updatePermissionGroupSetting(mPendingPermGroupIndex);
+ updatePermissionGroupSetting(index);
}
-
- mPendingPermGroupIndex = -1;
} else {
super.onActivityResult(requestCode, resultCode, data);
}
diff --git a/src/com/android/packageinstaller/permission/ui/wear/WarningConfirmationActivity.java b/src/com/android/packageinstaller/permission/ui/wear/WarningConfirmationActivity.java
index e26dabd..0371341 100644
--- a/src/com/android/packageinstaller/permission/ui/wear/WarningConfirmationActivity.java
+++ b/src/com/android/packageinstaller/permission/ui/wear/WarningConfirmationActivity.java
@@ -17,6 +17,7 @@
package com.android.packageinstaller.permission.ui.wear;
import android.app.Activity;
+import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.os.Bundle;
@@ -25,6 +26,8 @@ import com.android.packageinstaller.R;
public final class WarningConfirmationActivity extends Activity {
public final static String EXTRA_WARNING_MESSAGE = "EXTRA_WARNING_MESSAGE";
+ // Saved index that will be returned in the onActivityResult() callback
+ public final static String EXTRA_INDEX = "EXTRA_INDEX";
private ConfirmationViewHandler mViewHandler;
private String mMessage;
@@ -43,14 +46,12 @@ public final class WarningConfirmationActivity extends Activity {
@Override
public void onButton1() {
- setResult(Activity.RESULT_CANCELED);
- finish();
+ setResultAndFinish(Activity.RESULT_CANCELED);
}
@Override
public void onButton2() {
- setResult(Activity.RESULT_OK);
- finish();
+ setResultAndFinish(Activity.RESULT_OK);
}
@Override
@@ -107,4 +108,11 @@ public final class WarningConfirmationActivity extends Activity {
setContentView(mViewHandler.createView());
mViewHandler.invalidate();
}
+
+ private void setResultAndFinish(int result) {
+ Intent intent = new Intent();
+ intent.putExtra(EXTRA_INDEX, getIntent().getIntExtra(EXTRA_INDEX, -1));
+ setResult(result, intent);
+ finish();
+ }
}