Wednesday, September 19, 2012

Android calls management.

This was an amazing day today... I've set down with a colleague, to determine the calls states of an Android phone, and here are the results:

Phone state intent/Listener New outgoing call intent
num state number  
Out - OffHook V  
In + Out - OffHook V  
Out x2 - OffHook V  
In V Ringing -  
- OffHook -  
Out + In V Ringing -  
- OffHook -  
In x2 V Ringing -  
- OffHook -  
2 Calls + hang - - -  
2 Calls + swap - - -  
2 Calls + Conf - - -  



Why is this so amazing? 
  • First, the call events are separated to two intents, or one intent and a listener, which is ridicules...
  • Second, the events are so limited, that no function can be based according to the calls...
  • THERE ARE NO EVENTS FOR a second call hang up, call swap, or 2 calls ==> conference... WFT?? (terrible failure)
Note how many '-' are there... how many events are impotent.

I love Android, but the more I dig, the more dirt I find...

 If you have other insights please comment!

Thursday, August 2, 2012

How to determine if your application runs in debug...

Sometimes there are actions your Android application should perform while it runs in release, but not in debug, and vice verse.

The issue is that Android methods of checking whether the application is debuggable or not, are not reliable, and there are three of them...

This is highly frustrating.

The best solution I've found, which served me well, is to determine in runtime whether the apk which runs the application is signed with a debug certificate or not. I've tested this on tens of phones ranging from version 2.1 - 4.0.4.

Here is the code sample:

PackageManager pm = context.getPackageManager();
Signature sig = packageManager.getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES).signatures[0];
CertificateFactory cf = CertificateFactory.getInstance("X.509");
X509Certificate cert = (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(sig.toByteArray()));
String dn = cert.getIssuerDN().getName();
boolean debuggable=dn.contains(myDebugCertificateName);

On most development environment the default debug certificate name is:
myDebugCertificateName = "Android Debug"



The problem I noticed people having is that they don't even understand this is what they really need... they just solve it in the build, and add a flag during CI to the manifest and later extract the value at runtime, I find it ridicules!

Sunday, June 10, 2012

Android Know How-To

I have a new concept... instead of asking stupid question and wait for an answer, every thing I encounter and solve, would be documented and noted, with very good keywords, for maximum exposure.