Technically, this could be used to trilaterate over time and heatmap where associates spend their time, as well as what activity occurs where. To do this, we would need the coordinates of all AP’s in the given store.
The endpoint was an AWS Lambda function which pushed the data into an AWS dynamodb table.
Main Activity
package com.appcrawler.networklogger; import android.support.v7.app.AppCompatActivity; import android.support.v4.app.ActivityCompat; import android.os.Bundle; import java.util.HashMap; import java.util.ArrayList; import java.util.List; import android.util.Log; import android.widget.TextView; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.message.BasicNameValuePair; import org.apache.http.NameValuePair; import org.apache.http.HttpResponse; import org.apache.http.impl.client.DefaultHttpClient; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); boolean permissionGranted = ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == android.content.pm.PackageManager.PERMISSION_GRANTED; ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, 200); setContentView(R.layout.activity_main); final WifiReceiver LocalWireless = new WifiReceiver(this.getApplicationContext()); try { while (true) { Thread.sleep(15000); HashMapwireless = LocalWireless.getWifiStrength(); for (String key : wireless.keySet()) { Log.d("NETWORKLOGGER",key + " " +wireless.get(key)); String[] s = {key, wireless.get(key).toString()}; new PostNetwork().execute(s); } } } catch (Exception e) { Log.d("ERROR",e.getMessage()); } } }
The wifi receiver
package com.appcrawler.networklogger; import android.content.Context; import android.net.wifi.WifiManager; import android.net.wifi.ScanResult; import java.util.HashMap; import java.util.List; import android.util.Log; class WifiReceiver { Context cxt=null; public WifiReceiver(Context c){ this.cxt=c; } public HashMapgetWifiStrength(){ WifiManager wifiManager = (WifiManager) cxt.getSystemService(Context.WIFI_SERVICE); List wifiList = wifiManager.getScanResults(); Log.d("WIFI",wifiList.toString()); HashMap wireless=new HashMap (); for(int i=0; i< wifiList.size() ;i++) { ScanResult scanResult= wifiList.get(i); //int level = WifiManager.calculateSignalLevel(scanResult.level, 500); int level = wifiList.get(i).level; String SSID = scanResult.SSID; wireless.put(SSID,level); } return wireless; } }
The async class
package com.appcrawler.networklogger; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicNameValuePair; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.entity.StringEntity; import org.json.JSONObject; import android.os.AsyncTask; import java.util.ArrayList; import java.util.List; import android.util.Log; import java.io.BufferedReader; import java.io.InputStreamReader; public class PostNetwork extends AsyncTask{ @Override public String doInBackground(String... params) { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("https://your_api_endpoint_to_which_you_post_the_json_below"); httppost.addHeader("content-type", "application/json"); HttpResponse response = null; StringBuilder str = new StringBuilder(); try { JSONObject json = new JSONObject(); json.put("network", params[0]); json.put("dbm", params[1]); StringEntity param = new StringEntity(json.toString()); httppost.setEntity(param); response = httpclient.execute(httppost); BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8")); String line = null; try { while ((line = reader.readLine()) != null) { str.append(line + "\n"); } } catch (Exception e) { throw e; } Log.d("RESPONSE",str.toString()); } catch (Exception e) { Log.d("ERROR",e.getMessage()); } return response.toString(); } @Override protected void onPostExecute(String result) {} @Override protected void onPreExecute() {} @Override protected void onProgressUpdate(String... text) {} }
The android manifest
The build.gradle for the app
apply plugin: 'com.android.application' android { compileSdkVersion 26 useLibrary 'org.apache.http.legacy' defaultConfig { applicationId "com.appcrawler.networklogger" minSdkVersion 26 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true } dependencies { compile 'org.apache.httpcomponents:httpcore:4.4.1' compile 'org.apache.httpcomponents:httpclient:4.5' } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } packagingOptions { exclude 'META-INF/DEPENDENCIES' } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' }