User2288 I tried looking into this and I think I found some helpful info.
Basically, ANDROID_ID seems to be generated once, then it's stored in a database. I was unable to interact with the database when I tried quickly. I doubt it's possible.
As far as I can tell from reading the website and elsewhere, ANDROID_ID will be the same after reinstalling the same app. One source says the signatures need to be the same for an ANDROID_ID to be the same after reinstalling. It appears there's a function that removes ANDROID_IDs for apps that have been uninstalled, though I'm not sure exactly when it's run or how often. Based on the name, I think it's run on startup / when unlocking a profile and a new session starts, but I don't know for sure.
When looking through the code, I didn't see anything that allows an app to get another app's ANDROID_ID, but even if it were or is possible, I don't see how that would matter. It's only part of the original hash. Not very useful. Apps can just list other installed apps in the same profile anyway. Getting an ID isn't going to reveal any other info that isn't already available.
I don't want to attempt to say exactly how ANDROID_IDs are generated. I'm worried I'll use the wrong words. But, basically, there are two inputs that I could find: a completely randomly generated user ID (which is only used for this purpose as far as I can tell) and an app's signatures.
Here's the code for generating new ANDROID_IDs if anyone is curious.