Merge remote-tracking branch 'origin/BT_tethering' into development
This commit is contained in:
commit
f991325566
4
.idea/deploymentTargetDropDown.xml
generated
4
.idea/deploymentTargetDropDown.xml
generated
@ -7,11 +7,11 @@
|
|||||||
<deviceKey>
|
<deviceKey>
|
||||||
<Key>
|
<Key>
|
||||||
<type value="VIRTUAL_DEVICE_PATH" />
|
<type value="VIRTUAL_DEVICE_PATH" />
|
||||||
<value value="C:\Users\jens\.android\avd\Android_11.avd" />
|
<value value="C:\Users\jens\.android\avd\Android_10.avd" />
|
||||||
</Key>
|
</Key>
|
||||||
</deviceKey>
|
</deviceKey>
|
||||||
</Target>
|
</Target>
|
||||||
</targetSelectedWithDropDown>
|
</targetSelectedWithDropDown>
|
||||||
<timeTargetWasSelectedWithDropDown value="2021-11-07T11:58:40.808135100Z" />
|
<timeTargetWasSelectedWithDropDown value="2021-11-17T20:27:19.909652Z" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ public class Action
|
|||||||
setBluetooth,
|
setBluetooth,
|
||||||
setUsbTethering,
|
setUsbTethering,
|
||||||
setWifiTethering,
|
setWifiTethering,
|
||||||
|
setBluetoothTethering,
|
||||||
setDisplayRotation,
|
setDisplayRotation,
|
||||||
turnWifiOn,turnWifiOff,
|
turnWifiOn,turnWifiOff,
|
||||||
turnBluetoothOn,turnBluetoothOff,
|
turnBluetoothOn,turnBluetoothOff,
|
||||||
@ -31,7 +32,7 @@ public class Action
|
|||||||
changeSoundProfile,
|
changeSoundProfile,
|
||||||
turnUsbTetheringOn,turnUsbTetheringOff,
|
turnUsbTetheringOn,turnUsbTetheringOff,
|
||||||
turnWifiTetheringOn,turnWifiTetheringOff,
|
turnWifiTetheringOn,turnWifiTetheringOff,
|
||||||
enableScreenRotation, disableScreenRotation,
|
enableScreenRotation,disableScreenRotation,
|
||||||
startOtherActivity,
|
startOtherActivity,
|
||||||
waitBeforeNextAction,
|
waitBeforeNextAction,
|
||||||
wakeupDevice,
|
wakeupDevice,
|
||||||
@ -54,6 +55,8 @@ public class Action
|
|||||||
return context.getResources().getString(R.string.actionSetBluetooth);
|
return context.getResources().getString(R.string.actionSetBluetooth);
|
||||||
case setWifiTethering:
|
case setWifiTethering:
|
||||||
return context.getResources().getString(R.string.actionSetWifiTethering);
|
return context.getResources().getString(R.string.actionSetWifiTethering);
|
||||||
|
case setBluetoothTethering:
|
||||||
|
return context.getResources().getString(R.string.actionSetBluetoothTethering);
|
||||||
case setUsbTethering:
|
case setUsbTethering:
|
||||||
return context.getResources().getString(R.string.actionSetUsbTethering);
|
return context.getResources().getString(R.string.actionSetUsbTethering);
|
||||||
case setDisplayRotation:
|
case setDisplayRotation:
|
||||||
@ -178,6 +181,13 @@ public class Action
|
|||||||
else
|
else
|
||||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnWifiTetheringOff));
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnWifiTetheringOff));
|
||||||
}
|
}
|
||||||
|
else if(this.getAction().equals(Action_Enum.setBluetoothTethering))
|
||||||
|
{
|
||||||
|
if(this.getParameter1())
|
||||||
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnBluetoothTetheringOn));
|
||||||
|
else
|
||||||
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnBluetoothTetheringOff));
|
||||||
|
}
|
||||||
else if(this.getAction().equals(Action_Enum.setDisplayRotation))
|
else if(this.getAction().equals(Action_Enum.setDisplayRotation))
|
||||||
{
|
{
|
||||||
if(this.getParameter1())
|
if(this.getParameter1())
|
||||||
@ -382,6 +392,9 @@ public class Action
|
|||||||
case setWifiTethering:
|
case setWifiTethering:
|
||||||
Actions.setWifiTethering(context, getParameter1(), toggleActionIfPossible);
|
Actions.setWifiTethering(context, getParameter1(), toggleActionIfPossible);
|
||||||
break;
|
break;
|
||||||
|
case setBluetoothTethering:
|
||||||
|
Actions.BluetoothTetheringClass.setBluetoothTethering(context, getParameter1(), toggleActionIfPossible);
|
||||||
|
break;
|
||||||
case setDisplayRotation:
|
case setDisplayRotation:
|
||||||
Actions.setDisplayRotation(context, getParameter1(), toggleActionIfPossible);
|
Actions.setDisplayRotation(context, getParameter1(), toggleActionIfPossible);
|
||||||
break;
|
break;
|
||||||
|
@ -321,38 +321,46 @@ public class Actions
|
|||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "Bluetooth Tethering", "Changing Bluetooth Tethering to " + String.valueOf(desiredState), 4);
|
Miscellaneous.logEvent("i", "Bluetooth Tethering", "Changing Bluetooth Tethering to " + String.valueOf(desiredState), 4);
|
||||||
|
|
||||||
boolean state = Actions.isWifiApEnabled(context);
|
// boolean state = isTetheringOn(context);
|
||||||
|
|
||||||
if (toggleActionIfPossible)
|
// if (toggleActionIfPossible)
|
||||||
{
|
// {
|
||||||
Miscellaneous.logEvent("i", "Bluetooth Tethering", context.getResources().getString(R.string.toggling), 2);
|
// Miscellaneous.logEvent("i", "Bluetooth Tethering", context.getResources().getString(R.string.toggling), 2);
|
||||||
desiredState = !state;
|
// desiredState = !state;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (((state && !desiredState) || (!state && desiredState)))
|
// if (((state && !desiredState) || (!state && desiredState)))
|
||||||
{
|
// {
|
||||||
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
Class<?> classBluetoothPan = null;
|
Class<?> classBluetoothPan = null;
|
||||||
Constructor<?> BTPanCtor = null;
|
Constructor<?> BTPanCtor = null;
|
||||||
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,32 @@ 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(InvocationTargetException e)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Exact error message: "Bluetooth binder is null"
|
||||||
|
This means this device doesn't have bluetooth.
|
||||||
|
*/
|
||||||
|
Miscellaneous.logEvent("e", "Bluetooth Tethering", "Device probably doesn't have bluetooth. " + Log.getStackTraceString(e), 1);
|
||||||
|
Toast.makeText(context, context.getResources().getString(R.string.deviceDoesNotHaveBluetooth), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
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
|
||||||
{
|
{
|
||||||
|
@ -1361,6 +1361,8 @@ public class ActivityManageRule extends Activity
|
|||||||
items.add(new Item(typesLong[i].toString(), R.drawable.router));
|
items.add(new Item(typesLong[i].toString(), R.drawable.router));
|
||||||
else if(types[i].toString().equals(Action_Enum.setWifiTethering.toString()))
|
else if(types[i].toString().equals(Action_Enum.setWifiTethering.toString()))
|
||||||
items.add(new Item(typesLong[i].toString(), R.drawable.router));
|
items.add(new Item(typesLong[i].toString(), R.drawable.router));
|
||||||
|
else if(types[i].toString().equals(Action_Enum.setBluetoothTethering.toString()))
|
||||||
|
items.add(new Item(typesLong[i].toString(), R.drawable.router));
|
||||||
else if(types[i].toString().equals(Action_Enum.setDisplayRotation.toString()))
|
else if(types[i].toString().equals(Action_Enum.setDisplayRotation.toString()))
|
||||||
items.add(new Item(typesLong[i].toString(), R.drawable.displayrotation));
|
items.add(new Item(typesLong[i].toString(), R.drawable.displayrotation));
|
||||||
else if(types[i].toString().equals(Action_Enum.waitBeforeNextAction.toString()))
|
else if(types[i].toString().equals(Action_Enum.waitBeforeNextAction.toString()))
|
||||||
@ -1461,6 +1463,11 @@ public class ActivityManageRule extends Activity
|
|||||||
newAction.setAction(Action_Enum.setWifiTethering);
|
newAction.setAction(Action_Enum.setWifiTethering);
|
||||||
getActionParameter1Dialog(ActivityManageRule.this).show();
|
getActionParameter1Dialog(ActivityManageRule.this).show();
|
||||||
}
|
}
|
||||||
|
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setBluetoothTethering.toString()))
|
||||||
|
{
|
||||||
|
newAction.setAction(Action_Enum.setBluetoothTethering);
|
||||||
|
getActionParameter1Dialog(ActivityManageRule.this).show();
|
||||||
|
}
|
||||||
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setDisplayRotation.toString()))
|
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setDisplayRotation.toString()))
|
||||||
{
|
{
|
||||||
newAction.setAction(Action_Enum.setDisplayRotation);
|
newAction.setAction(Action_Enum.setDisplayRotation);
|
||||||
|
@ -531,6 +531,12 @@ public class ActivityPermissions extends Activity
|
|||||||
// https://stackoverflow.com/questions/32185628/connectivitymanager-requestnetwork-in-android-6-0
|
// https://stackoverflow.com/questions/32185628/connectivitymanager-requestnetwork-in-android-6-0
|
||||||
// addToArrayListUnique(Manifest.permission.CHANGE_NETWORK_STATE, requiredPermissions);
|
// addToArrayListUnique(Manifest.permission.CHANGE_NETWORK_STATE, requiredPermissions);
|
||||||
break;
|
break;
|
||||||
|
case setBluetoothTethering:
|
||||||
|
//addToArrayListUnique(Manifest.permission.CHANGE_NETWORK_STATE, requiredPermissions);
|
||||||
|
addToArrayListUnique(Manifest.permission.BLUETOOTH, requiredPermissions);
|
||||||
|
addToArrayListUnique(Manifest.permission.BLUETOOTH_ADMIN, requiredPermissions);
|
||||||
|
addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions);
|
||||||
|
break;
|
||||||
case setWifi:
|
case setWifi:
|
||||||
addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions);
|
||||||
// https://stackoverflow.com/questions/32185628/connectivitymanager-requestnetwork-in-android-6-0
|
// https://stackoverflow.com/questions/32185628/connectivitymanager-requestnetwork-in-android-6-0
|
||||||
|
@ -838,7 +838,6 @@ public class XmlFileInterface
|
|||||||
return (triggerCollection);
|
return (triggerCollection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static Trigger readTrigger(XmlPullParser parser) throws IOException, XmlPullParserException
|
private static Trigger readTrigger(XmlPullParser parser) throws IOException, XmlPullParserException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -158,6 +158,7 @@
|
|||||||
<string name="actionSetBluetooth">Bluetooth</string>
|
<string name="actionSetBluetooth">Bluetooth</string>
|
||||||
<string name="actionSetUsbTethering">USB Tethering</string>
|
<string name="actionSetUsbTethering">USB Tethering</string>
|
||||||
<string name="actionSetWifiTethering">Wifi Tethering</string>
|
<string name="actionSetWifiTethering">Wifi Tethering</string>
|
||||||
|
<string name="actionSetBluetoothTethering">Bluetooth Tethering</string>
|
||||||
<string name="actionSetDisplayRotation">Display rotation</string>
|
<string name="actionSetDisplayRotation">Display rotation</string>
|
||||||
<string name="actionTurnWifiOn">turn Wifi on</string>
|
<string name="actionTurnWifiOn">turn Wifi on</string>
|
||||||
<string name="actionTurnWifiOff">turn Wifi off</string>
|
<string name="actionTurnWifiOff">turn Wifi off</string>
|
||||||
@ -169,6 +170,8 @@
|
|||||||
<string name="actionTurnUsbTetheringOff">turn USB Tethering off</string>
|
<string name="actionTurnUsbTetheringOff">turn USB Tethering off</string>
|
||||||
<string name="actionTurnWifiTetheringOn">turn Wifi Tethering on</string>
|
<string name="actionTurnWifiTetheringOn">turn Wifi Tethering on</string>
|
||||||
<string name="actionTurnWifiTetheringOff">turn Wifi Tethering off</string>
|
<string name="actionTurnWifiTetheringOff">turn Wifi Tethering off</string>
|
||||||
|
<string name="actionTurnBluetoothTetheringOn">turn Bluetooth Tethering on</string>
|
||||||
|
<string name="actionTurnBluetoothTetheringOff">turn Bluetooth Tethering off</string>
|
||||||
<string name="actionTurnAirplaneModeOn">turn airplane mode on</string>
|
<string name="actionTurnAirplaneModeOn">turn airplane mode on</string>
|
||||||
<string name="actionTurnAirplaneModeOff">turn airplane mode off</string>
|
<string name="actionTurnAirplaneModeOff">turn airplane mode off</string>
|
||||||
<string name="actionEnableScreenRotation">enable screen rotation</string>
|
<string name="actionEnableScreenRotation">enable screen rotation</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user