Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1AB67E7C3 for ; Fri, 25 Jan 2013 22:45:13 +0000 (UTC) Received: (qmail 91839 invoked by uid 500); 25 Jan 2013 22:45:12 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 91785 invoked by uid 500); 25 Jan 2013 22:45:12 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 91776 invoked by uid 500); 25 Jan 2013 22:45:12 -0000 Delivered-To: apmail-incubator-callback-dev@incubator.apache.org Received: (qmail 91773 invoked by uid 99); 25 Jan 2013 22:45:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Jan 2013 22:45:12 +0000 Date: Fri, 25 Jan 2013 22:45:12 +0000 (UTC) From: "Joe Bowser (JIRA)" To: callback-dev@incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CB-2273) There is a bug in the android geolocation plugin of Cordova 2.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CB-2273?page=3Dcom.atlassian.ji= ra.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1356311= 3#comment-13563113 ]=20 Joe Bowser commented on CB-2273: -------------------------------- How do you know you're using our plugin and not the built-in Geolocation in= the Cordova WebView? =20 > There is a bug in the android geolocation plugin of Cordova 2.3 > --------------------------------------------------------------- > > Key: CB-2273 > URL: https://issues.apache.org/jira/browse/CB-2273 > Project: Apache Cordova > Issue Type: Bug > Components: Android > Affects Versions: 2.2.0, 2.3.0 > Environment: HTC t328D,Android 4.0.3 > Reporter: SunshineTech Zhang > Assignee: Joe Bowser > Labels: patch > > When I call the watchPosition function, it only call back my successCallb= ack function 2 times and errorCallback function once. That is, it call back= successCallback function of getCurrentPosition and watchPosition; and erro= rCallback function of watchPosition when timeout event was fired. Then the = plugin gives nothing any more. > Then I read the source code of org.apache.cordova.GeoBroker and org.apach= e.cordova.CordovaLocationListener. I found there was an issue in the win an= d fail method of org.apache.cordova.CordovaLocationListener. That is, after= the listener called its callbacks' by traversal, it then stop itself, so i= t doesn't listen position changed information for its watches list. > So I modify them, the plugin runs well. > 1. I modify the win and fail method in the org.apache.cordova.CordovaLoca= tionListener as the following: > protected void fail(int code, String message) { > for (CallbackContext callbackContext: this.callbacks) > { > this.owner.fail(code, message, callbackContext, false); > } > if(this.owner.isGlobalListener(this) && this.watches.size() =3D= =3D 0) > { > =09Log.d(TAG, "Stopping global listener"); > =09this.stop(); > } > this.callbacks.clear(); > Iterator it =3D this.watches.values().iterator()= ; > while (it.hasNext()) { > this.owner.fail(code, message, it.next(), true); > } > } > private void win(Location loc) { > for (CallbackContext callbackContext: this.callbacks) > { > this.owner.win(loc, callbackContext, false); > } > if(this.owner.isGlobalListener(this) && this.watches.size() =3D= =3D 0) > { > =09Log.d(TAG, "Stopping global listener"); > =09this.stop(); > } > this.callbacks.clear(); > Iterator it =3D this.watches.values().iterator()= ; > while (it.hasNext()) { > this.owner.win(loc, it.next(), true); > } > } > 2=E3=80=81I modify the win and fail method in the org.apache.cordova.GeoB= roker as the following: > public void win(Location loc, CallbackContext callbackContext, boolean ke= epCallback) { > =09PluginResult result =3D new PluginResult(PluginResult.Status.OK, t= his.returnLocationJSON(loc)); > =09result.setKeepCallback(keepCallback); > callbackContext.sendPluginResult(result); > } > public void fail(int code, String msg, CallbackContext callbackContext, b= oolean keepCallback) { > JSONObject obj =3D new JSONObject(); > String backup =3D null; > try { > obj.put("code", code); > obj.put("message", msg); > } catch (JSONException e) { > obj =3D null; > backup =3D "{'code':" + code + ",'message':'" + msg.replaceAl= l("'", "\'") + "'}"; > } > PluginResult result; > if (obj !=3D null) { > result =3D new PluginResult(PluginResult.Status.ERROR, obj); > } else { > result =3D new PluginResult(PluginResult.Status.ERROR, backup= ); > } > result.setKeepCallback(keepCallback); > callbackContext.sendPluginResult(result); > } -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs For more information on JIRA, see: http://www.atlassian.com/software/jira