From 7942bf37e5f0f1ee174d5266bfa6618a30a9be75 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Mon, 1 Apr 2013 07:27:56 +0000 Subject: [PATCH] 2013-04-01 Sergio Martin * src/pandroid/agent/PandroidAgentListener.java: Fixed a crash bug in some devices when try to retrieve the coordinates provider. Close unclosed cursor and change some error logs to normal logs git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7905 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_agents/android/ChangeLog | 7 +++++++ .../pandroid/agent/PandroidAgentListener.java | 18 +++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/pandora_agents/android/ChangeLog b/pandora_agents/android/ChangeLog index 255df84f27..be64b92b2e 100644 --- a/pandora_agents/android/ChangeLog +++ b/pandora_agents/android/ChangeLog @@ -1,3 +1,10 @@ +2013-04-01 Sergio Martin + + * src/pandroid/agent/PandroidAgentListener.java: Fixed + a crash bug in some devices when try to retrieve the + coordinates provider. Close unclosed cursor and change some + error logs to normal logs + 2012-09-24 Mark Holland * src/pandroid/agent/PandroidAgentListener.java: diff --git a/pandora_agents/android/src/pandroid/agent/PandroidAgentListener.java b/pandora_agents/android/src/pandroid/agent/PandroidAgentListener.java index 0e13d301b7..7466cdc7c1 100644 --- a/pandora_agents/android/src/pandroid/agent/PandroidAgentListener.java +++ b/pandora_agents/android/src/pandroid/agent/PandroidAgentListener.java @@ -484,19 +484,19 @@ try { // catches IOException below LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); List providers = lm.getProviders(true); - Log.e("PANDROID providers count", "" + providers.size()); + Log.d("PANDROID providers count", "" + providers.size()); /* Loop over the array backwards, and if you get an accurate location, then break out the loop*/ Location loc = null; for (int i=providers.size()-1; i>=0; i--) { - Log.e("PANDROID providers", providers.get(i)); + Log.d("PANDROID providers", providers.get(i)); loc = lm.getLastKnownLocation(providers.get(i)); if (loc != null) break; } if (loc != null) { - Log.e("PANDROID", "loc != null"); + Log.d("PANDROID", "loc != null"); //if(latitude != loc.getLatitude() || longitude != loc.getLongitude()) { lastGpsContactDateTime = getHumanDateTime(-1); //} @@ -512,6 +512,12 @@ try { // catches IOException below criteria.setCostAllowed(true); String bestProvider = lm.getBestProvider(criteria, true); + // If not provider found, abort GPS retrieving + if (bestProvider == null) { + Log.e("LOCATION", "No location provider found!"); + return; + } + lm.requestLocationUpdates(bestProvider, Core.defaultInterval, 1000, new LocationListener() { public void onLocationChanged(Location location) { @@ -612,11 +618,11 @@ try { // catches IOException below String gpsStatus = getSharedData("PANDROID_DATA", "gpsStatus", Core.defaultGpsStatus, "string"); if(gpsStatus.equals("enabled")) { - Log.e("PANDROID AGENT", "ENABLED"); + Log.d("PANDROID AGENT", "ENABLED"); gpsLocation(); } else { - Log.e("PANDROID AGENT", "DISABLED"); + Log.d("PANDROID AGENT", "DISABLED"); putSharedData("PANDROID_DATA", "latitude", "181.0", "float"); putSharedData("PANDROID_DATA", "longitude", "181.0", "float"); } @@ -886,6 +892,8 @@ try { // catches IOException below putSharedData("PANDROID_DATA", "missedCalls", ""+missed, "integer"); putSharedData("PANDROID_DATA", "outgoingCalls", ""+outgoing, "integer"); } + + c.close(); }// end getCalls /** * Retrieves the current cell signal strength in dB