Java 类org.apache.cordova.PermissionHelper 实例源码

项目:cordova-plugin-navigation    文件:NavigationPlugin.java   
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
    if (!action.equals("navigation")) {
        return false;
    }

    this.option = NavigationOption.parseArgs(args);
    this.callbackContext = callbackContext;

    if (!hasPermisssion()) {
        PermissionHelper.requestPermissions(this, 0, permissions);
    } else {
        this.showNavigationView();
    }

    PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
    pluginResult.setKeepCallback(true);
    callbackContext.sendPluginResult(pluginResult);
    return true;
}
项目:cordova-plugin-navigation    文件:LocationPlugin.java   
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    if (!action.equals("getCurrentPosition") && !action.equals("watchPosition")) {
        return false;
    }

    if (!hasPermisssion()) {
        int requestCode = UUID.randomUUID().hashCode();
        PermissionHelper.requestPermissions(this, requestCode, permissions);
        permissionCallback.put(requestCode, new CallbackContextHolder(action.equals("getCurrentPosition"), callbackContext));
    } else {
        this.initClient(action.equals("getCurrentPosition"), callbackContext);
    }

    PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT);
    pluginResult.setKeepCallback(true);
    callbackContext.sendPluginResult(pluginResult);
    return true;
}
项目:alerta-fraude    文件:AudioHandler.java   
private void promptForRecord()
{
    if(PermissionHelper.hasPermission(this, permissions[WRITE_EXTERNAL_STORAGE])  &&
            PermissionHelper.hasPermission(this, permissions[RECORD_AUDIO])) {
        this.startRecordingAudio(recordId, FileHelper.stripFileProtocol(fileUriStr));
    }
    else if(PermissionHelper.hasPermission(this, permissions[RECORD_AUDIO]))
    {
        getWritePermission(WRITE_EXTERNAL_STORAGE);
    }
    else
    {
        getMicPermission(RECORD_AUDIO);
    }

}
项目:alerta-fraude    文件:AudioHandler.java   
private void promptForRecord()
{
    if(PermissionHelper.hasPermission(this, permissions[WRITE_EXTERNAL_STORAGE])  &&
            PermissionHelper.hasPermission(this, permissions[RECORD_AUDIO])) {
        this.startRecordingAudio(recordId, FileHelper.stripFileProtocol(fileUriStr));
    }
    else if(PermissionHelper.hasPermission(this, permissions[RECORD_AUDIO]))
    {
        getWritePermission(WRITE_EXTERNAL_STORAGE);
    }
    else
    {
        getMicPermission(RECORD_AUDIO);
    }

}
项目:localcloud_fe    文件:Geolocation.java   
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    LOG.d(TAG, "We are entering execute");
    context = callbackContext;
    if(action.equals("getPermission"))
    {
        if(hasPermisssion())
        {
            PluginResult r = new PluginResult(PluginResult.Status.OK);
            context.sendPluginResult(r);
            return true;
        }
        else {
            PermissionHelper.requestPermissions(this, 0, permissions);
        }
        return true;
    }
    return false;
}
项目:localcloud_fe    文件:Geolocation.java   
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    LOG.d(TAG, "We are entering execute");
    context = callbackContext;
    if(action.equals("getPermission"))
    {
        if(hasPermisssion())
        {
            PluginResult r = new PluginResult(PluginResult.Status.OK);
            context.sendPluginResult(r);
            return true;
        }
        else {
            PermissionHelper.requestPermissions(this, 0, permissions);
        }
        return true;
    }
    return false;
}
项目:localcloud_fe    文件:Geolocation.java   
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    LOG.d(TAG, "We are entering execute");
    context = callbackContext;
    if(action.equals("getPermission"))
    {
        if(hasPermisssion())
        {
            PluginResult r = new PluginResult(PluginResult.Status.OK);
            context.sendPluginResult(r);
            return true;
        }
        else {
            PermissionHelper.requestPermissions(this, 0, permissions);
        }
        return true;
    }
    return false;
}
项目:siiMobilityAppKit    文件:Geolocation.java   
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    LOG.d(TAG, "We are entering execute");
    context = callbackContext;
    if(action.equals("getPermission"))
    {
        if(hasPermisssion())
        {
            PluginResult r = new PluginResult(PluginResult.Status.OK);
            context.sendPluginResult(r);
            return true;
        }
        else {
            PermissionHelper.requestPermissions(this, 0, permissions);
        }
        return true;
    }
    return false;
}
项目:siiMobilityAppKit    文件:Geolocation.java   
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    LOG.d(TAG, "We are entering execute");
    context = callbackContext;
    if(action.equals("getPermission"))
    {
        if(hasPermisssion())
        {
            PluginResult r = new PluginResult(PluginResult.Status.OK);
            context.sendPluginResult(r);
            return true;
        }
        else {
            PermissionHelper.requestPermissions(this, 0, permissions);
        }
        return true;
    }
    return false;
}
项目:aiui    文件:AIUIPlugin.java   
private void promptForRecord() {
    if (PermissionHelper.hasPermission(this, permission)) {
        Log.i(TAG,"开启唤醒");

        wakeup = EventManagerFactory.create(getApplicationContext(), "wp");
        wakeup.registerListener(wakeupListener);

        Map<String, Object> params = new LinkedHashMap<String, Object>();
        params.put(com.baidu.speech.asr.SpeechConstant.APP_ID, "10099877");
        params.put(com.baidu.speech.asr.SpeechConstant.ACCEPT_AUDIO_VOLUME, false);
        params.put(com.baidu.speech.asr.SpeechConstant.WP_WORDS_FILE, "assets:///WakeUp.bin");
        String json = null; // 这里可以替换成你需要测试的json
        json = new JSONObject(params).toString();
        wakeup.send(com.baidu.speech.asr.SpeechConstant.WAKEUP_START, json, null, 0, 0);

    } else {
        getMicPermission(0);
    }

}
项目:SaveImage    文件:SaveImage.java   
/**
 * Check saveImage arguments and app permissions
 *
 * @param args              JSON Array of args
 * @param callbackContext   callback id for optional progress reports
 *
 * args[0] filePath         file path string to image file to be saved to gallery
 */  
