Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,784,443 Members 47,822 Now Online
XDA Developers Android and Mobile Development Forum

Define Widgets in Custom ROMS

Tip us?
 
3c
Old
#11  
3c's Avatar
Senior Member
Thanks Meter 1,076
Posts: 1,972
Join Date: Jul 2005

 
DONATE TO ME
Question Interested to know we can make it work?

FYI, the various data in the appwidgets.xml are as follows:

The <p/> tags are for listing which widget is using which package/class already installed... Order is important as it is referenced from the <g /> tags.

The <h/> tags lists all launcher installed, its package name and id. It seems custom launchers loaded from market have all an id of 400!

The <g/> tags are the actual widgets already added to a launcher/home screen,
it's ID is the dev ID used by apps, unique on a single device
the h= attribute is the launcher reference (0, 1, ...) from the <h/> tags above.
the p= attribute is the package ref (0, 1, ...) from the <p/> tags above.

That file is updated when an launcher/home screen app calls many Android API methods, including those:

allocateAppWidgetId() to get a new dev ID as mentioned above and link future <g> tags to an existing <h> tag.
The h tag is ALWAYS a reference to the package having called this method! No way to get a widget ID from another app for a particular launcher!

bindAppWidgetId(int appWidgetId, ComponentName provider) to link the <g> tag along with the <p> tag



Even tried ADW Launcher and its home-screen backup/restore but it fails to restore anything!? What a crap!


I personnally use 'System Tuner' which actually restores home screens, except the widgets! Is Titanium Backup able to restore home screens widget?


I've been messing around with the appwidgets.xml file manually to restore a widget... Unfortunately nothing worked.


Did anyone found more info on the subject?
[ Old devices ] HD2, HTC Wildfire, Galaxy Nexus, Galaxy S, S2, S3, S4 quad/octa, S5 octa, Note, Note 2, HTC One, Xperia Z, Nexus 4, Padfone 2, TF101, TF700, TF701, IdeaPad A2109, HTC Sensation,
[ Current devices ] Nexus 5, Nexus 7 2012, Nexus 7 2013, Note 3, Note 3 Neo, Galaxy Tab S 10.5
[ Web ] 3c
[ Apps ] Android Tuner, System Tuner, Battery Monitor Widget
 
ripclawrings
Old
#12  
Junior Member
Thanks Meter 6
Posts: 10
Join Date: Mar 2009
Titanium Backup not restore widget......

Any news editing xml????
 
DieHappy
Old
#13  
DieHappy's Avatar
Senior Member
Thanks Meter 221
Posts: 119
Join Date: Oct 2006
Location: Pittsburgh, PA
Merry Xmas everyone! I finally got this to work with ADW.Launcher.

After setting up my widgets, icons, and ADW settings, I copied a couple of the files from "/data/data/org.adw.launcher" into a backup dir, and used an init.d script to replace the default files. The script deletes itself to make sure it only runs on the very first boot.

I had to experiment forever to get the right sleep time. This script needs to sleep for 45 seconds minimum in order to let ADW finish before it can swap the files. If you are using this with another launcher, you might need to change the sleep time.

Code:
#!/sbin/busybox sh

# THE SCRIPT MUST WAIT A MIN OF 45 SECONDS OR ELSE IT WILL NOT WORK
sleep 45
if [ -d "/data/data/org.adw.launcher-backup/" ]; then
	# RESTORE WIDGETS AND ICONS
        rm "/data/data/org.adw.launcher/databases/launcher.db-wal"
	cp "/data/data/org.adw.launcher-backup/databases/launcher.db-wal" "/data/data/org.adw.launcher/databases/launcher.db-wal"
        
        # RESTORE ADW SETTINGS
	rm "/data/data/org.adw.launcher/shared_prefs/launcher.preferences.almostnexus.xml"
	cp "/data/data/org.adw.launcher-backup/shared_prefs/launcher.preferences.almostnexus.xml" "/data/data/org.adw.launcher/shared_prefs/launcher.preferences.almostnexus.xml"

        # RESTART LAUNCHER
	killall android.process.acore

        # DELETE THIS SCRIPT TO MAKE SURE IT DOESN'T RUN AGAIN
	rm /system/etc/init.d/98adwreset
fi
The Following 2 Users Say Thank You to DieHappy For This Useful Post: [ Click to Expand ]
 
3c
Old
#14  
3c's Avatar
Senior Member
Thanks Meter 1,076
Posts: 1,972
Join Date: Jul 2005

 
DONATE TO ME
Quote:
Originally Posted by DieHappy View Post
Merry Xmas everyone! I finally got this to work with ADW.Launcher.

