Tuesday, November 22, 2011

Puzzle Pal: Swap letter and ROT 13

In The Game a couple weeks ago, one of the puzzles involves replacing a letter in a word to form another word. To my horror Puzzle Pal didn't know how to solve it! I quickly added a new solver and posted an update to the Android Market.

While I was at it, I realized that Puzzle Pal also didn't have a ROT 13 decoder, useful for geocaching, so I added that as well.

Enjoy!

Friday, November 18, 2011

Android: Protect ContentProvider with signature

I have been looking for secure ways for my Android apps to share data, and was looking into permissions. In particular, the signature level in android:protectionLevel looks really promising:

A permission that the system grants only if the requesting application is signed with the same certificate as the application that declared the permission. If the certificates match, the system automatically grants the permission without notifying the user or asking for the user's explicit approval.

The idea is to have a main app for displaying data, and multiple modules supplying the data. Permissions only work with one of the four application components: Activity, Service, ContentProvider, and BroadcastReceiver. ContentProvider is the logical choice for serving data.

Loading sqlite database from resource

It is a bit of a pain to write a ContentProvider, though. Since all I wanted was to test the permissions, I took a shortcut: I followed this tutorial and loaded a sqlite database from resource. To automate the database creation, I wrote a script to load the data from a tab-delimited file.

Permission setup

It took me many tries to get the permissions right. I know that the <provider> need to request the permission, but where do I declare it? I tried both in the module and the main app, but no luck, the main app could use the ContentProvider no matter how I signed the apps. Turns out it was a stupid error: I declared the permission with the <provider>, inside of the <application> block. It should go outside!

So the formula looks like this:

  • Declare the permission in the provider app
  • Request the permission in the provider app
  • Use the permission in the consumer app

When everything was setup properly, it was very satisfying to see my app throwing java.lang.SecurityException when I sign it with a non-matching certificate.

The code

I uploaded some sample code to github: http://github.com/chiuki/android-protected-provider. Hope you found it useful!

Monday, November 14, 2011

Grace Hopper Celebration: It's all about connections

As I am sitting in the Portland airport waiting for my flight back to San Francisco, I look back at the great times I had at the Grace Hopper Celebration last week. This is my third time attending GHC, and I always come back fully energized. What makes GHC so wonderful? It's all about connections.

Connecting to others like you

It can feel lonely being a woman in a male-dominated field like computer science. Simply being in the same venue with almost 3000 other women sends a very strong signal: you are not alone. As you sit in various sessions, you get to meet people in the same situation as you. You realize that you are a victim of the Imposter Syndrome, that everyone in the room also thought they got to where they are because they are lucky, not because they are good. You chat with the woman sitting next to you at lunch, making a deep connection because both of you are a few years into your job and unsure what to do next. You swap tips, you hear great advice, you share your stories, and you immerse yourself in the solidarity of your fellow women in computing.

Connecting to others unlike you

While it is energizing to meet people just like you, it is also empowering to see women thriving in so many different ways. You see a young professor doing groundbreaking research. You see a mother of six going back to school for a PhD and loving it. You see an executive taking the helm of a large corporation. You see an undergrad leading a non-profit project and making an impact. It shows you that success comes in many different sizes and shapes, and opens your eyes to the possibilities of greatness for yourself.

Connecting to yourself

When was the last time you took time to think about yourself and your career? At Grace Hopper Celebration, you step away from your daily responsibilities and think about the big picture. What I want to do? How do I get there? You are surrounded by amazingly supportive people, helping you recognize your achievements, hearing your fears and concerns, giving you tips and advice, and urging you to take charge of your future. You feel energized because you got to lift your head above the daily grind and see what's out there in the horizon. Your newfound connections let you know that you are not alone, that others before you have struggled and succeeded, and wherever you want to go, you will get there. It's a wonderful feeling.

Monday, November 7, 2011

Puzzle Pal: Recompiled for tablets

One of the first things I did after winning an Android tablet from the AT&T hackathon was to download Puzzle Pal. It worked, but was only rendering itself in a teeny tiny window in the middle. Time to recompile it with the latest SDK so it knows what to do with tablets.

I thought all I needed to do was to recompile, but it still didn't expand to fill up the whole space. Turns out I need to tell it not to run under compatibility mode for tablets in uses-sdk in AndroidManifest.xml:

<uses-sdk 
  android:minSdkVersion="3" 
  android:targetSdkVersion="12" />

And then I ran into another issue: the sudoku grid was not accepting inputs. Not quite sure what changed between the SDK versions, but now the view needs to implement TextWatcher and update the grid onTextChanged.

I didn't get a chance to optimize the UI for tablets, so the Braille decoder looks a bit silly. In any case, please grab the latest version from Android Market and let me know if you run into issues.