[Android Software Development] oberworld:
I was doing some test by modifing packages.xml and adding lines manually, without any init.d script.

My results:

- If you modify the file, system restores the file on every reboot, even if you set perms to 440, restore to 660 and reverts changes.

- if you install one app, the same result.

- if you edit the file and don't reboot, nothing happens.

- The apps that want to write on extsd already have the correct permissions on packages.xml but still can't write, no need to add the same permissions again.

- only way to make apps work without problems it's to cut and paste them on \system\priv-app

For example titanium backup works well in priv-app folder but not in system/app and not on data/app.

Testing more apps and the same, i have to put in priv-app.

Now i was comparing different permissions for titanium backup depends on folder:

Permissions on \data\app:

<package name="com.keramidas.TitaniumBackup" codePath="/data/app/com.keramidas.TitaniumBackup-1" nativeLibraryPath="/data/app/com.keramidas.TitaniumBackup-1/lib" primaryCpuAbi="arm64-v8a" publicFlags="940097092" privateFlags="0" pkgFlagsEx="0" ft="1553788cc40" it="1553788d4d9" ut="1553788d4d9" version="381" userId="10052">
<sigs count="1">
<cert index="1" />
</sigs>
<perms>
<item name="android.permission.READ_SMS" granted="true" flags="0" />
<item name="android.permission.READ_CALL_LOG" granted="true" flags="0" />
<item name="android.permission.USE_CREDENTIALS" granted="true" flags="0" />
<item name="android.permission.RECEIVE_BOOT_COMPLETED" granted="true" flags="0" />
<item name="android.permission.INTERNET" granted="true" flags="0" />
<item name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" granted="true" flags="0" />
<item name="android.permission.READ_EXTERNAL_STORAGE" granted="true" flags="0" />
<item name="android.permission.READ_PHONE_STATE" granted="true" flags="0" />
<item name="android.permission.WRITE_SMS" granted="true" flags="0" />
<item name="android.permission.WRITE_CONTACTS" granted="true" flags="0" />
<item name="android.permission.CHANGE_WIFI_STATE" granted="true" flags="0" />
<item name="android.permission.ACCESS_NETWORK_STATE" granted="true" flags="0" />
<item name="android.permission.WRITE_CALL_LOG" granted="true" flags="0" />
<item name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" granted="true" flags="0" />
<item name="android.permission.GET_ACCOUNTS" granted="true" flags="0" />
<item name="android.permission.WRITE_EXTERNAL_STORAGE" granted="true" flags="0" />
<item name="android.permission.VIBRATE" granted="true" flags="0" />
<item name="android.permission.ACCESS_WIFI_STATE" granted="true" flags="0" />
<item name="android.permission.WAKE_LOCK" granted="true" flags="0" />
<item name="android.permission.READ_CONTACTS" granted="true" flags="0" />
<item name="com.android.voicemail.permission.ADD_VOICEMAIL" granted="true" flags="0" />
</perms>

Permissions on \system\priv-app:

<package name="com.keramidas.TitaniumBackup" codePath="/system/priv-app/TitaniumBackup" nativeLibraryPath="/system/priv-app/TitaniumBackup/lib" primaryCpuAbi="arm64-v8a" publicFlags="940097093" privateFlags="8" pkgFlagsEx="0" ft="15537929fe0" it="15537929fe0" ut="15537929fe0" version="381" userId="10052">
<sigs count="1">
<cert index="1" />
</sigs>
<perms>
<item name="android.permission.READ_SMS" granted="true" flags="0" />
<item name="android.permission.READ_CALL_LOG" granted="true" flags="0" />
<item name="android.permission.USE_CREDENTIALS" granted="true" flags="0" />
<item name="android.permission.RECEIVE_BOOT_COMPLETED" granted="true" flags="0" />
<item name="android.permission.WRITE_MEDIA_STORAGE" granted="true" flags="0" />
<item name="android.permission.INTERNET" granted="true" flags="0" />
<item name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" granted="true" flags="0" />
<item name="android.permission.READ_EXTERNAL_STORAGE" granted="true" flags="0" />
<item name="android.permission.READ_PHONE_STATE" granted="true" flags="0" />
<item name="android.permission.WRITE_SMS" granted="true" flags="0" />
<item name="android.permission.WRITE_CONTACTS" granted="true" flags="0" />
<item name="android.permission.CHANGE_WIFI_STATE" granted="true" flags="0" />
<item name="android.permission.ACCESS_NETWORK_STATE" granted="true" flags="0" />
<item name="android.permission.WRITE_CALL_LOG" granted="true" flags="0" />
<item name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" granted="true" flags="0" />
<item name="android.permission.GET_ACCOUNTS" granted="true" flags="0" />
<item name="android.permission.WRITE_EXTERNAL_STORAGE" granted="true" flags="0" />
<item name="android.permission.VIBRATE" granted="true" flags="0" />
<item name="android.permission.ACCESS_WIFI_STATE" granted="true" flags="0" />
<item name="android.permission.WAKE_LOCK" granted="true" flags="0" />
<item name="android.permission.READ_CONTACTS" granted="true" flags="0" />
<item name="com.android.voicemail.permission.ADD_VOICEMAIL" granted="true" flags="0" />
</perms>

I was about to see what changes.

Hope this help.

EDIT: seems the only difference is privateflags and WRITE_MEDIA_STORAGE permissiion but if we add the permission the system will delete the permission on reboot or when installing an app.