public void runWithPermissions(Runnable r,Permission... permissions){
  SecurityManager sm=System.getSecurityManager();
  if (sm == null) {
    r.run();
  }
  if (!IS_ANDROID) {
    runWithSecurityManagerWithPermissions(r,permissions);
  }
}

public void runWithPermissions ( Runnable r , Permission ... permissions ) { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm == null ) { r . run ( ) ; } if ( ! IS_ANDROID ) { runWithSecurityManagerWithPermissions ( r , permissions ) ; } }
runs runnable r with a security policy that permits precisely the specified permissions . if there is no current security manager , the runnable is run twice , both with and without a security manager . we require that any security manager permit getpolicy / setpolicy .
