January 28, 2012

Important

Although the following methods can be used to access messages on the Android platform, the API is probably hidden from developers for a reason.

I think it’s hidden because mobile manufacturers are free to implement messaging as they like and the messaging application provided by Google is there only because every mobile platform needs messaging. I’m just guessing though…

Everything which is not in the official API reference is likely to change between releases and can also disappear without notice. Probably the API will be available with minor changes in “Google Experience” labeled phones because these devices ship the unmodified release builds, however there are already problems with this API on Hero, which is heavily customized by the manufacturer.

So think of this API as a reference implementation of messaging provided by the Google developers, which may or may not be available on an Android based device.

What we know

The official API has SmsManager to send sms.

For some reason android.provider.Telephony is hidden in the SDK although it is still in the /frameworks/base/core/java/ directory which in my reading should be public and usable to app developers. Let’s pretend for now that this is a mistake and it is public. This file has the [public static final String SMS_RECEIVED_ACTION = "android.provider.Telephony.SMS_RECEIVED"] broadcast intent to capture incoming messages. You have to hardcode the string “android.provider.Telephony.SMS_RECEIVED” in the intent-filter but at least it’s defined in the core.

Reading/Writing messages

Here comes the part which is NOT in the core platform. Everything is defined in the /packages/providers/TelephonyProvider/ directory. Accessing messages can be done through the standard ContentProvider API. The usable Uri-s are:


content:// +

sms

  • retreive all messages

sms/inbox
sms/sent
sms/draft
sms/outbox

  • retreive messages from the respective folders

sms/#
sms/inbox/#
sms/sent/#
sms/draft/#
sms/outbox/#

  • retreive a messages identified by its _id (Because _id-s are unique, all of the above maps to a select based on the message _id)

sms/undelivered
sms/failed
sms/failed/#
sms/queued
sms/conversations
sms/conversations/*
sms/raw
sms/attachments
sms/attachments/#
sms/threadID
sms/threadID/*
sms/status/#
sms/sr_pending
sms/icc
sms/icc/#

  • List/retreive messages from SIM

sms/sim
sms/sim/#

  • Deprecated Uris, “sim” replaced by “icc”

To be continued… I have to find some answers from the platform developers first :)

These are the settings for an android powered phone for T-Mobile in Hungary. However the link at the end of this post could help with a lot more countries and mobile operators.

Android settings for T-Mobile (Hungary):

Name: T-Mobile H
APN: internet
Proxy: 212.051.126.002
Port: 8080
Username: <Not set>
Password: <Not set>
Server: <Not set>
MMSC: http://mms.t-mobile.hu/servlets/mms
MMS Proxy: 212.051.126.010
MMS Port: 8080
MCC: 216
MNC: 30
APN type: <Not set>

Every setting above is available from your network operator (in Hungary the T-Mobile website contains a lot of documents about how to set up various phones to use in their network. If your operator has them too, just look at the settings of a fairly recent 3G capable phone for this information).

The only thing you won’t find is the setting for MCC and MNC (these are Mobile Country Code and Mobile Network Code) these two values are unique for every country and every operator (MCC: 216 for Hungary, MNC: 30 for T-Mobile in Hungary [01 for Pannon, 70 for Vodafone]).

But there is a really good list on Wikipedia: Mobile Network Code

Connecting two different subnets on different locations with linux firewalls is easy. I did it with OpenVPN because it’s easy to setup, secure and “just works”.

Everything worked fine. Email server on one subnet was reachable from the other, the samba server was available with \\ip style address. I thought that was all, work done…

Not quite.
Read the rest of this entry »

For months now I’ve been reading about SSDs. First I was just curious whether they could really outperform HDDs. Later I considered them for my personal use in laptops.

Now I’ve found the best in depth article about SSDs. It’s a bit long but it contains a lot of information for professionals, who really know something about hardware and want to know what an SSD can do and what limitations does it have which can affect everyday use.

The article can be found here:
[AnandTech] The SSD Anthology: Understanding SSDs and New Drives from OCZ

Now my last unanswered question about SSDs: “How long do they last really?”

Yesterday I changed my ~/.vimrc to make programming in a terminal easier. For years now I’ve been reusing the same one.

Here it is with comments:

" Turn on syntax highlights. Well it's not an IDE, but makes important things stand out enough
syntax on
" Make tab width 4 spaces
set tabstop=4
" Make indent width also 4
set shiftwidth=4
" Make indent rounded to next full shift width
set shiftround
" Expand tabs to spaces (doesn't mess up file indentation in other editors width different tab settings)
set expandtab
" Indent code blocks automatically (don't need to type a lot of tabs in deep indented lines after a linebreak)
set autoindent
" And make backspace delete smartly (like in any editor. through indents, linestarts and end of lines)
set backspace=indent,eol,start

And finally a command to remember to replace all tabs with spaces based on the values above. (Good for formatting text made in another editor)

:retab or :retab! to force replacing all tabs which are not surrounded by whitespaces

“You can leverage the power of Java by using any Java library within a JavaFX application. This way you can preserve your investment in Java and use JavaFX to build engaging visual experiences.”

The statement above is in the JavaFX FAQ at 4.4. And of course you can use any java library available without any changes.

However try to bind a variable form a simple java class to any value in a javafx class and you will see that integrating java into javafx is not as simple as it seems.

Read the rest of this entry »

I wanted to write about a bit of spyware history and evolution here, but I think we all know a lot about the problem already. Spywares are annoying, widespread and dangerous.

And hard to get rid of. Today spyware writers are becoming quite good at hiding spyware activity and making sure that an infected computer remains infected. A common approach is to change the winlogon notify registry key to run malware code on every single user login. Yes, even if you start windows in safe mode you have to log in, and if a program is loaded you cannot easily remove it from the computer.

Read the rest of this entry »