Fix and re-apply "[flipper] Automatically set Android devices into the permissive mode"
Summary: Reverts D36263724 (0ee8f09fe5) and fixes the underlying crash by setting only physical devices in the permissive mode
Reviewed By: passy
Differential Revision: D36275055
fbshipit-source-id: 25a691e9c07e20a3341630db508795c133a9bd81
This commit is contained in:
committed by
Facebook GitHub Bot
parent
56ea2fc782
commit
754afd0d2d
@@ -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> {
|
||||
try {
|
||||
await this.executeShellOrDie(
|
||||
|
||||
@@ -87,6 +87,16 @@ export class AndroidDeviceManager {
|
||||
});
|
||||
}
|
||||
|
||||
// Remote simulators connected via SSH tunnels
|
||||
const isRemoteDevice = device.id.startsWith('localhost');
|
||||
if (
|
||||
androidLikeDevice instanceof AndroidDevice &&
|
||||
type === 'physical' &&
|
||||
!isRemoteDevice
|
||||
) {
|
||||
await androidLikeDevice.setIntoPermissiveMode();
|
||||
}
|
||||
|
||||
// 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
|
||||
if (androidLikeDevice instanceof AndroidDevice) {
|
||||
|
||||
Reference in New Issue
Block a user