I got my GN fired up again last night and tested this out; it totally worked when I manually put back the old .xml and rebooted after a forced rebuild! All apps retain their permissions. Awesome idea!
Now just to figure out the best time/way in the process to automatically put it back... Waiting for it to reappear might not be the best way since I think it writes to it multiple times during a dexopt, but maybe if we just wait for bootcompleted? First I'll try just at the end of the script if it detects a backup. I'm going to see about extending the script to work on multiple users' runtime-permissions files as well.
I've submitted a new pull request on the gappsintegrator github.
Added in backup up of user(s) runtime-permissions files and then restore after boot is complete with a forced reboot for those apps needing force rebuild. (Only does the backup for the first app needing force rebuild since the files would have been deleted for any following app(s) requiring force rebuild.)
Found that some apps when updated would have a one line <updated-package> entry in packages.xml (Maps and GMS) instead of multiple lines as the script expected and put in a fix for that (only in the Marshmallow section, if KitKat/Lollipop can have the same situation, that fix should be copied to those sections as well.)
On my device, the time is in 1970 when the script starts, moved the log time stamp to the end where $logbuff is written out since it has the correct time by then.
Found that Google Play Games is an app requiring force rebuild.
For safety, I put in a limit of 4 apps per session to be integrated just so things will be quiet when the device starts to optimize.
Added a line to go ahead and delete the /data/app copy of the app during the session where packages.xml has already been updated to point at the /system/app copy (only in the Marshmallow section, left the lines touching integrated and looking for that on the next session as a backup for the deletion.)
(You may have already been notified of the pull request, sorry that was a little messy; I'm really done now!)