fix permission check

This commit is contained in:
Dominik Schürmann 2013-09-06 14:02:35 +02:00
parent 51cf7939d8
commit 9611236bf1

View File

@ -120,33 +120,36 @@ public class OtherHelper {
public static void checkPackagePermissionForActions(Activity activity, String pkgName,
String permName, String action, String[] restrictedActions) {
if (action != null) {
// PackageManager pkgManager = activity.getPackageManager();
PackageManager pkgManager = activity.getPackageManager();
// for (int i = 0; i < restrictedActions.length; i++) {
// if (restrictedActions[i].equals(action)) {
// if (pkgName != null
// && (pkgManager.checkPermission(permName, pkgName) == PackageManager.PERMISSION_GRANTED || pkgName
// .equals(Constants.PACKAGE_NAME))) {
// Log.d(Constants.TAG, pkgName + " has permission " + permName + ". Action "
// + action + " was granted!");
// } else {
// String error = pkgName + " does NOT have permission " + permName
// + ". Action " + action + " was NOT granted!";
// Log.e(Constants.TAG, error);
// Toast.makeText(activity, activity.getString(R.string.errorMessage, error),
// Toast.LENGTH_LONG).show();
//
// // end activity
// activity.setResult(Activity.RESULT_CANCELED, null);
// activity.finish();
// }
// }
// }
for (int i = 0; i < restrictedActions.length; i++) {
if (restrictedActions[i].equals(action)) {
// TODO: currently always cancels! THis is the old API
// end activity
activity.setResult(Activity.RESULT_CANCELED, null);
activity.finish();
// if (pkgName != null
// && (pkgManager.checkPermission(permName, pkgName) ==
// PackageManager.PERMISSION_GRANTED || pkgName
// .equals(Constants.PACKAGE_NAME))) {
// Log.d(Constants.TAG, pkgName + " has permission " + permName + ". Action "
// + action + " was granted!");
// } else {
// String error = pkgName + " does NOT have permission " + permName
// + ". Action " + action + " was NOT granted!";
// Log.e(Constants.TAG, error);
// Toast.makeText(activity, activity.getString(R.string.errorMessage, error),
// Toast.LENGTH_LONG).show();
//
// // end activity
// activity.setResult(Activity.RESULT_CANCELED, null);
// activity.finish();
// }
}
}
}
}