sudo apt-get install squashfs-tools bc gettext python-libxml2 genisoimage syslinux yasm
Sunday, November 17, 2013
AOSP Android-x86 build pre-requiste extras
For those building AOSP from android-x86.org (JB 4.3) project on Ubuntu 12.04 will need to install these additional requirements on top of those documented on source.android.com:
Thursday, May 30, 2013
To ubuntu: Respect my disk space!
So using a SSD means I get blazing performance for things like huge
compiles I need to do for AOSP or grep'ing through that huge codebase.
But it also means I don't exactly have huge amounts of disk space to spare so I was not too surprised when I started get low disk space wanring recently for my root partition - props to Ubuntu for doing this in such a nice way and giving direct access to the GUI tool to show disk usage.
What Ubuntu get less props for is for installing and then keeping on disk EVERY kernel update headers which were using over 2GB on my root partition!
A quick clean up was just a matter of:
sudo apt-get remove linux-headers-3.2.0-20*
sudo apt-get remove linux-headers-3.2.0-30*
sudo apt-get remove linux-headers-3.2.0-4[0-4]
I did those seperately because using sudo apt-get remove linux-headers-3.2.0-* seemed to also want to remove the linux-generic package which I wasn't sure would be a good idea.
PS. getting rid of the older kernel packages:
sudo apt-get remove linux-image-3.2.0-2[0-9]
freed up another 2GB!
But it also means I don't exactly have huge amounts of disk space to spare so I was not too surprised when I started get low disk space wanring recently for my root partition - props to Ubuntu for doing this in such a nice way and giving direct access to the GUI tool to show disk usage.
What Ubuntu get less props for is for installing and then keeping on disk EVERY kernel update headers which were using over 2GB on my root partition!
A quick clean up was just a matter of:
sudo apt-get remove linux-headers-3.2.0-20*
sudo apt-get remove linux-headers-3.2.0-30*
sudo apt-get remove linux-headers-3.2.0-4[0-4]
I did those seperately because using sudo apt-get remove linux-headers-3.2.0-* seemed to also want to remove the linux-generic package which I wasn't sure would be a good idea.
PS. getting rid of the older kernel packages:
sudo apt-get remove linux-image-3.2.0-2[0-9]
freed up another 2GB!
Tuesday, April 30, 2013
Intel N-6502 not sending data while connected to AP with WPA
Its been bugging me for a while now that I would intermittently have problems with my laptops intel N-6205 wifi card stop sending any data, even though it was correctly associated with an AP.
Then a few weeks ago I just accidentally noticed that it only actually happened when the laptop was running on battery power.
Finally today I remembered to have google around and first found this which lead me to here and so hey its an issue with the power management, even in intels windows drivers!
Finally I found: http://ubuntuforums.org/showthread.php?t=2058500
with the magic command:
sudo iwconfig wlan0 power off
(yes the command on the page misses including the network device name which of course is needed) and hey presto! no more failing to connect while on battery.
Now just need to add this to my init scripts and live with the slightly extra power draw on my 9cell!! extended battery.
Then a few weeks ago I just accidentally noticed that it only actually happened when the laptop was running on battery power.
Finally today I remembered to have google around and first found this which lead me to here and so hey its an issue with the power management, even in intels windows drivers!
Finally I found: http://ubuntuforums.org/showthread.php?t=2058500
with the magic command:
sudo iwconfig wlan0 power off
(yes the command on the page misses including the network device name which of course is needed) and hey presto! no more failing to connect while on battery.
Now just need to add this to my init scripts and live with the slightly extra power draw on my 9cell!! extended battery.
Wednesday, April 3, 2013
Logitech Linux Unification
Logitech has a great tech called "unifying" where a single usb wireless reciever can work with upto 6 compatible keyboards/mice. Of course the config utility is windows only but a quick google search gives the top result of a blog post with a simple handy c file and dead easy instructions on how to use it (in my case to pair a new K750 wireless keyboard).
And big thanks to the author of the utility Benjamin Tissoire, who posted it to the linux kernel mailing list.
Finally looks like the C util has a home along with a python frontend for it here.
And big thanks to the author of the utility Benjamin Tissoire, who posted it to the linux kernel mailing list.
Finally looks like the C util has a home along with a python frontend for it here.
Thursday, March 7, 2013
Selecting text in gnome terminal when using Tmux
TL;DR - hold down the shift key! Thanks to this post.
Sunday, September 30, 2012
Http stuff
the wikipedia article points out that the RFC952 forbids trailing hypens in domain names. Androids browser/webview enforce this, most other browsers (and heck DNS servers do not seem to bother)
The source code for the Apache HttpCore lib is not in the Androd SDK source package, so you need to get it direct from the AOSP git repo.
The source code for the Apache HttpCore lib is not in the Androd SDK source package, so you need to get it direct from the AOSP git repo.
Tuesday, August 28, 2012
Java Network Timeout handling
So this blog post (via stackoverflow as usual) points out that you need to manually handle timing out reads when using URLConnection and hence also HttpURLConnection.
The post also helpfully provides example code for such a manual timer:
The post also helpfully provides example code for such a manual timer:
try {
URLConnection con = urlObj.openConnection();
con.setConnectTimeout(5000);
con.setReadTimeout(5000);
new Thread(new InterruptThread(Thread.currentThread(), con)).start();
retVal = new Source(con);
} catch (IOException e) {
System.err.println("aborted parsing due to I/O: " + e.getMessage());
throw new IndexingException("aborted parsing due to timeout - " + aUrl);
}
public class InterruptThread implements Runnable {
Thread parent;
URLConnection con;
public InterruptThread(Thread parent, URLConnection con) {
this.parent = parent;
this.con = con;
}
public void run() {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
System.out.println("Timer thread forcing parent to quit connection");
((HttpURLConnection)con).disconnect();
System.out.println("Timer thread closed connection held by parent, exiting");
}
}
Monday, August 13, 2012
latest android sdk bug plus httpd
emulator in r20 segfaulting on a headless box without opengl.
the simple node based http static server to use:
https://github.com/nodeapps/http-server
to not have to use sudo anymore (on my laptop) to install node modules via npm globally (-g flag):
sudo chown -R username:group /usr/local/bin/
sudo chown -R username:group /usr/local/lib/
Monday, July 9, 2012
Android Http NPEs
Lovely...
Search google for a NPE from Androids Http package:
libcore.net.http.HttpConnection$Address.hashCode NPE
leads to bug report, which leads to another which finally points me to looking at my url closely and realising I typoed the protocol scheme. As the comment I left suggests, life would have been much clearer with a slightly more specific exception the a null pointer. Sigh.
Search google for a NPE from Androids Http package:
libcore.net.http.HttpConnection$Address.hashCode NPE
leads to bug report, which leads to another which finally points me to looking at my url closely and realising I typoed the protocol scheme. As the comment I left suggests, life would have been much clearer with a slightly more specific exception the a null pointer. Sigh.
Sunday, July 1, 2012
Android Emulator keyboard
Well this was a little time waster today:
Turns out that Android SDK r20 now defaults the hw.keyboard property to no.
This means that you will all of a sudden find that after upgrading to r20, keyboard entry (both physical and onscreen) will stop working in both existing and new AVDs.
So you need to set the property explicitly in each AVD config via the GUI or in:
.android/avd/MY_AVD_NAME.avd/config.ini
Turns out that Android SDK r20 now defaults the hw.keyboard property to no.
This means that you will all of a sudden find that after upgrading to r20, keyboard entry (both physical and onscreen) will stop working in both existing and new AVDs.
So you need to set the property explicitly in each AVD config via the GUI or in:
.android/avd/MY_AVD_NAME.avd/config.ini
Thursday, June 21, 2012
More Bash magic
set to automatically cd into a dir by typing its name:
shopt -s autocd
go back to previous pwd ($OLDPWD):
cd -
rename a path with a new suffix:
mv /var/www/test{,1}
Again all courtesy of my co-worker Ben.M
Tuesday, June 19, 2012
Android SDK Ant bugs
BEWARE: if you are using r15 of the Android SDK and building with a custom Ant post-build target then this bug might bite you! r17 through to r19 is confirmed as working ok.
Monday, June 11, 2012
Ubuntu UI Annoyances
If you find ubuntu new "on hover" osx-envy scrollbars as frustrating and annoying as I do you want to do:
sudo apt-get remove liboverlay-scrollbar*
(thanks to co-worker Ben M. for this super handy tip).
sudo apt-get remove liboverlay-scrollbar*
(thanks to co-worker Ben M. for this super handy tip).
Wednesday, May 23, 2012
Sunday, May 20, 2012
Git and Vim
Must remember to do to set the EDITOR shell env var to get nice git commit mesg highlighting everytime I do a OS re-install.
Tuesday, May 1, 2012
On Android Services, Threads and Exceptions
So it turns out that if you actually read the developer documentation carefully, "Services" in Android are not "background jobs" or "daemons" as you might expect from the name. No what they are is in fact simply a configuration mechanism to inform the Android OS that your application has work to do that can occur at times when your application Activities are not visible to the user.
Thus Services not only do not have their own separate Thread, but in fact are simply executed by your applications main thread, in response to events based on the service life-cycle. An important result of this is that within a Service or an Activity, all long-running jobs should be performed on a separate background as otherwise they will be run on the main thread.
The main source of confusion comes about because the Android developer documentation talks about Services being "killed" and restarted by the OS. But this actually simply referring to the process (i.e. the Linux process) which hosts each apps Dalvik VM and the fact that the OS can kill the process at anytime such as when memory is low. It's only in this case that Services would be "restarted" by the OS/Framework, but this of course only refers to the Services lifecycle callback methods (e.g. onCreate and onStartCommand) being called by your apps main thread after your app is restarted inside a new VM running within a new process. Once you understand this, the purpose of the "STICKY" flags then becomes obvious, as just being means to inform the framework how it should go about re-calling those callback methods after an app is restarted in a new VM.
An interesting result of all this is that there is no such thing as a Service "dying" in your app, except of course for the case of it throwing an uncaught exception, which would cause your apps main thread to exit and thus your whole app to "quit" bringing up the famous "Force Close" system dialog. Should you wish however to handle that situation, you have available to you the Thread.setDefaultUncaughtExceptionHandler() method which will allow you to catch unhandled exceptions and doing something useful (like logging them to the device storage or some external service) prior to your current foreground Activity existing.
Thus Services not only do not have their own separate Thread, but in fact are simply executed by your applications main thread, in response to events based on the service life-cycle. An important result of this is that within a Service or an Activity, all long-running jobs should be performed on a separate background as otherwise they will be run on the main thread.
The main source of confusion comes about because the Android developer documentation talks about Services being "killed" and restarted by the OS. But this actually simply referring to the process (i.e. the Linux process) which hosts each apps Dalvik VM and the fact that the OS can kill the process at anytime such as when memory is low. It's only in this case that Services would be "restarted" by the OS/Framework, but this of course only refers to the Services lifecycle callback methods (e.g. onCreate and onStartCommand) being called by your apps main thread after your app is restarted inside a new VM running within a new process. Once you understand this, the purpose of the "STICKY" flags then becomes obvious, as just being means to inform the framework how it should go about re-calling those callback methods after an app is restarted in a new VM.
An interesting result of all this is that there is no such thing as a Service "dying" in your app, except of course for the case of it throwing an uncaught exception, which would cause your apps main thread to exit and thus your whole app to "quit" bringing up the famous "Force Close" system dialog. Should you wish however to handle that situation, you have available to you the Thread.setDefaultUncaughtExceptionHandler() method which will allow you to catch unhandled exceptions and doing something useful (like logging them to the device storage or some external service) prior to your current foreground Activity existing.
Sunday, April 15, 2012
Automatic Android Release Builds with CI
So if you are using a CI server (eg. Hudson aka Jenkins) to build your Android app, when you come to release it you'll want to do that automatically too.
All thats required is this kind of stanza in your build.xml:
<property environment="env"/>
<target name="-post-build" >
<copy todir="bin">
<fileset dir="bin">
<include name="myappname-*.apk"/>
</fileset>
<globmapper from="myappname-*.apk" to="myappname-*.${env.BUILD_NUMBER}.apk"/>
</copy>
</target>
As you can see I'm also naming the final apk file with the Jenkins build number environment variable. There are a lot more other env vars that Jenkins sets that you can use.
Also note the reason I've used the globmapper is that this will work for both the debug and release build targets that are pre-defined in the standard android project ant build configs. This means you can have Hudson build configs for both debug and release.
If you want your release apk to be properly signed, you need to create a certificate and then point your ant build at it (ant.properties):
key.store=path/to/my.keystore
key.alias=mykeystore
If you don't want to type in the password for each build, you can add the following to your local.properties:
key.store.password=secretpasswd
key.alias.password=secretpasswd
And also add the passwd properties to your Jenkins config (click "Advanced" button in the "Invoke Ant" section of your build config). This way you never have to check your keystore passwords into version control.
Oh as a bonus, if you want to be able to access the build information within your apps code at runtime, you can stash this in a string value by putting something
like this in your build.xml:
<property environment="env"/>
All thats required is this kind of stanza in your build.xml:
<property environment="env"/>
<target name="-post-build" >
<copy todir="bin">
<fileset dir="bin">
<include name="myappname-*.apk"/>
</fileset>
<globmapper from="myappname-*.apk" to="myappname-*.${env.BUILD_NUMBER}.apk"/>
</copy>
</target>
As you can see I'm also naming the final apk file with the Jenkins build number environment variable. There are a lot more other env vars that Jenkins sets that you can use.
Also note the reason I've used the globmapper is that this will work for both the debug and release build targets that are pre-defined in the standard android project ant build configs. This means you can have Hudson build configs for both debug and release.
If you want your release apk to be properly signed, you need to create a certificate and then point your ant build at it (ant.properties):
key.store=path/to/my.keystore
key.alias=mykeystore
If you don't want to type in the password for each build, you can add the following to your local.properties:
key.store.password=secretpasswd
key.alias.password=secretpasswd
And also add the passwd properties to your Jenkins config (click "Advanced" button in the "Invoke Ant" section of your build config). This way you never have to check your keystore passwords into version control.
Oh as a bonus, if you want to be able to access the build information within your apps code at runtime, you can stash this in a string value by putting something
like this in your build.xml:
<property environment="env"/>
<target name="-pre-build">
<echo file="res/values/buildtag.xml"><![CDATA[<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="build_version">ABCXYZ123</string>
</resources>
]]>
</echo>
<replace file="res/values/buildtag.xml" token="ABCXYZ123" value="${env.BUILD_TAG}"/>
</target><echo file="res/values/buildtag.xml"><![CDATA[<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="build_version">ABCXYZ123</string>
</resources>
]]>
</echo>
<replace file="res/values/buildtag.xml" token="ABCXYZ123" value="${env.BUILD_TAG}"/>
Panel indicators for Unity
If you just want the system load indicator panel applet back just use this.
A whole lot more applets are listed in this answer.
A whole lot more applets are listed in this answer.
Tuesday, April 10, 2012
Html Notifications
Chrome has a simple API spec for doing "desktop notifications" from webpages. There's even a quasi-standard "editors draft" at the W3C for it.
Luckily someone has been nice enough to write a Firefox add-on to implement the API in Firefox (open source).
Unfortunately some sites such as Flowdock only sniff for the presence of the API in the DOM instead of actually doing a call to the API to ask user permission as suggested by the spec itself and so fails due to the different approach taken by the add0on vs the implementation in Chrome.
Luckily this is easily fixed by pre-approving Flowdocks url via a property in about:config
Luckily someone has been nice enough to write a Firefox add-on to implement the API in Firefox (open source).
Unfortunately some sites such as Flowdock only sniff for the presence of the API in the DOM instead of actually doing a call to the API to ask user permission as suggested by the spec itself and so fails due to the different approach taken by the add0on vs the implementation in Chrome.
Luckily this is easily fixed by pre-approving Flowdocks url via a property in about:config
key: extensions.html5notifications.permissions
value: {"www.210computing.com":0, "mydomain.flowdock.com" : 0}
Monday, April 9, 2012
Pretty JSON and Dark Ubuntu
Do get Eclipse using a dark theme to match dark background syntax highlighting plugin you need to set the gtk theme using myunity (from this answer on SO).
Pretty printing JSON with bash using just Python:
Using NodeJS and the pretty-data module to make a simple shell script.
Pretty printing JSON with bash using just Python:
Pretty JSON using an add-on in Firefox.echo '{"foo": "lorem", "bar": "ipsum"}' | python -mjson.tool
Using NodeJS and the pretty-data module to make a simple shell script.
Subscribe to:
Posts (Atom)