BT tethering

This commit is contained in:
jens 2021-11-13 14:48:56 +01:00
parent 5fdc68e396
commit 92ca6d6cb4
6 changed files with 39 additions and 11 deletions

View File

@ -24,6 +24,7 @@ public class Action
setBluetooth,
setUsbTethering,
setWifiTethering,
setBluetoothTethering,
setDisplayRotation,
turnWifiOn,turnWifiOff,
turnBluetoothOn,turnBluetoothOff,
@ -31,7 +32,7 @@ public class Action
changeSoundProfile,
turnUsbTetheringOn,turnUsbTetheringOff,
turnWifiTetheringOn,turnWifiTetheringOff,
enableScreenRotation, disableScreenRotation,
enableScreenRotation,disableScreenRotation,
startOtherActivity,
waitBeforeNextAction,
wakeupDevice,
@ -54,6 +55,8 @@ public class Action
return context.getResources().getString(R.string.actionSetBluetooth);
case setWifiTethering:
return context.getResources().getString(R.string.actionSetWifiTethering);
case setBluetoothTethering:
return context.getResources().getString(R.string.actionSetBluetoothTethering);
case setUsbTethering:
return context.getResources().getString(R.string.actionSetUsbTethering);
case setDisplayRotation:
@ -178,6 +181,13 @@ public class Action
else
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))
{
if(this.getParameter1())
@ -382,6 +392,9 @@ public class Action
case setWifiTethering:
Actions.setWifiTethering(context, getParameter1(), toggleActionIfPossible);
break;
case setBluetoothTethering:
Actions.BluetoothTetheringClass.setBluetoothTethering(context, getParameter1(), toggleActionIfPossible);
break;
case setDisplayRotation:
Actions.setDisplayRotation(context, getParameter1(), toggleActionIfPossible);
break;

View File

@ -321,16 +321,16 @@ public class Actions
{
Miscellaneous.logEvent("i", "Bluetooth Tethering", "Changing Bluetooth Tethering to " + String.valueOf(desiredState), 4);
boolean state = Actions.isWifiApEnabled(context);
// boolean state = isTetheringOn(context);
if (toggleActionIfPossible)
{
Miscellaneous.logEvent("i", "Bluetooth Tethering", context.getResources().getString(R.string.toggling), 2);
desiredState = !state;
}
// if (toggleActionIfPossible)
// {
// Miscellaneous.logEvent("i", "Bluetooth Tethering", context.getResources().getString(R.string.toggling), 2);
// desiredState = !state;
// }
if (((state && !desiredState) || (!state && desiredState)))
{
// if (((state && !desiredState) || (!state && desiredState)))
// {
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
Class<?> classBluetoothPan = null;
Constructor<?> BTPanCtor = null;
@ -372,7 +372,7 @@ public class Actions
}
}
}
}
// }
return true;
}

View File

@ -1361,6 +1361,8 @@ public class ActivityManageRule extends Activity
items.add(new Item(typesLong[i].toString(), R.drawable.router));
else if(types[i].toString().equals(Action_Enum.setWifiTethering.toString()))
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()))
items.add(new Item(typesLong[i].toString(), R.drawable.displayrotation));
else if(types[i].toString().equals(Action_Enum.waitBeforeNextAction.toString()))
@ -1461,6 +1463,11 @@ public class ActivityManageRule extends Activity
newAction.setAction(Action_Enum.setWifiTethering);
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()))
{
newAction.setAction(Action_Enum.setDisplayRotation);

View File

@ -531,6 +531,12 @@ public class ActivityPermissions extends Activity
// https://stackoverflow.com/questions/32185628/connectivitymanager-requestnetwork-in-android-6-0
// addToArrayListUnique(Manifest.permission.CHANGE_NETWORK_STATE, requiredPermissions);
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:
addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions);
// https://stackoverflow.com/questions/32185628/connectivitymanager-requestnetwork-in-android-6-0

View File

@ -830,7 +830,6 @@ public class XmlFileInterface
return (triggerCollection);
}
private static Trigger readTrigger(XmlPullParser parser) throws IOException, XmlPullParserException
{

View File

@ -158,6 +158,7 @@
<string name="actionSetBluetooth">Bluetooth</string>
<string name="actionSetUsbTethering">USB Tethering</string>
<string name="actionSetWifiTethering">Wifi Tethering</string>
<string name="actionSetBluetoothTethering">Bluetooth Tethering</string>
<string name="actionSetDisplayRotation">Display rotation</string>
<string name="actionTurnWifiOn">turn Wifi on</string>
<string name="actionTurnWifiOff">turn Wifi off</string>
@ -169,6 +170,8 @@
<string name="actionTurnUsbTetheringOff">turn USB Tethering off</string>
<string name="actionTurnWifiTetheringOn">turn Wifi Tethering on</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="actionTurnAirplaneModeOff">turn airplane mode off</string>
<string name="actionEnableScreenRotation">enable screen rotation</string>