After managed package is installed, post install script is executed under some virtual system user with God permissions. But there are some issues with this type of user when it comes to querying directly permission tables etc.
So we need a way to identify somehow in our business logic that it is this special package user executing logic from post install script context to react appropriately.
I've dumped UserInfo properties from post install script:
DEBUG: getName=MY_TEST_PACKAGE
DEBUG: getUserName=033f4000000xfuvaas@00dq0000000cbj6eag
DEBUG: getUserType=LicenseManager
DEBUG: [email protected]
DEBUG: getProfileId=00e41000001qaB4AAI
DEBUG: getSessionId=null
DEBUG: fetch user from db by id - users.size=0
Based on this it seems that the most reliable way would be to check if user with such id exists in User table - if no, than it's package user. Any better ideas? Is there more accurate way (prefereably without issuing separate query)?