/**
 * Project: ANE-Google-Analytics
 *
 * Author:  Alessandro Bianco
 * Website: http://alessandrobianco.eu
 * Twitter: @alebianco
 * Created: 21/12/12 15.02
 *
 * Copyright © 2013 Alessandro Bianco
 */
package eu.alebianco.air.extensions.analytics.functions;

import com.adobe.fre.FREContext;
import com.adobe.fre.FREFunction;
import com.adobe.fre.FREObject;
import com.stackoverflow.util.StackTraceInfo;
import eu.alebianco.air.extensions.utils.FREUtils;
import eu.alebianco.air.extensions.utils.LogLevel;

public class IsSupported implements FREFunction {

    @Override
    public FREObject call(FREContext context, FREObject[] args) {
        FREObject result;

        try {
            result = FREObject.newObject(true);
        } catch(Exception e) {
            FREUtils.logEvent(context, LogLevel.ERROR,
                    "Unable to create the return value. [Exception:(type:%s, method:%s)].",
                    FREUtils.stripPackageFromClassName(e.toString()), FREUtils.stripPackageFromClassName(StackTraceInfo.getCurrentClassName()));
            return FREUtils.createRuntimeException("ArgumentError", 0, "Unable to create the return value on method '%s'.", FREUtils.stripPackageFromClassName(StackTraceInfo.getCurrentClassName()));
        }

        return result;
    }
}
@@ -255,16 +255,112 @@
 tions;%0A%0A
+import android.Manifest;%0Aimport android.app.Activity;%0Aimport android.content.pm.PackageManager;%0A
 import c
@@ -757,16 +757,520 @@
 esult;%0A%0A
+        Activity activity = context.getActivity();%0A        PackageManager pm = activity.getPackageManager();%0A        int hasInternet = pm.checkPermission(Manifest.permission.INTERNET, activity.getPackageName());%0A        int hasNetworkState = pm.checkPermission(Manifest.permission.ACCESS_NETWORK_STATE, activity.getPackageName());%0A        Boolean hasPermissions = hasInternet == PackageManager.PERMISSION_GRANTED &&%0A                                 hasNetworkState == PackageManager.PERMISSION_GRANTED;%0A%0A
         
@@ -1320,12 +1320,22 @@
 ect(
-true
+hasPermissions
 );%0A 
@@ -1866,16 +1866,205 @@
      %7D%0A%0A
+        if (!hasPermissions) %7B%0A            FREUtils.logEvent(context, LogLevel.WARN, %22Application must have INTERNET and ACCESS_NETWORK_STATE permissions set in its Manifest.%22);%0A        %7D%0A%0A
         

verify that application has the appropriate permissions while checking if extension is supported