【问题标题】:AccessibilityService: Is possible draw password on remote smartphone screen with mouse?AccessibilityService:是否可以用鼠标在远程智能手机屏幕上绘制密码?
【发布时间】:2019-02-07 08:39:30
【问题描述】:

我正在从事类似于Team View QuickSupport 的项目,我想知道AccessibilityService 是否允许在能够绘制保护设备密码的远程屏幕上执行滑动?

我来尝试以下代码,但没有成功。到现在为止,发生的一切都是 android 代码上的一个异常,它说:

java.lang.IllegalStateException: 试图为手势添加太多笔触

这里:

gestureBuilder.addStroke(new GestureDescription.StrokeDescription(path, 0, time));

当前的Java代码是这样的:

    if (xline.contains("mouseswipescreen")) {

     String coords = xline.replace("mouseswipescreen", "");

     String[] tokens = coords.split(Pattern.quote("<|>"));

               float x = parseFloat(tokens[0]);
               float y = parseFloat(tokens[1]);
               String cmd = tokens[2];

     MyAccessibility.instance.Swipte((int) x, (int) y, 50, cmd);
 }

GestureDescription.Builder gestureBuilder;
Path path;

public void Swipte(int x, int y, int time, String command) {

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
        System.out.println(" ======= Swipte =======");

        if (command.equalsIgnoreCase("start")) {

            gestureBuilder = new GestureDescription.Builder();
            path = new Path();

            path.moveTo(x, y);

        } else if (command.equalsIgnoreCase("move")) {

            path.lineTo(x, y);
            gestureBuilder.addStroke(new GestureDescription.StrokeDescription(path, 0, time));

        } else if (command.equalsIgnoreCase("dispatch")) {

            dispatchGesture(gestureBuilder.build(), new GestureResultCallback() {
                @Override
                public void onCompleted(GestureDescription gestureDescription) {
                    System.out.println("SWIPTE Gesture Completed :D");
                    super.onCompleted(gestureDescription);
                }
            }, null);
        }
    }

}

现在更改此代码以执行保持这种方式的滑动屏幕:

public void Swipte(int x1, int y1, int x2, int y2, int time){

        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {

            System.out.println(" ======= Swipte =======");

            GestureDescription.Builder gestureBuilder = new GestureDescription.Builder();
            Path path = new Path();
            path.moveTo(x1,y1); // "mousedown"
            path.lineTo(x2,y2); // until last position found in "mousemove"

            gestureBuilder.addStroke(new GestureDescription.StrokeDescription(path, 0, time));
            dispatchGesture(gestureBuilder.build(), new GestureResultCallback() {
                @Override
                public void onCompleted(GestureDescription gestureDescription) {
                    System.out.println("SWIPTE Gesture Completed :D");
                    super.onCompleted(gestureDescription);
                }
            }, null);
        }

    }

结果是这样的:

看到是输入了错误的密码。

最后遵循基于上述第一个 Java 代码发送坐标 (reference) 的代码 (Delphi):

 private
    { Private declarations }
    fDown: Boolean;
    fPO: TPoint;
  public
    { Public declarations }
  end;

  ...

procedure TForm2.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  Index, XTouch, YTouch, RXCoord, RYCoord: Integer;
  List: TStrings;
  RScreen, Start: String;
begin
  Index := Form1.ListView1.ItemIndex;
  if Index = -1 then
    Exit;

    List := TStringList.Create;
    RScreen := Form1.ListView1.Selected.SubItems[6]; // Remote screen resolution

    try
      ExtractStrings(['x'], [], PChar(RScreen), List); // Ex: my smartphone is 1920x1080
      RYCoord := StrToInt(List[0]);                    // 1920 (height)
      RXCoord := StrToInt(List[1]);                    // 1080 (width)
    finally
      List.Free;
    end;

    XTouch := Round((X / Image1.Width) * RXCoord);
    YTouch := Round((Y / Image1.Height) * RYCoord);

    fPO := Point(XTouch, YTouch);
    Start := 'start';
    fDown := true;

    Form1.ServerSocket1.Socket.Connections[Index].SendText(format('mouseswipescreen%d<|>%d<|>%s'#13#10, [fPO.X, fPO.Y, Start]));

  end;
end;

procedure TForm2.Image1MouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
var
  Index, XTouch, YTouch, RXCoord, RYCoord: Integer;
  List: TStrings;
  RScreen, Move: String;
begin

  Index := Form1.ListView1.ItemIndex;
  if Index = -1 then
    Exit;

  List := TStringList.Create;
  RScreen := Form1.ListView1.Selected.SubItems[6]; // Remote screen resolution

  try
    ExtractStrings(['x'], [], PChar(RScreen), List); // Ex: my smartphone is 1920x1080
    RYCoord := StrToInt(List[0]);                    // 1920 (height)
    RXCoord := StrToInt(List[1]);                    // 1080 (width)
  finally
    List.Free;
  end;

  XTouch := Round((X / Image1.Width) * RXCoord);
  YTouch := Round((Y / Image1.Height) * RYCoord);

  if fDown then
  begin

    Move := 'move';

    Form1.ServerSocket1.Socket.Connections[Index].SendText(format('mouseswipescreen%d<|>%d<|>%s'#13#10, [fPO.X, fPO.Y, Move]));

    fPO := Point(XTouch, YTouch);

  end;

end;

procedure TForm2.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if fDown then
    fDown := false;
end;

【问题讨论】:

    标签: android delphi coordinates accessibilityservice android-accessibility


    【解决方案1】:

    好的,我回答了我自己的问题,AccessibilityService 的专家已经认为我正在构建恶意软件,而不是帮助这类人。


    回答:

    我上面的方法是正确的,不幸的是直到这一刻才看到,使用AccessibilityService 是不可能实现这个目标的,因为存在limitation on storage of gestureshere 是官方参考:

    addStroke(new GestureDescription.StrokeDescription(path, 0, time));
    

    而且,直到现在(在这种情况下)AccessibilityService 还不能在某些点(构成密码的 9 个点)执行“只按下而不是松开”的触摸手势屏幕)当执行并发送 2 次快速鼠标点击时:

    procedure TForm2.Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    

    在开始之前和绘制密码期间(拖动鼠标),只有在完全绘制密码并且:

    procedure TForm2.Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    

    被发送到远程设备。


    编辑:

    注意: Team View QuickSupport 能够做到这一点,因为使用了code of root gave to he by several vendors

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多