git rm; application toast pool; G1 bug

Alright, I know I saw it somewhere. How do I get git to add deletion of files to the transaction (when I deleted them w/out git rm and don’t want to git rm the whole list of them)? Can’t find the original answer but Stack Overflow’s top answer works for what I want. When I’ve done all my other adds and find there’s a bunch of deleted files left over… “git add -u”

On to fun stuff. I thought it seemed a bit wasteful to create toasts over and over, so I created a toast pool.

    // repository for created toasts
    private Map<Long,Toast> mToasts = new HashMap<Long,Toast>();
    private static final Long TOAST_LOG_DELETED = new Long(R.string.log_entry_deleted);
    private static final Long TOAST_LOG_CREATED = new Long(R.string.new_log_entry);
    protected void showToast(Long id) {
        Toast t = mToasts.get(id);
        if(t==null)
            mToasts.put(id, (t = Toast.makeText(this, id.intValue(), Toast.LENGTH_SHORT)));
        t.show();
    }

Initially I put this in an Activity that was creating a lot of toasts… then I thought, why not do this application-wide? Then if I need to show a toast with an Activity that’s finish()ing, it’ll still show. Plus better to have just one implementation and pool. So I put it in my Application object (WhenDidI) and the constants in my constant class (C). Now my toast calls look like this:

    ((WhenDidI) getApplication()).showToast(C.TOAST_LOG_DELETED);

A little wordy, but otherwise – good idea, no?

Asked my first question on StackOverflow yesterday. Seeing a bug with TimePicker apparently only on my G1. I’ll probably figure something out…

Most things in WhenDidI work as expected at this point, so I’m going to start getting familiar with styles and applying them everywhere. About time. This is a great post to help with understanding how styles are used in Android.

Advertisements

still kicking around eclipse problems [resolved?]

I don’t know what I did to deserve this :-) I think installing jpackage RPMs on my system was a mistake.

Java people seem to be perfectly happy to download a zip for eclipse, tomcat, etc. and just use that. So every user on a system gets their own copy? That’s just not how i’m used to doing application installs. (Anyway I tried it and had even weirder problems.)

I like to do things “the right way” with Fedora. I try to use yum to resolve all of my dependencies rather than go around installing things from source. Because if you have a package manager, you kind of need to let it be in charge, or the dependencies will bite your ass later. Right?

Jpackage is a valiant effort to bundle java dependencies into something that yum can consume. In particular it provides a compatibility RPM that sets up alternatives properly for the sun jdk rpm. It also has tomcat and other java notables. I don’t know much about the project other than that. I don’t remember why I added the repo initially, perhaps I was just hoping to get the compat RPM that way since I can’t seem to find one to match the current sun jdk on the site (still can’t – had to set up alternatives manually). but as jpackage seems to provide bleeding-edge stuff it’s replaced standard fedora rpms and won’t budge without a whole slew of updates being performed. i turned off the repo entirely after some of the scary suggestions and conflicts yum made with it.

So, fast forward to my eclipse/android problems. i kept getting an error about dependencies when i tried to install the eclipse ADT plugin – and not matter what software sites i enabled or RPMs I installed, it persisted. it was complaining about lucene (why this should be a dependency for what i’m doing? don’t know, but that’s the nature of these things). so eventually i thought maybe the real problem was that there was a conflict with RPMs i’d installed for dependencies blocking what eclipse was actually looking for. i found that i had lucene RPMs installed from jpackage which fedora itself offered, so i wanted to see what happened when i used the fedora versions.

This is where yum gave me problems.

Setting up Yum Shell
> remove lucene
Setting up Remove Process
> run
--> Running transaction check
---> Package lucene.noarch 0:2.4.1-5.jpp6 set to be erased
--> Processing Dependency: lucene for package: 1:openoffice.org-core-3.1.1-19.14.fc12.i686
--> Processing Dependency: lucene >= 2.3.1-3.4 for package: 1:eclipse-platform-3.5.1-22.fc12.i686
--> Processing Dependency: lucene = 2.4.1-5.jpp6 for package: lucene-contrib-2.4.1-5.jpp6.noarch
--> Running transaction check
---> Package eclipse-platform.i686 1:3.5.1-22.fc12 set to be erased
[...]
--> Finished Dependency Resolution
==============================================================================================
 Package                           Arch     Version                         Repository   Size
==============================================================================================
Removing:
 lucene                            noarch   2.4.1-5.jpp6                    installed   1.7 M
Removing for dependencies:
 eclipse-dltk                      noarch   1.0.0-3.fc12                    installed   6.8 M
 eclipse-dltk-ruby                 noarch   1.0.0-3.fc12                    installed   1.7 M
 eclipse-gef                       noarch   3.5.1-2.fc12                    installed   1.7 M
 eclipse-jdt                       i686     1:3.5.1-22.fc12                 installed    25 M
 eclipse-jgit                      noarch   0.6.0-0.1.git20091029.fc12      installed   741 k
 eclipse-platform                  i686     1:3.5.1-22.fc12                 installed    31 M
 lucene-contrib                    noarch   2.4.1-5.jpp6                    installed   864 k
 openoffice.org-brand              i686     1:3.1.1-19.14.fc12              installed   1.3 M
 openoffice.org-calc               i686     1:3.1.1-19.14.fc12              installed    61 k
 openoffice.org-calc-core          i686     1:3.1.1-19.14.fc12              installed    22 M
 openoffice.org-core               i686     1:3.1.1-19.14.fc12              installed   220 M
 openoffice.org-impress            i686     1:3.1.1-19.14.fc12              installed    58 k
 openoffice.org-impress-core       i686     1:3.1.1-19.14.fc12              installed   3.8 M
 openoffice.org-presenter-screen   i686     1:3.1.1-19.14.fc12              installed   3.7 M
 openoffice.org-writer             i686     1:3.1.1-19.14.fc12              installed    73 k
 openoffice.org-writer-core        i686     1:3.1.1-19.14.fc12              installed    17 M
Transaction Summary
==============================================================================================
Remove       17 Package(s)
Reinstall     0 Package(s)
Downgrade     0 Package(s)
Is this ok [y/N]:

Evidently lucene is a dependency for a multitude of eclipse and openoffice RPMs, so I didn’t want to just remove them – it would take me a long time to re-download and re-install all the RPMs once I’d updated lucene. And it shouldn’t be necessary.

To do things “the yum way” I would need to remove and replace them in one transaction. The Fedora versions are lower than the JPP versions so I tried a downgrade (I think this is new in F12).

> downgrade lucene lucene-contrib
> run
[nothing happens]
> Leaving Shell

I tried creating a transaction with a remove and install.

> remove lucene lucene-contrib
Setting up Remove Process
> install lucene lucene-contrib
Loading mirror speeds from cached hostfile
 * fedora: mirrors.rit.edu
 * rpmfusion-free: mirrors.tummy.com
 * rpmfusion-free-updates: mirrors.tummy.com
 * rpmfusion-nonfree: mirrors.tummy.com
 * rpmfusion-nonfree-updates: mirrors.tummy.com
 * updates: mirrors.rit.edu
Setting up Install Process
> run
--> Running transaction check
---> Package lucene.i686 0:2.3.1-5.5.fc12 set to be updated
---> Package lucene.noarch 0:2.4.1-5.jpp6 set to be erased
---> Package lucene-contrib.i686 0:2.3.1-5.5.fc12 set to be updated
---> Package lucene-contrib.noarch 0:2.4.1-5.jpp6 set to be erased
--> Finished Dependency Resolution
==============================================================================================
 Package                  Arch             Version                  Repository           Size
==============================================================================================
Installing:
 lucene                   i686             2.3.1-5.5.fc12           fedora              1.7 M
 lucene-contrib           i686             2.3.1-5.5.fc12           fedora              763 k
Removing:
 lucene                   noarch           2.4.1-5.jpp6             installed           1.7 M
 lucene-contrib           noarch           2.4.1-5.jpp6             installed           864 k
Transaction Summary
==============================================================================================
Install       2 Package(s)
Upgrade       0 Package(s)
Remove        2 Package(s)
Reinstall     0 Package(s)
Downgrade     0 Package(s)
Total size: 2.4 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Error: Transaction Check Error:
  package lucene-contrib-0:2.4.1-5.jpp6.noarch (which is newer than lucene-contrib-0:2.3.1-5.5.fc12.i686) is already installed
  package lucene-0:2.4.1-5.jpp6.noarch (which is newer than lucene-0:2.3.1-5.5.fc12.i686) is already installed

I think finally I tried “the RPM way” and removed them –nodeps and reinstalled them with yum (which of course complained about the RPM DB changing underneath it). Yum is intended to take over all system package management and do everything that RPM could do before, so what’s the way to serve this case?

