<CarlosDev/>

Current

Android 9 Pie: idle apps lose camera and mic

API 28, August 2018. Idle apps lost the camera, mic and sensors, cleartext HTTP became opt-in, hidden APIs started to fail, and a pill replaced the home button.

Published
Reading
16 min
Write-up
Stable
Series
Part 10 of 19 · Android, version by version
Android 9 Pie banner, with the version logo.
In this record12 sections

Android 9 Pie is the release that cut idle apps off from the camera, the microphone and the sensors. Apps targeting API 28 lost cleartext HTTP by default, and calls into hidden platform APIs started to fail. Users got a pill-shaped home button with swipe navigation, Adaptive Battery, and the last dessert name Google used in public.

The Android 9 home screen with the Pixel Launcher: the date and weather at the top, a blue wallpaper, a dock with Phone, Messages, Play Store, Chrome and Camera, a Google search bar, and a single pill-shaped home button at the bottom with no back or recents button
The Android 9 home screen, where the pill is the only navigation button. Wikimedia Commons · Apache License 2.0

At a glance

VersionAndroid 9
API level28
NamePie, public
Build.VERSION_CODESP
ReleasePixel rollout and AOSP source, 6 August 2018
Launch devicesPixel, Pixel XL, Pixel 2 and Pixel 2 XL by update; Pixel 3 and Pixel 3 XL came on it
Google Play target-API deadlineNew apps from August 2019, app updates from November 2019

The first developer preview came out on 7 March 2018; the five preview milestones are the parts below this overview. The beta followed on 8 May, during Google I/O, and thanks to Project Treble it also ran on phones from Essential, Nokia, Oppo, Sony, Vivo and Xiaomi.

On 6 August 2018 Google pushed the source to AOSP and started the over-the-air update to Pixel phones. 9to5Google reported the Pixel and Pixel 2 images live that day, with the August security patch. Essential started pushing the final release to the Essential Phone the same day. Google promised the update by the end of fall to devices in the beta from Sony, Xiaomi, HMD Global, Oppo, Vivo, OnePlus and Essential, and to qualifying Android One phones. AOSP lists the first Pie builds for Pixel 3 and Pixel 3 XL (PD1A) at the September 2018 patch level. AOSP security bulletins listed Android 9 for the last time in January 2022; from February 2022 they cover Android 10 and later.

What it brought

  • New system navigation. A single pill-shaped home button: swipe up for a new Overview with full-screen app previews, tap to go home. It was off by default, under Settings > Gestures > “Swipe up on home button”. Back stayed a button, hidden on the home screen.
  • Adaptive Battery. Built with DeepMind, it uses machine learning to give system resources to the apps the user cares about. Underneath are the App Standby Buckets, covered under What changed for your app.
  • Display cutout support. DisplayCutout and getDisplayCutout() report where the notch is. The layoutInDisplayCutoutMode window attribute takes DEFAULT, SHORT_EDGES or NEVER. Developer options can simulate a cutout on any device. The 9 CDD allows cutouts only on the short edges, at most one per edge.
  • Smaller user changes. A rotation button in the navigation bar when auto-rotate is off, a screenshot editor, a text magnifier while selecting, simplified volume controls, and Adaptive Brightness. The clock moved to the left of the status bar to leave room for a notch, and quick settings tiles lost their drop-down panels: a long press opens the setting instead, as Ars Technica noted.
  • Notifications. MessagingStyle takes a Person, shows images with setData(), keeps reply drafts (EXTRA_REMOTE_INPUT_DRAFT) and offers smart replies through RemoteInput.setChoices(). Users can block whole channel groups.
  • Multi-camera API. Apps can open streams from two or more physical cameras at once, or one logical camera that switches between them. External USB cameras work through Camera2 on supported devices.
  • Media and images. ImageDecoder replaces BitmapFactory, and AnimatedImageDrawable plays GIF and WebP. HEIF encoding, HDR VP9 Profile 2 and a Dynamics Processing audio effect joined the platform.
  • Wi-Fi RTT. On supported hardware, apps with ACCESS_FINE_LOCATION measure distance to IEEE 802.11mc access points without connecting. Three or more give a position typically within 1 to 2 meters.
  • Machine learning and text. Neural Networks API 1.1 with nine new operations, Smart Linkify on top of TextClassifier, PrecomputedText, and Slices and App Actions to show app content in Google surfaces.
  • ART and tracing. ART’s ahead-of-time compiler converts an app’s DEX files into a more compact form, so apps start faster and use less disk and RAM; low-end devices gain the most. System traces can be recorded on the device itself and shared as a report, HTML included.
  • Digital Wellbeing. The Dashboard, App Timer, the new Do Not Disturb and Wind Down. It shipped as a Google app from the Play Store, in beta on Pixel phones running Android 9.