private void saveImageToGallery(JSONArray args, CallbackContext callback) throws JSONException {
    this.filePath = args.getString(0);
    this.callbackContext = callback;
    Log.d("SaveImage", "SaveImage in filePath: " + filePath);

    if (filePath == null || filePath.equals("")) {
        callback.error("Missing filePath");
        return;
    }

    if (PermissionHelper.hasPermission(this, WRITE_EXTERNAL_STORAGE)) {
        Log.d("SaveImage", "Permissions already granted, or Android version is lower than 6");
        performImageSave();
    } else {
        Log.d("SaveImage", "Requesting permissions for WRITE_EXTERNAL_STORAGE");
        PermissionHelper.requestPermission(this, WRITE_PERM_REQUEST_CODE, WRITE_EXTERNAL_STORAGE);
    }      
}
项目:radioflow    文件:AudioHandler.java   
private void promptForRecord()
{
    if(PermissionHelper.hasPermission(this, permissions[WRITE_EXTERNAL_STORAGE])  &&
            PermissionHelper.hasPermission(this, permissions[RECORD_AUDIO])) {
        this.startRecordingAudio(recordId, FileHelper.stripFileProtocol(fileUriStr));
    }
    else if(PermissionHelper.hasPermission(this, permissions[RECORD_AUDIO]))
    {
        getWritePermission(WRITE_EXTERNAL_STORAGE);
    }
    else
    {
        getMicPermission(RECORD_AUDIO);
    }

}
项目:radioflow    文件:AudioHandler.java   
private void promptForRecord()
{
    if(PermissionHelper.hasPermission(this, permissions[WRITE_EXTERNAL_STORAGE])  &&
            PermissionHelper.hasPermission(this, permissions[RECORD_AUDIO])) {
        this.startRecordingAudio(recordId, FileHelper.stripFileProtocol(fileUriStr));
    }
    else if(PermissionHelper.hasPermission(this, permissions[RECORD_AUDIO]))
    {
        getWritePermission(WRITE_EXTERNAL_STORAGE);
    }
    else
    {
        getMicPermission(RECORD_AUDIO);
    }

}
项目:radioflow    文件:AudioHandler.java   
private void promptForRecord()
{
    if(PermissionHelper.hasPermission(this, permissions[WRITE_EXTERNAL_STORAGE])  &&
            PermissionHelper.hasPermission(this, permissions[RECORD_AUDIO])) {
        this.startRecordingAudio(recordId, FileHelper.stripFileProtocol(fileUriStr));
    }
    else if(PermissionHelper.hasPermission(this, permissions[RECORD_AUDIO]))
    {
        getWritePermission(WRITE_EXTERNAL_STORAGE);
    }
    else
    {
        getMicPermission(RECORD_AUDIO);
    }

}
项目:cordova-plugin-navigation    文件:NavigationPlugin.java   
public boolean hasPermisssion() {
    for (String p : permissions) {
        if (!PermissionHelper.hasPermission(this, p)) {
            return false;
        }
    }
    return true;
}
项目:cordova-plugin-navigation    文件:LocationPlugin.java   
public boolean hasPermisssion() {
    for (String p : permissions) {
        if (!PermissionHelper.hasPermission(this, p)) {
            return false;
        }
    }
    return true;
}
项目:localcloud_fe    文件:Geolocation.java   
public boolean hasPermisssion() {
    for(String p : permissions)
    {
        if(!PermissionHelper.hasPermission(this, p))
        {
            return false;
        }
    }
    return true;
}
项目:localcloud_fe    文件:Geolocation.java   
public boolean hasPermisssion() {
    for(String p : permissions)
    {
        if(!PermissionHelper.hasPermission(this, p))
        {
            return false;
        }
    }
    return true;
}
项目:localcloud_fe    文件:Geolocation.java   
public boolean hasPermisssion() {
    for(String p : permissions)
    {
        if(!PermissionHelper.hasPermission(this, p))
        {
            return false;
        }
    }
    return true;
}
项目:siiMobilityAppKit    文件:Calendar.java   
private boolean calendarPermissionGranted(String... types) {
  if (Build.VERSION.SDK_INT < 23) {
    return true;
  }
  for (final String type : types) {
    if (!PermissionHelper.hasPermission(this, type)) {
      return false;
    }
  }
  return true;
}
项目:siiMobilityAppKit    文件:Geolocation.java   
public boolean hasPermisssion() {
    for(String p : permissions)
    {
        if(!PermissionHelper.hasPermission(this, p))
        {
            return false;
        }
    }
    return true;
}
项目:siiMobilityAppKit    文件:Geolocation.java   
public boolean hasPermisssion() {
    for(String p : permissions)
    {
        if(!PermissionHelper.hasPermission(this, p))
        {
            return false;
        }
    }
    return true;
}
项目:siiMobilityAppKit    文件:Calendar.java   
private boolean calendarPermissionGranted(String... types) {
  if (Build.VERSION.SDK_INT < 23) {
    return true;
  }
  for (final String type : types) {
    if (!PermissionHelper.hasPermission(this, type)) {
      return false;
    }
  }
  return true;
}
项目:com.giants.multiimagespicker    文件:MultiImagesPicker.java   
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

    this.callbackContext = callbackContext;
    this.params = args.getJSONObject(0);

    if (action.equals("getPictures")) {

        maximumImagesCount = 9;
        desiredWidth = 0;
        desiredHeight = 0;
        quality = 100;
        if (this.params.has("maximumImagesCount")) {
            maximumImagesCount = this.params.getInt("maximumImagesCount");
        }
        if (this.params.has("width")) {
            desiredWidth = this.params.getInt("width");
        }
        if (this.params.has("height")) {
            desiredHeight = this.params.getInt("height");
        }
        if (this.params.has("quality")) {
            quality = this.params.getInt("quality");
        }


        if(!PermissionHelper.hasPermission(this, permissions[0])) {
            PermissionHelper.requestPermissions(this, PICK_ALBUM_SEC, permissions);
        } else {
            this.getPictures(maximumImagesCount, desiredWidth,desiredHeight,quality);
        }



        return true;
    }

    return false;
}
项目:sms-reader    文件:SmsReader.java   
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    if(!PermissionHelper.hasPermission(this, READ_SMS)) {
        PermissionHelper.requestPermission(this, SEARCH_REQ_CODE, READ_SMS);
        callbackContext.success("PLUGIN_PERMISSION_REQUESTED");
        return true;
    } else if (action.equals("checkText")) {
        String message = args.getString(0);
        this.checkText(message, callbackContext);
        return true;
    }
    return false;
}
项目:speech-recognition-android    文件:speechRecognitionAndroid.java   
private void promptForMic()
{
    if(PermissionHelper.hasPermission(this, permissions[RECORD_AUDIO])) {
        this.startRecognition();
    }
    else
    {
        getMicPermission();
    }

}
项目:api-recipe    文件:SpeechRecognition.java   
private void promptForMic()
{
    if(PermissionHelper.hasPermission(this, permissions[RECORD_AUDIO])) {
        this.startRecognition();
    }
    else
    {
        getMicPermission();
    }

}
项目:api-recipe    文件:SpeechRecognition.java   
private void promptForMic()
{
    if(PermissionHelper.hasPermission(this, permissions[RECORD_AUDIO])) {
        this.startRecognition();
    }
    else
    {
        getMicPermission();
    }

}
项目:cordova-plugin-openfilenative    文件:OpenFileNative.java   
@Override
public boolean execute(String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException {
    if (action.equals("openFileNative")) {
        callback = callbackContext;

        if (!PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)) {
            PermissionHelper.requestPermission(this, permissionRequestCode, Manifest.permission.READ_EXTERNAL_STORAGE);
            return true;
        }

        final JSONObject params = args.getJSONObject(0);
        if (!params.has("file") || params.has("file") && params.getString("file").length() == 0) {
            callback.error("File Parameter is missing");
            return true;
        }
        final String fileToOpen = params.getString("file");
        progressTitle = (params.has("progressTitle") && params.getString("progressTitle").length() > 0) ? params.getString("progressTitle") : "Open File";

        cordova.getActivity().runOnUiThread(new Runnable() {
            public void run() {
                try {
                    URI uri = new URI(fileToOpen);
                    if (uri.isAbsolute() && uri.getScheme().equalsIgnoreCase("market")) {
                        context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(fileToOpen)));
                        callback.success();
                    } else {
                        new DownloadAndOpenTask().execute(uri);
                    }
                } catch (URISyntaxException e) {
                    callback.error("Error while opening file \"" + fileToOpen + "\".");
                }
            }
        });
        return true;
    } else {
        return false;
    }
}
项目:cordova-plugin-baidu-geolocation    文件:GeolocationPlugin.java   
/**
 * 判断是否有对应权限
 */
