Translate

Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Sunday, February 16, 2020

Android - how disable the Home button


Here a way to disable the Home button (but also the Back and Menu).

CAUTION !!
Possible undesired side effects !  Use at your risk !

It is assumed you know how to work on Android and I'm talking about !

Sunday, July 22, 2018

Sunday, July 15, 2018

Android - proprietary ASN.1 encoder

The purpose of the ASN.1 coding specification described here is to have a way to create ASN.1 data sequence in a program without having an ASN.1 compiler capable to read a formal ASN.1 notation.
There are a lot of libraries out there with many different ways to handle the coding/decoding of an ASN.1 message. I needed something simple, cheap and fast so I created this system.
I originally created this years ago in C and now ported in Java for Android.

Sunday, June 24, 2018

ASN.1 - what is it ?

ASN.1 stands for Abstract Syntax Notation One, a standard protocol from ITU, is heavily used in telecommunication, for example in ISDN.

There is a lot of literature about ASN.1, books, white papers, online tools, etc. so I'm not duplicating here what already exists "out there" but I just sum up few things I think are interesting.

Saturday, June 16, 2018

Set Raspberry Pi as Bluetooth slave

Some notes about how to connect a Raspberry Pi 3 via Bluetooth to an Android phone.
These notes shows some suggestions about how to connect an Android phone to the Raspberry set as Bluetooth slave.
Android side I'm using an off the shelf app.

Saturday, May 12, 2018

Developer tips - Android studio

Bluetooth RFCOMM connection problem

If you like me are trying to set up a simple Bluetooth RFCOMM connection and you end up having connection errors, especially : read failed, socket might closed or timeout, read ret: -1
is possible the problem lies in a changed default assignment for the socket.

Friday, February 9, 2018

Developer tips - Visual Studio - workarounds

Ok, let me start with I didn't choose to use Visual Studio !!  ðŸ˜›
But sometime is the pain that choose you.

In my case I'm using Visual Studio 7.4 on a Mac in order to develop apps Android and iOS in C# (old Xamarin).

This article contains some tips I discovered that can be useful if somebody else has the pain to use 'that'.
Of course this article is working in progress, expect updates.


Tuesday, January 3, 2017

SmartPhone audio accessory

Some notes about some audio accessories for smartphone.

Hype Retro Walkie Talkie handset

This funny toy is shaped like a traditional-style ham radio microphone.
The idea is to "transform" the smartphone into an Ham radio. For example, used with Zello can facilitate to use it in a mobile environment or for who is nostalgic about it.

I tested it on the Samsung tablet but is not working with Zello.
However is working with other applications. This suggests that there are other differences other the 3.5 mm jack pinout.

Let's open it up


The quality of the gadget is of course very low. Beside, for 5$ really is not expected to be better.

The gadget

To open it there are just four Philips screws

The little board has a small amplifier based probably on  a LM386.



There are two push button and a trimmer for the ON/OFF and volume setting.
The small push button on the top is the one that is used to start the conversation.
The big push button on the side simply mute the speaker (IMHO wrong  choice since normally the PTT button is on the side on a normal/standard mike).

Operations


The idea is to plug the mike in the smartphone audio jack and turn it on.
After that the audio output is redirected to the small speaker and when pressing the PTT button, the mike is activated.



Wednesday, September 4, 2013

Smartphone audio cable adapter


Unfortunately doesn't seems in the smartphone and tablet world, to exist a single standard for the audio connectors (see article about the smartphone audio jack).

On the market do exists cable converter of any kind, however they are often unnecessarily costly.
If you need an audio jack adapter between the main two standard in the smartphone world, OMTP and CTIA, here what I did.

Shopping list


Quite easy ... we need three things :
  • a 4 wire cable
  • a TRRS male jack
  • a TRRS female jack
I solved buying the needed material from Sparkfun.
I ordered a TRRS male jack with 18" of cable (CAB-11580) for $1.95 and a TRRS jack breakout (BOB-11570) for $3.95.
The TRRS jack breakout

