[Sony Cross-Device General] niaboc79:
How to add Auto Synch Switcher

The Honami settings introduce a new switcher that you can use the same way as Wifi and Bluetooth, the Auto Synch Switcher.

I will show you an easy way to add it but I will have to teach you how are working the ID first :)

Little introduction to ID

What are the ID?

To tell you what they are, first I must tell you where they are... Open public.xml found in res/value and you will see something like that:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<public type="attr" name="state_encrypted" id="[COLOR="Red"]0x7f010000[/COLOR]" />
<public type="attr" name="icon" id="0x7f010001" />
<public type="attr" name="emptyColor" id="0x7f010002" />
<public type="attr" name="minTickWidth" id="0x7f010003" />
<public type="attr" name="optimalWidth" id="0x7f010004" />
<public type="attr" name="optimalWidthWeight" id="0x7f010005" />
<public type="attr" name="sweepDrawable" id="0x7f010006" />
<public type="attr" name="followAxis" id="0x7f010007" />
<public type="[COLOR="DarkOrange"]drawable[/COLOR]" name="preview" id="0x7f0200b8" />
<public type="drawable" name="appwidget_button_center" id="0x7f020001" />
<public type="drawable" name="appwidget_button_left" id="0x7f020002" />
<public type="drawable" name="appwidget_button_right" id="0x7f020003" />
<public type="drawable" name="btn_check_buttonless_on" id="0x7f020014" />
<public type="drawable" name="data_sweep_left" id="[COLOR="Lime"]0x7f[/COLOR]020018" />
<public type="mipmap" name="ic_launcher_settings" id="0x7f[COLOR="Magenta"]03[/COLOR]0000" />
<public type="layout" name="account_preference" id="0x7f040001" />
<public type="layout" name="account_sync_screen" id="0x7f040002" />
<public type="layout" name="add_account_screen" id="0x7f04[COLOR="Silver"]0003[/COLOR]" />

I've added some color to explain what are the different parts:

In Red you have the full ID, the long number will be used in the differents smali files as a shortcut.

In Dark Orange you have the type of ID, there are many differents type such as drawable, layout, styles, id, ...

In Lime you can see that the 4 first characters are always 0x7f, all IDs used by an apk who are inside this apk are starting by that.

In Magenta you can see two more characters, these two are related to the type saw earlier, for example type drawable 02, type layout 04, ...

In Silver you have the last 4 characters who are related to different names used for a same type. These numbers are in hexadecimal.

I need to show you an other place where you can find ID, inside framework-res.apk, Open public.xml found in res/value and you will see something like that:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<public type="attr" name="theme" id="[COLOR="Red"]0x01010000[/COLOR]" />
<public type="attr" name="label" id="0x01010001" />
<public type="attr" name="icon" id="0x01010002" />
<public type="attr" name="name" id="[COLOR="Lime"]0x010[/color]10003" />
<public type="attr" name="manageSpaceActivity" id="0x01010004" />
<public type="attr" name="allowClearUserData" id="0x01010005" />
<public type="attr" name="permission" id="0x01010006" />
<public type="id" name="background" id="0x01020000" />
<public type="id" name="checkbox" id="0x01020001" />
<public type="id" name="content" id="0x01020002" />
<public type="id" name="edit" id="0x01[COLOR="Magenta"]02[/color]0003" />
<public type="id" name="empty" id="0x01020004" />
<public type="style" name="Animation" id="0x01030000" />
<public type="style" name="Animation.Activity" id="0x01030001" />
<public type="style" name="Animation.Dialog" id="0x01030002" />
<public type="style" name="Animation.Translucent" id="0x01030003" />
<public type="style" name="Animation.Toast" id="0x01030004" />
<public type="style" name="Theme" id="0x01030005" />
<public type="style" name="Theme.NoTitleBar" id="0x0103[COLOR="Silver"]0006[/color]" />

I have used the same colors as before because this is exactly working the same way with some little variations.

The first characters are now 0x01 instead of 0x7, that means that these ID are inside framework-res.apk

BUT be carefull, when the IDs are used inside the smali files of an APK, the first zero after the x is always removed.

Example: 0x01030002 found in public.xml of framework-res.apk will be wrote inside a smali of an APK -> 0x1030002

Instructions

Now I can finally start :)

1) Copy AutoSyncEnabler.smali, AutoSyncDialogFragment.smali, AutoSyncDialogFragment$1.smali and AutoSyncDialogFragment$2.smali in smali/com/android/settings/

2) Open AutoSyncDialogFragment.smali with notepad++ and search "0x7" without the quote.

You will found 4 ID as explained, these ID are related to MY Settings.apk, that means that inside your apk, these "Shortcuts" may not be the good one...

I have include the public.xml found in MY settings.apk and called it public-settings.xml, open it too with notepad++ and in the same time open YOUR public.xml found in YOUR settings.apk

Let's do it for the first ID found in the smali: 0x7f0b067a, search now the full ID inside my public.xml, you will found this:

<public type="string" name="data_usage_auto_sync_off_dialog_title" id="[COLOR="Red"]0x7f0b067a[/COLOR]" />

So this ID is a shortcut for the "string" named "data_usage_auto_sync_off_dialog_title"

Now search in YOUR public.xml: "data_usage_auto_sync_off_dialog_title" without the quote and check if the full ID is the same. If the ID is different, use this one inside the smali files.

Do the same with all ID starting by 0x7

3) Copy Settings$HeaderAdapter.smali in smali/com/android/settings/ and open it with notepad++

Do a search for all ID starting by 0x7 and check between MY public.xml and YOUR public.xml

Do also a search for all ID starting by 0x1 (ID related to framework-res.apk) (You must found 5 different ID)

The first one found is 0x1010208

As I told you ID related to framework-res.apk found in smali are slightly different when they are in the public.xml of framework-res.apk (Remember the first character after the x ? )

I have include the public.xml found in MY framework-res.apk and called it public-framework-res.xml. Open MY public-framework-res.xml and YOUR public.xml of YOUR framework-res.apk

Do a search for "0x01010208" without the quote (I have added a zero after the x ;) ) in MY public.xml and you will found that:

<public type="attr" name="listSeparatorTextViewStyle" id="0x01010208" />

Now search "listSeparatorTextViewStyle" inside YOUR public.xml and check if the ID are the same, if different replace with the correct one (Don't forget to remove the zero in the smali).