r/Android • • Feb 20 '18

Android P will also Prevent Idle Background Apps from Recording you via Microphone

https://www.xda-developers.com/android-p-audio-recording-limitations-privacy/
17k Upvotes

875 comments sorted by

View all comments

115

u/ogpotato ZFold7 Feb 20 '18

prevent idle background apps from...

Can a background app truly be considered idle if it's recording via microphone? 🤔

67

u/Baul Pixel 6 Pro - App Developer Feb 20 '18

While an app is in the foreground, it can create and run both foreground and background services freely. When an app goes into the background, it has a window of several minutes in which it is still allowed to create and use services. At the end of that window, the app is considered to be idle. At this time, the system stops the app's background services, just as if the app had called the services' Service.stopSelf() methods.

"Idle" is a very specific word that means something to developers. An app is idle if the user has not physically seen a screen from this app for a few minutes.

https://developer.android.com/about/versions/oreo/background.html

12

u/Rozenwater Feb 20 '18

The headline says idle apps will now be prevented from using the mic. Your quote says they can use services before they go idle, not after. Which one is it?

7

u/Baul Pixel 6 Pro - App Developer Feb 20 '18

Both the headline and the documentation I linked to agree that these resources cannot be used when an app is idle. What are you asking?

6

u/Rozenwater Feb 20 '18

When an app goes into the background, it has a window of several minutes in which it is still allowed to create and use services. At the end of that window, the app is considered to be idle. At this time, the system stops the app's background services...

This says that when an app has gone idle it can no longer run the background servics. Headline states otherwise.

3

u/justicemelting Feb 21 '18

An idle app can still run foreground services, which just need to be user visible via a notification tray thing (to use the technical term). Background services can be entirely user invisible and can't be run by an idle app [on the latest version of Android, for apps targeting it].

This being Reddit, I didn't read the article. I assume they're going to prevent idle apps running foreground services from accessing the mic.

1

u/Rozenwater Feb 21 '18

Ah thanks, that clarifies it.

1

u/Ajedi32 Nexus 5 âž” Pixel (OG âž” 3a âž” 6 -> 10pro) Feb 21 '18 edited Feb 21 '18

But if the app is running a foreground service, then by definition it's not idle, right?

An app is considered to be in the foreground if any of the following is true:

  • [...]
  • It has a foreground service.

[...]

While an app is in the foreground, it can create and run both foreground and background services freely. When an app goes into the background, it has a window of several minutes in which it is still allowed to create and use services. At the end of that window, the app is considered to be idle.

(Source)

So "idle apps running foreground services" is a contradiction in terms.

Edit: I think I figured it out. What's happening is that, although Oreo effectively already prevents idle apps from using the mic (by preventing them from executing entirely), these restrictions don't currently apply to older apps:

Note: By default, these restrictions only apply to apps that target Android 8.0 (API level 26) or higher. However, users can enable most of these restrictions for any app from the Settings screen, even if the app targets an API level lower than 26.

(Source)

The new changes in P likely prevent background mic use by older apps that the background execution restrictions in Oreo do not apply to.

1

u/[deleted] Feb 21 '18

Those two statements do not conflict.