According to a report in XDA Developers, the website has spotted a couple of references in the Android Open Source Project (AOSP) code that suggest that Android P will prevent the idle (being in the background for more than defined time) apps from spying on you.

One AOSP code commit from January 19 introduces rules that will restrict the idle apps from accessing camera. If any app in the idle state tries to access the camera, Android will throw an error and close the cameras for that app.

Similarly, another AOSP code commit from the same day introduces rules that will stop idle apps from recording audio. If an app in the idle state does try to record audio, Android will let it record, but will send it empty data, meaning no real recording. Only after the app returns to active state, it will get real audio data recording.

Both these rules will greatly empower Android in protecting user privacy even if the users somehow end up with malicious apps on their phone.

If you are confused about idle and active app states, here are some simple explanations:

Active app state: When the app is running in the foreground and you can see or it is running in the background with a notification that you can see in the notification tray or lock-screen.

Idle app state: App in any other state than the two conditions above for an active app state is treated as idle app or app standby. The only exception to this are the device admin apps.

I hope this clears things up.

Android P developer preview is expected to be announced at the I/O conference in May, 2018, with the final version launch around October.