[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!