website logo
Surffy Docs
Surffy Docs (Korean)
Surffy-FFFLOW
Surffy-FFFLOW (Korean)
Navigate through spaces
⌘K
Surffy
Surffy Introduction
Surffy Main
Surffy User Management
NetFUNNEL
NetFUNNEL Introduction
NetFUNNEL Getting started
NetFUNNEL Main
Monitoring
Glossary of Terms
Release notes (v23.05.2)
Changelogs
For Developers
Web Agent
Android Agent
iOS Agent
Docs powered by archbee 

Android Agent

25min



Android

This document provides a guide to applying and integrating Surffy NetFUNNEL Agent in the Android OS (AOS) environment.

Installation

Add code where the NetFUNNEL service is required.

Apply the code recommended in this guide to the communication part of your user code, and you can use the Surffy service through external URL input.

Kotlin

Kotlin
|
  /* setting netfunnel config */
  fun nfInit() {
      /*
       * 1. AppName, 2. tenant API Server URL, 3. tenant Netfunnel Server URL, 4. netfunnel setting server URL,
       * 5. eum Server URL, 6. activity(waiting page on this activity), 7. context
       */
      Netfunnel.Init(
           "MyAppName",
           "{tenant API URL}",
           "{tenant NF URL}",
           "{nf-setting URL}",
           "{eum URL}",
           this,
           this.baseContext
       )
   }

  /*
    Netfunnel Logic Start
  */
  fun netfunnelStart() {
      /*
        * Action
        */
      val myInterface = object : AgentInterface() {
          override fun onSuccess() {  // call when no more waiting.
              object : Thread() {
                  override fun run() {
                      /**
                        * to do what you want to after no more waiting
                        * example, connect to another URL
                        */
                      try {
                          val url = URL("{serviceURL}")
                          val conn = url.openConnection() as HttpURLConnection
                          if (conn != null) {
                              conn.connectTimeout = 10000
                              conn.requestMethod = "GET"
                              conn.readTimeout = 10000
                              conn.doInput = true
                              val inputStream = conn.inputStream
                              val br = BufferedReader(InputStreamReader(inputStream, "UTF-8"))
                              conn.disconnect()
                          }
                      } catch (e: IOException) {
                          e.printStackTrace()
                      }
                      super.run()
                      /*
                        * example end
                        */
                  }
              }.start()
          }
          /* Optional */
          override fun onCancel(_cancelURL: String) {
              if( _cancelURL == "" ) {
                  return
              }
              /* do something what you want */
              
          }
      }
      /*
       * the URL which you want to enter after Addmission check
       */
      Netfunnel.nfStart("{service URL}", myInterface)/* netfunnel logic start! */
  }


Java