After setting up my widgets, icons, and ADW settings, I copied a couple of the files from "/data/data/org.adw.launcher" into a backup dir, and used an init.d script to replace the default files. The script deletes itself to make sure it only runs on the very first boot.

I had to experiment forever to get the right sleep time. This script needs to sleep for 45 seconds minimum in order to let ADW finish before it can swap the files. If you are using this with another launcher, you might need to change the sleep time.
Great finding! I'll try to integrate that into System Tuner asap! That would be awesome to have a way to restore launchers setup. All I managed so far is to restore a launcher's icons, without widget, but with that might be able to restore the widgets too
[ Old devices ] HD2, HTC Wildfire, Galaxy Nexus, Galaxy S, S2, S3, S4 quad/octa, S5 octa, Note, Note 2, HTC One, Xperia Z, Nexus 4, Padfone 2, TF101, TF700, TF701, IdeaPad A2109, HTC Sensation,
[ Current devices ] Nexus 5, Nexus 7 2012, Nexus 7 2013, Note 3, Note 3 Neo, Galaxy Tab S 10.5
[ Web ] 3c
[ Apps ] Android Tuner, System Tuner, Battery Monitor Widget
 
DieHappy
Old
#15  
DieHappy's Avatar
Senior Member
Thanks Meter 221
Posts: 119
Join Date: Oct 2006
Location: Pittsburgh, PA
I have not tested this out yet, but I'm pretty sure you can rename "/sdcard/adw_settings.xml" to "/data/data/org.adw.launcher-backup/launcher.preferences.almostnexus.xml" if you are using the ADW.Launcher settings backup.restore.

Likewise with renaming "/sdcard/adw_launcher.db" to "/data/data/org.adw.launcher-backup/launcher.db-wal". This file has an extension of .db-wal, but it is most likely the exact same file. I will have to test this out sometime to make sure.

I also wanted to point out that you only want to copy "launcher.preferences.almostnexus.xml" and "launcher.db-wal". Don't just delete /data/data/org.adw.launcher and replace the entire directory with your backup. If you do this it will just force close and probably delete the directory and recreate it again.

Does anyone else know what files to backup and restore from other launchers?

---------- Post added at 12:16 AM ---------- Previous post was at 12:08 AM ----------

Quote:
Originally Posted by 3c View Post
Great finding! I'll try to integrate that into System Tuner asap! That would be awesome to have a way to restore launchers setup. All I managed so far is to restore a launcher's icons, without widget, but with that might be able to restore the widgets too
If the widgets didn't come with the rom, you would have your program backup and restore the .apk files too. Fancy Widgets didn't seem to work right on a custom rom I was messing around with, I think because when ADW reset it knew where to place Fancy Widgets which had not yet run so it wasn't functional yet. Perhaps backing up this widgets /data/dir might do the trick, but I'm not sure.

ADW appears to delete and re-create the "/data/data/org.adw.launcher" dir if it exists when the program runs for the first time. This is the reason why I had to sleep for 45 seconds before replacing the files and restarting the launcher. If this is how all programs/widgets work, then using my method probably won't work on the settings for those files because they won't run automatically like the launcher does.
 
LastOttoman
Old
#16  
LastOttoman's Avatar
Senior Member
Thanks Meter 190
Posts: 169
Join Date: Mar 2010

 
DONATE TO ME
Default scripts/check_binaries: line 12: clear: command not found

scripts/check_binaries: line 12: clear: command not found

why do i get this error please help me ...

i have been searchin about all post but i did not find any answer tenkss ...
 
kyleforge
Old
#17  
Senior Member
Thanks Meter 69
Posts: 270
Join Date: Jan 2011
Location: Christchurch
Just decompile the launcher's APK and edit the default_homescreen.XML (it will have a different filename for different launchers). Recompile and sign. Done :)

Sent from my GT-I9100 using xda premium


Samsung Galaxy GT-i9195
- Stock XXUBML4

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


New Nvidia SHIELD Tablet OTA! Moto G 4G Gets Official CyangenMod 11 Nightlies – XDA Developer TV

The Nvidia SHIELD Tablet gets its … more

Prevent Apps from Locking Screen Orientation with HaveOwnOrientation

Most applications on Android play nicely with both landscape and … more

Create Your Own Launcher with HTMLauncher

There are hundreds of launcher replacement applications available for Android. Most of them are … more

First ROMs Appear for the Nvidia Shield Tablet

TheNvidia Shield Tablethas only been available for a little over a month. In that short time, … more