Automatically set Android devices into the permissive mode
Reviewed By: nikoant Differential Revision: D35356211 fbshipit-source-id: 471470c5ca91c824590a409c4474433f2277b1f2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
052f417224
commit
501abc6b55
@@ -120,6 +120,37 @@ export default class AndroidDevice extends ServerDevice {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async setIntoPermissiveMode(): Promise<void> {
|
||||||
|
console.debug('AndroidDevice.setIntoPermissiveMode', this.serial);
|
||||||
|
try {
|
||||||
|
try {
|
||||||
|
await this.adb.root(this.serial);
|
||||||
|
} catch (e) {
|
||||||
|
if (
|
||||||
|
!(e instanceof Error) ||
|
||||||
|
e.message !== 'adbd is already running as root'
|
||||||
|
) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.debug(
|
||||||
|
'AndroidDevice.setIntoPermissiveMode -> enabled root',
|
||||||
|
this.serial,
|
||||||
|
);
|
||||||
|
await this.executeShellOrDie('setenforce 0');
|
||||||
|
console.info(
|
||||||
|
'AndroidDevice.setIntoPermissiveMode -> success',
|
||||||
|
this.serial,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.info(
|
||||||
|
'AndroidDevice.setIntoPermissiveMode -> failed',
|
||||||
|
this.serial,
|
||||||
|
e,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async screenRecordAvailable(): Promise<boolean> {
|
async screenRecordAvailable(): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
await this.executeShellOrDie(
|
await this.executeShellOrDie(
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ export class AndroidDeviceManager {
|
|||||||
// The default way of capturing screenshots through adb does not seem to work
|
// The default way of capturing screenshots through adb does not seem to work
|
||||||
// There is a way of getting a screenshot through KaiOS dev tools though
|
// There is a way of getting a screenshot through KaiOS dev tools though
|
||||||
if (androidLikeDevice instanceof AndroidDevice) {
|
if (androidLikeDevice instanceof AndroidDevice) {
|
||||||
|
await androidLikeDevice.setIntoPermissiveMode();
|
||||||
|
|
||||||
const screenRecordAvailable =
|
const screenRecordAvailable =
|
||||||
await androidLikeDevice.screenRecordAvailable();
|
await androidLikeDevice.screenRecordAvailable();
|
||||||
androidLikeDevice.info.features.screenCaptureAvailable =
|
androidLikeDevice.info.features.screenCaptureAvailable =
|
||||||
|
|||||||
1
desktop/types/adbkit.d.ts
vendored
1
desktop/types/adbkit.d.ts
vendored
@@ -57,6 +57,7 @@ declare module 'adbkit' {
|
|||||||
serial: string,
|
serial: string,
|
||||||
command: string | string[],
|
command: string | string[],
|
||||||
) => Promise<NodeJS.ReadStream>;
|
) => Promise<NodeJS.ReadStream>;
|
||||||
|
root: (serial: string) => Promise<true>;
|
||||||
screencap: (serial: string) => Promise<NodeJS.WriteStream>;
|
screencap: (serial: string) => Promise<NodeJS.WriteStream>;
|
||||||
pull: (serial: string, path: string) => Promise<PullTransfer>;
|
pull: (serial: string, path: string) => Promise<PullTransfer>;
|
||||||
openLogcat: (
|
openLogcat: (
|
||||||
|
|||||||
Reference in New Issue
Block a user