Anyway, I eventually gave up on that installation – something else was still wrong after that – and moved over to my current installation which has no jpackage whatsoever. It seems to be working fine. Sorry jpackage folks, I don’t know what you’re doing but it doesn’t seem to work for me and I never want to mix repos like that again. I got so frustrated with the kinds of problems I saw I must have taken a year off my life. Have you ever clicked on a button to proceed and had NO response? No progress, no freezing up, no error, just… nothing, as if the button had no listener? Well I don’t know how it’s possible for normally functional software to be broken like that because of dependencies but I’ve had enough of it.

DDMS on Fedora; android screencast

I wasn’t looking forward to dealing with this kind of thing to get Android DDMS connected to a device on Fedora. Getting Ubuntu working was fairly straightforward after some Google-ing, but it didn’t sound like everything was just right on Fedora yet. However Fedora is what I’m happiest with, and having the SDK bridge working is a prerequisite for getting screen shots or screen casts from a device (useful for presenting), so I finally sat down and tried it out. Imagine my pleasant surprise to find that in Fedora 12 (at least) there’s a simple workaround: run adb as root (i.e. via sudo). Only adb has to run as root; then the device is available to the console user. This is still less than ideal but it’s good enough for me. This post is a good summary of the issues.

Onward, then, to androidscreencast. This works as advertised. It’s too bad you need to root the device to control it remotely, but mostly I’m interested in using this to make the tiny display on a device visible via a projector, so I don’t care much about remote control. For my purposes, the only problem is dealing with orientation; I stretched out the display and changed orientation a few times and a runtime exception was thrown. I guess, just don’t do that for now, and “patches welcome” no doubt. And the framerate isn’t great. But for my purposes this is quite useful. Sure would be better on YouTube than those crappy video zoom-ins on the device. And loads better for presenting something on the phone to a group.

Viewing source in eclipse with Android SDK (the easy way)

Forgot to mention, I finally got that article up on viewing source in Eclipse. I found the resources on how to do it weeks ago but wanted to write it up properly with screenshots and everything and was too busy! Anyway it’s over here:

http://android.opensourceror.org/2010/01/18/android-source/

I have a few things yet to do though:

  • This gives some hints on getting exactly the right version of source as opposed to a branch
  • Need to alter my published sources to comply with the license (oops)
  • Move the images and downloads to better hosting :-/

In other news, I need to look through this thread and see if I can get debugging a device to work in Fedora 12.

rooting my G1 and flashing to CyanogenMod

My old G1 with a cracked screen is good for something: trying out the root/mod procedures without worries :-)

First, to root: Downgrade phone

First thing to say is that you really do need to format the SD card. The phone wouldn’t find the firmware image with other stuff on the card. Also note that you gotta umount the phone device on the host before you can repartition the card from the host. gparted didn’t want to format the card as it was – it comes with one big partition at the root, gparted wanted to create a partition table and a partition so i let it.

I got the four colored horizontal bars, installed the update. Evidently there’s no “proper” way to turn the phone off from this mode – buttons do nothing – so I just remove battery/power.

The phone of course comes up freshly installed and w/ no SIM card it won’t activate. So I pop in the Sim card from my newer G1 and use that. I use the same Google account to activate, hope that’s no problem. Wish it would let me turn on wifi, would be a lot faster than edge. But OK, we’re set.

I’m sadly reminded of how responsive the phone was at this point, and how unresponsive my new phone is now with all the updates and installs. But OK, that’s why I’m doing this in the end.

Next, installing the … installer.

So I ran telnetd and used the telnet put the cm-update img on my SD card, but ls /sdcard doesn’t show anything there (and yes, I umounted from the host). netstat on the phone shows an IP address but I can’t telnet to it from my host, which sucks. It will ping but not accept telnet, weird. Hm, and after that ping, now it’s working, WTF. WEEEEIIRD. But at least now I don’t have to type on the phone keyboard.

So there’s nothing in /sdcard. I looked around and found a random article that showed what device is used for the sdcard, and mounted it manually. I assume the reason it didn’t mount itself is because of the new partition structure. Here’s what I did:

# mount -t vfat /dev/block/mmcblk0p1 /sdcard/
# ls /sdcard
DREAIMG.nbh
cm-recovery-1.4.img

Looks good. Something tells me that using a remote machine to run the self-flash routine may not be the greatest idea, so i use the on-phone telnet for that. Maybe if I’m brave I’ll try it the other way sometime. Or I’ll figure out how to do all this in an emulator.

