Newer versions of Android require explicit permission from the user
962619
private void requestCameraPermission() {
		int permissionCheck = ContextCompat.checkSelfPermission(this,
				Manifest.permission.CAMERA);

		if( permissionCheck != android.content.pm.PackageManager.PERMISSION_GRANTED) {
			ActivityCompat.requestPermissions(this,
					new String[]{Manifest.permission.CAMERA},
					0);
			// a dialog should open and this dialog will resume when a decision has been made
		}
	}
1313119
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_download_files(obj, user)
785056
protected void requestPermission(String[] permissions, int code) {
        if (Build.VERSION.SDK_INT >= 23) {
            List<String> deniedPermissions = getDeniedPermissions(this, permissions);
            if (deniedPermissions.isEmpty()) {
                onPermissionGranted(code);
            } else {
                permissions = new String[deniedPermissions.size()];
                deniedPermissions.toArray(permissions);
                ActivityCompat.requestPermissions(this, permissions, code);
            }
        } else {
            onPermissionGranted(code);
        }
    }
273589
def create_permission(self):
        """"""
        return Permission(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
641415
def has_permission(self, permission):
        
        f = self.create_future()

        #: Old versions of android did permissions at install time
        if self.api_level < 23:
            f.set_result(True)
            return f

        def on_result(allowed):
            result = allowed == Activity.PERMISSION_GRANTED
            self.set_future_result(f, result)

        self.widget.checkSelfPermission(permission).then(on_result)

        return f
699954
def setup_default_permissions(session, instance):
    
    if instance not in session.new or not isinstance(instance, Entity):
        return

    if not current_app:
        # working outside app_context. Raw object manipulation
        return

    _setup_default_permissions(instance)
814593
private void modify(Set<Permission> permissions, IResource resource, String user, String op) throws RequestExecutionException
    {
        process(String.format("UPDATE %s.%s SET permissions = permissions %s {%s} WHERE username = '%s' AND resource = '%s'",
                              Auth.AUTH_KS,
                              PERMISSIONS_CF,
                              op,
                              "'" + StringUtils.join(permissions, "','") + "'",
                              escape(user),
                              escape(resource.getName())));
    }
959913
public static boolean isPermissionGranted(@NonNull Context context, @NonNull String permission) {
        return ActivityCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
    }
381982
public static boolean checkPermission(Context context, String permission) {
    boolean hasPermission =
        (PackageManager.PERMISSION_GRANTED == context.checkCallingOrSelfPermission(permission));
    if (!hasPermission) {
      printErrorLog("permission " + permission + " is missing!");
    }
    return hasPermission;
  }
1368780
static void requestPermission(Source source, String[] permissions) {
        Intent intent = new Intent(source.getContext(), BridgeActivity.class);
        intent.putExtra(KEY_TYPE, BridgeRequest.TYPE_PERMISSION);
        intent.putExtra(KEY_PERMISSIONS, permissions);
        source.startActivity(intent);
    }
439655
def request_permission(cls, fine=True):
        
        app = AndroidApplication.instance()
        permission = (cls.ACCESS_FINE_PERMISSION
                      if fine else cls.ACCESS_COARSE_PERMISSION)
        f = app.create_future()

        def on_result(perms):
            app.set_future_result(f, perms[permission])

        app.request_permissions([permission]).then(on_result)

        return f
376350
private static void checkPermission() {
        SecurityManager security = System.getSecurityManager();
        if (security != null)
            security.checkPermission(modifyThreadPermission);
    }
307885
@Override
  public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
                                         @NonNull int[] grantResults) {
    if (requestCode == REQUEST_READ_CONTACTS) {
      if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
        populateAutoComplete();
      }
    }
  }
130564
private Set<Permission> checkPermissions(AAFAuthenticatedUser aau, String type, String instance) {
		// Can perform ALL actions
        String fullName = aau.getFullName();
        PermHolder ph = new PermHolder(aau);
        aafLur.fishOneOf(fullName, ph,type,instance,actions);
        return ph.permissions;
    }
557192
public static void getPermission(@NonNull Activity context, String permissions, @NonNull Response response) {
        getPermission(context, new String[]{permissions}, response);
    }
1272810
def fix_permissions (self):
        """"""
        if os.name == 'posix' and not self.dry_run:
            # Make the data files we just installed world-readable,
            # and the directories world-executable as well.
            for path in self.get_outputs():
                mode = os.stat(path)[stat.ST_MODE]
                if stat.S_ISDIR(mode):
                    mode |= 0o11
                mode |= 0o44
                os.chmod(path, mode)
213769
def set_permission(permission, value, app):
    
    # The object created to wrap PermissionSettingsModule is to work around
    # an intermittent bug where it will sometimes be undefined.
    script = """
      const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
      var a = {b: Cu.import("resource://gre/modules/PermissionSettings.jsm")};
      return a.b.PermissionSettingsModule.addPermission({
        type: '%s',
        origin: '%s',
        manifestURL: '%s/manifest.webapp',
        value: '%s',
        browserFlag: false
      });
    """
    app_url = 'app://' + app
    run_marionette_script(script % (permission, app_url, app_url, value), True)