It is possible maybe to find just a TRRS female for less, but the breakout is more flexible since it can be used also to provide a test platform (hook up oscilloscope, ecc.).
For about 9$ (the material plus shipment) is possible to have all the necessary to build the adapter.
A ready made cable converter can be found usually around 11$ plus shipment, but  the advantage to build it is that can be modified for other type of connections.

Schematic

OMAP<--->CTIA


Well, is really quite straightforward.
It is simply matter to connect the Tip and first Ring directly, and then swap  the other two.
The TRRS jack with the cable has this pinout :

  • Tip - red wire
  • Ring - white wire
  • Ring - green wire
  • Sleeve - black wire
On the PCB are marked the positions, so it is straightforward to connect the wires.




Saturday, August 31, 2013

Smartphone/tablets audio connectors

One of the few things really annoying is when manufactures decide to don't follow a single standard for the connectors of their products.
I have around some smartphones and there are differences on the audio (3.5 mm) connector.
These differences creates problems with some accessories.

For example I bought a very nice desktop phone stand from Aptiva, but I soon discovered that it is incompatible with my Sony Ericsson Xperia.
The same for a Hype Retro Walkie Talkie handset I wanted to use to enhance the Zello experience.
On the Sony is not working at all, on the Samsung tablet works in part (see the note on the bottom of this article).

So there are differences about the connection of the 3.5 mm audio port on these devices.
This article is trying to document the pinout of different phones/tablet and giving information about this problem and how to solve it.

Introduction


The typical 3.5 mm jack is divided in different areas :
  • Sleeve
    The part of the connector close to the handler, the cover.
  • Ring
    The part of the connector separated by a insulator ring
  • Tip
    The far part of the connector, the "point"
There are many different types of jack.
In the figure below, there is an explanation of the main parts of such connector.
This type of  jack is called TRRS  (Tip/Ring/Ring/Sleeve) and it become the "standard" for smartphones.

The most known type of jack is the one used to connect the standard stereo headset.
This type of jack is called TRS, from the initials of the connections :
Tip - Ring - Sleeve


CTIA Audio jack


CTIA defined an audio connector.
It is a TRRS  :
  • (sleeve) Microphone input
  • (ring) Ground (common)
  • (ring) Right Audio out
  • (tip) Left Audio out

iPhone 4S



Many audio accessories are labeled as iPhone compatible.
This means that the majority of the audio accessories found on the market follow the Apple standard for the 3.5 mm audio connector.
The iPhone/iPad audio jack follows the specifications defined by CTIA.



So every accessories that declare to be iPhone compatible has the pinout shown above.

OMTP audio jack


Android, as general rule, seems follow a standard defined by a group called OMTP.
However different manufacturers choose to follow the CTIA, others didn't.
The main difference between the CTIA and  OMTP is switching the place from Ground and the Mic.
So each Android smartPhone or Android  tablet can have different audio jack pinouts. That's very very bad.
This is the OMTP connector :


So let see different brands what offers.
Keep in mind that usually models of the same brand uses the same pinout, but it could be different !
So never assume.

Sony Ericsson Xperia LT18a


OMTP standard

In order to use Apple iPhone standard accessories, is necessary to use a converter.
It is possible to search for CTIA<--->OMTP conversion cable or it is relatively easy to build one.

Samsung Galaxy Tablet 7" GT-3113


CTIA standard

Samsung SPH-M910


CTIA standard


FriendlyArm Tiny210 SDK


This OEM board can run Android 4.0.3.
It has a TRS jack for the audio output and a TS jack for the audio input.





Sunday, August 12, 2012

Set up WiFi monitor with Wireshark

Sometimes is necessary to be able to see the traffic generated, or directed to, a WiFi appliance.
There are many possible ways to capture packets from a WiFi appliance, especially if the appliance allows to install packet capture applications.
However not always such thing is possible and considered the nature of the WiFI appliance, it can change the performances.
This article describes how I did set up an external monitor for the traffic to and from a WiFi appliance.

Basics


