Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tizen devices fixes #1703

Merged
merged 10 commits into from
Sep 20, 2024
29 changes: 18 additions & 11 deletions packages/sdk-tizen/src/deviceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,23 @@
return {};
};

export const launchTizenEmulator = async (name: string | true): Promise<boolean> => {
export const launchTizenEmulator = async (name: string | true, hideDevices?: boolean): Promise<boolean> => {
Marius456 marked this conversation as resolved.
Show resolved Hide resolved
const c = getContext();
logDefault(`launchTizenEmulator:${name}`);

if (name === true) {
const emulators = await execCLI(CLI_TIZEN_EMULATOR, 'list-vm');
const devices = await execCLI(CLI_SDB_TIZEN, 'devices');
const devices_lines = devices.split('\n');

const allDownloadedEmulators = emulators.split('\n'); // all tizen, tizenwatch and tizenmobile emulators

const specificEmulators = await getSubplatformDevices(allDownloadedEmulators, c.platform as string);
const devicesArr = devices_lines.slice(1).map((line: string) => line.split(' ')[0]); // devices array with only their ip

const lines = specificEmulators.concat(devicesArr);

const targetsArray = lines.map((line) => ({ id: line, name: line }));
const targetsArray = hideDevices
? specificEmulators.map((line) => ({ id: line, name: line }))
: lines.map((line) => ({ id: line, name: line }));

const choices = _composeDevicesString(targetsArray);

Expand All @@ -100,19 +100,18 @@

name = chosenEmulator;
}

if (name) {
if (name && typeof name === 'string') {
const ipRegex = /^(?:\d{1,3}\.){3}\d{1,3}:\d{1,5}$/;
if (name !== true && ipRegex.test(name)) {
if (ipRegex.test(name)) {
// if ip is chosen, real device boot should start
logInfo('Connecting to device');
c.runtime.target = name.split(':')[0];
await runTizenSimOrDevice();
return true;
await runTizenSimOrDevice(true);
return new Promise(() => logInfo('Device is launched.'));
}
try {
await executeAsync(
`${c.cli[CLI_TIZEN_EMULATOR]} launch --name ${name}`,

Check warning

Code scanning / CodeQL

Unsafe shell command constructed from library input Medium

This string concatenation which depends on
library input
is later used in a
shell command
.
ExecOptionsPresets.SPINNER_FULL_ERROR_SUMMARY
);
return true;
Expand Down Expand Up @@ -350,7 +349,7 @@
// }
// };

export const runTizenSimOrDevice = async () => {
export const runTizenSimOrDevice = async (onlyRun?: true | null) => {

Check failure on line 352 in packages/sdk-tizen/src/deviceManager.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'onlyRun' is defined but never used. Allowed unused args must match /^_/u
const c = getContext();
const { target } = c.runtime;
const { platform } = c;
Expand Down Expand Up @@ -384,8 +383,11 @@
let deviceID: string;

if (!tId) return Promise.reject(`Tizen platform requires "id" filed in platforms.tizen`);

const askForEmulator = async () => {
if (!target) {
launchTizenEmulator(true);
return;
}
const { startEmulator } = await inquirerPrompt({
name: 'startEmulator',
type: 'confirm',
Expand Down Expand Up @@ -426,6 +428,11 @@
const continueLaunching = async () => {
let hasDevice = false;

// if (onlyRun) {
// await execCLI(CLI_TIZEN, `run -p ${tId} -t ${deviceID}`);
// return true;
// }

await execCLI(CLI_TIZEN, `build-web -- "${tBuild}" -out "${intermediate}"`);
await execCLI(CLI_TIZEN, `package -- "${intermediate}" -s ${certProfile} -t wgt -o "${tOut}"`);

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-tizen/src/tasks/taskTargetLaunch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default createTask({
await checkAndConfigureTizenSdks();
const target = await getTargetWithOptionalPrompt();
await checkTizenSdk();
return launchTizenEmulator(target);
return launchTizenEmulator(target, true);
},
task: RnvTaskName.targetLaunch,
options: [RnvTaskOptions.target],
Expand Down
Loading