tethering detection

pull/1/head
jens 8 months ago
parent b3ad72cc50
commit b35208b7aa

@ -67,6 +67,7 @@ import java.net.NetworkInterface;
import java.security.KeyStore;
import java.util.Calendar;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -2067,4 +2068,34 @@ public class Actions
return null;
}
public static boolean isTetheringActive1(Context context)
{
try
{
for(Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();)
{
NetworkInterface intf = en.nextElement();
for(Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();)
{
InetAddress inetAddress = enumIpAddr.nextElement();
if(!intf.isLoopback())
{
if(intf.getName().contains("rndis"))
{
return true;
}
}
}
}
}
catch(Exception e)
{
Miscellaneous.logEvent("e", "isTetheringActive()", Log.getStackTraceString(e), 3);
}
return false;
}
}

@ -78,6 +78,16 @@ public class ActivityMainScreen extends ActivityGeneric
tbLockSound = (ToggleButton) findViewById(R.id.tbLockSound);
toggleService = (ToggleButton) findViewById(R.id.tbArmMastListener);
Button bTether = (Button)findViewById(R.id.bTethering);
bTether.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View view)
{
Toast.makeText(ActivityMainScreen.this, "Tethering active: " + String.valueOf(Actions.isTetheringActive1(ActivityMainScreen.this)), Toast.LENGTH_LONG).show();
}
});
bDonate = (Button)findViewById(R.id.bDonate);
if(!BuildConfig.FLAVOR.equalsIgnoreCase(AutomationService.flavor_name_googleplay))

@ -3,6 +3,7 @@ package com.jens.automation2.receivers;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
@ -53,8 +54,22 @@ public class BroadcastListener extends android.content.BroadcastReceiver impleme
for(String key : intent.getExtras().keySet())
{
Miscellaneous.logEvent("i", "Broadcast extra", "Broadcast " + intent.getAction() + " has extra " + key + " and type " + intent.getExtras().get(key).getClass().getName(), 4);
// Object ob = intent.getExtras().get(key);
// Miscellaneous.logEvent("i", "Broadcast extra", "Broadcast " + intent.getAction() + " has extra " + key + " and type " + intent.getExtras().get(key).getClass().getName(), 4);
Object ob = intent.getExtras().get(key);
String target = null;
if(Build.VERSION.SDK_INT >= 26)
target = "tetherArray";
else
target = "activeArray";
if(key.equals(target) && ob instanceof ArrayList)
{
if(((ArrayList<String>)ob).size() > 0)
;
}
Miscellaneous.logEvent("i", "Broadcast extra", "Broadcast " + intent.getAction() + " has extra " + key + " and type " + intent.getExtras().get(key).getClass().getName(), 4);
}
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.broadcastReceived);

@ -339,6 +339,12 @@
android:layout_marginTop="30dp"
android:gravity="center_horizontal" >
<Button
android:id="@+id/bTethering"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/test" />
<Button
android:id="@+id/bShowHelp"
android:layout_gravity="center_vertical"

Loading…
Cancel
Save