Compare commits

...
2 Commits
Author SHA1 Message Date
jens 56a766d03c registerReceiver option added 2026-08-13 18:58:55 +02:00
jens 5b86d57857 Number check fix 2026-08-09 16:12:16 +02:00
11 changed files with 69 additions and 14 deletions
@@ -106,7 +106,7 @@ public class ActivityManageActionSetSystemSetting extends Activity
selectedDataType.equalsIgnoreCase("Long") selectedDataType.equalsIgnoreCase("Long")
) )
{ {
if(!Miscellaneous.isNumeric(etSettingValue.getText().toString()) || Miscellaneous.isNonDecimalNumber(etSettingValue.getText().toString())) if(!Miscellaneous.isNumeric(etSettingValue.getText().toString()) || !Miscellaneous.isNumericNonDecimal(etSettingValue.getText().toString()))
{ {
Toast.makeText(ActivityManageActionSetSystemSetting.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show(); Toast.makeText(ActivityManageActionSetSystemSetting.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show();
return; return;
@@ -1154,12 +1154,24 @@ public class Miscellaneous extends Service
return true; return true;
} }
public static boolean isNonDecimalNumber(String number) public static boolean isNumericNonDecimal(String number)
{ {
if (number == null) if (number == null)
return false; return false;
return !number.contains(String.valueOf(getDecimalSeparator())); try
{
int temp = Integer.parseInt(number);
}
catch (Exception e)
{
return false;
}
if(number.contains(String.valueOf(getDecimalSeparator())))
return false;
else
return true;
} }
public static boolean isNumeric(String str) public static boolean isNumeric(String str)
@@ -1,5 +1,6 @@
package com.jens.automation2.receivers; package com.jens.automation2.receivers;
import static android.content.Context.RECEIVER_NOT_EXPORTED;
import static android.os.BatteryManager.*; import static android.os.BatteryManager.*;
import android.os.BatteryManager; import android.os.BatteryManager;
@@ -8,6 +9,7 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.os.Build;
import android.util.Log; import android.util.Log;
import com.jens.automation2.ActivityPermissions; import com.jens.automation2.ActivityPermissions;
@@ -30,7 +32,7 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
static boolean usbHostConnected = false; static boolean usbHostConnected = false;
static boolean batteryReceiverActive = false; static boolean batteryReceiverActive = false;
static IntentFilter batteryIntentFilter = null; static IntentFilter batteryIntentFilter = null;
static Intent batteryStatus = null; static Intent batteryStatusReceiverIntent = null;
private static int currentChargingState = 0; //0=unknown, 1=no, 2=yes private static int currentChargingState = 0; //0=unknown, 1=no, 2=yes
private static int currentChargingType = 0; //AC, wireless, USB private static int currentChargingType = 0; //AC, wireless, USB
@@ -52,7 +54,10 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
batteryIntentFilter.addAction(Intent.ACTION_BATTERY_LOW); batteryIntentFilter.addAction(Intent.ACTION_BATTERY_LOW);
} }
batteryStatus = automationServiceRef.registerReceiver(batteryInfoReceiverInstance, batteryIntentFilter); if(Build.VERSION.SDK_INT >= 26)
batteryStatusReceiverIntent = automationServiceRef.registerReceiver(batteryInfoReceiverInstance, batteryIntentFilter, Context.RECEIVER_NOT_EXPORTED);
else
batteryStatusReceiverIntent = automationServiceRef.registerReceiver(batteryInfoReceiverInstance, batteryIntentFilter);
batteryReceiverActive = true; batteryReceiverActive = true;
} }
@@ -1,11 +1,14 @@
package com.jens.automation2.receivers; package com.jens.automation2.receivers;
import static android.content.Context.RECEIVER_EXPORTED;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.os.Build;
import android.util.Log; import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
@@ -57,7 +60,11 @@ public class BluetoothReceiver extends BroadcastReceiver implements AutomationLi
{ {
Miscellaneous.logEvent("i", "BluetoothReceiver", "Starting BluetoothReceiver", 4); Miscellaneous.logEvent("i", "BluetoothReceiver", "Starting BluetoothReceiver", 4);
bluetoothReceiverActive = true; bluetoothReceiverActive = true;
AutomationService.getInstance().registerReceiver(bluetoothReceiverInstance, bluetoothReceiverIntentFilter);
if(Build.VERSION.SDK_INT >= 26)
AutomationService.getInstance().registerReceiver(bluetoothReceiverInstance, bluetoothReceiverIntentFilter, Context.RECEIVER_EXPORTED);
else
AutomationService.getInstance().registerReceiver(bluetoothReceiverInstance, bluetoothReceiverIntentFilter);
} }
} }
catch(Exception ex) catch(Exception ex)
@@ -57,7 +57,11 @@ public class ConnectivityReceiver extends BroadcastReceiver implements Automatio
{ {
Miscellaneous.logEvent("i", "Wifi Listener", "Starting connectivityReceiver", 4); Miscellaneous.logEvent("i", "Wifi Listener", "Starting connectivityReceiver", 4);
connectivityReceiverActive = true; connectivityReceiverActive = true;
automationServiceRef.registerReceiver(connectivityReceiverInstance, connectivityIntentFilter);
if(Build.VERSION.SDK_INT >= 26)
automationServiceRef.registerReceiver(connectivityReceiverInstance, connectivityIntentFilter, Context.RECEIVER_EXPORTED);
else
automationServiceRef.registerReceiver(connectivityReceiverInstance, connectivityIntentFilter);
} }
} }
catch(Exception ex) catch(Exception ex)
@@ -5,6 +5,7 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.os.Build;
import android.util.Log; import android.util.Log;
import com.jens.automation2.ActivityPermissions; import com.jens.automation2.ActivityPermissions;
@@ -105,7 +106,11 @@ public class HeadphoneJackListener extends BroadcastReceiver implements Automati
{ {
Miscellaneous.logEvent("i", "HeadsetJackListener", "Starting HeadsetJackListener", 4); Miscellaneous.logEvent("i", "HeadsetJackListener", "Starting HeadsetJackListener", 4);
headphoneJackListenerActive = true; headphoneJackListenerActive = true;
automationService.registerReceiver(this, headphoneJackListenerIntentFilter);
if(Build.VERSION.SDK_INT >= 26)
automationService.registerReceiver(this, headphoneJackListenerIntentFilter, Context.RECEIVER_NOT_EXPORTED);
else
automationService.registerReceiver(this, headphoneJackListenerIntentFilter);
} }
} }
catch(Exception ex) catch(Exception ex)
@@ -285,7 +285,12 @@ public class PhoneStatusListener implements AutomationListenerInterface
if(!outgoingCallsReceiverActive) if(!outgoingCallsReceiverActive)
{ {
Miscellaneous.logEvent("i", "PhoneStatusListener", "Starting PhoneStatusListener->outgoingCallsReceiver", 4); Miscellaneous.logEvent("i", "PhoneStatusListener", "Starting PhoneStatusListener->outgoingCallsReceiver", 4);
automationService.registerReceiver(outgoingCallsReceiverInstance, outgoingCallsIntentFilter);
if(Build.VERSION.SDK_INT >= 26)
automationService.registerReceiver(outgoingCallsReceiverInstance, outgoingCallsIntentFilter, Context.RECEIVER_NOT_EXPORTED);
else
automationService.registerReceiver(outgoingCallsReceiverInstance, outgoingCallsIntentFilter);
outgoingCallsReceiverActive = true; outgoingCallsReceiverActive = true;
} }
} }
@@ -1,5 +1,7 @@
package com.jens.automation2.receivers; package com.jens.automation2.receivers;
import static android.content.Context.RECEIVER_NOT_EXPORTED;
import android.Manifest; import android.Manifest;
import android.app.KeyguardManager; import android.app.KeyguardManager;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
@@ -71,7 +73,10 @@ public class ScreenStateReceiver extends BroadcastReceiver implements Automation
// Intent.ACTION_USER_UNLOCKED // Intent.ACTION_USER_UNLOCKED
} }
screenStatusIntent = automationServiceRef.registerReceiver(screenStateReceiverInstance, screenStateIntentFilter); if(Build.VERSION.SDK_INT >= 26)
screenStatusIntent = automationServiceRef.registerReceiver(screenStateReceiverInstance, screenStateIntentFilter, Context.RECEIVER_NOT_EXPORTED);
else
screenStatusIntent = automationServiceRef.registerReceiver(screenStateReceiverInstance, screenStateIntentFilter);
screenStateReceiverActive = true; screenStateReceiverActive = true;
} }
@@ -6,6 +6,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
import android.os.Build;
import com.jens.automation2.AutomationService; import com.jens.automation2.AutomationService;
import com.jens.automation2.Miscellaneous; import com.jens.automation2.Miscellaneous;
@@ -116,7 +117,10 @@ public class SubSystemStateReceiver extends BroadcastReceiver implements Automat
subSystemStateIntentFilter.addAction(stateBluetooth); subSystemStateIntentFilter.addAction(stateBluetooth);
} }
subSystemStatusIntent = automationServiceRef.registerReceiver(subSystemStateReceiverInstance, subSystemStateIntentFilter); if(Build.VERSION.SDK_INT >= 26)
subSystemStatusIntent = automationServiceRef.registerReceiver(subSystemStateReceiverInstance, subSystemStateIntentFilter, Context.RECEIVER_NOT_EXPORTED);
else
subSystemStatusIntent = automationServiceRef.registerReceiver(subSystemStateReceiverInstance, subSystemStateIntentFilter);
subSystemStateReceiverActive = true; subSystemStateReceiverActive = true;
} }
@@ -162,7 +162,11 @@ public class TetheringReceiver extends android.content.BroadcastReceiver impleme
try try
{ {
automationServiceRef.registerReceiver(receiverInstance, intentFilter); if(Build.VERSION.SDK_INT >= 26)
automationServiceRef.registerReceiver(receiverInstance, intentFilter, Context.RECEIVER_NOT_EXPORTED);
else
automationServiceRef.registerReceiver(receiverInstance, intentFilter);
receiverActive = true; receiverActive = true;
} }
catch(Exception e) catch(Exception e)
@@ -4,6 +4,7 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.os.Build;
import android.util.Log; import android.util.Log;
import com.jens.automation2.AutomationService; import com.jens.automation2.AutomationService;
@@ -43,8 +44,11 @@ public class TimeZoneListener extends BroadcastReceiver implements AutomationLis
timezoneListenerIntentFilter.addAction(Intent.ACTION_TIMEZONE_CHANGED); timezoneListenerIntentFilter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
timezoneListenerIntentFilter.addAction(Intent.ACTION_TIME_CHANGED); timezoneListenerIntentFilter.addAction(Intent.ACTION_TIME_CHANGED);
} }
automationService.registerReceiver(timeZoneListenerInstance, timezoneListenerIntentFilter); if(Build.VERSION.SDK_INT >= 26)
automationService.registerReceiver(timeZoneListenerInstance, timezoneListenerIntentFilter, Context.RECEIVER_NOT_EXPORTED);
else
automationService.registerReceiver(timeZoneListenerInstance, timezoneListenerIntentFilter);
} }
} }
catch(Exception ex) catch(Exception ex)