- Annotated by RemoteViews
- Can't be found by PathClassLoader with default class path - "."
The second one is not easy to attack. You need to know where this dot refers to. It is actually defined as an environment variable BOOTCLASSPATH in a file init.rc wrapped in your boot.img or ramdisk.img.
export BOOTCLASSPATH /system/framework/core.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/org.startsmall.widget.jarSo, you need to,
- Wrap your widget class in a jar library.
- Archive classes.dex only.
- The system.img can be decompressed by unyaffs. Decompress it and put jar library into system/framework.
- Compress whole system/ directory back to system.img by mkyaffs2image.
- The boot.img/ramdisk.img is just a cpio archive. Decompress ramdisk.img, do modification to init.rc and archive it back as cpio file.
If you don't want to do it, you need to make your custom widget self-handled. You can't update custom widgets by set methods of RemoteViews, but you can send broadcasts to update it because AppWidgetHostView instantiates custom widgets in your context.
You can see from above that it is possible to write custom widget class to be used in AppWidget design only when you have permissions to access image files. This means either you work for a phone company or you make custom ROMs.