<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Et-Setera</title>
	<atom:link href="http://www.setera.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.setera.org</link>
	<description>Ramblings of a geek</description>
	<lastBuildDate>Mon, 04 Mar 2013 01:44:58 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Ubuntu 12.10 Screen Brightness on Sony VAIO T15</title>
		<link>http://www.setera.org/2013/03/03/ubuntu-12-10-screen-brightness-on-sony-vaio-t15/</link>
		<comments>http://www.setera.org/2013/03/03/ubuntu-12-10-screen-brightness-on-sony-vaio-t15/#comments</comments>
		<pubDate>Mon, 04 Mar 2013 01:44:00 +0000</pubDate>
		<dc:creator>Craig Setera</dc:creator>
				<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.setera.org/?p=691</guid>
		<description><![CDATA[I recently picked up a new Sony VAIO T15 ultrabook laptop. A really nicely designed laptop for a good price. After repartitioning, I was able to install Ubuntu 12.10 in a dual-boot arrangement fairly easily and Ubuntu worked well out of the box. However, screen brightness controls using Gnome power manager did not work out [...]]]></description>
				<content:encoded><![CDATA[<p>I recently picked up a new Sony VAIO T15 ultrabook laptop. A really nicely designed laptop for a good price. After repartitioning, I was able to install Ubuntu 12.10 in a dual-boot arrangement fairly easily and Ubuntu worked well out of the box. However, screen brightness controls using Gnome power manager did not work out of the box and I had to to some hacking to get at least a bit of control.<br />
<span id="more-691"></span></p>
<h2>Background</h2>
<p>Normally, the backlight brightness is controlled via the /sys/class/backlight/acpi_video0 ACPI interface. However, the Intel video driver installs its controls as /sys/class/backlight/intel_backlight. This mismatch causes Gnome power management to fail to operate on this laptop.</p>
<h2>Short-term Solution</h2>
<p>While there are a number of different potential solutions on the internet, I was unable to get any of those to work as-is. The closest I came was with the solution list <a href="http://ubuntuforums.org/showthread.php?t=2033273&amp;page=2">here</a>. However, the keyboard shortcuts didn&#8217;t seem to work. Using those scripts, I was able to roll my own solution.</p>
<h3>Scripts</h3>
<p>Based on the solution listed above, I created two script files.</p>
<p><b>~/bin/brightdown.sh</b><br />
<code><br />
#!/bin/bash</code></p>
<p>curr=`cat /sys/class/backlight/intel_backlight/actual_brightness`<br />
if [ $curr -gt 0 ]; then<br />
curr=$((curr-610));<br />
echo $curr &gt; /sys/class/backlight/intel_backlight/brightness;<br />
fi</p>
<p><b>~/bin/brightdown.sh</b><br />
<code><br />
#!/bin/bash</code></p>
<p>curr=`cat /sys/class/backlight/intel_backlight/actual_brightness`<br />
if [ $curr -lt 4882 ]; then<br />
curr=$((curr+610));<br />
echo $curr &gt; /sys/class/backlight/intel_backlight/brightness;<br />
fi</p>
<p>Note that I placed these scripts in my personal <b>bin</b> folder rather than /etc/acpi. Each of the scripts must also be made executable.</p>
<h3>Root Access When Necessary</h3>
<p>Writing to the ACPI interface in the <code>/sys</code> folder requires root access. In order to avoid having to use <code>su</code> or <code>sudo</code> with a password in order to invoke these commands, the sudoers file can be configured to allow root execution without password for <i>just these commands</i>.</p>
<p>Using the <code>visudo</code> command, alter the sudo file as follows:</p>
<p><code><br />
username ALL=NOPASSWD: /home/username/bin/brightdown.sh<br />
username ALL=NOPASSWD: /home/username/bin/brightup.sh<br />
</code></p>
<p>where <i>username</i> is the name of the user to be given root access without a password to those commands.</p>
<h3>Keyboard Shortcuts</h3>
<p>As I was unable to get the standard keyboard shortcuts to work correctly with any of the suggested, I chose instead to create my own keyboard shortcuts. After installing, <a href="https://code.google.com/p/autokey/wiki/Overview">autokey</a>, I was able to create my own shortcuts for decreasing and increasing the brightness using the above scripts. In my case, I chose Ctrl+Shift+- to decrease the brightness and Ctrl+Shift++ to increase the brightness.</p>
<p>Using the autokey application, choose <i>New -&gt; Script</i>. Enter the name &#8220;Brightness Down&#8221;. Enter the command:</p>
<p><code>system.exec_command("sudo /home/username/bin/brightdown.sh")</code></p>
<p>and set the Hotkey to Ctrl+Shift+-.</p>
<div id="attachment_696" class="wp-caption aligncenter" style="width: 755px"><a href="http://www.setera.org/wp-content/uploads/2013/03/brightdown.png"><img class="size-full wp-image-696" alt="Decrease Brightness" src="http://www.setera.org/wp-content/uploads/2013/03/brightdown.png" width="745" height="639" /></a><p class="wp-caption-text">Autokey set up to decrease brightness</p></div>
<p>Do the same for increase the brightness, using the other script file.</p>
<h2>Longer Term Solution</h2>
<p>There is some hope according to <a href="https://bugs.launchpad.net/ubuntu/+source/linux/+bug/954661">Ubuntu Bug 954661</a> that this problem will be fixed via a kernel fix in the upcoming 13.04 Ubuntu release.  If that happens, I will be able to remove these simple workaround.  For the short-term though this works reasonably well.  The primary missing feature is auto-dimming the screen for power savings.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.setera.org/2013/03/03/ubuntu-12-10-screen-brightness-on-sony-vaio-t15/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pinpointing Android LocationManagerService Battery Drain</title>
		<link>http://www.setera.org/2012/09/10/pinpointing-android-locationmanagerservice-battery-drain/</link>
		<comments>http://www.setera.org/2012/09/10/pinpointing-android-locationmanagerservice-battery-drain/#comments</comments>
		<pubDate>Tue, 11 Sep 2012 02:16:30 +0000</pubDate>
		<dc:creator>Craig Setera</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://www.setera.org/?p=675</guid>
		<description><![CDATA[Recently, I was seeing severe battery drain on my Samsung Galaxy SII. Using the most awesome BetterBatteryStats application I was able to see that my phone was not being able to go into deep sleep due to WakeLocks from the LocationManagerService. Android&#8217;s LocationManagerService, is responsible for managing LocationProviders and issues location updates and alerts. If [...]]]></description>
				<content:encoded><![CDATA[<p>Recently, I was seeing severe battery drain on my Samsung Galaxy SII.  Using the most awesome <a href="https://play.google.com/store/apps/details?id=com.asksven.betterbatterystats">BetterBatteryStats</a> application I was able to see that my phone was not being able to go into deep sleep due to WakeLocks from the <em>LocationManagerService</em>.  Android&#8217;s <em>LocationManagerService</em>, is responsible for managing <em>LocationProviders</em> and issues location updates and alerts.  If applications are requesting location updates too frequently, the <em>LocationManagerService</em> may be forced to keep the phone awake to provide those updates.<br />
<span id="more-675"></span><br />
It is possible using the <em>dumpsys</em> command via the <em>adb shell</em> to find out which applications are currently requesting location updates.  For instance:</p>
<blockquote><p>adb shell dumpsys > /path/to/dumpsys.txt</p></blockquote>
<p>will collect the output of the <em>dumpsys</em> command run on the connected device into the specified file.  Looking in the output from <em>dumpsys</em> the <em>LocationManagerService</em> dumps into a section</p>
<blockquote><p>DUMP OF SERVICE location:</p></blockquote>
<p>Within that section, there are a number of LocationListeners that look something like</p>
<blockquote><p>    Receiver{419e7ad0 Listener android.os.BinderProxy@41b8abd0}mUpdateRecords: {passive=UpdateRecord{421e75a0 mProvider: passive mUid: 10084}}:<br />
      passive:<br />
        UpdateRecord{421e75a0 mProvider: passive mUid: 10084}<br />
        mProvider=passive mReceiver=Receiver{419e7ad0 Listener android.os.BinderProxy@41b8abd0}mUpdateRecords: {passive=UpdateRecord{421e75a0 mProvider: passive mUid: 10084}}<br />
        mMinTime=0 mMinDistance=0.0<br />
        mSingleShot=false<br />
        mUid=10084<br />
        mLastFixBroadcast:<br />
          mProvider=network mTime=1346849822124<br />
          mLatitude=44.0836108 mLongitude=-92.5067299<br />
          mHasAltitude=false mAltitude=0.0<br />
          mHasSpeed=false mSpeed=0.0<br />
          mHasBearing=false mBearing=0.0<br />
          mHasAccuracy=true mAccuracy=20.0<br />
          mExtras=Bundle[mParcelledData.dataSize=148]<br />
        mLastStatusBroadcast=0
</p></blockquote>
<p>This UpdateRecord is particularly bad because it is requesting constant updates:</p>
<blockquote><p>mMinTime=0 mMinDistance=0.0</p></blockquote>
<p>The <em>mUid</em> specifies the process identifier requesting the updates.  The processes are dumped within the same output and can be found in the section beginning:</p>
<blockquote><p>ACTIVITY MANAGER RUNNING PROCESSES (dumpsys activity processes)</p></blockquote>
<p>Each application is listed separately by process identifier:</p>
<blockquote><p>  *APP* UID 10084 ProcessRecord{41af23e8 13037:com.google.android.apps.maps:LocationFriendService/10084}<br />
    class=com.google.googlenav.android.AndroidGmmApplication<br />
    dir=/data/app/com.google.android.apps.maps-1.apk publicDir=/data/app/com.google.android.apps.maps-1.apk data=/data/data/com.google.android.apps.maps<br />
    packageList=[com.google.android.apps.maps]<br />
    compat={240dpi always-compat}<br />
    thread=android.app.ApplicationThreadProxy@42457df0 curReceiver=null<br />
    pid=13037 starting=false lastPss=0<br />
    lastActivityTime=-6m23s226ms lruWeight=-50901 serviceb=false keeping=false hidden=true empty=true<br />
    oom: max=15 hidden=12 curRaw=12 setRaw=12 cur=12 set=12<br />
    curSchedGroup=1 setSchedGroup=1 systemNoUi=false trimMemoryLevel=0<br />
    hasShownUi=false pendingUiClean=false hasAboveClient=false<br />
    setIsForeground=false foregroundServices=false forcingToForeground=null<br />
    persistent=false removed=false<br />
    adjSeq=3891 lruSeq=535<br />
    lastWakeTime=0 time used=0<br />
    lastCpuTime=20 time used=+20ms<br />
    lastRequestedGc=-6m28s504ms lastLowMemory=-6m28s504ms reportLowMemory=false<br />
    conProviders={ContentProviderRecord{418add48 com.android.providers.settings.SettingsProvider}=1}<br />
    receivers=[ReceiverList{41a84148 13037 com.google.android.apps.maps:LocationFriendService/10084 remote:41a83f70}]
</p></blockquote>
<p>With this information we have our culprit.  Process identifier 10084 is Google&#8217;s LocationFriendService (Latitude).  This process is requesting constant location updates and causing severe battery drain.  In this particular case, I was able to go through the Latitude settings and disable everything related to location updates.  With those settings disabled and a quick restart, my battery drain went back to normal again.  Hopefully this information may be helpful to others having battery drain issues related to location updated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.setera.org/2012/09/10/pinpointing-android-locationmanagerservice-battery-drain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EclipseME Lives!</title>
		<link>http://www.setera.org/2012/07/01/eclipseme-lives/</link>
		<comments>http://www.setera.org/2012/07/01/eclipseme-lives/#comments</comments>
		<pubDate>Sun, 01 Jul 2012 19:58:18 +0000</pubDate>
		<dc:creator>Craig Setera</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[EclipseME]]></category>
		<category><![CDATA[Mobile Tools for Java]]></category>

		<guid isPermaLink="false">http://www.setera.org/?p=663</guid>
		<description><![CDATA[When I started hacking on EclipseME way back in 2001, I never would have guessed that it would still be going in 2012 in use in the form of the Eclipse Mobile Tools for Java (MTJ) project and a shipping product. A few days ago, Gorkem Ercan of Nokia announced that the latest version of [...]]]></description>
				<content:encoded><![CDATA[<p>When I started hacking on <a href="http://www.eclipseme.org">EclipseME</a> way back in 2001, I never would have guessed that it would still be going in 2012 in use in the form of the <a href="http://www.eclipse.org/mtj/">Eclipse Mobile Tools for Java (MTJ)</a> project and a shipping product.  A few days ago, Gorkem Ercan of Nokia announced that the <a href="http://www.gorkem-ercan.com/2012/06/new-ide-based-on-eclipse-mtj.html">latest version of Nokia SDK for Java is now based on Eclipse MTJ</a>.  Even though I don&#8217;t really spend any time on the MTJ project these days, it is very cool to see the software still being put to good use.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.setera.org/2012/07/01/eclipseme-lives/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android Analog Clock Collection</title>
		<link>http://www.setera.org/2012/05/28/android-analog-clock-collection/</link>
		<comments>http://www.setera.org/2012/05/28/android-analog-clock-collection/#comments</comments>
		<pubDate>Mon, 28 May 2012 13:59:09 +0000</pubDate>
		<dc:creator>Craig Setera</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://www.setera.org/?p=664</guid>
		<description><![CDATA[While I haven&#8217;t entirely given up on my Android Clock Widget project, it has definitely stalled out for the time being. I have some potential ideas on how to move that project forward, but between work and coaching soccer I just don&#8217;t have much time at the moment to play around. In the meantime, I [...]]]></description>
				<content:encoded><![CDATA[<p>While I haven&#8217;t entirely given up on my <a href="http://www.setera.org/2011/09/04/clock-widget-project/">Android Clock Widget</a> project, it has definitely stalled out for the time being.  I have some potential ideas on how to move that project forward, but between work and coaching soccer I just don&#8217;t have much time at the moment to play around.  In the meantime, I wanted a nice analog clock on my phone&#8217;s homescreen.  While looking around the Google Play store, I came across the awesome <a href="https://play.google.com/store/apps/details?id=smsr.com.acc&#038;hl=en">Analog Clock Collection</a>.  For anyone looking for an analog clock widget, I&#8217;d recommend taking a look.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.setera.org/2012/05/28/android-analog-clock-collection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Still Deadlocked</title>
		<link>http://www.setera.org/2012/03/11/still-deadlocked/</link>
		<comments>http://www.setera.org/2012/03/11/still-deadlocked/#comments</comments>
		<pubDate>Sun, 11 Mar 2012 21:19:16 +0000</pubDate>
		<dc:creator>Craig Setera</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Clock]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.setera.org/?p=649</guid>
		<description><![CDATA[Wow&#8230; three months since my last post about my Android Clock Widget Project. While I&#8217;ve failed to bring stability to the clock selector during that time, I have figured out that the problem is not actually due to a deadlock. Instead, it appears that my project is tickling a bug in the Dalvik VM&#8217;s garbage [...]]]></description>
				<content:encoded><![CDATA[<p>Wow&#8230; three months since my <a href="http://www.setera.org/2011/12/27/deadlocked/">last post</a> about my <a href="http://www.setera.org/2011/09/04/clock-widget-project/">Android Clock Widget Project</a>.  While I&#8217;ve failed to bring stability to the clock selector during that time, I have figured out that the problem is not actually due to a deadlock.  Instead, it appears that my project is tickling a bug in the Dalvik VM&#8217;s garbage collector.  </p>
<p><span id="more-649"></span><br />
Depending on the device and operating system level, there are subtle changes in behavior.  In most cases, there is a crash log written to the /data/tombstones folder.  The most revealing tombstone file has come from a Samsung Captivate running a version of the <a href="http://forum.aokp.co/">AOKP ICS ROM</a>.</p>
<pre name="code" class="shell">
Build fingerprint: 'samsung/SGH-I897/SGH-I897:2.3.5/GINGERBREAD/UCKK4:user/release-keys'
pid: 1758, tid: 1777  >>> com.seterasoft.mclock <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad
 r0 deadbaad  r1 00000001  r2 40000000  r3 00000000
 r4 00000000  r5 00000027  r6 50c53b40  r7 00000064
 r8 41338018  r9 00000024  10 50c53a6c  fp 50c53ab0
 ip ffffffff  sp 50c53a30  lr 400fdf79  pc 400fa694  cpsr 60000030
 d0  0000000000000000  d1  0000000000000000
 d2  0000000000000000  d3  0000000000000000
 d4  0000000000000000  d5  0000000000000000
 d6  0000000000000000  d7  0000000000000000
 d8  0000000000000000  d9  0000000000000000
 d10 0000000000000000  d11 0000000000000000
 d12 0000000000000000  d13 0000000000000000
 d14 0000000000000000  d15 0000000000000000
 d16 0000000000000000  d17 0000000000000000
 d18 0000000000000000  d19 0000000000000000
 d20 0000000000000000  d21 0000000000000000
 d22 0000000000000000  d23 0000000000000000
 d24 0000000000000000  d25 0000000000000000
 d26 0000000000000000  d27 0000000000000000
 d28 0100010001000100  d29 0100010001000100
 d30 0000000000000000  d31 3ff0000000000000
 scr 2800001b

         #00  pc 00017694  /system/lib/libc.so
         #01  pc 00007bb0  /system/lib/libcutils.so (mspace_merge_objects)
         #02  pc 0007b6c8  /system/lib/libdvm.so (_Z21dvmHeapSourceFreeListjPPv)
         #03  pc 00042ce0  /system/lib/libdvm.so
         #04  pc 00032f94  /system/lib/libdvm.so (_Z22dvmHeapBitmapSweepWalkPK10HeapBitmapS1_jjPFvjPPvS2_ES2_)
         #05  pc 00042c9c  /system/lib/libdvm.so (_Z27dvmHeapSweepUnmarkedObjectsbbPjS_)
         #06  pc 000337c0  /system/lib/libdvm.so (_Z25dvmCollectGarbageInternalPK6GcSpec)
         #07  pc 0005ff6c  /system/lib/libdvm.so (_Z17dvmCollectGarbagev)
         #08  pc 00072a8e  /system/lib/libdvm.so
         #09  pc 00030a8c  /system/lib/libdvm.so
         #10  pc 00034248  /system/lib/libdvm.so (_Z12dvmInterpretP6ThreadPK6MethodP6JValue)
         #11  pc 0006c692  /system/lib/libdvm.so (_Z14dvmCallMethodVP6ThreadPK6MethodP6ObjectbP6JValueSt9__va_list)
         #12  pc 0006c6b4  /system/lib/libdvm.so (_Z13dvmCallMethodP6ThreadPK6MethodP6ObjectP6JValuez)
         #13  pc 0005f7c0  /system/lib/libdvm.so
         #14  pc 00012c14  /system/lib/libc.so (__thread_entry)
         #15  pc 00012744  /system/lib/libc.so (pthread_create)
</pre>
<p>The failing function appears to be implemented in dlmalloc.c in the Android source, but I really don't have any good idea about what might be causing the crash.  I also don't appear to be the only one, as there are <a href="http://groups.google.com/a/googleproductforums.com/forum/#!category-topic/maps/google-maps-for-mobile/XVVmMYYxLUI">other references on the web</a> that look similar.</p>
<p>To this point, I've tried a variety of things to try to track down the problem.  I've gone so far as to try to build my own version of the <a href="http://www.cyanogenmod.com/">Cyanogenmod</a> with the idea that I might be able to add more logging output.  So far, I've not had any luck with this approach.  I generally have no problem walking away from hobby projects when I lose interest.  However, this has turned into a competition of me versus the computer and I'm not quite ready to give up.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.setera.org/2012/03/11/still-deadlocked/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deadlocked</title>
		<link>http://www.setera.org/2011/12/27/deadlocked/</link>
		<comments>http://www.setera.org/2011/12/27/deadlocked/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 01:26:58 +0000</pubDate>
		<dc:creator>Craig Setera</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://www.setera.org/?p=628</guid>
		<description><![CDATA[I recently started spending more time on my Android Clock Widget Project. I&#8217;ve implemented some much needed caching of the SVG definitions, speeding performance of clock rendering substantially. In addition, I&#8217;ve been working on building a nice graphical clock selector. Unfortunately, this selector is causing me lots of frustration due to a race condition that [...]]]></description>
				<content:encoded><![CDATA[<p>I recently started spending more time on my <a href="http://www.setera.org/2011/09/04/clock-widget-project/">Android Clock Widget Project</a>.  I&#8217;ve implemented some much needed caching of the SVG definitions, speeding performance of clock rendering substantially.  In addition, I&#8217;ve been working on building a nice graphical clock selector.  Unfortunately, this selector is causing me lots of frustration due to a race condition that keeps deadlocking the application&#8217;s UI thread.<br />
<span id="more-628"></span></p>
<p>Parsing and rendering the various SVG layers that make up each clock is a relatively expensive operation.  Locking up the user interface while doing these operations is bad design and leads the user to believe that the application may not working correctly.  What I&#8217;m attempting to do seems pretty simple on the surface.  The following screen capture shows the (partially working) goal:</p>
<p><a href="http://www.setera.org/wp-content/uploads/2011/12/clocks.png"><img src="http://www.setera.org/wp-content/uploads/2011/12/clocks.png" alt="Clock Skin Selector" title="Clock Skin Selector" width="328" height="488" class="aligncenter size-full wp-image-629" /></a></p>
<p>The selector consists of two columns, an image of the clock on the left and the name of the clock on the right.  Using the standard ListActivity support, the goal is to show an indeterminate progress image in the left column until the layers have been loaded and rendered.  At that point, the animated progress image is hidden and the clock image is displayed.  </p>
<p>The implementation is simple in concept.  The list adapter subclasses the standard BaseAdapter implementation to provide an implementation of the <em>getView</em> method.  The <em>getView</em> method delegates loading of the clock&#8217;s image to an asynchronous task, keeping the user interface alive.  When the asynchronous task completes, it signals the adapter by calling <em>notifyDataSetChanged</em>.  The next call to <em>getView</em> will hide the progress animation and display the rendered image.</p>
<p>While this is mostly working, I&#8217;m hitting a random deadlock condition that locks up the UI thread, usually resulting in an &#8220;Application Not Responding&#8221; (ANR) error message to the user.  All of my attempts to diagnose and resolve this issue have ended with nothing but frustration.  So far, I&#8217;ve tried all of the &#8220;standard&#8221; approaches to diagnose this:</p>
<ul>
<li>Analyzed the traces.txt file generated by the ANR.  <br/> Unfortunately, the process never shows up in the log file.</li>
<li>Force-generated a traces.txt file using <em>kill SIGQUIT pid</em> while the application was still running.  <br/>Again, the process doesn&#8217;t seem to show up.  Instead, I see &#8220;W/dalvikvm(19144): threadid=4: spin on suspend #1 threadid=9 (pcf=0)&#8221; whenever attempting this.</li>
<li>Attempted to use the standard Eclipse debugger to suspend the UI thread once it is locked up.  <br/>No big surprise that it did not work.</li>
<li>Added lots of Log output trying to pinpoint the hang.  <br/>At least from that logging, it doesn&#8217;t <b>appear</b> to be a hang anywhere directly in my code.</li>
<li>I even tried to use method tracing to see if I could figure anything out.</li>
</ul>
<p>At this point, I&#8217;ve run out of good ideas on how to track down and fix this problem on my own.  I&#8217;ve gone ahead and joined the Google android-developers group and asked for ideas on solving this.  I&#8217;m still waiting for my question to clear moderation to see if anyone else can offer any insights.  If anyone reading this has any ideas, I&#8217;d love to hear them.  Until then, this project is officially deadlocked.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.setera.org/2011/12/27/deadlocked/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Relinking Android Market Applications</title>
		<link>http://www.setera.org/2011/11/02/relinking-android-market-applications/</link>
		<comments>http://www.setera.org/2011/11/02/relinking-android-market-applications/#comments</comments>
		<pubDate>Wed, 02 Nov 2011 23:00:59 +0000</pubDate>
		<dc:creator>Craig Setera</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.setera.org/?p=595</guid>
		<description><![CDATA[When I initially set up my Samsung Captivate, I used my work email as the primary email address for the device. This caused my Android Market applications to be associated with my work email. When Google started allowing multiple accounts, I added my personal GMail account to the device and managed to get a confusing [...]]]></description>
				<content:encoded><![CDATA[<p>When I initially set up my Samsung Captivate, I used my work email as the primary email address for the device.   This caused my Android Market applications to be associated with my work email.  When Google started allowing multiple accounts, I added my personal GMail account to the device and managed to get a confusing mix of installed applications associated with each account.  After being frustrated with this for a while, I decided I needed to fix this.</p>
<p><span id="more-595"></span><br />
The internet offered no examples of how I might go about doing this, so I went spelunking on my own.  For those that may need to do something similar, I decided to capture the steps I used to relink my Android Market applications with a single GMail address.  Before I go any further, let me offer some warnings:</p>
<p><b></p>
<ul>
<li style="background-color: #FF0000; color: #FFFFFF;">I AM NOT LIABLE IF YOU BREAK YOUR PHONE BY TRYING THIS. <br/> IF YOU DON&#8217;T KNOW WHAT YOU ARE DOING, DO NOT ATTEMPT THESE CHANGES.</li>
<li style="background-color: #FF0000; color: #FFFFFF;">My steps include a few things to hopefully avoid major breakage, however I&#8217;d urge caution.  Be careful.</li>
<li style="background-color: #FF0000; color: #FFFFFF;">Your device must be rooted in order to make the necessary changes.</li>
<li style="background-color: #FF0000; color: #FFFFFF;">These steps only work for free applications.  Paid applications are associated to a particular Google account using DRM.</li>
<li style="background-color: #FF0000; color: #FFFFFF;">CONSIDER YOURSELF WARNED</li>
</ul>
<p></b></p>
<p><b>November 13, 2011 Update</b></p>
<p><i>While this appears to work in the short term, I&#8217;m noticing applications slowly migrating back to the original accounts.  I&#8217;m not entirely sure where those values are being stored or how to fix this permanently.</i></p>
<h2>The Market Assets Database</h2>
<p>As of this writing, Android Market (implemented by the com.android.vending package) stores the linkage between an Android application package and the associated Android Market account in the file:</p>
<pre name="code" class="shell">
/data/data/com.android.vending/databases/market_assets.db
</pre>
<p>The <i>ASSETS</i> table within that SQLITE database contains the mappings as seen in this screenshot.</p>
<p><a href="http://www.setera.org/wp-content/uploads/2011/10/Screenshot-at-2011-10-29-124410.png"><img src="http://www.setera.org/wp-content/uploads/2011/10/Screenshot-at-2011-10-29-124410.png" alt="Market Assets DB" title="Market Assets DB" width="767" height="236" class="aligncenter size-full wp-image-596" /></a></p>
<p>Relinking applications is a matter of properly updating this table.  The prerequisites for this process are:</p>
<ul>
<li>Rooted device</li>
<li>Android Debug Tools (adb) installed and working</li>
</ul>
<h2>Relinking Process</h2>
<p>Start by making sure that Market application has been stopped:</p>
<ol>
<li>Navigate to Settings -> Applications -> Manage Applications</li>
<li>Locate and select the Market application in the list</li>
<li>Press the <i>Force Stop</i> button</li>
</ol>
<p>Make sure that your device is attached with USB Debugging enabled:</p>
<pre name="code" class="shell">
$ -> adb devices
List of devices attached 
3231174E43AA00EC	device
</pre>
<p>Open a shell on the device and navigate to the database directory:</p>
<pre name="code" class="shell">
$ -> adb shell
# cd /data/data/com.android.vending/databases
# ls -l
-rw-rw----    1 app_57   app_57       34816 Oct 29 11:55 market_assets.db
</pre>
<p>Backup the current file:</p>
<pre name="code" class="shell">
# cp market_assets.db market_assets.db.save
# ls -l
-rw-rw----    1 app_57   app_57       34816 Oct 29 11:55 market_assets.db
-rw-rw----    1 root     root         31744 Oct 29 11:44 market_assets.db.save
</pre>
<p>Update the database file:</p>
<pre name="code" class="shell">
# sqlite3 market_asset.db
sqlite> update ASSETS set ACCOUNT = 'new.email@gmail.com' 
   ...> where ACCOUNT = 'old.email@gmail.com';
sqlite> .exit
# exit
</pre>
<p>At this point, reboot your phone.  If all went correctly, your free applications should now be associated with <i>new.email@gmail.com</i>.</p>
<h2>Updating Paid Applications</h2>
<p>As I mentioned earlier, this process can&#8217;t be used to relink paid applications due to DRM that is tied to your account.  If you want to do this, most application developers will offer a refund if you purchase on a new account and send them the order details for both the old and new accounts.  Once you&#8217;ve purchased on the new account, you can uninstall for the old account and reinstall from the new.  This is a lot of effort, but can help if you need to switch market accounts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.setera.org/2011/11/02/relinking-android-market-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oops I Did It Again&#8230;</title>
		<link>http://www.setera.org/2011/10/29/oops-i-did-it-again/</link>
		<comments>http://www.setera.org/2011/10/29/oops-i-did-it-again/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 19:29:22 +0000</pubDate>
		<dc:creator>Craig Setera</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://www.setera.org/?p=617</guid>
		<description><![CDATA[One of these days I may actually learn my lesson when it comes to installing new software. Lately I&#8217;ve been busy with work and recovering from some surgery, so I haven&#8217;t really had the energy to focus on any of my personal programming projects. Instead, I&#8217;ve been doing a lot of home network administration and [...]]]></description>
				<content:encoded><![CDATA[<p>One of these days I may actually learn my lesson when it comes to installing new software.  Lately I&#8217;ve been busy with work and recovering from some surgery, so I haven&#8217;t really had the energy to focus on any of my personal programming projects.  Instead, I&#8217;ve been doing a lot of home network administration and software updates.  In a multiple cases, I&#8217;m reminded of why being on the leading (bleeding?) edge of software may not always be the easiest place to be.<br />
<span id="more-617"></span></p>
<h2>Ubuntu 11.10</h2>
<p>I have long used a dual-interface Linux machine at the edge of my network to provide firewall, file server and other interesting services to the network.  My old machine was getting pretty noisy and I was sure something was going to die and leave me in a bad situation.  I bought a cheap new HP tower machine to replace the old machine and was tripped up on multiple things:</p>
<ul>
<li>I didn&#8217;t think about the fact that my old network card would no longer fit in the machine due to bus changes.  I was further surprised to find out that it was impossible to find a PCIExpress networking card without going online and waiting for delivery.</li>
<li>The latest Ubuntu installer guessed that the HP machine was using UEFI for bootloading and failed to boot Ubuntu.  With lots of great help from the Ubuntu forums I was able to diagnose the issue and get grub-pc installed and the machine working.</li>
</ul>
<p>This machine is up and running pretty well now after the false starts.  I wish I could say the same for my Dell laptop.  Every time a new version of Ubuntu comes out, I tell myself I&#8217;m not going to update for <b>at least</b> a month and that I should really wait a bit longer for the issues to shake out.  Every time, I lose the battle to wait and end up regretting it after the fact.  While Ubuntu 11.10 has some pretty nice new features, I ran up against new regressions that I had to work through.</p>
<ul>
<li><a href="https://bugs.launchpad.net/ubuntu/+source/linux/+bug/872652">Screen backlight issue</a></li>
<li><a href="https://bugs.launchpad.net/ubuntu/+source/linux-restricted-modules/+bug/314574">Wireless connection issue</a></li>
</ul>
<p>Thanks to Canonical engineer Kamal Mostafa, I have a patched kernel to fix the backlight issue.  Unfortunately, I&#8217;m still struggling with the wireless issue that kills my wireless router from time to time.</p>
<h2>Cyanogen Mod 7.1</h2>
<p>I was excited to see <a href="http://www.cyanogenmod.com">Cyanogen Mod 7.1</a> come out with support for my Samsung Captivate.  I&#8217;m a fan of Android, but not a big fan of the crap-tacular software loaded on AT&#038;T devices by default.  The idea of installing a new ROM that was cleaner and faster was enticing.  While the transition has been relatively smooth, I&#8217;m seeing some strange behavior with my external 32G SD card.  I&#8217;m also having a hard time figuring out if the battery life is as good as it had been on the stock firmware.  I need to do more digging to figure that out.</p>
<p>In the end, I don&#8217;t expect my habit of installing new software will likely change very soon.  I usually try to avoid upgrading too early for mission critical hardware such as my work laptop.  Admittedly half of the fun of installing new software is that you can <b>usually</b> dig yourself out of a hole if something goes wrong.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.setera.org/2011/10/29/oops-i-did-it-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clock Widget Project</title>
		<link>http://www.setera.org/2011/09/04/clock-widget-project/</link>
		<comments>http://www.setera.org/2011/09/04/clock-widget-project/#comments</comments>
		<pubDate>Sun, 04 Sep 2011 23:55:11 +0000</pubDate>
		<dc:creator>Craig Setera</dc:creator>
				<category><![CDATA[AndEngine]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Clock]]></category>

		<guid isPermaLink="false">http://www.setera.org/?p=562</guid>
		<description><![CDATA[In my last post about inertia I mentioned that I had started to take a look at Android App Widgets. I&#8217;ve long had the idea that it would be interesting to create a widget capable of consuming themes for MacSlow&#8217;s Cairo Clock project. This very cool analog clock uses a set of SVG graphics to [...]]]></description>
				<content:encoded><![CDATA[<p>In my last post about <a href="http://www.setera.org/2011/07/30/inertia/">inertia</a> I mentioned that I had started to take a look at Android App Widgets.  I&#8217;ve long had the idea that it would be interesting to create a widget capable of consuming themes for <a href="http://macslow.net/?page_id=23">MacSlow&#8217;s Cairo Clock</a> project.  This very cool analog clock uses a set of SVG graphics to theme the clock in such a way that it can be scaled to various sizes.  While I&#8217;m not there quite yet, the ultimate goal is that the widget is capable of rendering all of the themes found at <a href="http://gnome-look.org/index.php?xcontentmode=186">gnome-look.org</a>.<br />
<span id="more-562"></span></p>
<p>This screen capture from the emulator shows multiple live instances of the widget running simultaneously with many different themes.  I would not suggest that anyone actually do this do the amount of memory required, however it shows the power of the themes.</p>
<div id="attachment_566" class="wp-caption aligncenter" style="width: 388px"><a href="http://www.setera.org/wp-content/uploads/2011/09/Screenshot.png"><img src="http://www.setera.org/wp-content/uploads/2011/09/Screenshot.png" alt="" title="Clock Themes" width="378" height="552" class="size-full wp-image-566" /></a><p class="wp-caption-text">Android analog clock displaying many themes simultaneously.</p></div>
<h2>Implementation Notes</h2>
<p>Getting to this point has been an interesting process, as the Android widget support definitely makes this type of widget somewhat difficult to build.</p>
<h3>AndEngine SVG Support</h3>
<p>I&#8217;ve had this idea for quite some time.  What helped me move forward was the addition of <a href="http://www.andengine.org/blog/category/andenginesvgtextureregionextension/">SVG support to AndEngine.</a>  Thanks to Nicolas Gramlich yet again for his excellent engine.  I&#8217;ve found a few glitches along the way that I&#8217;ve started to submit patches to the project to correct, but as always his code works amazingly well.</p>
<h3>Per-Minute Updates</h3>
<p>As I mentioned in <a href="http://www.setera.org/2011/07/30/inertia/">my inertia post</a>, the standard Android widgets model is really more of a &#8220;pull&#8221; model versus a &#8220;push&#8221; model.  The widget provider definition file (in XML) specifies the frequency that the Android framework will call the widget&#8217;s update functionality:</p>
<pre name="code" class="xml">
    android:updatePeriodMillis="1800000"
</pre>
<p>However, no matter what is specified for this value, Android limits the update frequency to no more than once every 30 minutes to avoid the battery drain associated with executing code too often.  Thus, it is necessary to push changes to the widget based on our own schedule to make sure the clock is updated every minute.</p>
<p>My initial implementation used Java&#8217;s Timer and TimerTask to do these updates.  Looking at the framework&#8217;s analog clock implementation, I discovered Android&#8217;s time-related broadcast messages:</p>
<ul>
<li><a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_TIME_TICK">Intent.ACTION_TIME_TICK</a></li>
<li><a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_TIME_CHANGED">Intent.ACTION_TIME_CHANGED</a></li>
<li><a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_TIMEZONE_CHANGED">Intent.ACTION_TIMEZONE_CHANGED</a></li>
</ul>
<p>Using these broadcast messages is a vast improvement over maintaining my own timer threads for this functionality.  However, since a widget is nothing more than a fancy broadcast receiver, it is necessary to spin up a separate service to register a broadcast receiver for these messages.  On reception of one of these messages, each clock instance is updated to match the current time.  This update generates a properly sized bitmap that is pushed to the widget instance:</p>
<pre name="code" class="java">
		RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.main);
		views.setImageViewBitmap(R.id.imageview, bitmap);
		appWidgetManager.updateAppWidget(instanceIdentifier, views);
</pre>
<p>It&#8217;s important to note that there is also an <i>updateAppWidget</i> method call that accepts an instance of <i>android.content.ComponentName</i>.  Using this method will update all instances for the specified provider with the bitmap.  It took a bit to figure out why all of my clock instances were showing the same theme until I realized it was due to using the wrong method.</p>
<h3>Improving Battery Performance</h3>
<p>Given that this widget is controlling updates rather than allowing the framework to do the job, my primary concern is in terms of performance.  Android devices are notorious for poor battery life, however it does seem that it is primarily due to background applications.  I&#8217;ve done a couple of things thus far to attempt to minimize battery usage.</p>
<h4>No Seconds Hand</h4>
<p>At least at the moment, the widget removes the seconds hand to avoid pushing more updates to the screen than necessary.  Assuming that Android wants to limit updates to once every 30 minutes, the widget is already pushing updates 30 times more often than the framework would like.  Multiplying that yet again by 60 seconds seems like a bit too much.  In the future, I may consider allowing the user to enable the seconds hands with proper warnings attached.</p>
<h4>Manage Broadcast Receiver Messages</h4>
<p>An unfortunate side effect of the way that widgets work is that it does not appear to be possible for a widget to determine if it is actually being displayed.  If a widget is placed on screen 1, but the user is currently viewing screen 2, there is really no reason to update the widget.  With that said, the implementation can still be smart about updates.  The service alters the messages it listens for based on the status of the screen:</p>
<ul>
<li>Screen Off</li>
<ul>
<li><a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_USER_PRESENT">Intent.ACTION_USER_PRESENT</a></li>
</ul>
<li>Screen On</li>
<ul>
<li><a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_SCREEN_OFF">Intent.ACTION_SCREEN_OFF</a></li>
<li><a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_TIME_TICK">Intent.ACTION_TIME_TICK</a></li>
<li><a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_TIME_CHANGED">Intent.ACTION_TIME_CHANGED</a></li>
<li><a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_TIMEZONE_CHANGED">Intent.ACTION_TIMEZONE_CHANGED</a></li>
</ul>
</ul>
<p>After the user has cleared the lock screen (ACTION_USER_PRESENT), the widget registers to hear time updates as well as the screen turning off.  Once the screen turns off, the widget stops listening for time updates and switches to listening for user presence.  This lowers the update frequency for the widgets when there is no chance that they will actually be visible to the user.</p>
<h2>What&#8217;s Next?</h2>
<p>This project has a chance of being something that I can complete and that others might be interested in actually <i>using</i>.  I&#8217;m considering whether I want to submit this to the Android Market when it is a bit further along.  If I do, I will have to decide whether or not I would charge for it which implies a certain level of required support.  Either way, I&#8217;m not at the point of releasing any significant amount of source code until I decide what to do with this project.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.setera.org/2011/09/04/clock-widget-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inertia</title>
		<link>http://www.setera.org/2011/07/30/inertia/</link>
		<comments>http://www.setera.org/2011/07/30/inertia/#comments</comments>
		<pubDate>Sun, 31 Jul 2011 00:23:30 +0000</pubDate>
		<dc:creator>Craig Setera</dc:creator>
				<category><![CDATA[AndEngine]]></category>
		<category><![CDATA[AndPingus]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.setera.org/?p=541</guid>
		<description><![CDATA[Inertia is the resistance of any physical object to a change in its state of motion or rest, or the tendency of an object to resist any change in its motion. For me, this also describes my tendencies toward side projects like my Pingus project. When I last worked on Pingus a couple of months [...]]]></description>
				<content:encoded><![CDATA[<blockquote><p>Inertia is the resistance of any physical object to a change in its state of motion or rest, or the tendency of an object to resist any change in its motion.</p></blockquote>
<p>For me, this also describes my tendencies toward side projects like my <a href="http://www.setera.org/2011/06/26/we-are-experiencing-technical-difficulties/">Pingus project</a>.  When I last worked on Pingus a couple of months ago, I updated the underlying <a href="http://andengine.org">AndEngine</a> libraries and found a ton of breaking changes.  I put Pingus on the shelf until I had more time to look at the breakage and how to solve it.  The AndEngine changes are pretty significant and I&#8217;m going to need to rethink portions of Pingus in order to get things running correctly again.  </p>
<p><span id="more-541"></span></p>
<p>Now my personal inertia is kicking in and causing me to put off this rework for a while.  To me, this is the biggest difference between work and hobby projects&#8230; I don&#8217;t <b>have</b> to work on hobby projects if I don&#8217;t want to.  Thus, Pingus is &#8220;on a break&#8221; for a while until I find the energy to bring it up to date relative to the underlying game engine. </p>
<p>In the meantime, I decided I wanted to spend a bit of time taking a look at Android&#8217;s <a href="http://developer.android.com/guide/topics/appwidgets/index.html">App Widget</a> support.  Until I started digging into the documentation and examples, I had always assumed that a widget was provided a Canvas to draw directly on to the home screen.  To me this seemed like it would have been the easiest way for developers to develop widgets.  </p>
<p>It turns out that Android AppWidgets don&#8217;t work that way at all.  AppWidgets are built on top of <a href="http://developer.android.com/reference/android/widget/RemoteViews.html">Remote Views</a>.  According to the Android documentation, Remote Views are</p>
<blockquote><p>A class that describes a view hierarchy that can be displayed in another process. The hierarchy is inflated from a layout resource file, and this class provides some basic operations for modifying the content of the inflated hierarchy.</p></blockquote>
<p>A Remote View is created in one process and passed into the process that owns the Android home screen.  It is actually a <a href="http://developer.android.com/reference/android/os/Parcelable.html">Parcelable</a> object, however due to class loading issues, there is only a very small number of Views and Widgets that are allowed to be passed across the process boundary.  For anything that involves relatively complex graphical rendering, the only real way to drive the widget&#8217;s contents is by specifying a very simple widget layout:</p>
<pre name="code" class="xml">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    
    <ImageView
    	android:id="@+id/imageview"
	    android:layout_width="fill_parent" 
	    android:layout_height="wrap_content" 
		android:src="@drawable/icon" />
	    
</LinearLayout>
</pre>
<p>and then sending bitmaps to the image view:</p>
<pre name="code" class="java">
	private void updateWidget(Context context, AppWidgetManager appWidgetManager) {
		Bitmap bitmap = Bitmap.createBitmap(100, 100, Config.ARGB_8888);
		Canvas canvas = new Canvas(bitmap);
		
		this.drawable.draw(canvas);

		RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.main);
		views.setImageViewBitmap(R.id.imageview, bitmap);

		ComponentName componentName = new ComponentName(context, MyAppWidgetProvider.class);
		appWidgetManager.updateAppWidget(componentName, views);
	}
</pre>
<p>While this seems like a high overhead way to handle updates to the widget contents, I have to assume that the Android developers had a good reason for doing things like this.  I can only hope that there are some tricks being done in the Android implementation that lower the cost of this operation.  Given that I&#8217;ve just managed to get this to work at all, I imagine there are is a lot of room for improvement in my use of this API.  However, I found it confusing enough to figure out how to do and thought others might benefit from my pain.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.setera.org/2011/07/30/inertia/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