Java
|
    /* setting netfunnel config */ 
    public void nfInit() {
       /*
        * 1. AppName, 2. tenant API Server URL, 3. tenant Netfunnel Server URL, 4. netfunnel setting server URL,
        * 5. eum Server URL, 6. activity(waiting page on this activity), 7. context
        */
        Netfunnel.Init("MyAppName", "{tenant API URL}", "{tenant NF URL}", "{nf-setting URL}", "{eum URL}", this, this.getBaseContext());
    }

    public void useHttpURLConnection() {
        /*
         * Addmission check Action
         */
        AgentInterface myInterface = new AgentInterface() {
            @Override
            public void onSuccess() { // This function is where the operation is implemented after the wait time check is completed and the entry is allowed.
                new Thread() {
                    @Override
                    public void run() {
                        /**
                         * to do what you want to after the waiting (or non waiting)
                         * example, connect to another URL
                         */
                        java.net.URL url = null;
                        try {
                            url = new URL("{service URL}");
                            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                            if (conn != null) {
                                conn.setConnectTimeout(10000);
                                conn.setReadTimeout(10000);
                                conn.setRequestMethod("GET");
                                conn.setDoInput(true);
                                InputStream inputStream = conn.getInputStream();
                                BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
                                conn.disconnect();
                            }
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                        super.run();
                        /*
                         * example end
                         */
                    }
                }.start();
            }
            @Override
            public void onCancel(@NonNull String _cancelURL) {
                if( _cancelURL == "" ) {
                    return;
                }
                /* do something what you want */
                
            }
        };
       /*
        * the URL which you want to enter after Addmission check
        */
        Netfunnel.nfStart("{service URL}", myInterface);/* netfunnel logic start! */
    }




Netfunnel

This class manages the overall flow.

As it is made of a singleton, you can reuse it by setting only the information that has changed since the initial information input as a setter.

Property

Users must enter the properties below:

  • AppName: The client's application name
  • Activity: The current Activity that NetFUNNEL is to be applied
  • Context: Context for getting device internal information (If it is null, it gets Activity's Context value.)
  • TenantAPIURL: Tenant API server address
  • TenantNFURL: Tenant NetFUNNEL server address
  • eumURL: End User Monitoring server address
  • SettingURL: Server address for NetFUNNEL setting

The TenantAPIURL, TenantNFURL properties can be entered from the console's AOS installation guide.

nfStart()

After registering all input properties and AgentInterface, calling the nfStart() method starts NetFUNNEL (Checking the queue).

After the NetFUNNEL action, you can record the next action in the onSuccess method of AgentInterface. AgentInterface will be explained later in detail.

AgentInterface

An interface that defines functionally for use by users.

In AgentInterface, functions are defined by overriding the following functions. If not defined, there is no action.

Method

  • public void onSuccess() *required
    • It defines the action after NetFUNNEL action. Put the actual working code in this part.
  • public void onCancel()
    • Defined to prepare for situations where actions such as cancellation occur during NetFUNNEL action.

Recommend not to insert the code that may affect the action from the next line that performs nfStart() method of NetFunnel class.

As all methods perform as callbacks, recommend not to use functions that can cause problems, such as Activity, for functions of AgentInterface.

WebView

Surffy-NetFUNNEL-Agent has a structure that the client within the WebView communicates with the server after showing the waiting room to the WebView.

EUM

If NetFUNNEL performs successfully, the user's EUM information starts to be collected, and when the NetFUNNEL ends, the collected information is sent to the server.



Requirements

The minimum required specifications are:

  • JAVA: JDK 1.8 and above
  • Android: Android Agent 23 (Marshmallow) and above

Function

  • VWR (Virtual Waiting Room)
  • EUM (End-User Monitoring)



Appendix

Anomaly Action Defense

No Internet connection

Add the defense logic that leads to the 'cancel' action when there is no internet connection.

Airplane mode

Sometimes bypass access (unauthorized access) is attempted through airplane mode. The defense against this is:

  • If airplane mode is on, we stop the communication and proceed to AgentInterface's onCancel method to defend the main flow.

Go-back (cancel)

Sometimes bypass access (unauthorized access) is attempted through the go-back button or the cancel button. The defense against this is:

  • If the cancel button is entered in the WebView, we stop the communication and proceed to onCancel method of AgentInterface to defend the main flow.
  • If the go-back button is entered, we proceed to onCancel method of AgentInterface by using the onBackPressed listener to defend the main flow.

Fast iteration input

Events that NetFUNNEL performs (onClick, etc.) are the user's domain, and NetFUNNEL can be repeatedly called when inputting (touching) quickly and repeatedly according to the implemented logic.

  • When the nfStart() function is called, the same service URL request is repeatedly checked for 1 second.



Add library

Download the aar file in the attached file and add it to the app unit gradle.

e.g. 'aar' file under 'libs' directory

implementation files('libs/surffy-agent_x.x.x.aar')



Response Status Code

Code

Description

note

200(SUCCESS)

on success

 

201(CONTUNUE)

on waiting

 

300(BYPASS)

Regardless of the 200 code in the server, it permits to enter

 

301(SERVERSIDE_BLOCK)

Blocked from the server

 

302(SERVERSIDE_IP_BLOCK)

The IP is blocked on the server

 

303(EXPRESS_NUMBER)

Regardless of the queue, it counts as Success immediately 



499(USER_CANCEL)

The user cancels

The cancel button in the NetFUNNEL WebView UI

500

No service 

Error code

502(KEY_DONE)

The key has already expired

 Error code

505(KEY_NOT_EXISTS)

The key doesn't exist

 Error code

507(INVALID_KEY)

Wrong key

 Error code

513(LICENSE_OVER)

Expired license



905(ERROR_DATA)

Data error



908(ERROR_SERVICE)

NetFUNNEL server not working



999(ERROR_SYSTEM)

NetFUNNEL server not working





Library usage example

https://drive.google.com/drive/u/0/folders/13PKIB4UWqxu9JnA_87zopN1wFWke_D9B


Connection communication example

https://drive.google.com/file/d/1Pr4a2Zb1XH_yD1jjzVMl6BPH0bxOpF0m/view












🏄‍♂️ Any other questions or feedback on Surffy docs? E-mail us at support@stclab.com.



Did this page help you?
Yes
No
PREVIOUS
Web Agent
NEXT
iOS Agent
Docs powered by archbee 
TABLE OF CONTENTS
Android
Installation
Kotlin
Java
Netfunnel
Property
nfStart()
AgentInterface
Method
WebView
EUM
Requirements
Function
Appendix
Anomaly Action Defense
No Internet connection
Airplane mode
Go-back (cancel)
Fast iteration input
Add library
Response Status Code
Library usage example
Connection communication example