Browse files

checking for permissions

  • Loading branch information...
1 parent 624b860 commit 3d84da4228004ebe6ae0d1aa850a2e301687a623 Jon Vlachoyiannis committed Mar 17, 2011
View
BIN example/libs/sfalma-trace.jar
Binary file not shown.
View
2 src/com/sfalma/trace/Sfalma.java
@@ -42,7 +42,7 @@
public class Sfalma {
// FIXME: Use Gson
- public static String createJSON(String app_package, String version, String phoneModel, String android_version, String stackTrace, String wifi_status, String mob_net_status, boolean gps_status) throws Exception {
+ public static String createJSON(String app_package, String version, String phoneModel, String android_version, String stackTrace, String wifi_status, String mob_net_status, String gps_status) throws Exception {
JSONObject json = new JSONObject();
JSONObject exception_json = new JSONObject();
View
21 src/com/sfalma/trace/SfalmaHandler.java
@@ -518,7 +518,6 @@ private static String CheckNetworkConnection(String typeOfConnection, final Cont
String connected = "false";
PackageManager packageManager = context.getPackageManager();
-
if (packageManager.checkPermission("android.permission.ACCESS_NETWORK_STATE", G.APP_PACKAGE) == PackageManager.PERMISSION_GRANTED){
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo[] netInfo = cm.getAllNetworkInfo();
@@ -544,14 +543,20 @@ private static String isMobileNetworkOn(final Context context) {
return CheckNetworkConnection("MOBILE", context);
}
- private static boolean isGPSOn(final Context context) {
- boolean gps_status = true;
+ private static String isGPSOn(final Context context) {
+ String gps_status = "true";
- LocationManager locManager;
- locManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
- if (!locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){
- gps_status = false;
- }
+ PackageManager packageManager = context.getPackageManager();
+ if (packageManager.checkPermission("android.permission.ACCESS_FINE_LOCATION", G.APP_PACKAGE) == PackageManager.PERMISSION_GRANTED){
+ LocationManager locManager;
+ locManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
+ if (!locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){
+ gps_status = "false";
+ }
+ }
+ else {
+ gps_status = "not available [permissions]";
+ }
return gps_status;
}

0 comments on commit 3d84da4

Please sign in to comment.