Phone manufacturers are offering updates for longer:
https://www.gsmarena.com/samsung_pledges_4_os_updates_5_year...Alternatively, the FOSS community (e.g. postmarketOS) are working on bringing plain old Linux to smartphones. It's not ready yet, but they're making good progress.
Many phones now support replaceable battiers: PinePhone Pro, Librem 5, Shift6mq.