Skip to content

Conversation

@vchimev
Copy link
Contributor

@vchimev vchimev commented Feb 27, 2018

This allows you to turn on/off "Don't keep activities" setting in the Developer options for Android.


public static setDontKeepActivities(value: boolean, device: IDevice) {
let status: 0 | 1;
value ? status = 1 : status = 0;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const status = value ? 1 : 0;

value ? status = 1 : status = 0;

const prefix = AndroidController.gettokenPrefix(device.type);
executeCommand(AndroidController.ADB + ` -s ${prefix}${device.token} shell service call activity 43 i32 ${status}`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`${AndroidController.ADB} -s ${prefix}${device.token} shell service call activity 43 i32 ${status}`

executeCommand(AndroidController.ADB + ` -s ${prefix}${device.token} shell service call activity 43 i32 ${status}`);

if (this.getAlwaysFinishActivitiesGlobalSettingsValue(device) !== value) {
throw new Error(`Failed to set \"Don't keep activities\" to ${value}!`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to escape the quotes when using backticks (`).


private static getAlwaysFinishActivitiesGlobalSettingsValue(device: IDevice): boolean {
const prefix = AndroidController.gettokenPrefix(device.type);
return executeCommand(AndroidController.ADB + " -s " + `${prefix}${device.token}` + " shell settings get global always_finish_activities").trim() === "1";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can move the command to a variable.
Also you can move the result of the execution to a variable.

AndroidController.ADB + " -s " + `${prefix}${device.token}` + " shell settings get global always_finish_activities"

-->

`${AndroidController.ADB} -s ${prefix}${device.token} shell settings get global always_finish_activities`

@vchimev vchimev force-pushed the vchimev/dont-keep-activities branch from fcb961c to 4649708 Compare February 27, 2018 19:34
@vchimev vchimev changed the title feat(android): add "Don't keep activities" abilities feat(android): add "Don't keep activities" functionality Feb 27, 2018
@vchimev
Copy link
Contributor Author

vchimev commented Feb 27, 2018

Ping @sis0k0 and @SvetoslavTsenov.

@vchimev vchimev force-pushed the vchimev/dont-keep-activities branch from d2c3508 to d64efd1 Compare February 28, 2018 07:26
@vchimev vchimev merged commit 9f829a3 into master Feb 28, 2018
@vchimev vchimev deleted the vchimev/dont-keep-activities branch February 28, 2018 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants