BT tethering
This commit is contained in:
parent
92ca6d6cb4
commit
17109b12d4
@ -349,6 +349,8 @@ public class Rule implements Comparable<Rule>
|
|||||||
return true;
|
return true;
|
||||||
case setWifiTethering:
|
case setWifiTethering:
|
||||||
return true;
|
return true;
|
||||||
|
case setBluetoothTethering:
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -337,22 +337,30 @@ public class Actions
|
|||||||
Object BTSrvInstance = null;
|
Object BTSrvInstance = null;
|
||||||
Method mBTPanConnect = null;
|
Method mBTPanConnect = null;
|
||||||
|
|
||||||
|
String sClassName = "android.bluetooth.BluetoothPan";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
classBluetoothPan = Class.forName(sClassName);
|
||||||
|
Constructor<?> ctor = classBluetoothPan.getDeclaredConstructor(Context.class, BluetoothProfile.ServiceListener.class);
|
||||||
|
|
||||||
|
ctor.setAccessible(true);
|
||||||
|
// Set Tethering ON
|
||||||
|
|
||||||
|
Class[] paramSet = new Class[1];
|
||||||
|
paramSet[0] = boolean.class;
|
||||||
|
|
||||||
|
synchronized (mutex)
|
||||||
|
{
|
||||||
|
setTetheringOn = classBluetoothPan.getDeclaredMethod("setBluetoothTethering", paramSet);
|
||||||
|
isTetheringOn = classBluetoothPan.getDeclaredMethod("isTetheringOn", null);
|
||||||
|
instance = ctor.newInstance(context, new BTPanServiceListener(context));
|
||||||
|
}
|
||||||
|
|
||||||
classBluetoothPan = Class.forName("android.bluetooth.BluetoothPan");
|
classBluetoothPan = Class.forName("android.bluetooth.BluetoothPan");
|
||||||
mBTPanConnect = classBluetoothPan.getDeclaredMethod("connect", BluetoothDevice.class);
|
mBTPanConnect = classBluetoothPan.getDeclaredMethod("connect", BluetoothDevice.class);
|
||||||
BTPanCtor = classBluetoothPan.getDeclaredConstructor(Context.class, BluetoothProfile.ServiceListener.class);
|
BTPanCtor = classBluetoothPan.getDeclaredConstructor(Context.class, BluetoothProfile.ServiceListener.class);
|
||||||
BTPanCtor.setAccessible(true);
|
BTPanCtor.setAccessible(true);
|
||||||
BTSrvInstance = BTPanCtor.newInstance(context, new BTPanServiceListener(context));
|
BTSrvInstance = BTPanCtor.newInstance(context, new BTPanServiceListener(context));
|
||||||
}
|
|
||||||
catch (ClassNotFoundException e)
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("e", "Bluetooth Tethering", Log.getStackTraceString(e), 1);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("e", "Bluetooth Tethering", Log.getStackTraceString(e), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
|
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
|
||||||
|
|
||||||
@ -372,9 +380,23 @@ public class Actions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
catch (NoSuchMethodException e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("e", "Bluetooth Tethering", Log.getStackTraceString(e), 1);
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("e", "Bluetooth Tethering", Log.getStackTraceString(e), 1);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("e", "Bluetooth Tethering", Log.getStackTraceString(e), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static class BTPanServiceListener implements BluetoothProfile.ServiceListener
|
public static class BTPanServiceListener implements BluetoothProfile.ServiceListener
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user