forked from jens/Automation
broadcast trigger
This commit is contained in:
parent
98b49036a7
commit
e39a2411ba
@ -57,6 +57,7 @@ android {
|
||||
abortOnError false
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
namespace 'com.jens.automation2'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.jens.automation2">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<supports-screens
|
||||
android:anyDensity="true"
|
||||
@ -159,6 +158,7 @@
|
||||
<activity android:name=".ActivityManageTriggerTimeFrame" />
|
||||
<activity android:name=".ActivityControlCenter" />
|
||||
<activity android:name=".ActivityManageTriggerPhoneCall" />
|
||||
<activity android:name=".ActivityManageTriggerBroadcast" />
|
||||
<activity android:name=".ActivityManageActionBrightnessSetting" />
|
||||
<activity android:name=".ActivityManageActionCreateNotification" />
|
||||
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.jens.automation2">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<supports-screens
|
||||
android:anyDensity="true"
|
||||
@ -157,6 +156,7 @@
|
||||
<activity android:name=".ActivityManageTriggerTimeFrame" />
|
||||
<activity android:name=".ActivityControlCenter" />
|
||||
<activity android:name=".ActivityManageTriggerPhoneCall" />
|
||||
<activity android:name=".ActivityManageTriggerBroadcast" />
|
||||
<activity android:name=".ActivityManageActionBrightnessSetting" />
|
||||
<activity android:name=".ActivityManageActionCreateNotification" />
|
||||
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.jens.automation2">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<supports-screens
|
||||
android:anyDensity="true"
|
||||
@ -144,6 +143,7 @@
|
||||
<activity android:name=".ActivityManageTriggerTimeFrame" />
|
||||
<activity android:name=".ActivityControlCenter" />
|
||||
<activity android:name=".ActivityManageTriggerPhoneCall" />
|
||||
<activity android:name=".ActivityManageTriggerBroadcast" />
|
||||
<activity android:name=".ActivityManageActionBrightnessSetting" />
|
||||
<activity android:name=".ActivityManageActionCreateNotification" />
|
||||
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.jens.automation2">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
|
||||
|
||||
|
@ -119,6 +119,8 @@ public class ActivityManageRule extends Activity
|
||||
final static int requestCodeActionCloseNotificationEdit = 806;
|
||||
final static int requestCodeActionControlMediaAdd = 807;
|
||||
final static int requestCodeActionControlMediaEdit = 808;
|
||||
final static int requestCodeTriggerBroadcastReceivedAdd = 809;
|
||||
final static int requestCodeTriggerBroadcastReceivedEdit = 810;
|
||||
|
||||
public static ActivityManageRule getInstance()
|
||||
{
|
||||
@ -298,6 +300,12 @@ public class ActivityManageRule extends Activity
|
||||
devicePositionEditor.putExtra(ActivityManageTriggerDeviceOrientation.vectorFieldName, selectedTrigger.getTriggerParameter2());
|
||||
startActivityForResult(devicePositionEditor, requestCodeTriggerDeviceOrientationEdit);
|
||||
break;
|
||||
case broadcastReceived:
|
||||
Intent broadcastEditor = new Intent(ActivityManageRule.this, ActivityManageTriggerBroadcast.class);
|
||||
broadcastEditor.putExtra(intentNameTriggerParameter1, selectedTrigger.getTriggerParameter());
|
||||
broadcastEditor.putExtra(intentNameTriggerParameter2, selectedTrigger.getTriggerParameter2());
|
||||
startActivityForResult(broadcastEditor, requestCodeTriggerBroadcastReceivedEdit);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -508,6 +516,8 @@ public class ActivityManageRule extends Activity
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.plane));
|
||||
else if(types[i].toString().equals(Trigger_Enum.roaming.toString()))
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.roaming));
|
||||
else if(types[i].toString().equals(Trigger_Enum.broadcastReceived.toString()))
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.satellite));
|
||||
else if(types[i].toString().equals(Trigger_Enum.phoneCall.toString()))
|
||||
{
|
||||
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageRule.this, "android.permission.SEND_SMS"))
|
||||
@ -726,6 +736,13 @@ public class ActivityManageRule extends Activity
|
||||
if (NfcReceiver.checkNfcRequirements(ActivityManageRule.this, true))
|
||||
getTriggerParameterDialog(context, booleanChoices).show();
|
||||
}
|
||||
else if(triggerType == Trigger_Enum.broadcastReceived)
|
||||
{
|
||||
newTrigger.setTriggerType(Trigger_Enum.broadcastReceived);
|
||||
Intent broadcastTriggerEditor = new Intent(myContext, ActivityManageTriggerBroadcast.class);
|
||||
startActivityForResult(broadcastTriggerEditor, requestCodeTriggerBroadcastReceivedAdd);
|
||||
return;
|
||||
}
|
||||
else
|
||||
getTriggerParameterDialog(context, booleanChoices).show();
|
||||
|
||||
@ -1359,7 +1376,7 @@ public class ActivityManageRule extends Activity
|
||||
{
|
||||
newTrigger.setParentRule(ruleToEdit);
|
||||
ruleToEdit.getTriggerSet().add(newTrigger);
|
||||
newTrigger.setTriggerParameter2(data.getStringExtra("triggerParameter2"));
|
||||
newTrigger.setTriggerParameter2(data.getStringExtra(intentNameTriggerParameter2));
|
||||
this.refreshTriggerList();
|
||||
}
|
||||
}
|
||||
@ -1630,6 +1647,30 @@ public class ActivityManageRule extends Activity
|
||||
this.refreshTriggerList();
|
||||
}
|
||||
}
|
||||
else if(requestCode == requestCodeTriggerBroadcastReceivedAdd)
|
||||
{
|
||||
if(resultCode == RESULT_OK)
|
||||
{
|
||||
newTrigger.setTriggerParameter(data.getBooleanExtra(ActivityManageRule.intentNameTriggerParameter1, true));
|
||||
newTrigger.setTriggerParameter2(data.getStringExtra(ActivityManageRule.intentNameTriggerParameter2));
|
||||
newTrigger.setParentRule(ruleToEdit);
|
||||
ruleToEdit.getTriggerSet().add(newTrigger);
|
||||
this.refreshTriggerList();
|
||||
}
|
||||
}
|
||||
else if(requestCode == requestCodeTriggerBroadcastReceivedEdit)
|
||||
{
|
||||
if(resultCode == RESULT_OK)
|
||||
{
|
||||
Trigger editedTrigger = new Trigger();
|
||||
editedTrigger.setTriggerType(Trigger_Enum.broadcastReceived);
|
||||
editedTrigger.setTriggerParameter(data.getBooleanExtra(ActivityManageRule.intentNameTriggerParameter1, true));
|
||||
editedTrigger.setTriggerParameter2(data.getStringExtra(ActivityManageRule.intentNameTriggerParameter2));
|
||||
editedTrigger.setParentRule(ruleToEdit);
|
||||
ruleToEdit.getTriggerSet().set(editIndex, editedTrigger);
|
||||
this.refreshTriggerList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected AlertDialog getActionTypeDialog()
|
||||
|
@ -0,0 +1,421 @@
|
||||
package com.jens.automation2;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class ActivityManageTriggerBroadcast extends Activity
|
||||
{
|
||||
RadioButton rbBroadcastReceived, rbBroadcastNotReceived;
|
||||
EditText etBroadcastTriggerAction;
|
||||
Button bBroadcastShowSuggestions, bSaveTriggerBroadcast;
|
||||
TextView tvBroadcastUrl;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_trigger_broadcasts);
|
||||
|
||||
bBroadcastShowSuggestions = findViewById(R.id.bBroadcastShowSuggestions);
|
||||
bSaveTriggerBroadcast = findViewById(R.id.bSaveTriggerBroadcast);
|
||||
etBroadcastTriggerAction = findViewById(R.id.etBroadcastTriggerAction);
|
||||
rbBroadcastReceived = findViewById(R.id.rbBroadcastReceived);
|
||||
rbBroadcastNotReceived = findViewById(R.id.rbBroadcastNotReceived);
|
||||
tvBroadcastUrl = findViewById(R.id.tvBroadcastUrl);
|
||||
|
||||
if(getIntent().hasExtra(ActivityManageRule.intentNameTriggerParameter1) && getIntent().hasExtra(ActivityManageRule.intentNameTriggerParameter2))
|
||||
{
|
||||
if(getIntent().getBooleanExtra(ActivityManageRule.intentNameTriggerParameter1, true))
|
||||
rbBroadcastReceived.setChecked(true);
|
||||
else
|
||||
rbBroadcastNotReceived.setChecked(true);
|
||||
|
||||
etBroadcastTriggerAction.setText(getIntent().getStringExtra(ActivityManageRule.intentNameTriggerParameter2));
|
||||
}
|
||||
|
||||
tvBroadcastUrl.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().getString(R.string.broadcastListUrl)));
|
||||
startActivity(browserIntent);
|
||||
}
|
||||
});
|
||||
|
||||
bBroadcastShowSuggestions.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ActivityManageTriggerBroadcast.this);
|
||||
builder.setTitle(getResources().getString(R.string.selectBroadcast));
|
||||
builder.setItems(broadcastSuggestions, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int which)
|
||||
{
|
||||
etBroadcastTriggerAction.setText(broadcastSuggestions[which]);
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
});
|
||||
|
||||
bSaveTriggerBroadcast.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
if(etBroadcastTriggerAction.getText() != null && !StringUtils.isEmpty(etBroadcastTriggerAction.getText().toString()))
|
||||
{
|
||||
Intent data = new Intent();
|
||||
data.putExtra(ActivityManageRule.intentNameTriggerParameter1, rbBroadcastReceived.isChecked());
|
||||
data.putExtra(ActivityManageRule.intentNameTriggerParameter2, etBroadcastTriggerAction.getText().toString());
|
||||
ActivityManageTriggerBroadcast.this.setResult(RESULT_OK, data);
|
||||
|
||||
finish();
|
||||
}
|
||||
else
|
||||
Toast.makeText(ActivityManageTriggerBroadcast.this, getResources().getString(R.string.enterText), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] broadcastSuggestions = {
|
||||
"android.accounts.LOGIN_ACCOUNTS_CHANGED",
|
||||
"android.accounts.action.ACCOUNT_REMOVED",
|
||||
"android.app.action.ACTION_PASSWORD_CHANGED",
|
||||
"android.app.action.ACTION_PASSWORD_EXPIRING",
|
||||
"android.app.action.ACTION_PASSWORD_FAILED",
|
||||
"android.app.action.ACTION_PASSWORD_SUCCEEDED",
|
||||
"android.app.action.AFFILIATED_PROFILE_TRANSFER_OWNERSHIP_COMPLETE",
|
||||
"android.app.action.APPLICATION_DELEGATION_SCOPES_CHANGED",
|
||||
"android.app.action.APP_BLOCK_STATE_CHANGED",
|
||||
"android.app.action.AUTOMATIC_ZEN_RULE_STATUS_CHANGED",
|
||||
"android.app.action.BUGREPORT_FAILED",
|
||||
"android.app.action.BUGREPORT_SHARE",
|
||||
"android.app.action.BUGREPORT_SHARING_DECLINED",
|
||||
"android.app.action.DATA_SHARING_RESTRICTION_APPLIED",
|
||||
"android.app.action.DATA_SHARING_RESTRICTION_CHANGED",
|
||||
"android.app.action.DEVICE_ADMIN_DISABLED",
|
||||
"android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED",
|
||||
"android.app.action.DEVICE_ADMIN_ENABLED",
|
||||
"android.app.action.DEVICE_OWNER_CHANGED",
|
||||
"android.app.action.INTERRUPTION_FILTER_CHANGED",
|
||||
"android.app.action.INTERRUPTION_FILTER_CHANGED_INTERNAL",
|
||||
"android.app.action.LOCK_TASK_ENTERING",
|
||||
"android.app.action.LOCK_TASK_EXITING",
|
||||
"android.app.action.MANAGED_USER_CREATED",
|
||||
"android.app.action.NETWORK_LOGS_AVAILABLE",
|
||||
"android.app.action.NEXT_ALARM_CLOCK_CHANGED",
|
||||
"android.app.action.NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED",
|
||||
"android.app.action.NOTIFICATION_CHANNEL_GROUP_BLOCK_STATE_CHANGED",
|
||||
"android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED",
|
||||
"android.app.action.NOTIFICATION_POLICY_CHANGED",
|
||||
"android.app.action.NOTIFY_PENDING_SYSTEM_UPDATE",
|
||||
"android.app.action.PROFILE_OWNER_CHANGED",
|
||||
"android.app.action.PROFILE_PROVISIONING_COMPLETE",
|
||||
"android.app.action.SECURITY_LOGS_AVAILABLE",
|
||||
"android.app.action.SYSTEM_UPDATE_POLICY_CHANGED",
|
||||
"android.app.action.TRANSFER_OWNERSHIP_COMPLETE",
|
||||
"android.app.action.USER_ADDED",
|
||||
"android.app.action.USER_REMOVED",
|
||||
"android.app.action.USER_STARTED",
|
||||
"android.app.action.USER_STOPPED",
|
||||
"android.app.action.USER_SWITCHED",
|
||||
"android.appwidget.action.APPWIDGET_DELETED",
|
||||
"android.appwidget.action.APPWIDGET_DISABLED",
|
||||
"android.appwidget.action.APPWIDGET_ENABLED",
|
||||
"android.appwidget.action.APPWIDGET_HOST_RESTORED",
|
||||
"android.appwidget.action.APPWIDGET_RESTORED",
|
||||
"android.appwidget.action.APPWIDGET_UPDATE",
|
||||
"android.appwidget.action.APPWIDGET_UPDATE_OPTIONS",
|
||||
"android.bluetooth.a2dp.profile.action.ACTIVE_DEVICE_CHANGED",
|
||||
"android.bluetooth.a2dp.profile.action.AVRCP_CONNECTION_STATE_CHANGED",
|
||||
"android.bluetooth.a2dp.profile.action.CODEC_CONFIG_CHANGED",
|
||||
"android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED",
|
||||
"android.bluetooth.a2dp.profile.action.PLAYING_STATE_CHANGED",
|
||||
"android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED",
|
||||
"android.bluetooth.adapter.action.DISCOVERY_FINISHED",
|
||||
"android.bluetooth.adapter.action.DISCOVERY_STARTED",
|
||||
"android.bluetooth.adapter.action.LOCAL_NAME_CHANGED",
|
||||
"android.bluetooth.adapter.action.SCAN_MODE_CHANGED",
|
||||
"android.bluetooth.adapter.action.STATE_CHANGED",
|
||||
"android.bluetooth.device.action.ACL_CONNECTED",
|
||||
"android.bluetooth.device.action.ACL_DISCONNECTED",
|
||||
"android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED",
|
||||
"android.bluetooth.device.action.ALIAS_CHANGED",
|
||||
"android.bluetooth.device.action.BATTERY_LEVEL_CHANGED",
|
||||
"android.bluetooth.device.action.BOND_STATE_CHANGED",
|
||||
"android.bluetooth.device.action.CLASS_CHANGED",
|
||||
"android.bluetooth.device.action.CONNECTION_ACCESS_CANCEL",
|
||||
"android.bluetooth.device.action.CONNECTION_ACCESS_REPLY",
|
||||
"android.bluetooth.device.action.CONNECTION_ACCESS_REQUEST",
|
||||
"android.bluetooth.device.action.FOUND",
|
||||
"android.bluetooth.device.action.MAS_INSTANCE",
|
||||
"android.bluetooth.device.action.NAME_CHANGED",
|
||||
"android.bluetooth.device.action.NAME_FAILED",
|
||||
"android.bluetooth.device.action.PAIRING_CANCEL",
|
||||
"android.bluetooth.device.action.PAIRING_REQUEST",
|
||||
"android.bluetooth.device.action.SDP_RECORD",
|
||||
"android.bluetooth.device.action.SILENCE_MODE_CHANGED",
|
||||
"android.bluetooth.device.action.UUID",
|
||||
"android.bluetooth.devicepicker.action.DEVICE_SELECTED",
|
||||
"android.bluetooth.devicepicker.action.LAUNCH",
|
||||
"android.bluetooth.headset.action.VENDOR_SPECIFIC_HEADSET_EVENT",
|
||||
"android.bluetooth.headset.profile.action.ACTIVE_DEVICE_CHANGED",
|
||||
"android.bluetooth.headset.profile.action.AUDIO_STATE_CHANGED",
|
||||
"android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED",
|
||||
"android.bluetooth.hearingaid.profile.action.ACTIVE_DEVICE_CHANGED",
|
||||
"android.bluetooth.hearingaid.profile.action.CONNECTION_STATE_CHANGED",
|
||||
"android.bluetooth.hiddevice.profile.action.CONNECTION_STATE_CHANGED",
|
||||
"android.bluetooth.input.profile.action.CONNECTION_STATE_CHANGED",
|
||||
"android.bluetooth.input.profile.action.HANDSHAKE",
|
||||
"android.bluetooth.input.profile.action.IDLE_TIME_CHANGED",
|
||||
"android.bluetooth.input.profile.action.PROTOCOL_MODE_CHANGED",
|
||||
"android.bluetooth.input.profile.action.REPORT",
|
||||
"android.bluetooth.input.profile.action.VIRTUAL_UNPLUG_STATUS",
|
||||
"android.bluetooth.pan.profile.action.CONNECTION_STATE_CHANGED",
|
||||
"android.bluetooth.pbap.profile.action.CONNECTION_STATE_CHANGED",
|
||||
"android.content.pm.action.SESSION_COMMITTED",
|
||||
"android.content.pm.action.SESSION_UPDATED",
|
||||
"android.hardware.action.NEW_PICTURE",
|
||||
"android.hardware.action.NEW_VIDEO",
|
||||
"android.hardware.hdmi.action.OSD_MESSAGE",
|
||||
"android.hardware.input.action.QUERY_KEYBOARD_LAYOUTS",
|
||||
"android.hardware.usb.action.USB_ACCESSORY_ATTACHED",
|
||||
"android.hardware.usb.action.USB_ACCESSORY_DETACHED",
|
||||
"android.hardware.usb.action.USB_DEVICE_ATTACHED",
|
||||
"android.hardware.usb.action.USB_DEVICE_DETACHED",
|
||||
"android.intent.action.ACTION_IDLE_MAINTENANCE_END",
|
||||
"android.intent.action.ACTION_IDLE_MAINTENANCE_START",
|
||||
"android.intent.action.ACTION_POWER_CONNECTED",
|
||||
"android.intent.action.ACTION_POWER_DISCONNECTED",
|
||||
"android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED",
|
||||
"android.intent.action.ACTION_SHUTDOWN",
|
||||
"android.intent.action.AIRPLANE_MODE",
|
||||
"android.intent.action.ALARM_CHANGED",
|
||||
"android.intent.action.APPLICATION_RESTRICTIONS_CHANGED",
|
||||
"android.intent.action.BATTERY_CHANGED",
|
||||
"android.intent.action.BATTERY_LOW",
|
||||
"android.intent.action.BATTERY_OKAY",
|
||||
"android.intent.action.BOOT_COMPLETED",
|
||||
"android.intent.action.CALL_DISCONNECT_CAUSE",
|
||||
"android.intent.action.CAMERA_BUTTON",
|
||||
"android.intent.action.CANCEL_ENABLE_ROLLBACK",
|
||||
"android.intent.action.CLEAR_DNS_CACHE",
|
||||
"android.intent.action.CLOSE_SYSTEM_DIALOGS",
|
||||
"android.intent.action.CONFIGURATION_CHANGED",
|
||||
"android.intent.action.CONTENT_CHANGED",
|
||||
"android.intent.action.DATA_SMS_RECEIVED",
|
||||
"android.intent.action.DATA_STALL_DETECTED",
|
||||
"android.intent.action.DATE_CHANGED",
|
||||
"android.intent.action.DEVICE_STORAGE_FULL",
|
||||
"android.intent.action.DEVICE_STORAGE_LOW",
|
||||
"android.intent.action.DEVICE_STORAGE_NOT_FULL",
|
||||
"android.intent.action.DEVICE_STORAGE_OK",
|
||||
"android.intent.action.DISTRACTING_PACKAGES_CHANGED",
|
||||
"android.intent.action.DOCK_EVENT",
|
||||
"android.intent.action.DOWNLOAD_COMPLETE",
|
||||
"android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED",
|
||||
"android.intent.action.DREAMING_STARTED",
|
||||
"android.intent.action.DREAMING_STOPPED",
|
||||
"android.intent.action.DROPBOX_ENTRY_ADDED",
|
||||
"android.intent.action.DYNAMIC_SENSOR_CHANGED",
|
||||
"android.intent.action.EMERGENCY_CALLBACK_MODE_CHANGED",
|
||||
"android.intent.action.EMERGENCY_CALL_STATE_CHANGED",
|
||||
"android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE",
|
||||
"android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE",
|
||||
"android.intent.action.FACTORY_RESET",
|
||||
"android.intent.action.FETCH_VOICEMAIL",
|
||||
"android.intent.action.GTALK_CONNECTED",
|
||||
"android.intent.action.GTALK_DISCONNECTED",
|
||||
"android.intent.action.HEADSET_PLUG",
|
||||
"android.intent.action.HEADSET_PLUG",
|
||||
"android.intent.action.INPUT_METHOD_CHANGED",
|
||||
"android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION",
|
||||
"android.intent.action.LOCALE_CHANGED",
|
||||
"android.intent.action.LOCKED_BOOT_COMPLETED",
|
||||
"android.intent.action.MANAGE_PACKAGE_STORAGE",
|
||||
"android.intent.action.MASTER_CLEAR_NOTIFICATION",
|
||||
"android.intent.action.MEDIA_BAD_REMOVAL",
|
||||
"android.intent.action.MEDIA_BUTTON",
|
||||
"android.intent.action.MEDIA_CHECKING",
|
||||
"android.intent.action.MEDIA_EJECT",
|
||||
"android.intent.action.MEDIA_MOUNTED",
|
||||
"android.intent.action.MEDIA_NOFS",
|
||||
"android.intent.action.MEDIA_REMOVED",
|
||||
"android.intent.action.MEDIA_SCANNER_FINISHED",
|
||||
"android.intent.action.MEDIA_SCANNER_SCAN_FILE",
|
||||
"android.intent.action.MEDIA_SCANNER_STARTED",
|
||||
"android.intent.action.MEDIA_SHARED",
|
||||
"android.intent.action.MEDIA_UNMOUNTABLE",
|
||||
"android.intent.action.MEDIA_UNMOUNTED",
|
||||
"android.intent.action.MY_PACKAGE_REPLACED",
|
||||
"android.intent.action.MY_PACKAGE_SUSPENDED",
|
||||
"android.intent.action.MY_PACKAGE_UNSUSPENDED",
|
||||
"android.intent.action.NEW_OUTGOING_CALL",
|
||||
"android.intent.action.NEW_VOICEMAIL",
|
||||
"android.intent.action.PACKAGES_SUSPENDED",
|
||||
"android.intent.action.PACKAGES_UNSUSPENDED",
|
||||
"android.intent.action.PACKAGE_ADDED",
|
||||
"android.intent.action.PACKAGE_CHANGED",
|
||||
"android.intent.action.PACKAGE_DATA_CLEARED",
|
||||
"android.intent.action.PACKAGE_ENABLE_ROLLBACK",
|
||||
"android.intent.action.PACKAGE_FIRST_LAUNCH",
|
||||
"android.intent.action.PACKAGE_FULLY_REMOVED",
|
||||
"android.intent.action.PACKAGE_INSTALL",
|
||||
"android.intent.action.PACKAGE_NEEDS_INTEGRITY_VERIFICATION",
|
||||
"android.intent.action.PACKAGE_NEEDS_VERIFICATION",
|
||||
"android.intent.action.PACKAGE_REMOVED",
|
||||
"android.intent.action.PACKAGE_REPLACED",
|
||||
"android.intent.action.PACKAGE_RESTARTED",
|
||||
"android.intent.action.PACKAGE_UNSUSPENDED_MANUALLY",
|
||||
"android.intent.action.PACKAGE_VERIFIED",
|
||||
"android.intent.action.PHONE_STATE",
|
||||
"android.intent.action.PROVIDER_CHANGED",
|
||||
"android.intent.action.PROXY_CHANGE",
|
||||
"android.intent.action.QUERY_PACKAGE_RESTART",
|
||||
"android.intent.action.REBOOT",
|
||||
"android.intent.action.ROLLBACK_COMMITTED",
|
||||
"android.intent.action.SCREEN_OFF",
|
||||
"android.intent.action.SCREEN_ON",
|
||||
"android.intent.action.SERVICE_STATE",
|
||||
"android.intent.action.SIM_STATE_CHANGED",
|
||||
"android.intent.action.SPLIT_CONFIGURATION_CHANGED",
|
||||
"android.intent.action.SUB_DEFAULT_CHANGED",
|
||||
"android.intent.action.TIMEZONE_CHANGED",
|
||||
"android.intent.action.TIME_SET",
|
||||
"android.intent.action.TIME_TICK",
|
||||
"android.intent.action.UID_REMOVED",
|
||||
"android.intent.action.UMS_CONNECTED",
|
||||
"android.intent.action.UMS_DISCONNECTED",
|
||||
"android.intent.action.USER_PRESENT",
|
||||
"android.intent.action.USER_UNLOCKED",
|
||||
"android.intent.action.WALLPAPER_CHANGED",
|
||||
"android.media.ACTION_SCO_AUDIO_STATE_UPDATED",
|
||||
"android.media.AUDIO_BECOMING_NOISY",
|
||||
"android.media.INTERNAL_RINGER_MODE_CHANGED_ACTION",
|
||||
"android.media.MASTER_MUTE_CHANGED_ACTION",
|
||||
"android.media.RINGER_MODE_CHANGED",
|
||||
"android.media.SCO_AUDIO_STATE_CHANGED",
|
||||
"android.media.STREAM_DEVICES_CHANGED_ACTION",
|
||||
"android.media.STREAM_MUTE_CHANGED_ACTION",
|
||||
"android.media.VIBRATE_SETTING_CHANGED",
|
||||
"android.media.VOLUME_CHANGED_ACTION",
|
||||
"android.media.action.CLOSE_AUDIO_EFFECT_CONTROL_SESSION",
|
||||
"android.media.action.HDMI_AUDIO_PLUG",
|
||||
"android.media.action.MICROPHONE_MUTE_CHANGED",
|
||||
"android.media.action.OPEN_AUDIO_EFFECT_CONTROL_SESSION",
|
||||
"android.media.action.SPEAKERPHONE_STATE_CHANGED",
|
||||
"android.media.tv.action.CHANNEL_BROWSABLE_REQUESTED",
|
||||
"android.media.tv.action.INITIALIZE_PROGRAMS",
|
||||
"android.media.tv.action.PREVIEW_PROGRAM_ADDED_TO_WATCH_NEXT",
|
||||
"android.media.tv.action.PREVIEW_PROGRAM_BROWSABLE_DISABLED",
|
||||
"android.media.tv.action.WATCH_NEXT_PROGRAM_BROWSABLE_DISABLED",
|
||||
"android.net.conn.BACKGROUND_DATA_SETTING_CHANGED",
|
||||
"android.net.conn.CAPTIVE_PORTAL_TEST_COMPLETED",
|
||||
"android.net.conn.CONNECTIVITY_CHANGE",
|
||||
"android.net.conn.DATA_ACTIVITY_CHANGE",
|
||||
"android.net.conn.INET_CONDITION_ACTION",
|
||||
"android.net.conn.RESTRICT_BACKGROUND_CHANGED",
|
||||
"android.net.conn.TETHER_STATE_CHANGED",
|
||||
"android.net.nsd.STATE_CHANGED",
|
||||
"android.net.scoring.SCORER_CHANGED",
|
||||
"android.net.scoring.SCORE_NETWORKS",
|
||||
"android.net.sip.action.SIP_CALL_OPTION_CHANGED",
|
||||
"android.net.sip.action.SIP_INCOMING_CALL",
|
||||
"android.net.sip.action.SIP_REMOVE_PROFILE",
|
||||
"android.net.sip.action.SIP_SERVICE_UP",
|
||||
"android.net.sip.action.START_SIP",
|
||||
"android.net.wifi.BATCHED_RESULTS",
|
||||
"android.net.wifi.NETWORK_IDS_CHANGED",
|
||||
"android.net.wifi.RSSI_CHANGED",
|
||||
"android.net.wifi.SCAN_RESULTS",
|
||||
"android.net.wifi.STATE_CHANGE",
|
||||
"android.net.wifi.WIFI_STATE_CHANGED",
|
||||
"android.net.wifi.action.WIFI_NETWORK_SUGGESTION_POST_CONNECTION",
|
||||
"android.net.wifi.action.WIFI_SCAN_AVAILABILITY_CHANGED",
|
||||
"android.net.wifi.aware.action.WIFI_AWARE_STATE_CHANGED",
|
||||
"android.net.wifi.p2p.CONNECTION_STATE_CHANGE",
|
||||
"android.net.wifi.p2p.DISCOVERY_STATE_CHANGE",
|
||||
"android.net.wifi.p2p.PEERS_CHANGED",
|
||||
"android.net.wifi.p2p.STATE_CHANGED",
|
||||
"android.net.wifi.p2p.THIS_DEVICE_CHANGED",
|
||||
"android.net.wifi.rtt.action.WIFI_RTT_STATE_CHANGED",
|
||||
"android.net.wifi.supplicant.CONNECTION_CHANGE",
|
||||
"android.net.wifi.supplicant.STATE_CHANGE",
|
||||
"android.nfc.action.ADAPTER_STATE_CHANGED",
|
||||
"android.nfc.action.PREFERRED_PAYMENT_CHANGED",
|
||||
"android.nfc.action.TRANSACTION_DETECTED",
|
||||
"android.os.action.ACTION_EFFECTS_SUPPRESSOR_CHANGED",
|
||||
"android.os.action.DEVICE_IDLE_MODE_CHANGED",
|
||||
"android.os.action.LIGHT_DEVICE_IDLE_MODE_CHANGED",
|
||||
"android.os.action.POWER_SAVE_MODE_CHANGED",
|
||||
"android.os.action.POWER_SAVE_MODE_CHANGED_INTERNAL",
|
||||
"android.os.action.POWER_SAVE_MODE_CHANGING",
|
||||
"android.os.action.POWER_SAVE_TEMP_WHITELIST_CHANGED",
|
||||
"android.os.action.POWER_SAVE_WHITELIST_CHANGED",
|
||||
"android.os.action.UPDATE_EMERGENCY_NUMBER_DB",
|
||||
"android.provider.Telephony.MMS_DOWNLOADED",
|
||||
"android.provider.Telephony.SECRET_CODE",
|
||||
"android.provider.Telephony.SIM_FULL",
|
||||
"android.provider.Telephony.SMS_CARRIER_PROVISION",
|
||||
"android.provider.Telephony.SMS_CB_RECEIVED",
|
||||
"android.provider.Telephony.SMS_DELIVER",
|
||||
"android.provider.Telephony.SMS_RECEIVED",
|
||||
"android.provider.Telephony.SMS_REJECTED",
|
||||
"android.provider.Telephony.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED",
|
||||
"android.provider.Telephony.WAP_PUSH_DELIVER",
|
||||
"android.provider.Telephony.WAP_PUSH_RECEIVED",
|
||||
"android.provider.action.DEFAULT_SMS_PACKAGE_CHANGED",
|
||||
"android.provider.action.EXTERNAL_PROVIDER_CHANGE",
|
||||
"android.provider.action.SMS_EMERGENCY_CB_RECEIVED",
|
||||
"android.provider.action.SMS_MMS_DB_CREATED",
|
||||
"android.provider.action.SMS_MMS_DB_LOST",
|
||||
"android.provider.action.SYNC_VOICEMAIL",
|
||||
"android.security.STORAGE_CHANGED",
|
||||
"android.security.action.KEYCHAIN_CHANGED",
|
||||
"android.security.action.KEY_ACCESS_CHANGED",
|
||||
"android.security.action.TRUST_STORE_CHANGED",
|
||||
"android.service.controls.action.ADD_CONTROL",
|
||||
"android.settings.ENABLE_MMS_DATA_REQUEST",
|
||||
"android.speech.tts.TTS_QUEUE_PROCESSING_COMPLETED",
|
||||
"android.speech.tts.engine.TTS_DATA_INSTALLED",
|
||||
"android.telephony.action.AREA_INFO_UPDATED",
|
||||
"android.telephony.action.DEFAULT_SMS_SUBSCRIPTION_CHANGED",
|
||||
"android.telephony.action.DEFAULT_SUBSCRIPTION_CHANGED",
|
||||
"android.telephony.action.PRIMARY_SUBSCRIPTION_LIST_CHANGED",
|
||||
"android.telephony.action.REFRESH_SUBSCRIPTION_PLANS",
|
||||
"android.telephony.action.SECRET_CODE",
|
||||
"android.telephony.action.SERVICE_PROVIDERS_UPDATED",
|
||||
"android.telephony.action.SIM_APPLICATION_STATE_CHANGED",
|
||||
"android.telephony.action.SIM_CARD_STATE_CHANGED",
|
||||
"android.telephony.action.SIM_SLOT_STATUS_CHANGED",
|
||||
"android.telephony.action.SUBSCRIPTION_CARRIER_IDENTITY_CHANGED",
|
||||
"android.telephony.action.SUBSCRIPTION_PLANS_CHANGED",
|
||||
"android.telephony.action.SUBSCRIPTION_SPECIFIC_CARRIER_IDENTITY_CHANGED",
|
||||
"android.telephony.euicc.action.NOTIFY_CARRIER_SETUP_INCOMPLETE",
|
||||
"android.telephony.euicc.action.OTA_STATUS_CHANGED",
|
||||
"android.telephony.ims.action.WFC_IMS_REGISTRATION_ERROR",
|
||||
"com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS",
|
||||
"com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS",
|
||||
"com.android.internal.intent.action.ACTION_FORBIDDEN_NO_SERVICE_AUTHORIZATION",
|
||||
"com.android.internal.provider.action.VOICEMAIL_SMS_RECEIVED"
|
||||
};
|
||||
}
|
@ -86,8 +86,8 @@ public class ActivityManageTriggerPhoneCall extends Activity
|
||||
else
|
||||
{
|
||||
Intent data = new Intent();
|
||||
data.putExtra("triggerParameter", false);
|
||||
data.putExtra("triggerParameter2", tp2Result);
|
||||
data.putExtra(ActivityManageRule.intentNameTriggerParameter1, false);
|
||||
data.putExtra(ActivityManageRule.intentNameTriggerParameter2, tp2Result);
|
||||
ActivityManageTriggerPhoneCall.this.setResult(RESULT_OK, data);
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ public class ActivityPermissions extends Activity
|
||||
}
|
||||
}
|
||||
|
||||
protected static void addToArrayListUnique(String value, ArrayList<String> list)
|
||||
public static void addToArrayListUnique(String value, List<String> list)
|
||||
{
|
||||
if (!list.contains(value))
|
||||
list.add(value);
|
||||
|
@ -248,8 +248,6 @@ public class AutomationService extends Service implements OnInitListener
|
||||
reloadSettings, reloadPointsOfInterest, reloadRules, updateNotification
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
public void serviceInterface(serviceCommands command)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Bind", "Ahhhh, customers... How can I help you?", 5);
|
||||
|
@ -5,6 +5,7 @@ import android.util.Log;
|
||||
|
||||
import com.jens.automation2.location.CellLocationChangedReceiver;
|
||||
import com.jens.automation2.location.WifiBroadcastReceiver;
|
||||
import com.jens.automation2.receivers.BroadcastListener;
|
||||
import com.jens.automation2.receivers.DateTimeListener;
|
||||
import com.jens.automation2.receivers.AutomationListenerInterface;
|
||||
import com.jens.automation2.receivers.BatteryReceiver;
|
||||
@ -67,6 +68,7 @@ public class ReceiverCoordinator
|
||||
DateTimeListener.class,
|
||||
BatteryReceiver.class,
|
||||
BluetoothReceiver.class,
|
||||
BroadcastListener.class,
|
||||
ConnectivityReceiver.class,
|
||||
DeviceOrientationListener.class,
|
||||
HeadphoneJackListener.class,
|
||||
@ -163,6 +165,10 @@ public class ReceiverCoordinator
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.noiseLevel))
|
||||
NoiseListener.startNoiseListener(AutomationService.getInstance());
|
||||
|
||||
// startBroadcastListener
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.broadcastReceived))
|
||||
BroadcastListener.getInstance().startListener(AutomationService.getInstance());
|
||||
|
||||
// startProcessListener
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.process_started_stopped))
|
||||
ProcessListener.startProcessListener(AutomationService.getInstance());
|
||||
@ -206,6 +212,7 @@ public class ReceiverCoordinator
|
||||
TimeZoneListener.stopTimeZoneListener();
|
||||
DateTimeListener.stopAlarmListener(AutomationService.getInstance());
|
||||
NoiseListener.stopNoiseListener();
|
||||
BroadcastListener.getInstance().stopListener(AutomationService.getInstance());
|
||||
ProcessListener.stopProcessListener(AutomationService.getInstance());
|
||||
MediaPlayerListener.getInstance().stopListener(AutomationService.getInstance());
|
||||
DeviceOrientationListener.getInstance().stopListener(AutomationService.getInstance());
|
||||
@ -266,6 +273,17 @@ public class ReceiverCoordinator
|
||||
NoiseListener.stopNoiseListener();
|
||||
}
|
||||
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.broadcastReceived))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "LocationProvider", "Starting BroadcastReceiver because used in a new/changed rule.", 4);
|
||||
BroadcastListener.getInstance().startListener(AutomationService.getInstance());
|
||||
}
|
||||
else
|
||||
{
|
||||
Miscellaneous.logEvent("i", "LocationProvider", "Shutting down BroadcastReceiver because not used in any rule.", 4);
|
||||
BroadcastListener.getInstance().stopListener(AutomationService.getInstance());
|
||||
}
|
||||
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.process_started_stopped))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "LocationProvider", "Starting ProcessListener because used in a new/changed rule.", 4);
|
||||
|
@ -3,7 +3,6 @@ package com.jens.automation2;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
@ -14,6 +13,7 @@ import com.jens.automation2.location.LocationProvider;
|
||||
import com.jens.automation2.location.WifiBroadcastReceiver;
|
||||
import com.jens.automation2.receivers.BatteryReceiver;
|
||||
import com.jens.automation2.receivers.BluetoothReceiver;
|
||||
import com.jens.automation2.receivers.BroadcastListener;
|
||||
import com.jens.automation2.receivers.ConnectivityReceiver;
|
||||
import com.jens.automation2.receivers.DeviceOrientationListener;
|
||||
import com.jens.automation2.receivers.HeadphoneJackListener;
|
||||
@ -58,6 +58,7 @@ public class Trigger
|
||||
musicPlaying,
|
||||
deviceStarts,
|
||||
serviceStarts,
|
||||
broadcastReceived,
|
||||
phoneCall; //phoneCall always needs to be at the very end because of Google's shitty so called privacy
|
||||
|
||||
public String getFullName(Context context)
|
||||
@ -110,6 +111,8 @@ public class Trigger
|
||||
return context.getResources().getString(R.string.deviceStarts);
|
||||
case serviceStarts:
|
||||
return context.getResources().getString(R.string.serviceStarts);
|
||||
case broadcastReceived:
|
||||
return context.getResources().getString(R.string.broadcastReceivedTitle);
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
@ -221,6 +224,10 @@ public class Trigger
|
||||
if(!checkServiceStarts())
|
||||
result = false;
|
||||
break;
|
||||
case broadcastReceived:
|
||||
if(!checkBroadcastReceived())
|
||||
result = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -237,6 +244,18 @@ public class Trigger
|
||||
return result;
|
||||
}
|
||||
|
||||
boolean checkBroadcastReceived()
|
||||
{
|
||||
/*
|
||||
We cannot reasonably check the current state for every broadcast event.
|
||||
We can only hope that when starting the receiver we get an initial broadcast
|
||||
for every current state. That collection of states will be saved and checked if
|
||||
it contains the specific event of this trigger.
|
||||
*/
|
||||
|
||||
return triggerParameter == BroadcastListener.getInstance().broadcastsCollectionContains(triggerParameter2);
|
||||
}
|
||||
|
||||
boolean checkNotification()
|
||||
{
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
|
||||
@ -1262,9 +1281,9 @@ public class Trigger
|
||||
return triggerType;
|
||||
}
|
||||
|
||||
public void setTriggerType(Trigger_Enum settriggerType)
|
||||
public void setTriggerType(Trigger_Enum setTriggerType)
|
||||
{
|
||||
this.triggerType = settriggerType;
|
||||
this.triggerType = setTriggerType;
|
||||
}
|
||||
|
||||
public boolean getTriggerParameter()
|
||||
@ -1601,6 +1620,14 @@ public class Trigger
|
||||
// This type doesn't have an activate/deactivate equivalent
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.serviceHasJustStarted));
|
||||
break;
|
||||
case broadcastReceived:
|
||||
if(triggerParameter)
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.broadcastReceived));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.broadcastNotReceived));
|
||||
|
||||
returnString.append(": " + triggerParameter2);
|
||||
break;
|
||||
default:
|
||||
returnString.append("error");
|
||||
break;
|
||||
@ -1665,10 +1692,6 @@ public class Trigger
|
||||
{
|
||||
ArrayList<String> triggerTypesList = new ArrayList<String>();
|
||||
|
||||
/*for(int i=0; i<Trigger_Enum.values().length; i++)
|
||||
{
|
||||
triggerTypesList.add(Trigger_Enum.values()[i].getFullName(context));
|
||||
}*/
|
||||
for(Trigger_Enum triggerType : Trigger_Enum.values())
|
||||
triggerTypesList.add(triggerType.getFullName(context));
|
||||
|
||||
|
@ -99,15 +99,12 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
||||
|
||||
if(intent.getAction().equals(Intent.ACTION_BATTERY_LOW))
|
||||
{
|
||||
Log.i("Battery", "Low battery event");
|
||||
Miscellaneous.logEvent("i", "Battery", "Low battery event", 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
// Miscellaneous.logEvent("i", "BatteryReceiver", "Received battery event.");
|
||||
// if(intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED))
|
||||
// {
|
||||
batteryLevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
|
||||
// int scale = -1;
|
||||
// int voltage = -1;
|
||||
@ -120,13 +117,13 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
||||
|
||||
int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
|
||||
int statusPlugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
|
||||
// Miscellaneous.logEvent("i", "BatteryReceiver", "Status: " + String.valueOf(statusPlugged));
|
||||
Miscellaneous.logEvent("i", "BatteryReceiver", "Status: " + String.valueOf(statusPlugged), 5);
|
||||
|
||||
switch(statusPlugged)
|
||||
{
|
||||
case BatteryManager.BATTERY_PLUGGED_AC:
|
||||
// Toast.makeText(context, "Regular charging", Toast.LENGTH_LONG).show();
|
||||
// Miscellaneous.logEvent("i", "BatteryReceiver", "Regular charging.");
|
||||
Miscellaneous.logEvent("i", "BatteryReceiver", "Regular charging.", 5);
|
||||
this.actionCharging(context);
|
||||
break;
|
||||
case BatteryManager.BATTERY_PLUGGED_USB:
|
||||
@ -136,11 +133,8 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
||||
|
||||
switch(status)
|
||||
{
|
||||
// case BatteryManager.BATTERY_STATUS_CHARGING:
|
||||
// break;
|
||||
case BatteryManager.BATTERY_STATUS_FULL:
|
||||
// Toast.makeText(context, "Regular charging full", Toast.LENGTH_LONG).show();
|
||||
// Miscellaneous.logEvent("i", "BatteryReceiver", "Device has been fully charged.");
|
||||
Miscellaneous.logEvent("i", "BatteryReceiver", "Device has been fully charged.", 5);
|
||||
this.actionCharging(context);
|
||||
break;
|
||||
case BatteryManager.BATTERY_STATUS_DISCHARGING:
|
||||
@ -264,11 +258,13 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startListener(AutomationService automationService)
|
||||
{
|
||||
BatteryReceiver.startBatteryReceiver(automationService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopListener(AutomationService automationService)
|
||||
{
|
||||
|
@ -0,0 +1,130 @@
|
||||
package com.jens.automation2.receivers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.util.Log;
|
||||
|
||||
import com.jens.automation2.ActivityPermissions;
|
||||
import com.jens.automation2.AutomationService;
|
||||
import com.jens.automation2.Miscellaneous;
|
||||
import com.jens.automation2.Rule;
|
||||
import com.jens.automation2.Trigger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BroadcastListener extends android.content.BroadcastReceiver implements AutomationListenerInterface
|
||||
{
|
||||
ArrayList<String> broadcastsCollection = new ArrayList<>();
|
||||
public static AutomationService automationServiceRef = null;
|
||||
private static boolean broadcastReceiverActive = false;
|
||||
private static BroadcastListener broadcastReceiverInstance = null;
|
||||
private static IntentFilter broadcastIntentFilter = null;
|
||||
private static Intent broadcastStatus = null;
|
||||
|
||||
public static BroadcastListener getInstance()
|
||||
{
|
||||
if(broadcastReceiverInstance == null)
|
||||
broadcastReceiverInstance = new BroadcastListener();
|
||||
|
||||
return broadcastReceiverInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
broadcastsCollection.add(intent.getAction());
|
||||
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.broadcastReceived);
|
||||
for(int i=0; i<ruleCandidates.size(); i++)
|
||||
{
|
||||
if(ruleCandidates.get(i).getsGreenLight(context))
|
||||
ruleCandidates.get(i).activate(automationServiceRef, false);
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<String> getBroadcastsCollection()
|
||||
{
|
||||
return broadcastsCollection;
|
||||
}
|
||||
|
||||
public boolean broadcastsCollectionContains(String event)
|
||||
{
|
||||
return broadcastsCollection.contains(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startListener(AutomationService automationService)
|
||||
{
|
||||
if(!broadcastReceiverActive)
|
||||
{
|
||||
BroadcastListener.automationServiceRef = automationService;
|
||||
|
||||
if(broadcastReceiverInstance == null)
|
||||
broadcastReceiverInstance = new BroadcastListener();
|
||||
|
||||
if(broadcastIntentFilter == null)
|
||||
{
|
||||
broadcastIntentFilter = new IntentFilter();
|
||||
|
||||
List<String> actionList = new ArrayList<>();
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.broadcastReceived);
|
||||
for(int i=0; i<ruleCandidates.size(); i++)
|
||||
{
|
||||
for(Trigger t : ruleCandidates.get(i).getTriggerSet())
|
||||
{
|
||||
if(t.getTriggerType().equals(Trigger.Trigger_Enum.broadcastReceived))
|
||||
{
|
||||
ActivityPermissions.addToArrayListUnique(t.getTriggerParameter2(), actionList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(String s : actionList)
|
||||
broadcastIntentFilter.addAction(s);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
broadcastStatus = automationServiceRef.registerReceiver(broadcastReceiverInstance, broadcastIntentFilter);
|
||||
broadcastReceiverActive = true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
/*
|
||||
We might be confronted with permission issues here.
|
||||
*/
|
||||
Miscellaneous.logEvent("e", "BroadcastListener", Log.getStackTraceString(e), 1);
|
||||
broadcastReceiverActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopListener(AutomationService automationService)
|
||||
{
|
||||
if(broadcastReceiverActive)
|
||||
{
|
||||
if(broadcastReceiverInstance != null)
|
||||
{
|
||||
automationServiceRef.unregisterReceiver(broadcastReceiverInstance);
|
||||
broadcastReceiverInstance = null;
|
||||
}
|
||||
|
||||
broadcastReceiverActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isListenerRunning()
|
||||
{
|
||||
return broadcastReceiverActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Trigger.Trigger_Enum[] getMonitoredTrigger()
|
||||
{
|
||||
return new Trigger.Trigger_Enum[] { Trigger.Trigger_Enum.broadcastReceived };
|
||||
}
|
||||
}
|
BIN
app/src/main/res/drawable/satellite.png
Normal file
BIN
app/src/main/res/drawable/satellite.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
@ -96,6 +96,11 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/sendEmailToDev" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/logsExplanation" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_span="2"
|
||||
|
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_margin="@dimen/default_margin">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_span="2"
|
||||
android:textSize="25dp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/broadcastReceivedTitle" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/explanationBroadcastTrigger" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvBroadcastUrl"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="@dimen/default_margin"
|
||||
android:text="@string/broadcastListUrl" />
|
||||
|
||||
<RadioGroup
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbBroadcastReceived"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="@string/broadcastReceived" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbBroadcastNotReceived"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/broadcastNotReceived" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etBroadcastTriggerAction"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bBroadcastShowSuggestions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/broadcastsShowSuggestions" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSaveTriggerBroadcast"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/save" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
@ -804,4 +804,12 @@
|
||||
<string name="serviceStarts">Service starts</string>
|
||||
<string name="deviceHasJustStarted">device has just started</string>
|
||||
<string name="serviceHasJustStarted">service has just started</string>
|
||||
<string name="broadcastReceived">broadcast received</string>
|
||||
<string name="broadcastNotReceived">broadcast not received</string>
|
||||
<string name="explanationBroadcastTrigger">Most events on your phone will be \"published\" by broadcasting them throughout the operating system.\nFor example turning on/off airplane mode will trigger such a broadcast. Those broadcasts are not automatically visible/audible, but if an application (like Automation) is interested it can hook up to them. When they occur it will get notified and can react.\n\nYou can define a broadcast event here for which the application will wait. You may enter it manually, copy & paste it from somewhere or pick one from the list of suggestions. As this trigger is meant to be and remain very flexible I cannot provide you with explanations for the items.\n\nThe list of suggestions does not claim to be complete. Please visit the below URL to have a look at the Android documentation.\nAlso any app can send custom events which will not appear in the Android documentation of course.\n\nMany broadcasts require specific permissions in order to work. I try to request permissions where I know they will be required. If you think a permission is required for the action you entered, please let me know.\n\nNot received means there has not been such a broadcast ever since the service has been started. Responding to certain parameters is in development.</string>
|
||||
<string name="broadcastListUrl">https://developer.android.com/reference/android/content/Intent.html</string>
|
||||
<string name="broadcastReceivedTitle">Broadcast received</string>
|
||||
<string name="logsExplanation">To avoid unnecessary wearing of your storage, logs are not saved by default. So if you have a problem please activate logging in settings first and set log level to 5. Then reproduce the problem. Only then logs can be attached.</string>
|
||||
<string name="broadcastsShowSuggestions">Show suggestions</string>
|
||||
<string name="selectBroadcast">Select broadcast</string>
|
||||
</resources>
|
@ -5,7 +5,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.1.3'
|
||||
classpath 'com.android.tools.build:gradle:7.2.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
||||
|
Loading…
Reference in New Issue
Block a user