Security and privacy

  • Idle apps lose input. While an app’s UID is idle, the microphone reports empty audio, SensorManager sensors stop sending events, and its cameras disconnect with an error. Use a foreground service to keep receiving sensor events.
  • TLS by default. For apps targeting API 28, isCleartextTrafficPermitted() returns false unless the Network Security Configuration allows cleartext for a domain. The table for apps targeting API 28 says what to do.
  • Private DNS. Android 9 upgrades DNS to DNS over TLS when the network’s server supports it. Users can turn it off or name a provider in “Private DNS” under Network & internet. Apps that resolve names themselves can check LinkProperties.isPrivateDnsActive().
  • BiometricPrompt. The system draws one biometric dialog for fingerprint, face or iris. Apps should move from FingerprintManager to BiometricPrompt.
  • StrongBox. A new Keystore backed by a separate secure chip with its own CPU, storage and true random number generator. Request it with setIsStrongBoxBacked(true); an unsupported key throws StrongBoxUnavailableException. The 9 CDD only strongly recommends it.
  • Android Protected Confirmation. On supported devices that launch with Android 9, ConfirmationPrompt shows a statement the user approves outside the main OS. The Trusted Execution Environment then signs it.
  • Keymaster 4. Secure key import, Triple DES for legacy systems, separate patch levels per partition, and setUnlockedDeviceRequired() for keys that cannot decrypt while the screen is locked.
  • APK Signature Scheme v3. It can carry a proof-of-rotation record, so an app can move to a new signing key.
  • Platform hardening. Control Flow Integrity in the media framework, NFC and Bluetooth, kernel CFI support, more integer overflow sanitizers, and a stricter seccomp filter. File-based encryption now works with adoptable storage, and metadata encryption arrived where hardware supports it.
  • Lockdown. “Show lockdown option” in the lock screen settings adds a “Lockdown” button to the power menu. It turns off Smart Lock, fingerprint unlocking and notifications on the lock screen until the user unlocks with a PIN, pattern or password.
  • Encrypted backups. With a PIN, pattern or password set, Android backups are encrypted with a client-side secret, and restoring them needs that screen lock.
  • Smaller changes. A developer option for a randomized MAC address when connecting to Wi-Fi, WPS deprecated, Android secure encrypted files (ASEC) removed, and hostname checks no longer fall back to the certificate’s CN.

Permissions

  • CALL_LOG group. READ_CALL_LOG, WRITE_CALL_LOG and PROCESS_OUTGOING_CALLS moved out of the PHONE group into a new CALL_LOG group. Request them on their own or get a SecurityException.
  • Phone numbers. Numbers in the phone state broadcast and in PhoneStateListener come back empty without READ_CALL_LOG.
  • Wi-Fi scans. WifiManager.startScan() needs ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION, CHANGE_WIFI_STATE, and location services on. Reading SSID and BSSID from getConnectionInfo() needs a location permission and ACCESS_WIFI_STATE.
  • Cell info. With device location off, getAllCellInfo(), getCellLocation() and getNeighboringCellInfo() return nothing.
  • Serial number. Build.getSerial() needs READ_PHONE_STATE.
  • Added. FOREGROUND_SERVICE (normal), USE_BIOMETRIC (normal), ACCEPT_HANDOVER (dangerous) and NFC_TRANSACTION_EVENT (normal).
  • Deprecated. USE_FINGERPRINT, in favour of USE_BIOMETRIC.

What changed for your app

All apps on Android 9

ChangeWhat to do
App Standby Buckets: active, working set, frequent, rare, neverCheck with UsageStatsManager.getAppStandbyBucket(); test with adb shell am set-standby-bucket <pkg> rare
Idle apps lose camera, microphone and sensorsMove continuous sensor work into a foreground service
Restrictions on non-SDK interfacesReplace hidden calls with SDK ones; find them with StrictMode.detectNonSdkApiUsage()
Foreground apps can scan Wi-Fi 4 times in 2 minutes, all background apps once in 30Cache scan results instead of scanning on demand
NETWORK_STATE_CHANGED_ACTION no longer carries SSID or BSSIDCall getConnectionInfo()
Battery saver applies background limits to every appTest with battery saver on
Bouncy Castle versions of many algorithms deprecatedUse the Conscrypt provider
FLAG_ACTIVITY_NEW_TASK enforced again from a non-activity contextAdd the flag when starting an activity from a service or application context
Rotation lock can hold any rotation the top activity supportsDo not assume portrait
getCameraIdList() can list several front or back camerasLet the user choose among them
Apps targeting API 16 or lower show a warning when launchedRaise targetSdkVersion to 17 or higher

The bucket limits jobs, alarms and high-priority FCM messages, and in “rare” also network access. They apply only on battery, and the manufacturer decides how apps are assigned.

The Wi-Fi background limit used to apply to each app: on Android 8.0 and Android 8.1 Oreo, every background app could scan once in 30 minutes. On Android 9 that one scan is shared by all of them.

The old-app warning reads “This app was built for an older version of Android and may not work properly.” AOSP shows it when targetSdkVersion is below ro.build.version.min_supported_target_sdk, which Pie sets to 17.

Non-SDK interfaces fall into lists. The light greylist keeps working, with log entries and toasts to flag it. The dark greylist fails for apps targeting API 28, and the blacklist fails for every app, with errors such as NoSuchMethodError or NoSuchFieldException.

light greylist dark greylist no yes blacklist App calls a non-SDK method Which list? Works, logged targetSdk 28? Fails as if missing

To test, adb shell settings put global hidden_api_policy_p_apps 1 (and hidden_api_policy_pre_p_apps for older targets) lifts the restriction.

Apps targeting API 28

ChangeWhat to do
Cleartext traffic blocked by defaultUse HTTPS, or set cleartextTrafficPermitted="true" for named domains in the Network Security Configuration
startForeground() needs FOREGROUND_SERVICEDeclare it; it is a normal permission
Build.SERIAL returns "unknown"Request READ_PHONE_STATE and call Build.getSerial()
Apache HTTP client off the bootclasspathDeclare <uses-library android:name="org.apache.http.legacy" android:required="false"/> or drop it
One WebView data directory per processKeep WebView in one process, or call WebView.setDataDirectorySuffix()
Per-app SELinux domainsShare files through a content provider, not world-readable files
Built-in DNS clients must honour Private DNSUse encrypted DNS to the same host, or the system resolver
Zero-area views are not focusable; no implicit initial focusRequest initial focus explicitly
WebView reads 8-digit hex colours as RGBA and sniffs no MIME types for file:Fix ARGB colours in CSS and give local files their extension

What lasted

  • Gesture navigation became full in Android 10: back from an edge swipe, home from the bottom, and the default on new devices, with three buttons still offered.
  • Non-SDK restrictions grow every release. Interfaces still allowed in Pie but blocked in Android 10 sit on the max-target-p list.
  • Background camera and microphone got stricter in Android 11: a foreground service needs the camera or microphone type, and one started from the background cannot use them.
  • Device identifiers: Android 10 put Build.getSerial() and the IMEI behind READ_PRIVILEGED_PHONE_STATE, which Play apps cannot hold.
  • BiometricPrompt reached older versions through the AndroidX Biometric library, which added BiometricManager.
  • Dessert names ended here. Google dropped them with Android 10.

Worth knowing

  • At launch the Easter egg was still just a “P”, as Ars Technica noted: a letter drawn over colour rings that change on every launch and resize with two fingers. Pixel 3 builds (android-9.0.0_r11) swapped it for a drawing app labelled PAINT.APK.
  • In AOSP, Build.SERIAL is set by reading a property called no.such.thing. A comment explains why: a function call stops compilers from inlining the value, so the platform can return "unknown" to apps targeting API 28.
  • Google’s own post joked about the name: “Slices (pie…slices…get it?!)”.
  • When Google retired dessert names in August 2019, one reason it gave was that “pies are not a dessert in some places”.
An Essential Phone on a metal bench showing the Android 9 Easter egg: a large letter P over red, green and purple rings, with the display cutout at the top
The Android 9 Easter egg on an Essential Phone, photographed on 7 August 2018. Davidlamma, Wikimedia Commons · CC BY-SA 4.0

Part 1 of 5

1 min

Android P Developer Preview 1: first build

7 March 2018. A flash-only build for developers that already had cutout support, the idle-app limits on camera and mic, cleartext blocked by default and the first non-SDK warnings.

Read on its own: Android P Developer Preview 1: first build

Google released the first developer preview of “Android P” on 7 March 2018, five months before the final release. Dave Burke called it “an early baseline build for developers only” and promised more for Google I/O in May.

Release date7 March 2018
BuildPPP1.180208.014, as reported by Droid Life; AOSP tags it android-p-preview-1
DevicesPixel, Pixel XL, Pixel 2 and Pixel 2 XL; Android Emulator
How to get itManual download and flash only; Android Beta was not open for P
Platform stabilityNo; APIs still changing

The build brought Wi-Fi RTT (IEEE 802.11mc) for indoor positioning, display cutout support with getDisplayCutout() and layoutInDisplayCutoutMode, a developer option that simulates a cutout, richer MessagingStyle notifications, the multi-camera API, ImageDecoder and AnimatedImageDrawable, HDR VP9 and HEIF encoding, data-cost hints for JobScheduler, Neural Networks API 1.1, and the GlobalPlatform Open Mobile API for secure elements.

Several defining behaviour changes were already in place. Idle apps lost the microphone, camera and sensors. Network Security Configuration blocked cleartext traffic by default. Build.SERIAL moved behind READ_PHONE_STATE, and installing an app targeting below API 17 showed a warning dialog. Calls into restricted non-SDK interfaces showed a toast and a log line. Fingerprint authentication used a new FingerprintDialog API, which the next milestone replaced.

Part 2 of 5

1 min

Android P Beta: open to partner phones

8 May 2018. The Google I/O build, also Developer Preview 2, reached six partner phones through Treble and added Adaptive Battery, Slices, BiometricPrompt and hard non-SDK errors.

Read on its own: Android P Beta: open to partner phones

Google announced Android P Beta on 8 May 2018, at Google I/O. It is the second developer preview: AOSP tags it android-p-preview-2, and 9to5Google called it “the second Developer Preview build of Android P”. It was the first P build anyone could get over the air.

Release date8 May 2018
DevicesPixel, Pixel XL, Pixel 2 and Pixel 2 XL; Sony Xperia XZ2, Xiaomi Mi Mix 2S, Nokia 7 Plus, Oppo R15 Pro, Vivo X21UD and X21, and Essential PH-1
How to get itOver the air through Android Beta on Pixel; partner builds from each manufacturer’s site
Platform stabilityNo; final APIs came with Beta 2

