@midscene/android 0.23.0 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/index.d.ts +0 -1
- package/dist/es/index.js +22 -9
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.js +22 -9
- package/dist/types/index.d.ts +0 -1
- package/package.json +4 -4
package/dist/es/index.d.ts
CHANGED
package/dist/es/index.js
CHANGED
|
@@ -21,7 +21,6 @@ var defaultNormalScrollDuration = 1e3;
|
|
|
21
21
|
var debugPage = getDebug("android:device");
|
|
22
22
|
var AndroidDevice = class {
|
|
23
23
|
constructor(deviceId, options) {
|
|
24
|
-
this.screenSize = null;
|
|
25
24
|
this.yadbPushed = false;
|
|
26
25
|
this.devicePixelRatio = 1;
|
|
27
26
|
this.adb = null;
|
|
@@ -185,10 +184,29 @@ ${Object.keys(size).filter((key) => size[key]).map(
|
|
|
185
184
|
const orientationMatch = orientationStdout.match(
|
|
186
185
|
/SurfaceOrientation:\s*(\d)/
|
|
187
186
|
);
|
|
188
|
-
|
|
187
|
+
if (!orientationMatch) {
|
|
188
|
+
throw new Error("Failed to get orientation from input");
|
|
189
|
+
}
|
|
190
|
+
orientation = Number(orientationMatch[1]);
|
|
189
191
|
debugPage(`Screen orientation: ${orientation}`);
|
|
190
192
|
} catch (e) {
|
|
191
|
-
debugPage("Failed to get orientation,
|
|
193
|
+
debugPage("Failed to get orientation from input, try display");
|
|
194
|
+
try {
|
|
195
|
+
const orientationStdout = await adb.shell(
|
|
196
|
+
"dumpsys display | grep mCurrentOrientation"
|
|
197
|
+
);
|
|
198
|
+
const orientationMatch = orientationStdout.match(
|
|
199
|
+
/mCurrentOrientation=(\d)/
|
|
200
|
+
);
|
|
201
|
+
if (!orientationMatch) {
|
|
202
|
+
throw new Error("Failed to get orientation from display");
|
|
203
|
+
}
|
|
204
|
+
orientation = Number(orientationMatch[1]);
|
|
205
|
+
debugPage(`Screen orientation (fallback): ${orientation}`);
|
|
206
|
+
} catch (e2) {
|
|
207
|
+
orientation = 0;
|
|
208
|
+
debugPage("Failed to get orientation from display, default to 0");
|
|
209
|
+
}
|
|
192
210
|
}
|
|
193
211
|
if (size.override || size.physical) {
|
|
194
212
|
return { ...size, orientation };
|
|
@@ -196,9 +214,6 @@ ${Object.keys(size).filter((key) => size[key]).map(
|
|
|
196
214
|
throw new Error(`Failed to get screen size, output: ${stdout}`);
|
|
197
215
|
}
|
|
198
216
|
async size() {
|
|
199
|
-
if (this.screenSize) {
|
|
200
|
-
return this.screenSize;
|
|
201
|
-
}
|
|
202
217
|
const adb = await this.getAdb();
|
|
203
218
|
const screenSize = await this.getScreenSize();
|
|
204
219
|
const match = (screenSize.override || screenSize.physical).match(
|
|
@@ -216,12 +231,11 @@ ${Object.keys(size).filter((key) => size[key]).map(
|
|
|
216
231
|
width,
|
|
217
232
|
height
|
|
218
233
|
);
|
|
219
|
-
|
|
234
|
+
return {
|
|
220
235
|
width: logicalWidth,
|
|
221
236
|
height: logicalHeight,
|
|
222
237
|
dpr: this.devicePixelRatio
|
|
223
238
|
};
|
|
224
|
-
return this.screenSize;
|
|
225
239
|
}
|
|
226
240
|
adjustCoordinates(x, y) {
|
|
227
241
|
const ratio = this.devicePixelRatio;
|
|
@@ -533,7 +547,6 @@ ${Object.keys(size).filter((key) => size[key]).map(
|
|
|
533
547
|
console.error("Error during cleanup:", error);
|
|
534
548
|
}
|
|
535
549
|
this.connectingAdb = null;
|
|
536
|
-
this.screenSize = null;
|
|
537
550
|
this.yadbPushed = false;
|
|
538
551
|
}
|
|
539
552
|
async back() {
|
package/dist/lib/index.d.ts
CHANGED
package/dist/lib/index.js
CHANGED
|
@@ -56,7 +56,6 @@ var defaultNormalScrollDuration = 1e3;
|
|
|
56
56
|
var debugPage = (0, import_logger.getDebug)("android:device");
|
|
57
57
|
var AndroidDevice = class {
|
|
58
58
|
constructor(deviceId, options) {
|
|
59
|
-
this.screenSize = null;
|
|
60
59
|
this.yadbPushed = false;
|
|
61
60
|
this.devicePixelRatio = 1;
|
|
62
61
|
this.adb = null;
|
|
@@ -220,10 +219,29 @@ ${Object.keys(size).filter((key) => size[key]).map(
|
|
|
220
219
|
const orientationMatch = orientationStdout.match(
|
|
221
220
|
/SurfaceOrientation:\s*(\d)/
|
|
222
221
|
);
|
|
223
|
-
|
|
222
|
+
if (!orientationMatch) {
|
|
223
|
+
throw new Error("Failed to get orientation from input");
|
|
224
|
+
}
|
|
225
|
+
orientation = Number(orientationMatch[1]);
|
|
224
226
|
debugPage(`Screen orientation: ${orientation}`);
|
|
225
227
|
} catch (e) {
|
|
226
|
-
debugPage("Failed to get orientation,
|
|
228
|
+
debugPage("Failed to get orientation from input, try display");
|
|
229
|
+
try {
|
|
230
|
+
const orientationStdout = await adb.shell(
|
|
231
|
+
"dumpsys display | grep mCurrentOrientation"
|
|
232
|
+
);
|
|
233
|
+
const orientationMatch = orientationStdout.match(
|
|
234
|
+
/mCurrentOrientation=(\d)/
|
|
235
|
+
);
|
|
236
|
+
if (!orientationMatch) {
|
|
237
|
+
throw new Error("Failed to get orientation from display");
|
|
238
|
+
}
|
|
239
|
+
orientation = Number(orientationMatch[1]);
|
|
240
|
+
debugPage(`Screen orientation (fallback): ${orientation}`);
|
|
241
|
+
} catch (e2) {
|
|
242
|
+
orientation = 0;
|
|
243
|
+
debugPage("Failed to get orientation from display, default to 0");
|
|
244
|
+
}
|
|
227
245
|
}
|
|
228
246
|
if (size.override || size.physical) {
|
|
229
247
|
return { ...size, orientation };
|
|
@@ -231,9 +249,6 @@ ${Object.keys(size).filter((key) => size[key]).map(
|
|
|
231
249
|
throw new Error(`Failed to get screen size, output: ${stdout}`);
|
|
232
250
|
}
|
|
233
251
|
async size() {
|
|
234
|
-
if (this.screenSize) {
|
|
235
|
-
return this.screenSize;
|
|
236
|
-
}
|
|
237
252
|
const adb = await this.getAdb();
|
|
238
253
|
const screenSize = await this.getScreenSize();
|
|
239
254
|
const match = (screenSize.override || screenSize.physical).match(
|
|
@@ -251,12 +266,11 @@ ${Object.keys(size).filter((key) => size[key]).map(
|
|
|
251
266
|
width,
|
|
252
267
|
height
|
|
253
268
|
);
|
|
254
|
-
|
|
269
|
+
return {
|
|
255
270
|
width: logicalWidth,
|
|
256
271
|
height: logicalHeight,
|
|
257
272
|
dpr: this.devicePixelRatio
|
|
258
273
|
};
|
|
259
|
-
return this.screenSize;
|
|
260
274
|
}
|
|
261
275
|
adjustCoordinates(x, y) {
|
|
262
276
|
const ratio = this.devicePixelRatio;
|
|
@@ -568,7 +582,6 @@ ${Object.keys(size).filter((key) => size[key]).map(
|
|
|
568
582
|
console.error("Error during cleanup:", error);
|
|
569
583
|
}
|
|
570
584
|
this.connectingAdb = null;
|
|
571
|
-
this.screenSize = null;
|
|
572
585
|
this.yadbPushed = false;
|
|
573
586
|
}
|
|
574
587
|
async back() {
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/android",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"description": "Android automation library for Midscene",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Android UI automation",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"appium-adb": "12.12.1",
|
|
27
|
-
"@midscene/core": "0.23.
|
|
28
|
-
"@midscene/
|
|
29
|
-
"@midscene/
|
|
27
|
+
"@midscene/core": "0.23.1",
|
|
28
|
+
"@midscene/web": "0.23.1",
|
|
29
|
+
"@midscene/shared": "0.23.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@modern-js/module-tools": "2.60.6",
|