Archive for October, 2008

So I wonder which is more open? G1 or iPhone

At first blush, the G1 is obviously more open than the iPhone – open source platform, open SDK from day 1, and you can install software from anywhere just by selecting a menu option.

But this software runs in a Java sandbox. You don’t appear to have access to the operating system outside the sandbox.

And I have a jailbroken iPhone. I can ssh into my phone. I can use the phone without a SIM card (G1 goes into “emergency calls only” mode). I can modify startup scripts. I can write applications to do anything on the phone. I can change anything I want to on the phone, as a Simple Matter Of Programming. Is the G1 that open? Not the Android platform – the actual, G1 device in my hands…

Of course, as a platform, Android is much more open than iPhone OS. But the actual device? So far, I’m saying a jailbroken iPhone…

Leave a Comment

So I Compared a T-Mobile G1 vs an iPhone

I’ll continue to update this as I continue to learn about both phones, but I’ll start with some first impressions.

  • The G1 is noticeably bigger, but not bad.

    It’s bigger than the iPhone, bigger than my RAZR VR3, thinner than my wife’s old T-Mobile Wing, but way smaller than my Zaurus c860. It fits in a shirt pocket or pants pocket (though my wife is concerned about it being tight in her jeans pockets).

    It meets my size criteria, though I’d like it to be smaller – I forget the iPhone is in my pocket, not likely to forget the G1.

  • The bend of the G1 isn’t bad. I was really concerned from the pictures of the bent-up bottom of the phone, but you don’t notice it, it isn’t bad to hold either in portrait or landscape. Not a problem.
  • The iPhone screen is noticeably larger, and a bluer white. The G1 screen is brighter, and a bit warmer (more yellow) white.
  • Android needs a review of “small screen” mentality. Apple got this right (very right) in that whatever application is presenting content to the user gets the whole screen. Smaller-than-screen windows should be rare, and only for very small announcements.

    There are lots of places Android uses sub-screen windows, often presenting large amounts of content without making full use of the available screen real estate. This is present in basic functionality – like the Applications tab not using the whole screen – and applications using dialog boxes.

    You can really see this by going into the Settings|About section – all the Legal documents are presented in a centered dialog box, appearing over the background window, even though they have pages and pages of content. If you open the DMCA info, you get a web page that is scrolled horizontally half off this tiny dialog box because of navigation controls on the left side (but they’re not even visible because the page is scrolled down past them). Really obnoxious. Kudos to Apple.

    Oh, and one more example: setting up a Wireless access code. the G1 pops up a dialog box (again, smaller than screen size) for you to enter your key. And you have to open the keyboard, rotating to landscape mode, to enter it, because there is no onscreen touch keyboard. Then you type the key, and there is a half-exposed control at the bottom of the dialog box. If you scroll the dialog box up a bit, you can see that it is a checkbox to display the key as you’re typing it. If the dialog took advantage of the whole screen, you wouldn’t need to scroll to see this option.

  • Android is much less aware of its device than the iPhone is. No, I’m not trying to anthropomorphize the phones.

    When you tip the iphone, it (usually) rotates to landscape. Touch is integrated throughout the iPhone system, to go back, to select options, etc. You always interact by touching the screen.

    I haven’t found anything on the G1 that recognizes when I’m holding it landscape unless I open the keyboard. Then everything is landscape, even if I’m still holding the phone vertically. The only way to rotate the browser to landscape/wide-screen viewing is to open the keyboard.

    With Android, you go to the home screen by pushing the off-center home button. You get menus by pressing the menu button. You go back by pressing the back button. These functions are never presented on screen for a touch. I find myself constantly wondering, “How to I get back to that last window? Oh, yeah, the button”, whereas with the iPhone, it’s presented where your focus is, on the screen. I’m always forgetting what functions need the menu button, which need home, and which need back.

    Now, I realize that onscreen controls cost screen real estate (not as much as the “dialog boxes” do, though!). Maybe I’ll remember the G1 controls more naturally later, but for now, the physical buttons aren’t helping usability.

    And sometimes, things you really should be able to touch can’t be selected by touch – in the google legal information, you can’t touch-to-select a link until you’ve touched the trackball, then you can touch to select.

  • Apple’s browser is easier to use. The zoom & scroll is easier than the G1, thanks to the multitouch interface. Android could do better than its clunky buttons even without a touch screen, but for now it’s clunky.
  • To take a screenshot on an iPhone: hold down the “sleep” button and press and release the “home” button. It saves the screenshot to the Photos directory.

    To take a screenshot on the G1: connect the G1 via USB, install the SDK, run DDMS, select your handset, and press Ctrl-S, then save the image. (http://www.downloadsquad.com/2008/10/22/taking-screenshots-on-an-android-based-phone/) *sigh*

Comments (4)

So I Had to Force Reset (Shutdown) my G1

When I turned on my T-Mobile G1 phone this morning, it showed a picture of a big triangle with an exclamation point inside it, and a G1 lying flat on its back.

It was completely unresponsive.

I tried holding down the power-off (end) button, alone and in combination with the various other buttons, but didn’t find anything that drew a response. Plugging the phone in to a USB cable connected to a computer caused the computer to recognize there was a USB device.

I tried scanning the “Tips and Tricks” booklet that came with the phone. Nothing. The user manual? Nada.

Finally, consulting the modern Oracle of Delphi (Google, that is), I found the answer:

Solution: Hold the Home and Back buttons for a few seconds (nothing happens) then release (and the phone restarts).

*whew*

For what it’s worth, the battery level was at 5% when it completed rebooting. I guess the phone didn’t like having its battery get really low overnight?

Comments (2)

So I Got a Defective T-Mobile G1

Just after I got my iPhone, my wife heard the announcement of the T-Mobile G1. She knows I’m an open source kinda guy, and she’d heard me complain about the then-awful iPhone SDK agreement, so when she heard the announcement, she came down to my office and told me about it (I’d heard it already), and said, “This sounds just like you! You should get one and develop for it!” So I placed my preorder immediately. (Thanks, Sweetheart!)

When it arrived, I was delighted. Neat stuff, though I need to do a full review – the iPhone is definitely more polished at this point.

However, my particular phone had a small problem – a column of pixels about 15 pixels in from the left edge of the screen is defective.

This let me contact T-Mobile phone support on day 1 of the G1 event.

I spent about an hour on the phone (had to call from another phone, because the first representative told me they’d have to open up the phone, look under the battery, etc. – but they never did). I spoke with representatives from customer support (4), technical support or PDA support (2), and somebody dealing with returns but it was his first day and he eventually decided I’d been routed to him by mistake. My favorite line from him was, “How did you get it already?” (My answer: T-mobile shipped it to me??)

Anyway, T-mobile eventually came through and sent me a new G1, and it does not have the pixel issue, so I’m going to send the other one back RSN (Real Soon Now).

Thanks, T-Mobile!

kb

Leave a Comment

So I built an iPhone application in xCode without $99

I’m developing for the iPhone, and I even got a Macbook, but I don’t really want to start my $99/year until I’m ready to publish something to the AppStore. So, how do you develop with xCode for the iPhone, without an Apple Developer certificate?

  1. Download and install xCode and the SDK from the iPhone developer center. Run the installer.
  2. Create a self-signed certificate on your mac.

    Start Keychain Access: Open Finder, Utilities (shift-command-U), Keychain Access. Then Keychain Access, Certificate Assistant, Create a Certificate. Enter the name “iPhone Developer”, Self Signed Root, and check Let me override defaults. Continue, and Continue again – that you’re creating a self-signed certificate.

    Serial number 1 should be fine, make the validity period longer so you don’t have to mess with this again (3650 days sounds good…), and choose Certificate Type: Code Signing. Continue, enter an email address, I put “iPhone Developer” in the certificate information here, too, and then just hit Continue until it creates the certificate.

  3. Download a project of your choice from the Apple iPhone developer pages (I grabbed WhichWayIsUp). Open the .dmg and copy the files (or the .zip and extract the files) into a directory you can edit (I put it under $HOME/Documents).
  4. Open the xcode project file (or the project file from xcode).
  5. Turn off built-in code signing: open Project settings (Project | Project settings). Choose the Build tab. In the Code Signing section, for Any iPhone OS Device, erase the name “iPhone Developer” and leave it blank.
  6. The jailbroken iPhone still needs the code to be marked as “signed” (or the application gets killed on startup), so add a custom build step to sign the executable (you’ll need to do this for each project – and I haven’t found where to update it after adding it…):

    Download gen_entitlements.py and place it in $HOME/bin. Make it executable (chmod 755 $HOME/bin/gen_entitlements.py).

    Add the build step to execute gen_entitlements.py:

    Project | New Build Phase | New Run Script Build Phase

    Add the following script code (note that you need to update $HOME/bin depending on where you put gen_entitlements.py. You may also want to update the my.company text):

    export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
    if [ "${PLATFORM_NAME}" == "iphoneos" ]; then
    	$HOME/bin/gen_entitlements.py "my.company.${PROJECT_NAME}" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent";
    	codesign -f -s "iPhone developer" --resource-rules "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/ResourceRules.plist" \
    		 --entitlements "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent"  "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/"
    fi
    
  7. Choose the iPhone as the Active SDK: Project | Set Active SDK | Device – iPhone OS 2.1
  8. Build the project (command-B). If prompted, allow the use of the iPhone Developer key to sign the code. (I choose Always allow).
  9. Copy the built file to the iphone (update text as needed): scp -r ~/Documents/WhichWayIsUp/build/Debug-iphoneos/WhichWayIsUp.app root@miphone:/Applications
  10. Refresh the Springboard cache. You can do this in several different ways. Pick one:
    • Install or update an application via Cydia or AppStore
    • Use the Cydia application “Respring”
    • In the Cydia package “BossPrefs” touch the Power icon, then “Fast Respring”

  11. Your application should show up in the Springboard. Run it, and enjoy. (Or be disappointed that the box in WhichWayIsUp doesn’t rotate smoothly, but only switches to vertical/horizontal. *sigh*)

Much of the detail of this process and the gen_entitlements.py script came from Sylvain Munaut – Thanks! Note that I did not need to install the binary patches he lists at the end of his process.

Comments (11)

So I read the new Apple iPhone SDK Agreement

It’s much better than the old one.

Apple removed the non-communicate clauses (except you still can’t be first to disclose pre-release information).

Of interest, they also removed the “can only use the SDK on Apple-labeled hardware” clause. I had privately speculated that the tying of the Apple Market to Mac OS to Apple-labeled hardware would be a violation of anti-trust law – leveraging one monopoly to promote another monopoly (“tying”).

It looks like Apple has rescinded this tying arrangement, but retains the Mac OS license restriction to only use Mac OS on Apple-labeled hardware. I’ll have to address that sometime in another post, but I believe that restriction is invalid, as a monopoly tying arrangement in a contract of adhesion.

Leave a Comment

So I opened the Mac menus with the keyboard

I bought a used Macbook off eBay, to do iphone development. And ’cause I’ve been interested in the platform for a while.

Never used a Mac much before, and I’m trying to find all the keyboard shortcuts to keep my finger off the trackpad…

How do I access the menus with just the keyboard? Lifehacker gives the tip that you can do it with ctrl-f2 for the menu, and ctrl-f3 for the Dock. However on my Macbook, those affect sound & display, so you have to do ctrl-fn-f2 and ctrl-fn-f3. Contortionist, and it just opens the Apple (System) menu and you use arrow keys from there, but at least I don’t have to use the trackpad…

Comments (1)

So I had to force reset my iPhone (force shutdown/poweroff)

If your phone locks up, is unresponsive, and won’t go to sleep, etc., you probably need to reset it by forcing a shutdown. This happens occasionally with stock or jailbroken iphones, original and 3G. This crash may occur more frequently in low disk space conditions.

This isn’t a painful procedure and doesn’t lose your data – it just takes a minute.

Hold down the “home” and “sleep” buttons for several seconds (about 10). You may see the “Slide to poweroff” screen appear. The screen may go black. Don’t let go until you see the apple logo (or pineapple logo for jailbroken phones). Let go and wait a minute, and your phone will boot up normally.

kb

Leave a Comment

So I Found Ways to Develop for iPhone

To develop for the iPhone, you have a few choices:

Web applications

Advantages:

  • choose your tools, choose your development platform
  • can make it available to non-iPhone users
  • requires connectivity

Disadvantages:

  • requires a hosting provider
  • limited to safari interface (i.e., tap, rotate, two-finger scroll, pinch zooming, no accelerometer, little iphone glitz)

Toolkits available:

Additional tools/techniques:

  • Web clip bookmark icon create an icon for use in the home screen (hit + in Safari, then “Add to home screen”)
  • Data links allow you to encapsulate webapp and state in the URL. Provides a mechanism to save a “bookmarklet” (“webclip”) that encapsulates the application. If we can also sync back to the online application, that would complete the round-trip.
  • iPhone in Action book has discussion of tradeoffs of web vs native applications

Native applications via the Apple SDK

Advantages:

  • best tools available, including the simulator
  • access to all documented iPhone SDK features
  • publish your application in the AppStore
  • lots of books published or being written

Disadvantages:

  • iPhone only
  • Limitations on application functionality from iPhone SDK agreement (no interpreters, no plugins, …)
  • Requires Apple approval of application for listing in AppStore
  • Requires signing a non-disclosure agreement (NDA)NDA lifted!
  • requires Mac OS X as development platform

Toolkits available:

Native applications via the open source tools

Advantages:

  • no NDA to sign
  • develop on your platform of choice
  • full access to anything the community has discovered
  • (possibly more than the documented SDK)
  • you can even develop ON the iPhone

Disadvantages

Toolkits available:

So, there you have it. Three options.

What will you do?

Comments (1)

So I Don’t Like System.Net.HttpListener

…or at least, I disagree with a design choice made in a class it uses – System.Net.EndPointManager

Backstory (Exposition)

I’ve been doing some work with the generally excellent Dekiwiki. It’s a descendant of MediaWiki, of WikipediA fame. (Does anyone actually capitalize the “A” in WikipediA? I just noticed it on the logo on their website. Really. Never saw it before. Anyway, back to our, umm, backstory…)

Dekiwiki provides some neat extension capabilities, and a useful REST API, and a really cool web service framework. Oh, and it comes with a wiki, too.

Inciting Incident

But I noticed that the dekiwiki API process (running in mono) listens on all interfaces of its port – not just localhost:

netstat -anp | grep 8081
tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 31194/mono

Well, that was disturbing, because it means people from the Internet (you know, “bad guys”) can connect to this internal process.

Complications

There’s a configuration value that looks like it should limit it, in /etc/dekiwiki/mindtouch.host.conf:

# Port the API listens on
HTTP_PORT="8081"

# hostname to listen on
IP="127.0.0.1"

Rising Action

But it doesn’t.

Digging into the code (gotta love open source…), I found that it was just using the HttpListener class from Mono. HttpListener delegates to EndPointManager, which includes this code:

// Always listens on all the interfaces, no matter the host name/ip used.
EndPointListener epl = GetEPListener (IPAddress.Any, lp.Port, listener, lp.Secure);

Climax

And sure enough, some experimentation with IronPython and .Net on Windows

    from System.Net import *
    l=HttpListener()
    l.Prefixes.Add( "http://localhost:8080/" )
    l.Start()

showed that Microsoft works the same way.

netstatp -an | grep -B2 8080
[TCP] ipy.exe:3656
State: LISTENING
Local: 0.0.0.0:8080

*sigh*

Denouement

I can understand why – Microsoft wants the HttpListener class to work like virtual hosts in an HTTP 1.1 environment, so you can distinguish URL requests for different web applications by hostname, but that doesn’t mean the “bind sockets only to the appropriate interface” principle isn’t valuable, too.

But at least if you request something over that socket from an external host, you won’t match the specified URL prefix, so you’ll get an error. That’s something anyway. And you can always set up firewall rules to block the port…

kb

Comments (1)