Skip to content

add clipboard api - #69

Merged
KazuCocoa merged 7 commits into
appium:masterfrom
KazuCocoa:add_clipbord
Mar 30, 2018
Merged

add clipboard api#69
KazuCocoa merged 7 commits into
appium:masterfrom
KazuCocoa:add_clipbord

Conversation

@KazuCocoa

@KazuCocoa KazuCocoa commented Mar 28, 2018

Copy link
Copy Markdown
Member

https://github.com/appium/appium-base-driver/pull/199/files

TODO

  • For Android
  • For iOS
  • Append func test
    • And make sure they work
      • iOS
      • Android
  • Add docstring
  • Update CHANGELOG

note: for android

java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
  at android.os.Handler.<init>(Handler.java:209)
  at android.os.Handler.<init>(Handler.java:123)
  at android.content.ClipboardManager$2.<init>(ClipboardManager.java:69)
  at android.content.ClipboardManager.<init>(ClipboardManager.java:69)
  at android.app.SystemServiceRegistry$12.createService(SystemServiceRegistry.java:276)
  at android.app.SystemServiceRegistry$12.createService(SystemServiceRegistry.java:275)
  at android.app.SystemServiceRegistry$CachedServiceFetcher.getService(SystemServiceRegistry.java:884)
  at android.app.SystemServiceRegistry.getSystemService(SystemServiceRegistry.java:837)
  at android.app.ContextImpl.getSystemService(ContextImpl.java:1370)
  at io.appium.uiautomator2.utils.ClipboardHelper.getManager(ClipboardHelper.java:37)
  at io.appium.uiautomator2.utils.ClipboardHelper.getTextData(ClipboardHelper.java:45)
  at io.appium.uiautomator2.handler.GetClipboard.safeHandle(GetClipboard.java:61)
  at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:56)
  at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:238)
  at io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:229)
  at io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:44)
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
  at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
  at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
  at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
  at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)
  at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
  at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
  at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
  at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
  at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
  at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
  at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
  at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
  at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:611)
  at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:514)
  at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:468)
  at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)
  at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
  at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.jav

note: for iOS

  • Work with the latest WDA (Appium fork)

Comment thread lib/appium_lib_core/common/device.rb Outdated
end

def add_clipboard
add_endpoint_method(:get_clipboard) do

@mykola-mokhnach mykola-mokhnach Mar 28, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather have separate set of methods for Android and iOS

android only can get/set string content, so there will be methods like set_clipboard_text and get_clipboard_text
in iOS one could also add set_clipboard_image/get_clipboard_image and get/set_clipboard_url

all methods should perform base64 to string encoding/decoding automatically.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I see. 👍
I haven't stepped into details yet.

thanks!

Comment thread lib/appium_lib_core/android/device.rb Outdated
#
# @example
#
# @driver.get_performance_data package_name: package_name, data_type: data_type, data_read_timeout: 2

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copypaste?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup 😅

@KazuCocoa

Copy link
Copy Markdown
Member Author

When I tried to clipbord for uia2, I faced Can't create handler inside thread that has not called Looper.prepare(). The reason is the process work on which thread. I'll continue to work the issue.

Otherwise, I'll merge this PR since the client-side works well.

@KazuCocoa KazuCocoa changed the title [WIP]add clipboard api add clipboard api Mar 30, 2018
@KazuCocoa

Copy link
Copy Markdown
Member Author

I've fixed the android issue and I've confirmed the ruby client works fine. merge.

@KazuCocoa
KazuCocoa merged commit 993840a into appium:master Mar 30, 2018
@KazuCocoa
KazuCocoa deleted the add_clipbord branch March 30, 2018 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants