The glasses themselves were already integrated with AI prior to Avengers: Infinity War as we see Tony wear them at the beginning of the film. However, at this point in time it is F.R.I.D.A.Y. that Tony has integrated into them. Assuming E.D.I.T.H. isn’t just F.R.I.D.A.Y. renamed.

Tony Stark: F.R.I.D.A.Y., what am I looking at?
F.R.I.D.A.Y.: Not sure, I'm working on it.
Avengers: Infinity War
Tony would then have prepared everything for Peter either during the five year gap or sometime during the events of the film, no information is given as to when. Like you I’d speculate it probably happened after figuring out about time travel and before starting the Time Heist. This seems even more likely as he recorded a "death message" before going on the Time Heist which we see played in Avengers: Endgame, if he was ever going to set things up for when he was gone for Peter that seems like the perfect opportunity.
Tony Stark (hologram): So I thought I'd probably better record a little greeting... In the case of an untimely death on my part. Not that, death in any time isn't untimely. This time travel thing that we're gonna try and pull off tomorrow, it's... it's got me scratching my head about the survivability of it all. But then again, that's the hero gig. Part of the journey is the end. [Tony suddenly gets up walking towards his camera] Uh, what am I even trippin' for? Everything's gonna work out exactly the way it's supposed to. [He leans down and smiles. He is looking straight at Morgan] I love you 3,000.
Avengers: Endgame
It is worth noting though that whilst Tony chose Peter to take over from him, as Happy knew about it, Fury was the one who actually decided to give the glasses to Peter as we find out in the post credits scene. Whilst it could have been in Tony’s will we don’t know for sure so it’s up for speculation which of them actually decided to give them to Peter.
Tony also never had to give the glasses to Fury or anyone for that matter, all he needed to do was leave instructions for what to do with them when/if he died. There’s also nothing stopping the will/instructions also stating give to Peter if he comes back else give to Morgan.
As for the drone network that was mentioned to be a security network designed by Stark. Presumably that has been active for a while but we just haven’t seen it because it hasn’t really been needed.