May 13

About
I'm Nicholas FitzRoy-Dale, a software developer from Sydney, Australia. I'm interested in embedded systems and operating system research, code optimisation, 8-bit music, rock climbing, shiny things...
May 13
SPI Flash programmer for Arduino
May 12
Call-by-name semantics
- The expression (* a 2) is evaluated, yielding an integer (presumably).
- That integer is passed to “add1” and bound to “lhs”.
- add1 executes, adding the value of lhs, which is just an integer, to 1.
- The expression (* a 2) is compiled to a thunk, which is a parameterless closure — it’s a callable thing (i.e. it is code which produces a value), which retains the scope of wherever it was defined.
- A pointer to the closure is passed to add1.
- add1 evaluates “lhs”, which results in an integer.
- add1 adds the result of the evaluation to 1 and returns it.
Apr 11
Walter Bright on making programming languages
Jan 24
AOSP: emulator: don't copy the system image
I haven't tested this for very long, so maybe it will break everything. As a precaution, you might want to remount as ro before quitting the emulator if you make any changes to /system (i.e. if you have previously done an adb remount): adb shell mount -o remount,ro /system.
Jan 23
WhatsApp: fake contacts
Dec 31
Five-minute AOSP hack: remove proximity sensor support
I recently dropped my Nexus 4 and broke its LCD. If replacing this £85 part wasn’t annoying enough, I also managed to lose the tiny rubber part which makes the proximity sensor work. Without it, the LCD turns off, and stays off, during phone calls. (Actually, I didn’t break the LCD — I just cracked the front glass — but I had to buy a new LCD + glass + digitiser assembly anyway.)
Fortunately, the proximity sensor sucked even before I broke it. :) I don’t press phones right up to my face, so talking is often a flickery screen-on, screen-off business anyway. So I hacked AOSP to ignore any hardware-supported proximity sensors.
With this change, you can control the LCD normally using the power button, even during phone (or Skype, etc) calls.
wzdd@ubuntu:~/aosp-nexus4/frameworks/base$ git diff diff --git a/core/java/android/hardware/SystemSensorManager.java b/core/java/android/hardware/SystemSensorManager.java index 0204e94..9dd8d7f 100644 --- a/core/java/android/hardware/SystemSensorManager.java +++ b/core/java/android/hardware/SystemSensorManager.java @@ -265,7 +265,7 @@ public class SystemSensorManager extends SensorManager { Sensor sensor = new Sensor(); i = sensors_module_get_next_sensor(sensor, i); - if (i>=0) { + if (i>=0 && (sensor.getType() != Sensor.TYPE_PROXIMITY)) { //Log.d(TAG, "found sensor: " + sensor.getName() + // ", handle=" + sensor.getHandle()); fullList.add(sensor);
Oct 30
Five-minute AOSP hack: dismiss voicemail notification
My Android device (a Nexus 4) won't let me dismiss the voicemail notification icon without actually clearing the voicemail. This is pretty annoying, particularly since either my phone provider (Three UK) or my device sometimes gets it wrong and tells me that I have voicemail when I don't.
If you're compiling your version of Android from the AOSP source code (and I realise this means almost nobody) you can change this by removing the piece of code in the phone app which tells Android not to let you dismiss the notification. Here's a patch against 4.2.2:
wzdd@ubuntu:~/aosp-nexus4/packages/apps/Phone$ git diff
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index 42dcdb6..906ba61 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -1283,7 +1283,7 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
if (vibrate) {
notification.defaults |= Notification.DEFAULT_VIBRATE;
}
- notification.flags |= Notification.FLAG_NO_CLEAR;
configureLedNotification(notification);
mNotificationManager.notify(VOICEMAIL_NOTIFICATION, notification);
} else {
Remember to envsetup and lunch. Then you can patch and "mmm packages/apps/Phone", then copy the new Phone.apk (from out/) to the device.
4.4 update: For Android 4.4, it all changed:
- Modify packages/services/Telephony/src/com/android/phone/NotificationMgr.java
- mmm packages/services/Telephony/
- Install out/target/product/hammerhead/system/priv-app/TeleService.apk
Apr 1
KeePass NFC: Unlock your KeePassDroid database with NFC
I'm pleased to announce KeePassNFC, a stand-alone application which lets you use a rewritable NFC tag to unlock your KeePassDroid database. This is a follow-up to KeePassDroid: NFC Support (this is a better implementation of that same idea) and Idea: an NFC authentication scheme.
To use it:
- Install KeePassNFC: Play store
- Set up your NFC tag
- Unlock your password database to your heart's desire
To set up the tag, launch KeePassNFC:
Here you must select a database, and then, optionally, a keyfile and password. The options are hopefully self-explanatory. Press "Write NFC" and hold an NFC tag near your device to program it, and you're done.
Now, holding the tag near your device will automatically load KeePassNFC, which will decrypt your password using the data stored on the fob and launch KeePassDroid.
KeePassNFC is open source, and you may download the source code.
Questions:
- Why two separate apps? KeePassDroid has very few application permissions, which is good security practise. Using two separate apps means not having to give NFC permission to KeePassDroid itself.
- How secure is it? Reasonably. The NFC tag stores only random numbers, and the password itself is encrypted with those numbers. So an attacker would have to scan your NFC tag and either steal or root your Android device to get your password. If you suspect that your NFC tag has been read, you can use KeePassNFC to re-write it with new random values, rendering the previous information useless.
Update: A previous version of this blog included a custom version of KeePassDroid. I'm pleased to say that the current version of KeePassDroid in the Play store incorporates the required changes (technical: it supports being supplied a database password via an Intent), so my custom version isn't required. For the curious: here is the source code for the required changes.
This NFC implementation grew out of discussion on the KeePassDroid forums. You can view and add to that conversation at Google Groups' KeePassDroid forum.
Mar 9
KeePassDroid NFC support
Update: I reimplemented this as two separate apps, which is a bit nicer from a security perspective. Write-up and APK for the new version.
Just as I threatened in my previous post, I've implemented NFC support in KeePassDroid. This means that you can create an NFC tag which decrypts your database, no password required.
You'll need a spare, writeable NFC tag, such as one of these.
You'll also need to use my version of KeePassDroid:
KeePassDroid.apk | Source code on Github
Select a database as normal. When you get to the password screen, enter your password and press the new "NFC..." button.
You will be taken to the NFC writing activity:
Select "Write NFC" and place an NFC card on your device.
When you're done, you should be able to scan your NFC card and go directly to your password database from anywhere in Android.
Details on the security of this scheme are in the previous post. The short version is that it's okay if your NFC tag gets stolen or copied, and it's okay if your phone gets stolen, but if your NFC tag gets copied and your phone gets stolen you have a problem.
Note that you can rewrite the NFC tag as many times as you like. Each time you do, a new encryption key is generated. So if you lose an NFC tag, just write a new one and the previous tag immediately becomes useless.
Comments, questions, and bug reports welcomed. This has been minimally tested (on a Nexus 4) and I make no guarantees that it does anything at all. :)
Of course, I didn't write KeePassDroid. It's by Bryan Pellin and a lot of other contributors. Official site.
Good luck and enjoy!