cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (CB-10963) cordova-android does not support multiple runtime permission requests
Date Fri, 25 Mar 2016 20:10:25 GMT


ASF GitHub Bot commented on CB-10963:

Github user jasongin commented on a diff in the pull request:
    --- Diff: framework/src/org/apache/cordova/ ---
    @@ -0,0 +1,65 @@
    +       Licensed to the Apache Software Foundation (ASF) under one
    +       or more contributor license agreements.  See the NOTICE file
    +       distributed with this work for additional information
    +       regarding copyright ownership.  The ASF licenses this file
    +       to you under the Apache License, Version 2.0 (the
    +       "License"); you may not use this file except in compliance
    +       with the License.  You may obtain a copy of the License at
    +       Unless required by applicable law or agreed to in writing,
    +       software distributed under the License is distributed on an
    +       KIND, either express or implied.  See the License for the
    +       specific language governing permissions and limitations
    +       under the License.
    +package org.apache.cordova;
    +import android.util.Pair;
    +import android.util.SparseArray;
    + * Provides a collection that maps unique request codes to CordovaPlugins and Integers.
    + * Used to ensure that when plugins make requests for runtime permissions, those requests
do not
    + * collide with requests from other plugins that use the same request code value.
    + */
    +public class CallbackMap {
    +    private int currentCallbackId = 0;
    +    private SparseArray<Pair<CordovaPlugin, Integer>> callbacks;
    +    public CallbackMap() {
    +        this.callbacks = new SparseArray<Pair<CordovaPlugin, Integer>>();
    +    }
    +    /**
    +     * Stores a CordovaPlugin and request code and returns a new unique request code
to use
    +     * in a permission request.
    +     *
    +     * @param receiver      The plugin that is making the request
    +     * @param requestCode   The original request code used by the plugin
    +     * @return              A unique request code that can be used to retrieve this callback
    +     *                      with getAndRemoveCallback()
    +     */
    +    public int registerCallback(CordovaPlugin receiver, int requestCode) {
    +        int mappedId = this.currentCallbackId++;
    --- End diff --
    Can this be called concurrently? If so, consider using java.util.concurrent.atomic.AtomicInteger.

> cordova-android does not support multiple runtime permission requests
> ---------------------------------------------------------------------
>                 Key: CB-10963
>                 URL:
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>         Environment: Marshmallow
>            Reporter: Richard B Knoll
>            Assignee: Richard B Knoll
>              Labels: android, reproduced, triaged
> If a plugin makes multiple permission requests before the user grants/denies them, only
the last one will get returned. More importantly, requests from multiple plugins can interfere
with each other.
> For example, if Plugin A makes a permission request and then Plugin B immediately makes
another permission request before the user grants/denies Plugin A's request, then Plugin A
will never receive the results of its request (Android seems to return permission requests
in reverse order of when they were made, so Plugin B will actually get the correct result
> I've got a fix for this and will open a PR momentarily.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message