Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

checking for permissions

  • Loading branch information...
commit 624b860263475264f878949eadd6241d8f27aaef 1 parent 4de2b29
Jon Vlachoyiannis authored
View
3  example/AndroidManifest.xml
@@ -15,9 +15,6 @@
<uses-permission android:name="android.permission.INTERNET" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-sdk android:minSdkVersion="3" />
</manifest>
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, boolean wifi_status, boolean 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, boolean gps_status) throws Exception {
JSONObject json = new JSONObject();
JSONObject exception_json = new JSONObject();
View
30 src/com/sfalma/trace/SfalmaHandler.java
@@ -62,7 +62,6 @@
import android.location.LocationManager;
import android.location.LocationListener;
import android.location.Location;
-import android.Manifest.permission;
/**
* Usage:
@@ -515,26 +514,33 @@ private static void installHandler() {
}
}
- private static boolean CheckNetworkConnection(String typeOfConnection, final Context context) {
- boolean connected = false;
+ private static String CheckNetworkConnection(String typeOfConnection, final Context context) {
+ String connected = "false";
- //if (android.Manifest.permission.ACCESS_NETWORK_STATE ==
+ 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();
+ for (NetworkInfo ni : netInfo) {
+ if (ni.getTypeName().equalsIgnoreCase(typeOfConnection))
+ if (ni.isConnected())
+ connected = "true";
+ }
- ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo[] netInfo = cm.getAllNetworkInfo();
- for (NetworkInfo ni : netInfo) {
- if (ni.getTypeName().equalsIgnoreCase(typeOfConnection))
- if (ni.isConnected())
- connected = true;
}
+ else {
+ connected = "not available [permissions]";
+ }
+
return connected;
}
- private static boolean isWifiOn(final Context context) {
+ private static String isWifiOn(final Context context) {
return CheckNetworkConnection("WIFI", context);
}
- private static boolean isMobileNetworkOn(final Context context) {
+ private static String isMobileNetworkOn(final Context context) {
return CheckNetworkConnection("MOBILE", context);
}
Please sign in to comment.
Something went wrong with that request. Please try again.