forked from jens/Automation
Merge remote-tracking branch 'origin/development' into development
# Conflicts: # app/src/main/res/values/strings.xml
This commit is contained in:
commit
937c6ffe1d
@ -396,7 +396,7 @@ public class Rule implements Comparable<Rule>
|
||||
return true;
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3);
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 4);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -393,7 +393,7 @@ public class Rule implements Comparable<Rule>
|
||||
return true;
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3);
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 4);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -396,7 +396,7 @@ public class Rule implements Comparable<Rule>
|
||||
return true;
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3);
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 4);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -491,7 +491,7 @@ public class Action
|
||||
Actions.setUsbTethering(context, getParameter1(), toggleActionIfPossible);
|
||||
break;
|
||||
case setWifi:
|
||||
Actions.WifiStuff.setWifi(context, getParameter1(), toggleActionIfPossible);
|
||||
Actions.WifiStuff.setWifi(context, getParameter1(), getParameter2(), toggleActionIfPossible);
|
||||
break;
|
||||
case setWifiTethering:
|
||||
Actions.setWifiTethering(context, getParameter1(), toggleActionIfPossible);
|
||||
|
@ -44,6 +44,7 @@ import com.jens.automation2.location.WifiBroadcastReceiver;
|
||||
import com.jens.automation2.receivers.ConnectivityReceiver;
|
||||
import com.jens.automation2.receivers.NotificationListener;
|
||||
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.conn.ClientConnectionManager;
|
||||
@ -83,10 +84,6 @@ public class Actions
|
||||
public static AutomationService automationServerRef;
|
||||
public static Context context;
|
||||
private static Intent playMusicIntent;
|
||||
private static boolean suAvailable = false;
|
||||
private static String suVersion = null;
|
||||
private static String suVersionInternal = null;
|
||||
private static List<String> suResult = null;
|
||||
public final static String smsSeparator = "&sms&";
|
||||
public final static String dummyPackageString = "dummyPkg239asd";
|
||||
|
||||
@ -215,9 +212,20 @@ public class Actions
|
||||
|
||||
public static class WifiStuff
|
||||
{
|
||||
public static Boolean setWifi(Context context, Boolean desiredState, boolean toggleActionIfPossible)
|
||||
public static Boolean setWifi(Context context, Boolean desiredState, String parameter2, boolean toggleActionIfPossible)
|
||||
{
|
||||
if(context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.Q)
|
||||
boolean forceUseRoot = false;
|
||||
|
||||
try
|
||||
{
|
||||
forceUseRoot = Boolean.parseBoolean(parameter2);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if(context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.Q || forceUseRoot)
|
||||
return setWifiWithRoot(context, desiredState, toggleActionIfPossible);
|
||||
else
|
||||
return setWifiOldFashioned(context, desiredState, toggleActionIfPossible);
|
||||
@ -253,8 +261,15 @@ public class Actions
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Wifi", "Changing wifi to " + String.valueOf(desiredState), 4);
|
||||
|
||||
if (desiredState && Settings.useWifiForPositioning)
|
||||
WifiBroadcastReceiver.startWifiReceiver(automationServerRef.getLocationProvider());
|
||||
try
|
||||
{
|
||||
if (desiredState && Settings.useWifiForPositioning)
|
||||
WifiBroadcastReceiver.startWifiReceiver(automationServerRef.getLocationProvider());
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("w", "setWifiOldFashioned()", Log.getStackTraceString(e), 4);
|
||||
}
|
||||
|
||||
WifiManager myWifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
|
||||
@ -1865,6 +1880,12 @@ public class Actions
|
||||
|
||||
protected static boolean executeCommandViaSu(String[] commands)
|
||||
{
|
||||
boolean suAvailable = false;
|
||||
String suVersion = null;
|
||||
String suVersionInternal = null;
|
||||
// List<String> suResult = null;
|
||||
int suResult;
|
||||
|
||||
boolean success = false;
|
||||
|
||||
try
|
||||
@ -1874,17 +1895,30 @@ public class Actions
|
||||
{
|
||||
suVersion = Shell.SU.version(false);
|
||||
suVersionInternal = Shell.SU.version(true);
|
||||
suResult = Shell.SU.run(commands);
|
||||
|
||||
if (suResult != null)
|
||||
Miscellaneous.logEvent("i", "executeCommandViaSu()", "suVersion: " + suVersion + ", suVersionInternal: " + suVersionInternal, 5);
|
||||
|
||||
// suResult = Shell.SU.run(commands);
|
||||
suResult = Shell.Pool.SU.run(commands);
|
||||
|
||||
// if (suResult != null)
|
||||
// success = true;
|
||||
|
||||
Miscellaneous.logEvent("i", "executeCommandViaSu()", "RC=" + String.valueOf(suResult), 3);
|
||||
|
||||
if(suResult == 0)
|
||||
success = true;
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("w", "executeCommandViaSu()", "su not available.", 4);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", "executeCommandViaSu()", "Returning " + String.valueOf(success), 4);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@ -42,6 +43,7 @@ public class ActivityManageTriggerWifi extends Activity
|
||||
List<String> wifiList = new ArrayList<>();
|
||||
ArrayAdapter<String> wifiSpinnerAdapter;
|
||||
private final static int requestCodeLocationPermission = 124;
|
||||
TextView tvWifiTriggerNameLocationNotice;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
@ -55,11 +57,19 @@ public class ActivityManageTriggerWifi extends Activity
|
||||
spinnerWifiList = (Spinner) findViewById(R.id.spinnerWifiList);
|
||||
bTriggerWifiSave = (Button) findViewById(R.id.bTriggerWifiSave);
|
||||
bLoadWifiList = (Button) findViewById(R.id.bLoadWifiList);
|
||||
tvWifiTriggerNameLocationNotice = (TextView)findViewById(R.id.tvWifiTriggerNameLocationNotice);
|
||||
|
||||
wifiSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, wifiList);
|
||||
spinnerWifiList.setAdapter(wifiSpinnerAdapter);
|
||||
spinnerWifiList.setEnabled(false); // bug in Android; this only works when done in code, not in xml
|
||||
|
||||
if(
|
||||
Miscellaneous.getTargetSDK(Miscellaneous.getAnyContext()) >= 29
|
||||
&&
|
||||
!ActivityPermissions.isPermissionDeclaratedInManifest(Miscellaneous.getAnyContext(), Manifest.permission.ACCESS_BACKGROUND_LOCATION)
|
||||
)
|
||||
tvWifiTriggerNameLocationNotice.setVisibility(View.VISIBLE);
|
||||
|
||||
if (getIntent().hasExtra("edit"))
|
||||
{
|
||||
boolean connected = getIntent().getBooleanExtra("wifiState", false);
|
||||
|
@ -509,6 +509,12 @@ public class ActivityPermissions extends Activity
|
||||
case wifiConnection:
|
||||
addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions);
|
||||
addToArrayListUnique(Manifest.permission.ACCESS_WIFI_STATE, requiredPermissions);
|
||||
if(
|
||||
Miscellaneous.getTargetSDK(Miscellaneous.getAnyContext()) >= 29
|
||||
&&
|
||||
isPermissionDeclaratedInManifest(Miscellaneous.getAnyContext(), Manifest.permission.ACCESS_BACKGROUND_LOCATION)
|
||||
)
|
||||
addToArrayListUnique(Manifest.permission.ACCESS_BACKGROUND_LOCATION, requiredPermissions);
|
||||
break;
|
||||
case notification:
|
||||
addToArrayListUnique(Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE, requiredPermissions);
|
||||
|
@ -1911,4 +1911,9 @@ public class Miscellaneous extends Service
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getTargetSDK(Context context)
|
||||
{
|
||||
return context.getApplicationContext().getApplicationInfo().targetSdkVersion;
|
||||
}
|
||||
}
|
@ -63,7 +63,7 @@ public class WifiBroadcastReceiver extends BroadcastReceiver
|
||||
// int state = -1;
|
||||
NetworkInfo myWifi = null;
|
||||
|
||||
if(intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) //gefeuert bei Trennung
|
||||
if(intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) // fired upon disconnection
|
||||
{
|
||||
// state = intent.getIntExtra(WifiManager.NETWORK_STATE_CHANGED_ACTION, -1);
|
||||
// Miscellaneous.logEvent("i", "WifiReceiver", "NETWORK_STATE_CHANGED_ACTION: " + String.valueOf(state));
|
||||
|
@ -100,6 +100,7 @@
|
||||
android:id="@+id/bSendEmailToDev"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/sendEmailToDev" />
|
||||
|
||||
<TextView
|
||||
|
@ -47,6 +47,19 @@
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:id="@+id/tvWifiTriggerNameLocationNotice"
|
||||
android:layout_span="2"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:textColor="@color/red"
|
||||
android:text="@string/locationRequiredToDetermineWifiName"
|
||||
android:layout_marginVertical="@dimen/default_margin"
|
||||
android:visibility="gone" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
|
@ -841,6 +841,7 @@
|
||||
<string name="wakeLockTimeout">Specify timeout</string>
|
||||
<string name="wakeLockExplanation">Activate will keep the screen on while deactivate will let it turn off. For keeping it on you can either enter a duration after which it may turn off again or you can keep it on indefinitely. In the latter case you would need to create another keep-awake action (in this or another rule) in which you select deactivate.</string>
|
||||
<string name="mayUseRegularExpressions">You may also enter a regular expression here.</string>
|
||||
<string name="locationRequiredToDetermineWifiName">To get the wifi SSID, the app requires location permissions. Because the Google version cannot get that, you can only use this trigger if you do not specify an SSID. So it can only be used to detect if wifi is connected or not.</string>
|
||||
<string name="simplyDismissNotification">Simply dismiss</string>
|
||||
<string name="clickNotificationButton">Click a button</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user