public boolean hasPermisssion() {
    for(String p : permissions)
    {
        if(!PermissionHelper.hasPermission(this, p))
        {
            return false;
        }
    }
    return true;
}
项目:Flashlight-PhoneGap-Plugin    文件:Flashlight.java   
public boolean hasPermisssion() {
  for (final String p : permissions) {
    if (!PermissionHelper.hasPermission(this, p)) {
      return false;
    }
  }
  return true;
}
项目:cordova-plugin-navigation    文件:NavigationPlugin.java   
public void requestPermissions(int requestCode) {
    PermissionHelper.requestPermissions(this, requestCode, permissions);
}
项目:cordova-plugin-navigation    文件:LocationPlugin.java   
public void requestPermissions(int requestCode) {
    PermissionHelper.requestPermissions(this, requestCode, permissions);
}
项目:keemob    文件:FileUtils.java   
private void getReadPermission(String rawArgs, int action, CallbackContext callbackContext) {
    int requestCode = pendingRequests.createRequest(rawArgs, action, callbackContext);
    PermissionHelper.requestPermission(this, requestCode, Manifest.permission.READ_EXTERNAL_STORAGE);
}
项目:keemob    文件:FileUtils.java   
private void getWritePermission(String rawArgs, int action, CallbackContext callbackContext) {
    int requestCode = pendingRequests.createRequest(rawArgs, action, callbackContext);
    PermissionHelper.requestPermission(this, requestCode, Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
项目:keemob    文件:FileUtils.java   
private boolean hasReadPermission() {
    return PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
}
项目:keemob    文件:FileUtils.java   
private boolean hasWritePermission() {
    return PermissionHelper.hasPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
项目:keemob    文件:FileUtils.java   
private void getReadPermission(String rawArgs, int action, CallbackContext callbackContext) {
    int requestCode = pendingRequests.createRequest(rawArgs, action, callbackContext);
    PermissionHelper.requestPermission(this, requestCode, Manifest.permission.READ_EXTERNAL_STORAGE);
}
项目:keemob    文件:FileUtils.java   
private void getWritePermission(String rawArgs, int action, CallbackContext callbackContext) {
    int requestCode = pendingRequests.createRequest(rawArgs, action, callbackContext);
    PermissionHelper.requestPermission(this, requestCode, Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
项目:keemob    文件:FileUtils.java   
private boolean hasReadPermission() {
    return PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
}