Office Hours — Today, June 5

Thursday, June 1

Mark M.
has entered the room
Mark M.
turned on guest access
Jun 5
3:55 PM
Dimitris K.
has entered the room
Dimitris K.
Greetings from Germany Mark!
Mark M.
hello, Dimitris!
how can I help you today?
(or tonight, in your case)
Dimitris K.
I am a huge fan and this is the first time I really need your help and the book is not enough to guide me through!
So I would like to know if somehow its possible to load any website on a webview and get the focused text elements that the user focuses and paste some data inside.
Mark M.
I assume that there are some JavaScript events for focus change
but I am not aware of a way to get it purely from Java
Dimitris K.
Just to point the use case. There is a strange tablet with a laser barcode scanner pre installed and I get the scanned data through a USB port
I need to paste the data
inside textfields on a website
Mark M.
it is at least theoretically possible to use evaluateJavascript() (or the older loadUrl()) to inject some JavaScript that hooks those focus-change events, passing the information along to your Java code via some object injected via addJavascriptInterface()
I don't know how easy it is to identify and hook up listeners for all focusable elements, as I'm not a DOM/JavaScript expert
but I would attack the problem that way, looking to see how to accomplish your aims via injected JavaScript
Dimitris K.
I'm really not into web and I kinda hate javascript but from what I found it guest ok if you are willing to set up methods on the website first
4:00 PM
Dimitris K.
but I need a solution that should work with any website
Mark M.
Dimitris K.
So maybe my first thought should be the real solution and that was to use a custom keyboard implementation that pastes from the port (if data is coming)
Mark M.
a custom IME is a possibility -- I have heard of people doing that
Dimitris K.
I though maybe the Anysoftkeyboard open source project could be used for that
but somehow (on windows) I cant build the project
Mark M.
the challenge there is either switching over to that IME when needed or having a dual-purpose IME (normal text entry plus data from the scanner)
Dimitris K.
(issues with native code)
I was considering to map a special character for the paste
Mark M.
I have not written a custom IME, and so I do not know all of the tricks you might need there
Dimitris K.
Is there any alternative to the Anysoftkeyboard that doesnt really need native code to be compiled ?
Mark M.
um, I seem to recall the Hacker's Keyboard was open source
I see a few others on F-Droid (after the loooooooooooooong list of AnySoftKeyboard language-specific apps)
4:05 PM
Mark M.
AFAIK there is nothing intrinsic to writing an IME that requires NDK code
Dimitris K.
nice suggestion I will try that one as well, it does have some native code but looks a bit more structured so probably I will be able to make it run
Mark M.
back on the JavaScript front, it seems relatively easy to find the element with the focus: https://stackoverflow.com/a/497108/115145
Dimitris K.
they use native for dictionaries
Mark M.
ah, OK
Dimitris K.
I tried that but it kinda didnt work
maybe I just didnt implement it properly though
everything is a bit mysterious when it comes to the webview :P
View paste
String scriptSrc = "(function() { return document.activeElement;})();";

				wv.requestFocus(View.FOCUS_DOWN);
				wv.evaluateJavascript(scriptSrc, new ValueCallback<String>() {
					@Override
					public void onReceiveValue(String value) {
						Log.e(TAG, "onReceiveValue: WOWOWOWOWOW "+ value );
					}
				});
I kinda imagine that this should be the expected call
Mark M.
I don't know that returning something will be useful
I would have the scriptSrc actually put the text into the DOM element
Dimitris K.
hmm should I be able to somehow get a callback that something is focused ?
(maybe not since there is nothing defined for that on the websites side)
Mark M.
oh, if that is what you were aiming for, I suppose that could work
did you not get a value back, or was the value unintelligible, or what was the specific issue with this code?
Dimitris K.
well I need to paste the data inside the element but first I need to know when to trigger that action
4:10 PM
Dimitris K.
I got null
Mark M.
and something definitely had the focus then?
I haven't tried requestFocus() with WebView
Dimitris K.
well there are many posts suggesting that it works
but sadly everyone used local html websites
Mark M.
they key is whether it works for the specific version of Android you are running -- what's on the tablet?
Dimitris K.
so there was no post about doing such on a real website that you dont really have access to
4.4
Mark M.
I would not expect the behavior of requestFocus() to vary based on where the HTML is coming from, though it might vary by version of Android
when you looked at the WebView after executing that code snippet, did something visually have the focus?
Dimitris K.
hmm I think the version should be ok
by default the webview focuses the 1st focusable element
Mark M.
it may also be a synchronization issue
Dimitris K.
wv.setWebChromeClient(new CustomWebChromeClient());
View paste
private final class CustomWebChromeClient
			extends WebChromeClient {
		@Override
		public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
			Log.e("TestExamples", "JS Alert :: " + message);
			return false;
		}
	}
maybe I should also use something like that
Mark M.
for debugging purposes, it might be useful, though console.log statements should go to LogCat
4:15 PM
Dimitris K.
so I can get a response each time something happens (currently I only got data on onPageFinished)
Mark M.
back on the synchronization point, requestFocus() might get queued and wind up occurring after your evaluateJavascript() or something
Dimitris K.
that would actually be an issue
:/
Mark M.
you might poke around JavaScript, see what the equivalent code is to set the focus, and try embedding that in with the rest of your JavaScript
and see if that changes anything
Dimitris K.
I guess I need to experiment a bit more with that
do you still think thats a better option than the keyboard ?
Mark M.
how much control do you have over the tablet?
do you have to worry about people switching to this IME, or switching away from it?
Dimitris K.
no thats not an issue
Mark M.
do you have i18n concerns? how many character sets would the keyboard need to support?
Dimitris K.
there wont be more than 10 tablets and the people using them just want to optimize the efficiency
it should be a basic french supporting keyboard
Mark M.
oh, OK, that's smaller than I was envisioning :-)
Dimitris K.
yeah its small
Mark M.
the advantage of the IME is that it could work for things other than the WebView
it's a more general-purpose solution
Dimitris K.
(really small for the trouble it is giving me :P)
Mark M.
but, as I noted, I haven't messed with writing one, so I have no idea how easy or hard it will be to add in your logic
Dimitris K.
they do have a past functionality built it so I should be able to use that in a custom way (I guess)
paste*
built in*
4:20 PM
Mark M.
BTW, this looks to be the code for setting the focus from JavaScript: https://stackoverflow.com/q/277544/115145
yannie
has entered the room
yannie
Hi mark
Mark M.
Dimitris: let me take a question from yannie, and I will be back with you in a bit
yannie: hi! how can I help you today?
yannie
Having some issues with Espresso, it's not seeing views that I can see on the app
any suggestions on how to debug that
Mark M.
what do you mean by "not seeing views"?
yannie
submit button for example
I can see it, and it's active
but espresso throws an error saying it's not present
could be a sync issue?
idling issue?
Mark M.
I have no idea
so, onView(withId(...)) is throwing an exception?
yannie
sometimes, other times the test goes OK
Mark M.
or how are you identifying the button?
yannie
id
Mark M.
OK, I can see why you might think it's a sync issue, as "it's a timing thing" certainly leads in that direction...
is there anything unusual about when/how the button is added to the UI?
(e.g., you are adding it via addView() based on some work that is being done)
yannie
it waits for a download
so it could be the idlingResource?
Mark M.
possibly, perhaps the IdlingResource is yielding too soon
4:25 PM
Mark M.
I'm not a deep Espresso user, so I will have difficulty giving you specific advice
yannie
ok, but I'm on the right track debugging that?
the_new_mr
has entered the room
yannie
would that be your thought process?
Mark M.
it's certainly worth an experiment
yannie
ok
thanks
one last thing
Mark M.
for example, if there is another widget that has similar characteristics to the submit button vis a vis timing, you might check to see if it too results in the same error
yannie
when are the "mini books" coming out?
Mark M.
View paste
(the_new_mr: hi! I will be with you shortly!)
yannie
ok
Mark M.
I have some stuff coming out later this month (I hope -- waiting on a third party) and July
yannie
cool
Mark M.
so, stay tuned!
yannie
thanks
the_new_mr
ok. thanks
Mark M.
yannie: let me take questions from the others, and I will back with you in a bit
the_new_mr: your turn! do you have a question?
yannie
ok
the_new_mr
hi Mark
how's things?
Mark M.
um, Things are on Developer Preview 4
:-)
the_new_mr
lol
ah man... cheesy... that's the way i like my jokes :)
yannie
has left the room
the_new_mr
speaking of things, i sold my vacuum cleaner the other day... well, it was only gathering dust
aaaaanyway.... to my question....
Dimitris K.
nice one
Mark M.
neither of us should quit our day jobs
the_new_mr
lol
4:30 PM
the_new_mr
there's a guy who makes a living out of this. Tim Vine. check him out
4:30 PM
the_new_mr
that's one of his jokes
so.... i have a general question that has a specific element
i'll start with the general question
if something is deprecated and will be removed, what is it that will put one in a situation where it is actually deprecated?
compile sdk version? target sdk? or the sdk of the device?
or rather, actually removed. not just deprecated
Mark M.
are you referring to items in the Android SDK that are deprecated?
the_new_mr
yes
Mark M.
they are almost never removed
at least, in terms of core classes
stuff gets removed from the Support Libraries, under the premise that if you need it, don't upgrade the library
the_new_mr
wyeah
here's the specific question...
View paste
here:
https://android-developers.googleblog.com/2016/06/security-crypto-provider-deprecated-in.html
Mark M.
deprecated things in the core SDK usually stick around, perhaps with reduced functionality, to ensure binary compatibility
the_new_mr
they say they are "deprecating the implementation of the SHA1PRNG algorithm and the Crypto provider altogether"
Mark M.
that's something that they *could* remove, as it did not break any true compile-time contract
yes, and this SO post suggests that it is truly gone: https://stackoverflow.com/q/36813098/115145
the_new_mr
there's a warning message that appears in logcat that says you should "not rely on it being available in the future" (or something like that)
4:35 PM
Mark M.
I'll take your word for that
but I would get off of that provider ASAP
and I would test your code on Android O even more ASAP-ly
the_new_mr
yeah. we don't want to use it
honestly, i don't
i wanted to move but business etc etc
plus the app is being sunset soon
thing is, if we don't change our compile sdk version or target sdk version, do we still get affected?
Mark M.
as was mentioned in the SO question that I linked to, you can always copy that provider into your app
probably
the_new_mr
true
might do that
Mark M.
they're being somewhat cagey on that point
the_new_mr
well, that's my question
when they remove it, is it gone off of the device or off of the sdk we're using?
Mark M.
the device
the_new_mr
the sdk we're compiling against?
the device?
Mark M.
yes
the_new_mr
ok. that's a major OMG momwn
moment
Mark M.
it's not strictly in the SDK
the SDK has the javax.crypto classes
and they aren't going away
but SPIs are not compile-time contracts
they're just strings (e.g., "Crypto")
the_new_mr
ok. quite scary. so basically, someone may get an OS update and boom, it's gone!
Mark M.
yes
now, it is possible that they might have some targetSdkVersion check in there
the_new_mr
ok. mega ouch. thanks for that. that's basically all i needed to know
Mark M.
so they would still return it for targetSdkVersion less than such-and-so
the_new_mr
yeah. but then who knows?!
Mark M.
agreed
the_new_mr
ok. good to know. thanks
Mark M.
particularly with security things like this, they tend to take a harder line
the_new_mr
yeah, can't blame them on that really
Mark M.
but, test on Android O
4:40 PM
the_new_mr
ok. we're probably in trouble then. thanks for your help!
yeah, we did
Mark M.
you're welcome!
the_new_mr
but i must test this functionality..
and see if the key is being generated differently
Mark M.
let me switch back to Dmitris, and I'll return to you shortly
Dmitris: your turn! do you have another question?
Dimitris K.
Well I guess I need to experiment first with all the things we talked about
the_new_mr
well, i think i'm okay with that. thanks Mark as always
Dimitris K.
but you will hear from me often since on my main job im in a huge project alone ^^
Mark M.
if nothing else, Thursday's chat is in a more Germany-friendly time slot :-)
the_new_mr
has left the room
Dimitris K.
I will be back with more ! ^^ thank you for your time! Btw for more personalized private solutions I can send you a mail for business inquires right ?
Mark M.
yes, private consulting/training is certainly an option
Dimitris K.
Do you have any experience with device owner apps
Mark M.
nope
Dimitris K.
apps that should run as system apps
Mark M.
I know the general device owner concept, but I have not tried setting it up
4:45 PM
Dimitris K.
I'm gonna have to make an updater tool that will control a "visual" app makes sure every thing is fluid and be able to update both itself and the "visual"
all of that in a custom kiosk mode
Mark M.
most of that is outside my area of expertise
Dimitris K.
so I guess some consulting might be needed
If I manage to make it run as smooth as needed I will inform you on the process
its an interesting point for digital signage
Mark M.
yes, there are plenty of semi-embedded Android solutions using that sort of stuff
Dimitris K.
all devices there are custom and rooted
Mark M.
though, I suspect that long-term, more will move to Android Things
Dimitris K.
your chapter on controlling the second device saved me
second screen *
the_new_mr
has entered the room
the_new_mr
hi Mark
Mark M.
yes, that's an under-utilized part of the SDK, IMHO
the_new_mr
quick follow up when you're ready there
Dimitris K.
so thats all for today, thanks again!!
Enjoy the rest of your day
Mark M.
Dimitris: you're welcome!
the_new_mr: go right ahead!
Dimitris K.
has left the room
4:50 PM
the_new_mr
ok... just realised there's something at the bottom of that blog post
Note 1: as a temporary measure to keep apps working, we decided to still create the instance for apps targeting SDK version 23, the SDK version for Marshmallow, or less. Please don't rely on the presence of the Crypto provider in the Android SDK, our plan is to delete it completely in the future.
from that, looks like targeting 22 should be grand
Mark M.
um...
I'd be more worried about the "our plan is to delete it completely in the future" part
the_new_mr
so like... do you think we're okay till we sunset?
Mark M.
as "the future" could be Android O, for all I know
the_new_mr
yeah
that's the bit that could be open to intepretation
Mark M.
when is the app slated to sunset?
the_new_mr
that's the thing.....
it was supposed to be july and now they're saying september!!!
damn business!
Mark M.
of 2017 or 2018?
the_new_mr
they should have listened to me before!
2017
next time i'll know to insist
i'll put it down to experience
anyway...
this is the pickle we're in
Mark M.
and is this a hard sunset (i.e., the app isn't supposed to work anymore), or does it just mean that you're no longer supporting it?
the_new_mr
well, bit of both
as they're transitioning users over to another app
Mark M.
ah
the_new_mr
God knows how its doing its encryption
i must actually check with them!
Mark M.
well, in the 2017-to-early-2018 timeframe, there is Android O and a possible O MR1
the_new_mr
yeah i know!
that's the worrying part!
Mark M.
I would be somewhat surprised if they deleted Crypto in an MR1 release
the_new_mr
massive race against time
you would hope so!
4:55 PM
Mark M.
and, of course, the rollout of O/O MR1 will be glacial as usual
the_new_mr
i must do some testing tomorrow on n and o
no doubt
Mark M.
so if your stuff works on O, you're probably OK
the_new_mr
what do you mean exactly by glacial?
Mark M.
I don't know if "probably" is sufficient for your situation, though
well, Android 7.x is only at about 5% of the device ecosystem now
the_new_mr
yeah. this is the thing....
yeah. but there can be a sky is falling situation
0.1% of our users and the business freaks out
don't blame them for that either tbh
so.... IF we were to bring it into our codebase as a safety measure...
what exactly should we do?
Mark M.
the_new_mr
just bring in the whole security package?
Mark M.
just the classes that you need
as you will need to refactor them into some other package
the_new_mr
ok
Mark M.
I have no idea how far down the rabbit hole goes with that code, but my guess is that it won't be too many classes
the_new_mr
trial and error i suppose
here's hoping anyway!
Mark M.
then, as that answer points out, directly use your local copy, vs. doing the string-based provider lookup
the_new_mr
looks like i have an adventure in wonderland coming up!
yeah
one last question....
do manufacturers remove stuff themselves? i'm wondering if samsung have removed the crypto provider when google haven't yet
and is there some way to see the changelog for manufacturers OS updates?
Mark M.
I can't rule it out, but their tendency is to add things, more than remove them
the_new_mr
yeah
5:00 PM
Mark M.
and I don't even know if manufacturers *have* a changelog, let alone if others can access it
the_new_mr
was just thinking maybe samsung or whoever would be like "this is insecure. rip it out"
Mark M.
they tend to let sleeping dogs lie
the_new_mr
oh dear =/ would hope they do
ok. thanks for all your help as always man
Mark M.
happy to be useful!
and that's a wrap for today's chat
next one is tomorrow at 7:30pm US Eastern
the_new_mr
thanks. bye!
the_new_mr
has left the room
Mark M.
turned off guest access

Thursday, June 1

 

Office Hours

People in this transcript

  • Dimitris Kirakosian
  • Mark Murphy
  • the_new_mr
  • yannie