Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add finger print command to android Driver #473

Merged
merged 1 commit into from Dec 18, 2017

Conversation

alizelzele
Copy link
Contributor

@alizelzele alizelzele commented Sep 18, 2016

Change list

added finger print function to android driver. defined the command url and helper method, and created an Action shortcut to use it.

Types of changes

What types of changes are you proposing/introducing to Java client?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Details

it is a simple function to activate emulators fingerprint sensor. the command is like driver.fingerPrint(x) where x is the finger number (1 to 10). this command is created based on add finger print to route

@saikrishna321
Copy link
Member

@alizelzele can you please add tests?

@TikhomirovSergey
Copy link
Contributor

@saikrishna321 +1
@alizelzele Could you add some tests?

@saikrishna321
Copy link
Member

@TikhomirovSergey @alizelzele what is the use-case for this PR?

@TikhomirovSergey
Copy link
Contributor

@saikrishna321 This is why I'm asking for tests.

@alizelzele
Copy link
Contributor Author

@saikrishna321 @TikhomirovSergey since android 6.0 there is a finger print sensor installed on some devices for security + some applications already started supporting fingerprint instead of their login method.

I am a bit busy now, will try to add test for it ASAP.
Test should activate fingerprint security in the setting, and disable security after that, since if it stays there, all other tests will fail (with default appium setting, which does not wipe the data on session start)

Copy link
Member

@SrinivasanTarget SrinivasanTarget left a comment

Choose a reason for hiding this comment

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

By Saying fingerprintID,
Are you sure it is finger number from 1 to 10? If so how can a device or a emulator knows finger 1 to 10 prints of owner?
AFIK it should be the saved fingerprint's (counts) on your device/emulator to access it in security settings.Also i don't think any device that supports 10 prints to be stored. Please update enough information in this PR or could be links to clarify these q's.

@alizelzele
Copy link
Contributor Author

@SrinivasanTarget this function is only for emulators. Android 6 support fingerprint , and emulator supports that behavior by allowing you to use 10 predefined fingerprints. You just select which finger id you want to touch the sensor and it will touch it for you :-).
Sorry if I was not clear about functionality. I added an screenshot from emulator options to make it a bit more clear.
emulator fingerprint function

@SrinivasanTarget
Copy link
Member

@alizelzele Ok Thanks for your clarification. Few remarks,

1)Adding tests as mentioned above.
2)https://github.com/appium/java-client/pull/473/files#diff-9fde7d141e27783a303930113c99c211R62 should be fingerPrint i.e P should be case-sensitive.
3)I think gradle check will be failing. Refer this: https://github.com/appium/java-client/blob/master/docs/Note-for-developers.md. Fix the checkstyle errors.
4) javadoc is not clear. Mention it like this,

Authenticate users by using their fingerprint scans on supported emulators.
@param fingerprintId    fingerprints stored in Android Keystore system.

@SrinivasanTarget SrinivasanTarget added this to the 5.0.0 milestone Sep 25, 2016
@SrinivasanTarget
Copy link
Member

@alizelzele Did you got a chance to look into this?

@alizelzele alizelzele force-pushed the finger-print branch 3 times, most recently from c3131e6 to 0473a25 Compare October 8, 2016 06:20
@alizelzele
Copy link
Contributor Author

@SrinivasanTarget

  1. test method added
  2. changed fingerprint to fingerPrint
  3. update code with google code style and pass gradle check
  4. update the documentation as you asked

p.s: sorry for the big delay. I were busy at work since it was close to national holiday in china, and after that it was (obviously) national holidays. (and more obvious, I am working in china 😄 )

@SrinivasanTarget
Copy link
Member

@alizelzele Cool will review it soon.

@SrinivasanTarget
Copy link
Member

Nice Catch @codacy-bot. @alizelzele Can you please fix this?