The partner phones were possible because of Project Treble, which Google called “proof of what Treble can do”. The build added the user-facing features Pie is known for: Adaptive Battery with four App Standby buckets, the single-button system navigation, battery-based background restrictions in Settings, and the text Magnifier. For developers it added Slices (with the APIs in Android Jetpack), smart replies in notifications, new TextClassifier entity types, the Dynamics Processing audio effect, Android Protected Confirmation and StrongBox keys.

Two changes broke what Preview 1 had shipped. BiometricPrompt replaced FingerprintDialog, with one USE_BIOMETRIC permission, and FingerprintManager and USE_FINGERPRINT became deprecated. Non-SDK interfaces that were not exempted now threw exceptions instead of showing a toast, and StrictMode gained detectNonSdkApiUsage() to find them.

Part 3 of 5

1 min

Android P Beta 2: API 28 is final

6 June 2018. Developer Preview 3 froze API level 28, shipped the official SDK, opened Google Play to apps targeting it, and settled which non-SDK interfaces stayed reachable.

Read on its own: Android P Beta 2: API 28 is final

Beta 2 came out on 6 June 2018, four weeks after Google I/O. Google described it as “an update that includes the final Android P APIs”. AOSP tags it android-p-preview-3, and 9to5Google reported it as Developer Preview 3.

Release date6 June 2018
BuildPPP3.180510.008, in the AOSP tag message and in 9to5Google’s report
DevicesPixel, Pixel XL, Pixel 2 and Pixel 2 XL; partner phones over the following weeks
How to get itOver the air through Android Beta, or by flashing the factory image
Platform stabilityYes: API level 28 and the official SDK

With the API frozen, Google opened Google Play to APKs compiled against or targeting API 28, and asked developers to move targetSdkVersion to 28 “as soon as possible”. An app already on API 26 for Play’s upcoming rule, it said, faced “a small jump”.

On 12 June Google explained what Beta 2 did to non-SDK interfaces. Most interfaces that developers had reported went on a greylist that stayed available. Apps targeting API 28 could reach only the greylist; apps targeting Oreo or lower kept most access and got logcat warnings instead. Google said Beta 2 should “closely match” the final release on this point.

Part 4 of 5

1 min

Android P Beta 3: early release candidate

2 July 2018. Developer Preview 4 was an early release candidate with near-final system behaviours, the July 2018 security patch and D8 as a standalone build tool.

Read on its own: Android P Beta 3: early release candidate

Beta 3 came out on 2 July 2018. Google called it “an early release candidate build of Android with near-final system behaviors” on the API level 28 that Beta 2 had frozen. AOSP tags it android-p-preview-4.

Release date2 July 2018
BuildPPP4.180612.004, as reported by 9to5Google
DevicesPixel, Pixel XL, Pixel 2 and Pixel 2 XL; Android Emulator; partner phones later
How to get itOver the air through Android Beta, or by flashing the factory image
Platform stabilityYes, since Beta 2

The build added no APIs. It carried bug fixes, the July 2018 security updates, and an Android Studio build-tools update that shipped D8 as an independent tool. Google asked developers to test against App Standby buckets, the privacy restrictions and the non-SDK limits.

Part 5 of 5

1 min

Android P Beta 4: release candidate

25 July 2018. Developer Preview 5, the last milestone before launch, was a release candidate with final system behaviours on the API 28 frozen since Beta 2.

Read on its own: Android P Beta 4: release candidate

Beta 4 came out on 25 July 2018, twelve days before the final release. Google called it “the last preview milestone before we launch the official Android P platform”. AOSP tags it android-p-preview-5.

Release date25 July 2018
BuildPPP5.180610.010, as reported by 9to5Google
DevicesPixel, Pixel XL, Pixel 2 and Pixel 2 XL; partner phones over the following weeks
How to get itOver the air through Android Beta, or by flashing the system image
Platform stabilityYes, since Beta 2

It was “a release candidate build with final system behaviors”. Google asked developers to finish compatibility testing, watch for non-SDK interface use, and publish updates without changing their target level first. Android 9 Pie shipped on 6 August 2018.

Filed under

Citations

52

External references