Recently, I have read about Smart Card API (Open Mobile API) and figured out that not every device can work with a secure element as the Smart Card API is not implemented on every device. So can anybody say if I can work with a secure element of Android Emulator SIM card if I have no physical SIM card?
Not on the stock Android emulator. The Android emulator (AVD) that ships with the ANdroid SDK does not currently support the Open Mobile API either.
However, the SEEK-for-Android project provides patches to the Android emulator to allow a secure element to be attached over PC/SC (smart card) or MSD (uSD card). Detailed instructions can be found in their wiki.. Be aware though, that those patches seem to target some Android 4.2.2 and might not work out-of-the-box with other Android versions.
Related
I understand that to access SIM/eSE from an Android app we need to install Open Mobile API addon on Android Studio. However, is it true that it will not work on all NFC phones? For example, do some OEM limited access to SIM/eSE? Or are there phones where only custom firmware will work with Open Mobile API?
Also, is there a list of phones that support Open Mobile API by default?
That's correct. The phone needs to implement the Open Mobile API (by means of the smartcard system service) in order for your app to be able to use it. Not all devices implement this. It's mainly devices from Samsung, Sony, and HTC which support the Open Mobile API.
In addition to that restriction, you need the SE (UICC/eSE) set up to allow your application (this is handled by GlobalPlatform SE Access Control) to interact with the SE.
Finally, I'm not aware of any complete list (and ther probably is none). However, have a look at the question List of OMAPI supported devices to get some ideas on how to test devices and how to let Play Store generate a list for you.
You may also want to read our report Open Mobile API: Accessing the UICC on Android Devices to get some idea about how the Open Mobile API works.
I need to develop an app for windows for data transfers to android devices via mtp. That is when android is connected to windows via USB cable and android offers mtp menu as protocol for USB.
Can someone tell from which android version onwards can I assume that the device definitely has mtp support. Can this assumption be even made ?
Secondly is it android feature or does the mtp support depends on manufacturer regardless of android version ?
If you check the Android Compatibility Definition Document for Lollipop/Android 5.0 section 7.6.2 states that:
Device implementations MAY use USB mass storage, but SHOULD use Media Transfer Protocol
As it doesn't read 'MUST', I'm afraid there are no guarantees that devices which would have Google Play would have MTP, but I would be surprised if the major manufacturers didn't follow it and have an MTP implementation.
You can check the documents for older version of Android here:
http://source.android.com/compatibility/downloads.html
The [MTP] was added since Android API 12,
which Platform Version is [Android 3.1.x].
so, the [above a certain api] may be android 3.1
and ,this is the android feature,and I think the manufactur has no reason to unenable it.
Android API : developer.android.com
I have been checking since some time to mount external drives to android phone i.e., if I plug external drive(hard/flash/camera) to android device, the android phone should be able to access the storage file system.
There are apps in the market which controls external devices through phone.
I can use the USB Host mode { http://developer.android.com/guide/topics/connectivity/usb/index.html } to communicate with the usb device. But USB Host and Accessory modes are directly supported in Android 3.1 (API level 12) or newer platforms.
While an app named DSLR Controller { https://play.google.com/store/apps/details?id=eu.chainfire.dslrcontroller&hl=en } , requires Android 2.1 or above. Since the application is based on accessing the camera through android phone. If the app displays the correct info, then the task of accessing the storage of camera (or any other drive) seems to be possible.
But I want to use the application in lower version as well. Any kind of help will be appreciated.
Please comment,if need any more description of the problem.
Thanks.
You can create an application based on FileManager open source project on Github. You can specify there to identify your device. You can change these code according to your need.
Here is the link Adroid-File-Manager
If you just want to be able to access USB storage (like a flash drive) you can open the files the normal Java way (java.io.File, etc). Android ICS automatically mounts flash drives under /sdcard/usbStorage/, but I'm not sure about previous versions or other types of hardware. It might still work, though, so I'd suggest that you test it and see what happens.
The only sure way of getting this done is to use API level above 12, otherwise a few phones may have support for usb host but most of them wont support it.
The reason being first of all you need hardware support for usb host, even if that is present the drivers needed might not be compiled into the kernel, i did some work while trying to implement usb host on nook color, even though it had hardware support, getting usb host working took almost 2 months and a dedicated app. So its not something you will be able to do for every device. A few might support it out of the box but even those would need root and lots more work for mounting drives and all that..
the DSLR camera also does it the same way look at the requirements
- Android device with ARMv7-A or newer CPU architecture (most 1ghz+ devices)
- Not rooted: Android 3.1 or higher with USB host kernel+API support
- Rooted: Android 2.3.1 or higher with USB host kernel support
These are the only devices that can support USB host.
From the app description, Android 2.x devices need to be rooted. This suggests that they have some native implementation of the USB host code (possibly a pre-compiled kernel module they load).
Therefore, the solution for this varies based on the specific hardware and software (kernel, vendor modifications, skin) it is running.
I have an android phone (nexus s, sdk v15) which shall send a string to a development board running in nfc-reader/writer-mode by using tag-emulation. I know this is not officially supported by android, so I could do it natively by accessing the driver directly(?).
Is there any example out there where anyone has done this before or an app which does this (and preferably is open source?)
I found some stuff on google where it is generally advised not to do this, or where people talk about how it would be possible or how they've (very generally) done it, but I couldn't find any code or precise advice.
I don't want to access the secure element or do any smartcard stuff that needs to be approved by the vendor/provider. I just want to transfer the string. I also know this could be done by the android api methods via p2p, but this doesn't work well with the board, so I give this approach a try.
For a device running stock KitKat 4.4
With Android KitKat 4.4 the ability to have the phone act as an NFC card is built into the operating system so you no longer have to rely on Cyanogenmod or a custom ROM. It won't let the phone act as a Mifare Classic tag per se but I've had great results in getting my phone to communicate with an ACR122 reader so I'd definitely recommend this option if you can get 4.4 on your device.
If you're wanting to run below 4.4 and are willing to use Cyanogenmod
It is possible to load applications onto your device and have them communicate with a reader via NFC quite easily however you must be running Cyanogenmod, this feature is present from CM 9.1.
Wanting to run on Gingerbread (the old answer)
Yes it is possible and there's been a patch put out there for 2.3.4 to enable it, I'll post a few links for you to have a read of.
They do require flashing a 2.3.4 Gingerbread ROM to your device along with some other patches to enable the card emulation features so if you're not willing to do that then they won't be of much use but as far as I'm aware it's the only way to get it working. I haven't actually tested this myself but user comments suggest it works.
Here is a link to a blog describing the whole process: http://techshek4u.blogspot.co.uk/2012/01/applying-card-emulation-patch-to_03.html
Here is a link to the original forum post with the patch for 2.3.4 to enable it:
http://forum.xda-developers.com/showthread.php?t=1281946
And a link to the original discussion where various developers are trying to get it working, depending on your technical knowledge of Android and NFC this could be more or less interesting: https://groups.google.com/forum/#!msg/android-developers/1fw1qfFqpGc/6dlzvTqExN4J
Caution: According to NFCGuy from his answer "Don't bother with downgrading your phone to GB if it is running ICS. You cannot downgrade the NFC firmware to be compatible again with GB, so NFC will simply not work if you flash your device with GB."
If you root your device, it is possible to create an app that turns on the card emulation mode. It is not too difficult, see e.g. https://stackoverflow.com/a/10506299/1202968.
However, card emulation is completely handled by the Secure Element. Your app has no access to the data that is being transferred. The only way to get control over that would be to create and install a Java Card applet on the Secure Element. However, to be able to do that you need acces to secret authentication keys that are only known to Google.
PS: Don't bother with downgrading your phone to GB if it is running ICS. You cannot downgrade the NFC firmware to be compatible again with GB, so NFC will simply not work if you flash your device with GB.
Host card emulation is now officially supported by Android, according to http://developer.android.com/guide/topics/connectivity/nfc/hce.html
Android has USB accessory or host mode in 2.3.4, 3.1 and higher versions.
But when I use Android 2.3.3 or 2.2, I can power the connected camera and also can access pen drive content.
Why is this happening and then? Is it just the library that we have in some of the versions and nothing about the internal hardware?
If not about internal hardware than is it possible to create our own driver for all version to have the device in host mode?
Android itself support host mode in almost all recent versions. So you can connect keyboard, mouse, usb-drive, etc to a android device. This is done on system level, but not exposed to user's apps.
In Android 2.3.3 (api level 10) was added interfaces to access usb device from userspace. So now you can write app that communicates with an usb device.
Technically, you can write JNI wrapper for libusb, and use host functionality in earlier Android releases, but there are many pitfalls, so I don't recommend you to do this.