cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jasongin <...@git.apache.org>
Subject [GitHub] cordova-android pull request: CB-10963: Handle overlapping permiss...
Date Fri, 25 Mar 2016 20:09:41 GMT
Github user jasongin commented on a diff in the pull request:

    https://github.com/apache/cordova-android/pull/285#discussion_r57485105
  
    --- Diff: framework/src/org/apache/cordova/CallbackMap.java ---
    @@ -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
    +
    +         http://www.apache.org/licenses/LICENSE-2.0
    +
    +       Unless required by applicable law or agreed to in writing,
    +       software distributed under the License is distributed on an
    +       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +       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.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message