<CarlosDev/>

Current

Android 4.4 KitKat: Android on 512 MB

API 19, October 2013. Project Svelte fit Android into 512 MB of RAM, apps got a storage access framework and NFC card emulation, and SELinux began enforcing.

Published
Reading
10 min
Write-up
Stable
Series
Part 2 of 19 · Android, version by version
Android 4.4 KitKat banner, with the version logo.
In this record7 sections

Android 4.4 KitKat is the release Google slimmed down so it could run on phones with 512 MB of RAM. For developers it added the storage access framework, printing, NFC host card emulation and immersive full-screen mode. It also put SELinux into enforcing mode and closed shared storage behind READ_EXTERNAL_STORAGE.

At a glance

VersionAndroid 4.4 (4.4W for watches)
API level19 (20 for 4.4W)
NameKitKat, public
Build.VERSION_CODESKITKAT (KITKAT_WATCH)
SDKPlatform revision 1, October 2013; announced 31 October 2013
Release31 October 2013, on the Nexus 5
Launch deviceNexus 5 (LG)
Google Play target-API deadlineNone. Play’s target-API rule started in 2018, at API 26

Google announced Android 4.4 and the Nexus 5 on 31 October 2013 and said the phone was “available today on Google Play”. Phone Scoop reported the same day that orders would ship on 5 November. Google promised the update “in the next few weeks” for the Nexus 4, Nexus 7, Nexus 10 and the Google Play editions of the Galaxy S4 and HTC One.

Android 4.4W, API 20

API 20 exists only for watches. The SDK release notes describe Android 4.4W as the version that “makes KitKat available for Android Wear”, with revision 1 in June 2014. TechCrunch reported the full Android Wear SDK launch at Google I/O on 25 June 2014. Its one documented behaviour change: an AlertDialog might not have a default background if the theme does not set one.

What it brought

The Nexus 5 home screen on Android 4.4.2, with see-through status and navigation bars over the wallpaper, white status icons, and Hangouts in the dock
The Nexus 5 on Android 4.4.2. The status and navigation bars are translucent and the status icons are white. Wikimedia Commons · Apache 2.0
  • Project Svelte. Google’s name for the effort to cut Android’s memory use “so Android can run comfortably on only 512MB of RAM”, from the kernel up to Google’s own apps such as Chrome and YouTube. The details are under “What changed for low-RAM devices” below.
  • Storage access framework. A system picker opens documents from any provider, local or cloud. Apps call ACTION_OPEN_DOCUMENT or ACTION_CREATE_DOCUMENT; storage services subclass DocumentsProvider and implement queryRoots(), queryChildDocuments(), queryDocument() and openDocument().
  • Printing. android.print and android.printservice. An app subclasses PrintDocumentAdapter, draws pages into a PdfDocument, and calls PrintManager.print(). Printer makers ship a PrintService.
  • Host card emulation. Any app can emulate an NFC smart card by extending HostApduService, with no secure element. Ars Technica noted what that meant: Google Wallet could run on any KitKat NFC phone, and Settings got a “Tap & pay” screen to choose the payment app.
  • Immersive mode. SYSTEM_UI_FLAG_IMMERSIVE and SYSTEM_UI_FLAG_IMMERSIVE_STICKY hide the status and navigation bars while the user keeps touching the app. A swipe from the edge brings them back.
  • Translucent system bars. Theme.Holo.NoActionBar.TranslucentDecor, or windowTranslucentStatus and windowTranslucentNavigation.
  • Chromium WebView. WebView moved to a Chromium-based implementation, with evaluateJavascript() and remote debugging through WebView.setWebContentsDebuggingEnabled().
  • Default SMS app. The user picks one “Default SMS app” in Settings. Only that app receives SMS_DELIVER_ACTION and can write to the SMS provider. Ars Technica found Hangouts replacing the Messaging app as the default on the Nexus 5.
  • Default launcher. Settings gained a “Home” screen that sets the preferred CATEGORY_HOME activity. It appears only once two or more home apps are installed, and then stays: AOSP’s comment reads “Once we decide to show Home settings, keep showing it forever”.
  • Screen recording. adb shell screenrecord records the display to MP4, without audio, for up to three minutes.
  • Smaller additions. The transitions framework (android.transition), hardware step detector and step counter sensors, sensor batching, an IR blaster API (ConsumerIrManager), NFC reader mode, Bluetooth MAP and HID over GATT, ImageReader, closed-caption settings, and auto-mirrored drawables for right-to-left languages.

Security and privacy

  • SELinux enforcing. Android 4.3 ran SELinux in permissive mode; 4.4 enforces it. The enforcement was partial: the 4.4 CDD requires domains such as installd, netd and vold to enforce, while the domain for third-party apps “SHOULD remain in permissive mode”. About phone shows “SELinux status”.
  • Verified boot. Android 4.4 supports verified boot through the optional dm-verity kernel feature.
  • Encryption. Full-disk encryption uses scrypt to derive its key. The CDD requires every device with a lock screen to support it.
  • Certificate warnings and pinning. Android warns the user when a certificate is added to the device store. It also detects and blocks fraudulent Google certificates in TLS connections.
  • Smaller changes. The Android Keystore gained ECDSA. VPNs apply per user on multi-user devices. All platform code is compiled with FORTIFY_SOURCE level 2.
  • SMS writes. Only the default SMS app can write to the SMS provider. SMS_RECEIVED_ACTION is now a broadcast no app can abort.
  • Screen capture. SurfaceView.setSecure() keeps protected content out of screen recordings.

Permissions

All permissions were still granted at install. Runtime requests came two years later, in Android 6.0. What changed in 4.4 was external storage.

yes no primary secondary, such as an SD card or App needs a file on external storage In its own Android/data/package folder? Read and write with no permission Which volume? READ_EXTERNAL_STORAGE to read, WRITE_EXTERNAL_STORAGE to write Read with READ_EXTERNAL_STORAGE; writing needs WRITE_MEDIA_STORAGE, system apps only ACTION_OPEN_DOCUMENT: the user picks the file, no permission
  • Reading is enforced. READ_EXTERNAL_STORAGE existed since API 16 but was not enforced. From API 19, an app without it cannot read shared files. In AOSP’s platform.xml, WRITE_EXTERNAL_STORAGE now carries the read group too.
  • App folders need no permission. An app can read and write Android/data/<package>/ on external storage with no permission. A FUSE daemon synthesizes the file owner and mode to make that work.
  • SD card writes are closed. The CDD forbids apps from writing to secondary external storage outside their own folders, so files can be cleaned up when an app is uninstalled. In AOSP, write access to those volumes goes through WRITE_MEDIA_STORAGE, a signature|system permission that third-party apps cannot get.
  • Added. TRANSMIT_IR (normal), plus the INSTALL_SHORTCUT and UNINSTALL_SHORTCUT launcher permissions as SDK constants.
  • Roles chosen in Settings. Being the default SMS app, receiving notifications as a listener and handling “Tap & pay” are granted by the user in Settings, not through a permission dialog.

What changed for your app

All apps on Android 4.4

ChangeWhat to do
Shared external storage needs READ_EXTERNAL_STORAGEDeclare it if you read files outside your own folder
Apps cannot write to secondary storageWrite to your folders from getExternalFilesDirs(), or let the user choose a location with ACTION_CREATE_DOCUMENT
Only the default SMS app can write to the SMS providerDeclare the receivers, activity and service that make you eligible as default; other apps read through SMS_RECEIVED_ACTION
WebView is based on ChromiumTest your web content; apps targeting API 18 or lower run in a “quirks mode”
Low-RAM devices existCheck ActivityManager.isLowRamDevice() and turn off memory-heavy features
The action bar always shows its overflow buttonExpect users to reach overflow actions on screen, even on devices with a Menu key

A messaging app that is not the default does not crash when it writes to the SMS provider. Google warned that the write “will silently fail”.

The overflow change is in AOSP’s ActionBarPolicy. In 4.3, showsOverflowMenuButton() returned true only when the device had no permanent Menu key or was a TV. In 4.4 it always returns true.

Apps targeting API 19

ChangeWhat to do
AlarmManager.set() and setRepeating() are inexact and batchedUse setExact() for a precise time, setWindow() for a range
addPeriodicSync() uses a flex of about 4% of the periodUse requestSync() with SyncRequest.Builder to set your own
PreferenceActivity.isValidFragment() throws unless overriddenOverride it and accept only your own fragment classes
A javascript: URL in WebView replaces the page with its resultRun scripts with evaluateJavascript()
getSharedPreferences() rejects a null namePass a name
App folders on external storage need no permissionStop asking for storage permissions you only used for your own folder

For isValidFragment(), AOSP’s default throws a RuntimeException for apps targeting API 19: “Subclasses of PreferenceActivity must override isValidFragment(String) to verify that the Fragment class is valid!”

What changed for low-RAM devices

The archived “Low RAM” guide on source.android.com lists what Project Svelte did. Google’s team built the target first. Dave Burke, Android’s head of engineering, told ReadWrite they ran a Nexus 4 at 512 MB, at 960×540, on two CPU cores instead of four and at a lower clock, and used it as their daily phone.

The kernel side validated Kernel Same-page Merging (KSM) and swap to ZRAM. The framework killed cached processes that grew too large and started background services one at a time. system_server and SystemUI shrank, and the new ArrayMap and ArraySet replaced HashMap and HashSet across much of the framework to save memory. Two tools came with it: adb shell dumpsys procstats and a “Process Stats” developer option.

The 4.4 CDD sets the floor at 340 MB of memory for the kernel and user space. A device with less than 512 MB must return true from ActivityManager.isLowRamDevice().

What lasted

  • ART. Android 4.4 shipped the ahead-of-time Android Runtime as an experiment, behind “Select runtime” in developer options, with Dalvik as the default. ART became the default runtime in Android 5.0.
  • SELinux went from partial to full enforcement in Android 5.0: more than 60 domains instead of a handful.
  • The storage access framework is still how apps open user files without a storage permission. Android 5.0 added ACTION_OPEN_DOCUMENT_TREE for whole folders.
  • Exact alarms got stricter again: apps targeting Android 12 need SCHEDULE_EXACT_ALARM to set them.
  • Immersive flags were deprecated in API 30 in favour of WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE.
  • Play services stopped updating on KitKat in August 2023. Google said KitKat devices were under 1% of active devices and that they would get no Play services version beyond 23.30.99.
  • Security patches ended earlier. The October 2017 bulletin is the last to list 4.4.4 among the updated AOSP versions; from November 2017 the oldest is 5.0.2.

Worth knowing

  • The name. Nestlé and Google announced “Android KitKat” on 3 September 2013, with more than 50 million KitKat bars branded for it in 19 markets. Nestlé said many commentators had expected “Key Lime Pie”. Developers kept calling it “KLP” internally. John Lagerling, Google’s director of Android global partnerships, told the BBC: “We realised that very few people actually know the taste of a key lime pie,” and that it was “not a money-changing-hands kind of deal”.
  • AOSP comments. Build.java calls API 19 “KitKat, another tasty treat” and API 20 “KitKat for watches, snacks on the run.”
  • The Easter egg. Tapping “Android version” in About phone three times shows the first letter of the build ID, a K on builds such as KRT16M, spinning on each tap. A long press turns it into the KitKat-style logo, and another long press opens a wall of dessert tiles, run in a process named :sweetsweetdesserts. Its source marks the KitKat tile “used with permission” and the Key Lime Pie tile “from an alternative timeline”.
  • For posterity. The first time you open it, Android saves the timestamp in Settings.System.EGG_MODE, under the comment “For posterity: the moment this user unlocked the easter egg”. If the egg fails to launch, it logs “Couldn’t catch a break.”

Filed under

Citations

48

External references