Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
scar45
Old
(Last edited by scar45; 13th June 2011 at 06:28 AM.)
#1  
scar45's Avatar
Recognized Themer - OP
Thanks Meter 621
Posts: 893
Join Date: Aug 2006
Location: Ontario

 
DONATE TO ME
Lightbulb [MOD/DEV] Charging Battery Animation with Dock Connected ** Help needed! **

OK this thread is dedicated to developing a WORKING charging battery icon animation. The main problem is this: ASUS' code only allows for still images to be drawn when the battery is charging (specifically when the dock is connected). Applying existing techniques to allow for animation results in the following exception:

Code:
W/dalvikvm(  149): threadid=8: thread exiting with uncaught exception (group=0x401ab760)
E/AndroidRuntime(  149): *** FATAL EXCEPTION IN SYSTEM PROCESS: android.server.ServerThread
E/AndroidRuntime(  149): java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.BATTERY_CHANGED flg=0x60000010 (has extras) } in com.android.server.asus.DockManagerService$3@40a446c8
E/AndroidRuntime(  149): 	at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:725)
E/AndroidRuntime(  149): 	at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime(  149): 	at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(  149): 	at android.os.Looper.loop(Looper.java:132)
E/AndroidRuntime(  149): 	at com.android.server.ServerThread.run(SystemServer.java:608)
E/AndroidRuntime(  149): Caused by: java.lang.ClassCastException: android.graphics.drawable.AnimationDrawable cannot be cast to android.graphics.drawable.BitmapDrawable
E/AndroidRuntime(  149): 	at com.android.server.asus.DockManagerService.adjustStatusBarDockLocked(DockManagerService.java:371)
E/AndroidRuntime(  149): 	at com.android.server.asus.DockManagerService.updateLocked(DockManagerService.java:317)
E/AndroidRuntime(  149): 	at com.android.server.asus.DockManagerService.updateDockBatteryState(DockManagerService.java:309)
E/AndroidRuntime(  149): 	at com.android.server.asus.DockManagerService.access$300(DockManagerService.java:55)
E/AndroidRuntime(  149): 	at com.android.server.asus.DockManagerService$3.onReceive(DockManagerService.java:229)
E/AndroidRuntime(  149): 	at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:716)
E/AndroidRuntime(  149): 	... 4 more
The line in question is the following: "Caused by: java.lang.ClassCastException: android.graphics.drawable.AnimationDrawable cannot be cast to android.graphics.drawable.BitmapDrawable", which is pretty much self-explanatory.

Anyways, I have dug into it more and traced the issue back to the source where I believe it is triggered from. First off, let me explain what I did:
  • Extracted 'classes.dex' from 'services.jar'
  • Decompiled 'classes.dex' using dex2jar
  • Was only able to view the source code with JD-GUI (don't know how to make edits)
  • Traced the issue to the file \com\android\server\asus\DockManagerService.class

In the 'DockManagerService.class', there are references to BitmapDrawable which I think need to be AnimatedDrawable, since that is what the logcat debug message says above (in the OP). I have no idea what to change it to exactly (let alone recompile it), but I believe this is where we need to look ('...' is edited-out code):

Code:
  private void adjustStatusBarDockLocked()
...
...
        localImageView.setImageResource(n);
        int i1 = this.mDockBatteryLevel;
        localImageView.setImageLevel(i1);
        Bitmap localBitmap = ((BitmapDrawable)localImageView.getDrawable().getCurrent()).getBitmap();
        localRemoteViews.setImageViewBitmap(16908985, localBitmap);
      }
Also, near the top of 'DockManagerService.class', there is the following:

Code:
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
...not sure if we'd need to add something like 'android.graphics.drawable.AnimationDrawable;' in order to get animations supported?

Anyways, that's about as far as I can get with my current knowledge. If any other experienced dev is out there, it would be super great if they could give their thoughts, suggestions, ANYTHING!

Hopefully after we get to the bottom of this, we'll be able to have animated charging icons which support the ASUS dock.

OH, and forgot to mention that users of the OC kernel by Clemsyn (which is currently NOT built from source, since the 3.1 official ASUS source has not yet been released) do not suffer from this problem, since that OC kernel has broken support for the dock battery level/charging status. It currently only becomes an issue with the Stock 3.1 kernel which is able to correctly read the Dock Status.

Thanks in advance!

░▒▓ (also) Developer of the
░▒▓ PCB Series of Themes
 
Highland3r
Old
#2  
Senior Member
Thanks Meter 68
Posts: 388
Join Date: Sep 2009
This may (or may not) help - but -
Can you locate the source for "BatteryService" and see if anything in there helps?

Also - did the Asus "limited release" for the Dock issues not contain a working Dock Status? If it did, someone may have the files kicking around from that which could have the parts you need in?
Galaxy Nexus (MoDaCo JR4)
Nexus One (OxygeN1 mod)
Nexus 7 (MoDaCo JR5)
 
Bob Smith42
Old
(Last edited by Bob Smith42; 14th June 2011 at 01:01 AM.)
#3  
Senior Member
Thanks Meter 57
Posts: 516
Join Date: Jun 2011
I use a widget called "bat stat" that uses animation, but it does not handle the dock (of course). It is small, has great animation and graphics, and is not well know yet it is in the market.

Was thinking to do my own tf version, will let you know if succeeds.

Hope this helps.

=======
UPDATE:

I finished the *graphics* to represent various tablet & dock and charging or discharging states.
I will look at some widget *codes* next.

 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...