/**
* add a new finger print to security.
*/
@Test public void pressKeyCodeTest() throws Exception {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SrinivasanTarget the code is suppose to throw exception if the test fails. I add try catch to whole test body and assert fail on failing :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

use the @Test(expected = MyException.class) syntax for such case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mykola-mokhnach throwing exception is not the expected behavior. if it throws any that means it failed. try catch is there to prevent throwing exception on test fail (as asked by @SrinivasanTarget )

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, perhaps it makes sense to add some nice description to the fail method in such case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

service.start();

if (service == null || !service.isRunning()) {
throw new RuntimeException("An appium server node is not started!");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SrinivasanTarget This part of code is duplicate of io.appium.java_client.android.BaseAndroidTest. I will use another RuntimeException to throw, Don't think adding a new Exception class is required

capabilities.setCapability("appPackage", "com.android.settings");
capabilities.setCapability("appActivity", activity);
return (AndroidDriver) new AndroidDriver<AndroidElement>(service.getUrl(), capabilities);
// return (AndroidDriver) new AndroidDriver<AndroidElement>(new URL("http://localhost:4723/wd/hub"), capabilities);
Copy link
Member

Choose a reason for hiding this comment

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

Comment should be removed here.

@SrinivasanTarget
Copy link
Member

@alizelzele Can you sign CLA?

@@ -16,6 +16,7 @@

package io.appium.java_client.android;

Copy link
Member

Choose a reason for hiding this comment

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

AndroidDeviceActionShortcuts API is deprecated.

@alizelzele
Copy link
Contributor Author

@SrinivasanTarget I believe i already signed the cla ( maybe with another email).
can you point me to CLA link ( I could not find it in docs ) :">

@jsf-clabot
Copy link

jsf-clabot commented Dec 1, 2016

CLA assistant check
All committers have signed the CLA.

@SrinivasanTarget
Copy link
Member

@alizelzele Above is the link now. But still there are some work left for you to complete.

@SrinivasanTarget
Copy link
Member

@alizelzele Please refer this: #509

@alizelzele
Copy link
Contributor Author

@SrinivasanTarget signed it. It was new! I guess I mistake it with Selion CLI :-)
remove the comment and update the code for deprecated interface.

Copy link
Contributor

@TikhomirovSergey TikhomirovSergey left a comment

Choose a reason for hiding this comment

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

@alizelzele I think that the FingerPrintTest may be more simle. Also there are merge conflicts.


import java.util.concurrent.TimeUnit;

public class FingerPrintTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

@alizelzele Why don't you like to extend the BaseAndroidTest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TikhomirovSergey because test needs access to service created in BaseAndroidTest which is private.

Copy link
Contributor

@TikhomirovSergey TikhomirovSergey left a comment

Choose a reason for hiding this comment

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

The FingerPrintTest needs to be improved. Also it needs to resolve conflicts.

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
capabilities.setCapability("appPackage", "com.android.settings");
capabilities.setCapability("appActivity", activity);
Copy link
Contributor

Choose a reason for hiding this comment

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

@alizelzele Maybe ApiDemos has convenient functionality. Have you tried to play with it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TikhomirovSergey searched it. did not find anything fingerprint related to use.

@saikrishna321
Copy link
Member

@TikhomirovSergey this feature is part of Android base driver server from version 2.0.16

@TikhomirovSergey TikhomirovSergey modified the milestones: 5.1.0, 5.0.0 Aug 28, 2017
@fuzzybinary
Copy link

What's the current state of this feature / PR? Does it need to be redone or just have the comments addressed?

@alizelzele
Copy link
Contributor Author

Sorry guys, I did not find any time to reply and fix the issues.

the test needs to enable lock on device and make sure it is unlocked after the test, which added a bit of complexity to code. I was going to update appium-unlock to support sending passKey when unlocking to make things more clear and easier to handle.

I am rebasing and fixing merge issues now. but if I remember correctly the xpath in test were not valid anymore. will give it a shot

@alizelzele
Copy link
Contributor Author

Stupid github (me), I push without committing my changes first, and github automatically closed the PR. 🤦‍♂️

@alizelzele alizelzele reopened this Nov 21, 2017
@alizelzele
Copy link
Contributor Author

update the code and fixed merge conflicts. test run correctly and successfully on this avd:

 Device: Nexus 5 (Google)
   Path: ??? :)
 Target: Default
         Based on: Android 6.0 (Marshmallow) Tag/ABI: default/x86_64
   Skin: 1080x1920

which emulator config you are using that the test in failing on? since test is written using xpath and it is also running system applications, it is a bit (very) fragile. did not find any other way to do it though.

@SrinivasanTarget
Copy link
Member

@alizelzele Thanks for changes. we will review it soon today.

@TikhomirovSergey TikhomirovSergey dismissed their stale review November 23, 2017 21:14

I have started to review it again. I am going to provide the feedback ASAP

Copy link
Contributor

@TikhomirovSergey TikhomirovSergey left a comment

Choose a reason for hiding this comment

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

Hi @alizelzele Thank you very much for update

I was trying to run the test on different emulators with different API levels. The result was the same NoSuchElementException. could you provide some information to make the test running green or please make some improvements

@alizelzele
Copy link
Contributor Author

@TikhomirovSergey It works on my system 😀 😁 😁
I will try to improve it (although I am still not sure if anything else can be used instead of xpath.)
can you give me AVD details you used? maybe I can start with error you get and improve on that front.

@alizelzele
Copy link
Contributor Author

@TikhomirovSergey likely on Windows emulator there is another additional step when you want to enable security!

I updated the test, add more comment and test it. one issue on my system is that for some reason following command and thus appium was not able to trigger fingerprint:

adb emu finger touch 1

but I test the code using debugger and it is working also on windows too. hope you won't have the issue with SDK.

@appium appium deleted a comment Dec 2, 2017
@TikhomirovSergey TikhomirovSergey dismissed their stale review December 4, 2017 20:45

@alizelzele ok. I have started to check it again.

Copy link
Contributor

@TikhomirovSergey TikhomirovSergey left a comment

Choose a reason for hiding this comment

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

@alizelzele I can approve this PR. But I want to propese some additional changes at the additional PR. I am going to propose it ASAP

@h2904
Copy link

h2904 commented Dec 12, 2017

Hey guys,
so I am trying to automate a flow which involves fingerprint authentication, Once I register fingerprint on android simulator ,navigate to the app's login page and start to enter credentials, webdriver throws a exception saying unhandled alert present, even though there is no alert shown, the text of the alert is (which i got from alert.getText) [{"touchIdRequested":false,"credentials":{}}]" , If I remove the fingerprint registration from simulator i do not get the error, and am able to successfully login. The login page is in webView Context

other environment details:
Platform: Mac OS X
Appium:1.7.1
Android Simulator version:8.1.0(Pixel)
Android driver version:3.3.0

Please let me know if you have any information regarding the issue.

@TikhomirovSergey TikhomirovSergey merged commit c8946c1 into appium:master Dec 18, 2017
TikhomirovSergey added a commit that referenced this pull request Dec 18, 2017
@alizelzele alizelzele deleted the finger-print branch December 19, 2017 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants