1- /**
1+ /*
22 * Copyright (c) Microsoft Corporation.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
1616
1717package com .microsoft .playwright .androiddriver ;
1818
19- import android .bluetooth .BluetoothClass ;
2019import android .graphics .Point ;
2120import android .graphics .Rect ;
2221import android .net .LocalServerSocket ;
2322import android .net .LocalSocket ;
24- import android .os .Bundle ;
2523import android .view .accessibility .AccessibilityNodeInfo ;
2624
2725import androidx .test .ext .junit .runners .AndroidJUnit4 ;
3230import androidx .test .uiautomator .Direction ;
3331import androidx .test .uiautomator .UiDevice ;
3432import androidx .test .uiautomator .UiObject2 ;
35- import androidx .test .uiautomator .UiSelector ;
3633import androidx .test .uiautomator .Until ;
3734
3835import org .json .JSONArray ;
4845import java .lang .reflect .InvocationTargetException ;
4946import java .lang .reflect .Method ;
5047import java .nio .charset .StandardCharsets ;
51- import java .util .ArrayList ;
5248import java .util .regex .Pattern ;
5349
5450/**
6056@ SdkSuppress (minSdkVersion = 21 )
6157public class InstrumentedTest {
6258
59+ @ SuppressWarnings ("ConstantConditions" )
6360 private static BySelector parseSelector (JSONObject param ) throws JSONException {
6461 JSONObject selector = param .getJSONObject ("selector" );
6562 BySelector result = null ;
6663 if (selector .has ("checkable" )) {
6764 boolean value = selector .getBoolean ("checkable" );
68- result = result != null ? result .checkable (value ) : By .checkable (value );
65+ result = result != null ? result .checked (value ) : By .checkable (value );
6966 }
7067 if (selector .has ("checked" )) {
7168 boolean value = selector .getBoolean ("checked" );
@@ -146,7 +143,7 @@ private static int parseTimeout(JSONObject params) throws JSONException {
146143
147144 private static Point parsePoint (JSONObject params , String propertyName ) throws JSONException {
148145 JSONObject point = params .getJSONObject (propertyName );
149- return new Point (params .getInt ("x" ), params .getInt ("y" ));
146+ return new Point (point .getInt ("x" ), point .getInt ("y" ));
150147 }
151148
152149 private static Direction parseDirection (JSONObject params ) throws JSONException {
@@ -313,6 +310,7 @@ private static AccessibilityNodeInfo getRootA11yNode(UiDevice device) {
313310 getQueryController .setAccessible (true );
314311 Object queryController = getQueryController .invoke (device );
315312
313+ assert queryController != null ;
316314 Method getRootNode = queryController .getClass ().getDeclaredMethod ("getRootNode" );
317315 getRootNode .setAccessible (true );
318316 return (AccessibilityNodeInfo ) getRootNode .invoke (queryController );
@@ -343,6 +341,7 @@ public void main() {
343341 DataInputStream dis = new DataInputStream (is );
344342 DataOutputStream dos = new DataOutputStream (socket .getOutputStream ());
345343
344+ //noinspection InfiniteLoopStatement
346345 while (true ) {
347346 int id = 0 ;
348347 String method = null ;
@@ -356,7 +355,7 @@ public void main() {
356355 id = message .getInt ("id" );
357356 method = message .getString ("method" );
358357 params = message .getJSONObject ("params" );
359- } catch (JSONException e ) {
358+ } catch (JSONException ignored ) {
360359 }
361360 if (method == null )
362361 continue ;
@@ -365,6 +364,7 @@ public void main() {
365364 response .put ("id" , id );
366365 response .put ("result" , params );
367366 try {
367+ assert params != null ;
368368 switch (method ) {
369369 case "wait" :
370370 wait (device , params );
0 commit comments