The idea is to put a computer running wireshark between the router WiFi and the rest of the network.
The main constraint is to have a WiFi router SEPARATED by the rest of the network.
This a graphic representing the  setting :



The key part is a laptop with two NIC cards. In my case the laptop is running Kubuntu 12.04

Shopping list

It is needed :
 
  • 1 laptop with Linux installed, with two ethernet ports
  • 1 PCMCA NIC if the laptop has already an embedded NIC
  • bridge utilities
  • Wireshark 

The environment 

The machine used to build the monitor is a Gateway Tablet running Kubuntu 12.04, plus a LinkSys PCMCA NIC card.
The first step, recognizing the extra NIC card, should not pose any problem.
In my case the LinkSys NIC was recognized and configured automatically by the OS as eth1.
The next step is to install Wireshark from the Kubuntu repository, and enabled it to capture packets from eth0 or eth1.


Bridge setting

After preparing the hardware and tested both the ethx ports, it is necessary to set up the machine to act as a bridge, in order to have packets received from the eth0 port sent to the eth1 port, and viceversa.
Without such functionality, the two networks are isolated, i.e. the phone can not receive anything from the network.

In order to simplify the configuration, I forced on both the NIC a manual address.


  • 192.168.2.71
    for the eth0 
  • 192.168.2.72
    for the eth1. 

After opening a terminal, I installed the brctl program (sudo apt-get install bridge-utils).
The bridge-utils are not installed by default in the Kubuntu 12.04 but are available in the repository.
At this point I created, configured and activated a bridge between the two NICs.


  • sudo brctl addbr wshark
    Creates a new bridge called wshark 
  • sudo brctl addif wshark eth0
    Adds the eth0 to the wshark bridge 
  • sudo brctl addif wshark eth1
    Adds the eth1 to the wshark bridge 
  • sudo brctl stp wshark on
    Enables the STP 


After creating the bridge, it has to be activated.
To do so, simply use the ifconfig command :

sudo ifconfig wshark up

At this point the bridge should be working.
Note that after issuing these commands the eth0 and eth1 are not accessible anymore.
It is convenient to create a script with all the above commands to simplify the setting of the system.


Running Wireshark


After the bridge is activated is possible to run Wireshark.

Among the available interfaces to use to capture traffic, it will be present a wshark interface that is the bridge.

To capture data transiting the two inetrfaces, just choose that one.


Thursday, May 3, 2012

YAAA - Yet Another Android Article




Android, the platform to develop mobile applications.
Is time to start to play with that.

It is assumed starting knowing  nothing  about Android.

The first thing is to have some documentation about Android in order to learn about it.
There are a lot of books and documentation out there, so I just started to grab something, possibly free (no resources to invest in that :) ).
As introduction, also if is an old book, this PDF book  can be useful, at least to have some basics idea about Android.
Of course there is the official updated Google documentation where to start, but I have to admit sometime a book is better as starting point. 

Basically to start to develop for Android, at least three things are needed :  

  • The Android SDK  
  • Java SDK
  • Eclipse plus Android plugins
Eclipse is actually suggested, is not mandatory, but since many examples and documentation assume Eclipse to be used, so it is :)
This article assumes the development host to be a Linux one (Ubuntu 10.04 and 12.04)

Installation

First of course download the latest versions of the software to be installed.
The system I used to install Android the first time, documented in this article, is a quad processor Dell computer, with Ubuntu 10.04 installed.
I was able to install the Android development software over a Kubuntu 12.04 following the procedure described on this article.


Java JDK

Java can be the critical part of the system and MUST BE present before to install the rest of the environment.
Probably Java already exists on the development machine, but it is possible is an old one or incompatible one with the Android SDK.
So the first thing to do is to verify if :

  • Java already exists on the machine
  • if the installed version is a JDK version (the JRE version is not enough)
  • if the installed version is compatible with Android SDK 
  • eventually remove it and install the latest one
To verify what version of Java is installed on the machine (Linux only) ope a terminal and digit :