Ran flash_image, the lack of feedback is disconcerting but OK. Took no time at all, I guess this was a minor thing I could’ve done remotely.

Now to get the files for the actual OS image.

I downloaded DRC83_base_defanged and checked the MD5 sum (downloads get corrupted and I don’t wanna brick the thing). Deleted the other files on the SD card. Download latest version of CM, checked MD5 sum. Downloaded the radio thing, no md5sum to check, doh.

Now the actual flashing of the firmware. This goes as described until the end. It was showing the box opening up to the phone for a LOOONG time. I asked on IRC if this was normal and they said not, but that status indicated it was likely doing the radio update. Pressing Home + Red (End) got me back to the recovery menu. I don’t remember what all I did there – I think I retried “Apply images”, I know I rebooted at least once and got the menu back or the box-to-phone screen. Eventually I chose the “reboot” option from the menu, and it started booting the CyanogenMod screen so I knew I was at least not too bad off.

(08:05:00 AM) sosiouxme: looks good. how do i tell if the radio update worked?
(08:05:25 AM) PsychoI3oy: sosiouxme, settings->about phone
(08:05:37 AM) PsychoI3oy: for baseband version the first number after the _ should be a 2

It was. So evidently I’m good. Very relieved, could’ve been bricked.

For some reason I can’t mount the SD card on the phone. Going to move it back to my stock phone and write its original image back over it if I can. Should be fun fiddling with CM and maybe I can show it tonight at Android meetup.

back in the saddle… (?)

Hoo boy have I been busy, mostly too busy to track it here. Found some actual contract work – well, if I could just get a signed contract. And also have been exploring Spring for a potential job offer. But my tech-fu has been failing left and right, don’t know what happened!

My trouble started a week ago when I went to my Android hack night and Eclipse on my laptop wouldn’t even bring up any editors. At the time I thought it was somehow related to the STS (SpringSource Tool Suite) I had installed (it’s another eclipse distro) but now I doubt it was related; there had been a number of other system updates and I think some of them caused problems, though I’m still at this date unclear what happened. I installed an entire parallel Fedora 12 system reusing my home directory but not introducing all the rpmfusion/jpackage stuff and it seemed to do better with Android but I ended up monkeying around with .eclipse and eclipse-workspace/.metadata until I’m not sure what I did anymore. All the while switching back and forth between the two OS installs did wonders for my firefox config. I *think* it’ll play Flash again now.

In the midst of all that I was trying to get work done and try out Spring. STS gave me fits, and I’m really not sure how much of it is STS/Java and how much was related to other issues was having. I stopped trying to figure things out on the notebook after a while, but I tried STS on Ubuntu and on WinXP and the best I could get it to was that it would build the examples and deploy them to tomcat, but this might not work after the first time, and half of my projects were riddled with all kinds of dependency problems. Dependencies in Java are a nightmare. I’m sure if I sat in a cube next to some gurus for a few days, they’d get my system in shape. But having to figure it out alone is infuriating.

But the fun did not end there. My laptop started acting really odd yesterday; stopped being able to open applications and such. I rebooted and the shutdown had lots of complaints about stuff that was refusing to unmount and such. After reboot I couldn’t log in graphically. I got to a place where it was trying to login and stuck, and I couldn’t switch to any consoles so had to do a hard stop, and of course when it rebooted I was nailed with fsck (for BOTH installs of Fedora now). Then I was fiddling with it and started getting messages about “can’t modify (foo) – read-only filesystem” – this was for BOTH the OS and home partitions. From what I could gather in /var/log/messages, the OS started having problems with the filesystems and just remounted everything to read-only – have never seen this before. I rebooted (more scary umount msgs) and applied some Fedora updates, hopefully those may improve things, or I may just have a hardware problem and need a new drive or something. That’s doable but what a pain. I also noticed on the latest reboot that firefox is spawning off numerous gtk-gnash instances that burn CPU for two flash movies in my tabs that I’m not even playing. Killed them all but that really should not be happening. So not too confident in laptop still :-(

Agenda for today: root my old G1, try out CyanogenMod on it, and see if I can get androidscreencast going.

dropping in for a minute

Android is just different: guess I have the advantage of just never having worked on those platforms before :-)

Also very excited to see Calculon – a Java DSL for Android Activity testing – Awesome – just when I thought nobody cared about TDD on Android.

Been super busy and will continue to be for a while. Only had a few minutes to drop in. But I guess that’s better than sitting around bored!