Permissions for startActivity() reduced

This commit is contained in:
Jens 2023-12-03 23:24:58 +01:00
parent e4828a9720
commit 9ead47bdf7
6 changed files with 49 additions and 22 deletions

View File

@ -1043,7 +1043,12 @@ public class Actions
{ {
Miscellaneous.logEvent("i", "StartOtherActivity", "Starting other Activity...", 4); Miscellaneous.logEvent("i", "StartOtherActivity", "Starting other Activity...", 4);
String params[] = param.split(";"); String params[];
if(param.contains(Action.actionParameter2Split))
params = param.split(Action.actionParameter2Split);
else
params = param.split(";");
try try
{ {

View File

@ -58,10 +58,10 @@ public class ActivityManageActionStartActivity extends Activity
RadioButton rbStartAppSelectByActivity, rbStartAppSelectByAction, rbStartAppByActivity, rbStartAppByBroadcast, rbStartAppByService, rbStartAppByForegroundService; RadioButton rbStartAppSelectByActivity, rbStartAppSelectByAction, rbStartAppByActivity, rbStartAppByBroadcast, rbStartAppByService, rbStartAppByForegroundService;
final String urlShowExamples = "https://server47.de/automation/examples_startProgram.html"; final String urlShowExamples = "https://server47.de/automation/examples_startProgram.html";
final static String startByActivityString = "0"; public final static String startByActivityString = "0";
final static String startByBroadcastString = "1"; public final static String startByBroadcastString = "1";
final static String startByServiceString = "2"; public final static String startByServiceString = "2";
final static String startByForegroundServiceString = "3"; public final static String startByForegroundServiceString = "3";
final static int requestCodeForRequestQueryAllPackagesPermission = 4711; final static int requestCodeForRequestQueryAllPackagesPermission = 4711;
@ -234,29 +234,29 @@ public class ActivityManageActionStartActivity extends Activity
String parameter2 = ""; String parameter2 = "";
if (rbStartAppSelectByActivity.isChecked()) if (rbStartAppSelectByActivity.isChecked())
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString(); parameter2 += etPackageName.getText().toString() + Action.actionParameter2Split + etActivityOrActionPath.getText().toString();
else else
{ {
if (etPackageName.getText().toString() != null && etPackageName.getText().toString().length() > 0) if (etPackageName.getText().toString() != null && etPackageName.getText().toString().length() > 0)
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString(); parameter2 += etPackageName.getText().toString() + Action.actionParameter2Split + etActivityOrActionPath.getText().toString();
else else
parameter2 += Actions.dummyPackageString + ";" + etActivityOrActionPath.getText().toString(); parameter2 += Actions.dummyPackageString + Action.actionParameter2Split + etActivityOrActionPath.getText().toString();
// if(etClassName.getText().toString().length() > 0) // if(etClassName.getText().toString().length() > 0)
parameter2 += ";" + etClassName.getText().toString(); parameter2 += Action.actionParameter2Split + etClassName.getText().toString();
} }
if (rbStartAppByActivity.isChecked()) if (rbStartAppByActivity.isChecked())
parameter2 += ";" + startByActivityString; parameter2 += Action.actionParameter2Split + startByActivityString;
else if(rbStartAppByService.isChecked()) else if(rbStartAppByService.isChecked())
parameter2 += ";" + startByServiceString; parameter2 += Action.actionParameter2Split + startByServiceString;
else if(rbStartAppByForegroundService.isChecked()) else if(rbStartAppByForegroundService.isChecked())
parameter2 += ";" + startByForegroundServiceString; parameter2 += Action.actionParameter2Split + startByForegroundServiceString;
else else
parameter2 += ";" + startByBroadcastString; parameter2 += Action.actionParameter2Split + startByBroadcastString;
for (String s : intentPairList) for (String s : intentPairList)
parameter2 += ";" + s; parameter2 += Action.actionParameter2Split + s;
returnData.putExtra(ActivityManageRule.intentNameActionParameter2, parameter2); returnData.putExtra(ActivityManageRule.intentNameActionParameter2, parameter2);
@ -628,7 +628,13 @@ public class ActivityManageActionStartActivity extends Activity
rbStartAppSelectByActivity.setChecked(!selectionByAction); rbStartAppSelectByActivity.setChecked(!selectionByAction);
rbStartAppSelectByAction.setChecked(selectionByAction); rbStartAppSelectByAction.setChecked(selectionByAction);
String[] params = input.getStringExtra(ActivityManageRule.intentNameActionParameter2).split(";"); String[] params;
String partsString = input.getStringExtra(ActivityManageRule.intentNameActionParameter2);
if(partsString.contains(Action.actionParameter2Split))
params = partsString.split(Action.actionParameter2Split);
else
params = partsString.split(";");
if(Miscellaneous.isNumeric(params[2])) // old configuration file if(Miscellaneous.isNumeric(params[2])) // old configuration file
{ {

View File

@ -650,7 +650,18 @@ public class ActivityPermissions extends Activity
// ) // )
// addToArrayListUnique("net.kollnig.missioncontrol.permission.ADMIN", requiredPermissions); // addToArrayListUnique("net.kollnig.missioncontrol.permission.ADMIN", requiredPermissions);
if(Build.VERSION.SDK_INT >= 29) if(Build.VERSION.SDK_INT >= 29)
addToArrayListUnique(Manifest.permission.SYSTEM_ALERT_WINDOW, requiredPermissions); {
String parts[];
if(action.getParameter2().contains(Action.actionParameter2Split))
parts = action.getParameter2().split(Action.actionParameter2Split);
else
parts = action.getParameter2().split(";");
// Permission only required for starts of activity, not broadcasts or services
if(parts[2].equals(ActivityManageActionStartActivity.startByActivityString))
addToArrayListUnique(Manifest.permission.SYSTEM_ALERT_WINDOW, requiredPermissions);
}
break; break;
case triggerUrl: case triggerUrl:
addToArrayListUnique(Manifest.permission.INTERNET, requiredPermissions); addToArrayListUnique(Manifest.permission.INTERNET, requiredPermissions);

View File

@ -1286,20 +1286,24 @@ public class XmlFileInterface
else else
newTag = tag.replace("/", Action.intentPairSeparator); newTag = tag.replace("/", Action.intentPairSeparator);
String[] newTagPieces = newTag.split(";"); String[] newTagPieces = new String[0];
if(newTag.contains(Action.actionParameter2Split))
newTagPieces = newTag.split(Action.actionParameter2Split);
else
newTag.split(";");
if(newTagPieces.length < 2 || (!newTagPieces[0].contains(Actions.dummyPackageString) && newTagPieces[1].contains(Action.intentPairSeparator))) if(newTagPieces.length < 2 || (!newTagPieces[0].contains(Actions.dummyPackageString) && newTagPieces[1].contains(Action.intentPairSeparator)))
{ {
newTag = Actions.dummyPackageString + ";" + newTag; newTag = Actions.dummyPackageString + Action.actionParameter2Split + newTag;
newTagPieces = newTag.split(";"); newTagPieces = newTag.split(Action.actionParameter2Split);
} }
if(newTagPieces.length < 3) if(newTagPieces.length < 3)
newTag += ";" + ActivityManageActionStartActivity.startByActivityString; newTag += Action.actionParameter2Split + ActivityManageActionStartActivity.startByActivityString;
else if(newTagPieces.length >= 3) else if(newTagPieces.length >= 3)
{ {
if(newTagPieces[2].contains(Action.intentPairSeparator)) if(newTagPieces[2].contains(Action.intentPairSeparator))
newTag = newTagPieces[0] + ";" + newTagPieces[1] + ";" + ActivityManageActionStartActivity.startByActivityString + ";" + newTagPieces[2]; newTag = newTagPieces[0] + Action.actionParameter2Split + newTagPieces[1] + Action.actionParameter2Split + ActivityManageActionStartActivity.startByActivityString + Action.actionParameter2Split + newTagPieces[2];
} }
newAction.setParameter2(newTag); newAction.setParameter2(newTag);

View File

@ -134,7 +134,7 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
{ {
case BatteryManager.BATTERY_STATUS_CHARGING: case BatteryManager.BATTERY_STATUS_CHARGING:
case BatteryManager.BATTERY_STATUS_FULL: case BatteryManager.BATTERY_STATUS_FULL:
Miscellaneous.logEvent("i", "BatteryReceiver", "Device has been fully charged.", 5); // Miscellaneous.logEvent("i", "BatteryReceiver", "Device has been fully charged.", 5);
this.actionCharging(context); this.actionCharging(context);
break; break;
case BatteryManager.BATTERY_STATUS_DISCHARGING: case BatteryManager.BATTERY_STATUS_DISCHARGING:

View File

@ -0,0 +1 @@
* Fixed: Overlay permission for start other program action only required if startByActivity() is selected