$ java -version
In my case I had :
steve@Oliver3:~$ java -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.13) (6b20-1.9.13-0ubuntu1~10.04.1)
OpenJDK Server VM (build 19.0-b09, mixed mode)
steve@Oliver3:~$ 
The documentation about Android specify to have Java 1.5 or 1.6 and the  JDK version, so I should be OK.
The latest JDK  is available at this URL.
The first choice, the Java JDK, must be chosen.
In my case I selected this one :
http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u3-download-1501626.html 
After downloaded it I exctracted it in the /home/steve/Android directory but NOT installed for the moment since I assume the one already installed is OK.

CAUTION !  In some distributions Java JDK from Sun/Oracle is not available anymore !
In this case the OpenJDK is the "official" release to use with Android ! 

 Android SDK

The Android SDK contains all the Java libraries to develop for Android plus tools to compile and debug the code, i.e. an Android simulator.  So in theory there is no need to have a specific hardware (see note) in order to install and develop under Android.

The latest  SDK can be download from the official Android  website.
Choose the SDK version for your system. In my case I choose the Linux one.
Create a directory somewhere on your disk where to exctract the tarball. I created :

 /home/steve/Android  and exctracted the tarball into  android-sdk-linux.

Tip
Can be useful to have the SDK tools in the path. Many sources suggest to create a system variable called ANDROID_SDK and add it to the main path.
Edit  the .profile file (in the main user home - for example in my case : /home/steve/.profile) and add :

export ANDROID_SDK="/home/steve/Android/android-sdk-linux"
export PATH="$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools"

Save the file. The next time the system starts the Android SDK path will be available, with also the system variable ANDROID_SDK. 
  
Then, after reading the  SDK Readme.txt file, I opened a terminal and run the android program under tool :
$ cd /home/steve/Android/android-sdk-linux/tools/./android   (or if the path is set, ./android)

The program is needed in order to "populate" the SDK. The SDK exctracted is moslty empty.
By default  is marked for installation the latest Andorid SDK, at the time of this article, the 4.0.3.
Follow the instructions and install it (select Accept all)
I choose to install also the documentation. The installation tooks few minutes and of course is necessary to be online since everything needed is downloaded from Google.
Here a screenshot after the installation :


Note : at the installation time I didn't have ANY Android hardware. Having a specific hardware it means to select the version of Android capable to run on a specific one, not necessarily the latest one will work on a specific hardware !!

It is possible to install more than one Android API version and actually is one thing necessary to have.
The project usually uses the correct version as defined in the project parameters.  
To select the correct API to use for a project, go in the Project menu', select Properties and then choose Android.

The API in use for the project is stored in the file project.properties in the project root. 

Eclipse

The last tool to have is Eclipse.
As said before is not mandatory, but since many examples and tools that simplify the life are based on Eclipse, I choose to install it and use it.
As suggested in the eBook, at the URL  is possible to download Eclipse.
There are many different choices. I choose the "basic" Java version called Eclipse Classic. 
After downloading it, I exctracted in the /home/steve/Android/eclipse directory.
To start it, is enough to go in the eclipse directory and start ... eclipse :)
The first thing to do is to create a workplace for Eclipse. I created mine in the /home/steve/Android/Workplace directory.

Configuration


There are some plug-ins for Eclipse that  integrate the Android SDK and facilitate to create Android applications.
The indications on the book are not exactly precise since the version of Eclipse is quite different.
So basically, from within Eclipse, go to the Help menu, select Install New Software.
A windows appears :


In the box Work with, digit the address of the repository for the Eclispe plug in for Android :
https://dl-ssl.google.com/android/eclipse/
In the box below (Name) will appears the possible plug-ins. Mark them all then click on Next and follows the instructions. 
After the installation Eclipse need to be restarted. After that it will asks for the Android SDK.


Since I already installed the SDK, I selected the Use existing SDKs and browse for the main directory of it.
Follows the instructions to complete the binding between Eclipse and Android SDK.
After this point, Eclipse is ready to be used to develop and debug Android applications.