Showing posts with label android p. Show all posts
Showing posts with label android p. Show all posts

Sunday, October 21, 2018

Cryptography Changes Inwards Android P

Cryptography Changes Inwards Android P

Posted past times Adam Vartanian, Software Engineer

We promise you're enjoying the foremost developer preview of Android P. We wanted to specifically telephone phone out about backward-incompatible changes nosotros innovation to brand to the cryptographic capabilities inwards Android P, which you lot tin run across inwards the developer preview.

Changes to providers

Starting inwards Android P, nosotros innovation to deprecate about functionality from the BC provider that's duplicated past times the AndroidOpenSSL (also known every bit Conscrypt) provider. This volition simply impact applications that specify the BC provider explicitly when calling getInstance() methods. To endure clear, nosotros aren't doing this because nosotros are concerned most the safety of the implementations from the BC provider, rather because having duplicated functionality imposes additional costs too risks piece non providing much benefit.

If you lot don't specify a provider inwards your getInstance() calls, no changes are required.

If you lot specify the provider past times mention or past times instance—for example, Cipher.getInstance("AES/CBC/PKCS7PADDING", "BC") or Cipher.getInstance("AES/CBC/PKCS7PADDING", Security.getProvider("BC"))—the take you lot arrive Android P volition depend on what API score your application targets. For apps targeting an API score earlier P, the telephone phone volition render the BC implementation too log a alert inwards the application log. For apps targeting Android P or later, the telephone phone volition throw NoSuchAlgorithmException.

To resolve this, you lot should halt specifying a provider too utilisation the default implementation.

In a after Android release, nosotros innovation to withdraw the deprecated functionality from the BC provider entirely. Once removed, whatever telephone phone that requests that functionality from the BC provider (whether past times mention or instance) volition throw NoSuchAlgorithmException.

Removal of the Crypto provider

In a previous post, nosotros announced that the Crypto provider was deprecated kickoff inwards Android Nougat. Since then, whatever asking for the Crypto provider past times an application targeting API 23 (Marshmallow) or earlier would succeed, but requests past times applications targeting API 24 (Nougat) or after would fail. In Android P, nosotros innovation to withdraw the Crypto provider entirely. Once removed, whatever telephone phone to SecureRandom.getInstance("SHA1PRNG", "Crypto") volition throw NoSuchProviderException. Please ensure your apps convey been updated.

Friday, October 19, 2018

Protecting Users Amongst Tls Past Times Default Inwards Android P

Protecting Users Amongst Tls Past Times Default Inwards Android P

Posted yesteryear Republic of Chad Brubaker, Senior Software Engineer Android Security

Android is committed to keeping users, their devices, in addition to their information safe. One of the ways that nosotros popular off along information rubber is yesteryear protecting all information that enters or leaves an Android device amongst Transport Layer Security (TLS) inward transit. As nosotros announced inward our Android P developer preview, we're farther improving these protections yesteryear preventing apps that target Android P from allowing unencrypted connections yesteryear default.

This follows a diversity of changes we've made over the years to improve protect Android users.To foreclose accidental unencrypted connections, nosotros introduced the android:usesCleartextTraffic manifest attribute inward Android Marshmallow. In Android Nougat, nosotros extended that attribute yesteryear creating the Network Security Config feature, which allows apps to betoken that they create non intend to transportation network traffic without encryption. In Android Nougat in addition to Oreo, nosotros nevertheless allowed cleartext connections.

How create I update my app?

If your app uses TLS for all connections in addition to hence you lot accept zilch to do. If not, update your app to role TLS to encrypt all connections. If you lot nevertheless involve to brand cleartext connections, popular off along reading for to a greater extent than or less best practices.

Why should I role TLS?

Android considers all networks potentially hostile in addition to hence encrypting traffic should travel used at all times, for all connections. Mobile devices are particularly at run a hazard because they regularly connect to many dissimilar networks, such equally the Wi-Fi at a java shop.

All traffic should travel encrypted, regardless of content, equally whatsoever unencrypted connections tin travel used to inject content, increase assault surface for potentially vulnerable customer code, or rails the user. For to a greater extent than information, encounter our yesteryear blog post in addition to Developer Summit talk.

Isn't TLS slow?

No, it's not.

How create I role TLS inward my app?

Once your server supports TLS, only alter the URLs inward your app in addition to server responses from http:// to https://. Your HTTP stack handles the TLS handshake without whatsoever to a greater extent than work.

If you lot are making sockets yourself, role an SSLSocketFactory instead of a SocketFactory. Take extra attention to role the socket correctly equally SSLSocket doesn't perform hostname verification. Your app needs to create its ain hostname verification, preferably yesteryear calling getDefaultHostnameVerifier() amongst the expected hostname. Further, beware that HostnameVerifier.verify() doesn't throw an exception on fault but instead returns a boolean number that you lot must explicitly check.

I involve to role cleartext traffic to...

While you lot should role TLS for all connections, it's mayhap that you lot involve to role cleartext traffic for legacy reasons, such equally connecting to to a greater extent than or less servers. To create this, alter your app's network safety config to permit those connections.

We've included a pair instance configurations. See the network safety config documentation for a flake to a greater extent than help.

Allow cleartext connections to a specific domain

If you lot involve to permit connections to a specific domain or ready of domains, you lot tin role the next config equally a guide:

<network-security-config>     <domain-config cleartextTrafficPermitted="true">         <domain includeSubdomains="true">insecure.example.com</domain>         <domain includeSubdomains="true">insecure.cdn.example.com</domain>     </domain-config> </network-security-config> 

Allow connections to arbitrary insecure domains

If your app supports opening arbitrary content from URLs over insecure connections, you lot should disable cleartext connections to your ain services spell supporting cleartext connections to arbitrary hosts. Keep inward hear that you lot should travel cautious almost the information received over insecure connections equally it could accept been tampered amongst inward transit.

<network-security-config>     <domain-config cleartextTrafficPermitted="false">         <domain includeSubdomains="true">example.com</domain>         <domain includeSubdomains="true">cdn.example2.com</domain>     </domain-config>     <base-config cleartextTrafficPermitted="true" /> </network-security-config> 

How create I update my library?

If your library straight creates secure/insecure connections, brand certain that it honors the app's cleartext settings yesteryear checking isCleartextTrafficPermitted before opening whatsoever cleartext connection.

Thursday, October 18, 2018

Dns Over Tls Back Upward Inward Android P Developer Preview

Posted yesteryear Erik Kline, Android software engineer, as well as Ben Schwartz, Jigsaw software engineer

The offset stride of almost every connectedness on the meshwork is a DNS query. Influenza A virus subtype H5N1 client, such every bit a smartphone, typically uses a DNS server provided yesteryear the Wi-Fi or cellular network. The customer asks this DNS server to convert a domain name, similar www.google.com, into an IP address, similar 2607:f8b0:4006:80e::2004. Once the customer has the IP address, it tin connect to its intended destination.

When the DNS protocol was designed inwards the 1980s, the meshwork was a much smaller, simpler place. For the yesteryear few years, the Internet Engineering Task Force (IETF) has worked to define a novel DNS protocol that provides users amongst the latest protections for safety as well as privacy. The protocol is called "DNS over TLS" (standardized every bit RFC 7858).

Like HTTPS, DNS over TLS uses the TLS protocol to constitute a secure channel to the server. Once the secure channel is established, DNS queries as well as responses can't move read or modified yesteryear anyone else who mightiness move monitoring the connection. (The secure channel exclusively applies to DNS, thus it can't protect users from other kinds of safety as well as privacy violations.)

DNS over TLS inwards P

The Android P Developer Preview includes built-in back upwards for DNS over TLS. We added a Private DNS manner to the Network & meshwork settings.

By default, devices automatically upgrade to DNS over TLS if a network's DNS server supports it. But users who don't desire to utilisation DNS over TLS tin plough it off.

Users tin move inwards a hostname if they desire to utilisation a someone DNS provider. Android thus sends all DNS queries over a secure channel to this server or marks the network every bit "No meshwork access" if it can't accomplish the server. (For testing purposes, come across this community-maintained list of compatible servers.)

DNS over TLS manner automatically secures the DNS queries from all apps on the system. However, apps that perform their ain DNS queries, instead of using the system's APIs, must ensure that they create non post insecure DNS queries when the organisation has a secure connection. Apps tin instruct this information using a novel API: LinkProperties.isPrivateDnsActive().

With the Android P Developer Preview, we're proud to acquaint built-in back upwards for DNS over TLS. In the future, nosotros promise that all operating systems volition include secure transports for DNS, to furnish ameliorate protection as well as privacy for all users on every novel connection.

Monday, October 15, 2018

Faster Adoption Amongst Projection Treble

Posted past times Iliyan Malchev, Project Treble Architect

Android P Beta available at android.com/beta

As Android continues to evolve, each novel unloose of the OS brings novel features, novel user experiences, too meliorate security. It is of import that these novel releases detect their agency to mobile devices equally fast equally possible.

Yesterday, nosotros announced that the next devices, inwards improver to Pixel too Pixel 2, right away back upward Android P Beta: Sony Xperia XZ2, Xiaomi Mi Mix 2S, Nokia seven Plus, Oppo R15 Pro, Vivo X21, OnePlus vi too Essential PH‑1. Android P Beta provides an chance for developers too early on adopters closed to the the world to seek the latest Android release, exam their apps, too render feedback.

In this post, nosotros render an update to Project Treble too the technology scientific discipline that allowed us to convey Android Beta to to a greater extent than phones this year.

Building the Foundation

Bringing the novel Android unloose apace to the hands of users takes a combined seek betwixt Google, silicon manufacturers (SM), device manufacturers (OEMs), too carriers. This procedure is technically challenging too requires aligning the schedules betwixt our manufacture partners.

To cut the technical difficulties, nosotros launched Project Treble equally component of Android Oreo.

The Silicon Manufacturers

Next, to capitalize on the foundation nosotros built, nosotros collaborated closely amongst the silicon manufacturers, where the journeying of making an Android device ever begins.

Any device amongst the latest version of Android must endure based on an SoC amongst the proper software back upward for it. This software, usually referred to equally the Board Support Package (BSP), contains non exclusively the chip-specific vendor implementation, but besides all of the Android Open Source Project (AOSP) too pieces of the framework that are missing from AOSP itself (e.g., carrier-specific telephony functionality).

 each novel unloose of the OS brings novel features Faster Adoption amongst Project Treble

These BSPs are the starting signal for all device launches. OEMs adjust the vendor implementation to their hardware too add together their ain custom framework components.

While silicon manufacturers ever desire the latest version of Android inwards their BSPs, the costs possess got been prohibitive. By making it possible for newer AOSP frameworks to run on older, already-released vendor implementations, Project Treble dramatically reduces the postulate for continuous investment inwards older silicon to back upward each Android release. Silicon manufacturers possess got to produce all this piece of job simply once, rather than every fourth dimension at that topographic point is a novel unloose of Android.

Solving the Timing Problem

However, that outset fourth dimension even too then has to happen. Below is a chart, which illustrates the seek the diverse actors expend over fourth dimension equally they become through each release. You tin intend of it equally code churn or põrnikas count over time.

 each novel unloose of the OS brings novel features Faster Adoption amongst Project Treble

The nautical chart shows how at that topographic point is rattling piddling fourth dimension inwards the twelvemonth for Google, silicon manufacturers, too the OEMs to all this work. Any overlap betwixt phases causes code churn too introduces pregnant schedule risk. For OEMs who target the vacation season, it is oftentimes safer to launch on an older BSP amongst a year-old or fifty-fifty older Android version. This dynamic has been at the middle of the deadening uptake of the latest Android release, fifty-fifty on flagship devices.

 each novel unloose of the OS brings novel features Faster Adoption amongst Project Treble

To solve this, we've worked closely amongst Qualcomm, MediaTek too Samsung Electronics’ System LSI Business to co-develop their BSPs, starting amongst Android P. Their BSPs are right away gear upward for Android P on a much-accelerated schedule, reducing the overall seek significantly. These silicon manufacturers are right away able to render a stable too high-quality unloose much before than before, allowing OEMs to convey the latest innovations of Android to their customers across the globe.

 each novel unloose of the OS brings novel features Faster Adoption amongst Project Treble

This is an of import pace inwards accelerating the adoption of Android releases that convey numerous benefits to our partners, users, too Android developers. We hold off forwards to seeing many to a greater extent than partners launch or upgrade devices to Android P.

Friday, October 12, 2018

Wear Bone Developer Preview Reenabling Alarms Together With Jobs For Background Apps

Posted yesteryear Hoi Lam, Lead Developer Advocate, Wear OS yesteryear Google

From the cause of the Wear OS yesteryear Google developer preview, battery life has been a major focus area. When nosotros talked to the developer community, the update that attracted the nearly feedback was the disabling of alarms in addition to jobs for background apps. After listening to developer feedback in addition to reviewing the battery statistics, nosotros are reversing this change. This should live reflected inwards all connected Wear OS preview devices, therefore at that topographic point is no remove to reflash your device.

App Standby Buckets

The determination came equally nosotros reviewed the feedback in addition to saw that a strict on/off setting prevents reasonable usage in addition to promotes anti-patterns. Going forward, nosotros conception to leverage the App Standby Buckets characteristic inwards Android P to fine-tune a suitable setting for Wear OS devices. The exact setting for alarms in addition to jobs for background apps is however beingness iterated on. Developers are advised to follow the best practices to brand certain their apps comport well, whichever bucket the apps are in.

Input in addition to information privacy inwards background apps

Another expanse that developers should pay attending to is the strengthening of input in addition to information privacy for background apps inwards Android P. Depending on an app's requirements, developers may remove to role a foreground service to enable access to the device sensor throughout the day.

Please hand us your feedback

We facial expression to supply to a greater extent than updates to this preview before the lastly production release. Please submit whatever bugs y'all notice via the Wear OS yesteryear Google number tracker. The before y'all submit them, the higher the likelihood that nosotros tin include the fixes inwards the lastly release.

An Update On Non-Sdk Restrictions Inwards Android P

Posted yesteryear David Brazdil together with Nicolas Geoffray, Software Engineers

In Android, nosotros assist immensely well-nigh providing the best sense to our users together with our developers. With each OS release, novel features enable you lot to supply amazing experiences for users; however, nosotros noticed that some app developers cause got been using non-SDK interfaces, which leads to increased crashes for users together with emergency rollouts for developers. We desire to create amend together with require your assist to ensure that Android is stable amongst each novel OS.

Three months ago, nosotros announced our plans to start restricting the usage of non-SDK interfaces inwards Android P. We know these restrictions tin move behave upon your unloosen workflow, together with nosotros desire to brand certain you lot cause got the tools to break usage of non-SDK interfaces, equally good equally fourth dimension inwards your planning for adjusting to the novel policies together with for giving us feedback.

In the Developer Preview together with Beta 1, nosotros cause got provided ways for you lot to encounter the behave upon of these restrictions on your app. In the Developer Preview, purpose of restricted APIs demo upwardly inwards logs together with toast messages, together with inwards Beta 1, nosotros provided a StrictMode policy that allows you lot to programmatically break these restrictions together with create your ain logging. For example:

We sympathise at that spot tin move live multiple reasons apps desire to purpose non-SDK interfaces, together with ensuring your app volition proceed to operate inwards Android P is of import to us. Many of you lot cause got explained your purpose cases through our issue tracker (thank you!), together with for most of these requests, nosotros cause got lifted the restrictions on specific non-SDK interfaces for Android P yesteryear adding them to the greylist. In addition, our squad has conducted static analysis on millions of apps together with processed thousands of automated reports from internal together with external beta testers. Through this analysis, nosotros cause got identified additional non-SDK interfaces that apps rely on together with added them to the greylist. For everything on the greylist, nosotros volition live investigating world SDK alternatives for hereafter releases. However, it's possible nosotros may cause got missed some non-SDK interface uses, together with hence nosotros cause got made the bulk of them available for apps whose target SDK is Android Oreo or below.

In summary, apps running on Android P volition live dependent area to restricted usage of non-SDK interfaces. If you lot are targeting Android P, the greylist shows the non-SDK interfaces that volition silent live available, piece all other non-SDK interfaces volition non live accessible. If you lot are targeting Android Oreo or below, most restrictions volition non apply, but you lot volition teach logcat warnings if you lot are accessing non-SDK interfaces that are non inwards the greylist (note that users don't encounter such warnings).

Try out our novel Beta ii release together with purpose StrictMode to break your non-SDK interfaces usage. You should await Beta ii to closely tally what the lastly unloosen volition implement for restricting non-SDK interface usages. Also, delight accept a aspect at our novel FAQ, which nosotros promise volition respond whatever questions you lot cause got roughly the feature. If not, let us know!

Thursday, October 11, 2018

Amend Biometrics Inwards Android P

Posted yesteryear Vishwath Mohan, Security Engineer

To drib dead along users safe, most apps too devices guide keep an authentication mechanism, or a way to examine that you're you. These mechanisms autumn into 3 categories: noesis factors, possession factors, too biometric factors. Knowledge factors enquire for something you lot know (like a PIN or a password), possession factors enquire for something you lot guide keep (like a token generator or safety key), too biometric factors enquire for something you lot are (like your fingerprint, iris, or face).

Biometric authentication mechanisms are becoming increasingly popular, too it's tardily to run into why. They're faster than typing a password, easier than carrying unopen to a divide safety key, too they forestall i of the most mutual pitfalls of knowledge-factor based authentication—the guide chances of shoulder surfing.

As to a greater extent than devices contain biometric authentication to safeguard people's soul information, we're improving biometrics-based authentication inwards Android P by:

  • Defining a ameliorate model to stair out biometric security, too using that to functionally constrain weaker authentication methods.
  • Providing a mutual platform-provided entry indicate for developers to integrate biometric authentication into their apps.

A ameliorate safety model for biometrics

Currently, biometric unlocks quantify their functioning today amongst 2 metrics borrowed from machine learning (ML): False Accept Rate (FAR), too False Reject Rate (FRR).

In the instance of biometrics, FAR measures how oftentimes a biometric model accidentally classifies an wrong input equally belonging to the target user—that is, how oftentimes some other user is falsely recognized equally the legitimate device owner. Similarly, FRR measures how oftentimes a biometric model accidentally classifies the user's biometric equally incorrect—that is, how oftentimes a legitimate device possessor has to retry their authentication. The get-go is a safety concern, piece the minute is problematic for usability.

Both metrics produce a dandy project of measuring the accuracy too precision of a given ML (or biometric) model when applied to random input samples. However, because neither metric accounts for an active aggressor equally component of the threat model, they produce non furnish real useful information well-nigh its resilience against attacks.

In Android 8.1, nosotros introduced 2 novel metrics that to a greater extent than explicitly concern human relationship for an aggressor inwards the threat model: Spoof Accept Rate (SAR) too Imposter Accept Rate (IAR). As their names suggest, these metrics stair out how easily an aggressor tin give notice bypass a biometric authentication scheme. Spoofing refers to the utilization of a known-good recording (e.g. replaying a phonation recording or using a appear upwardly or fingerprint picture), piece impostor credence way a successful mimicking of some other user's biometric (e.g. trying to audio or expect similar a target user).

Strong vs. Weak Biometrics

We utilization the SAR/IAR metrics to categorize biometric authentication mechanisms equally either strong or weak. Biometric authentication mechanisms amongst an SAR/IAR of 7% or lower are strong, too anything higher upwardly 7% is weak. Why 7% specifically? Most fingerprint implementations guide keep a SAR/IAR metric of well-nigh 7%, making this an appropriate criterion to start amongst for other modalities equally well. As biometric sensors too classification methods improve, this threshold tin give notice potentially last decreased inwards the future.

This binary classification is a slight oversimplification of the arrive at of safety that dissimilar implementations provide. However, it gives us a scalable machinery (via the tiered authentication model) to appropriately compass the capabilities too the constraints of dissimilar biometric implementations across the ecosystem, based on the overall guide chances they pose.

While both strong too weak biometrics volition last allowed to unlock a device, weak biometrics:

  • require the user to re-enter their main PIN, pattern, password or a strong biometric to unlock a device later a 4-hour window of inactivity, such equally when left at a desk or charger. This is inwards improver to the 72-hour timeout that is enforced for both strong too weak biometrics.
  • are non supported yesteryear the forthcoming BiometricPrompt API, a mutual API for app developers to securely authenticate users on a device inwards a modality-agnostic way.
  • can't authenticate payments or participate inwards other transactions that involve a KeyStore auth-bound key.
  • must exhibit users a alert that articulates the risks of using the biometric before it tin give notice last enabled.

These measures are intended to let weaker biometrics, piece reducing the guide chances of unauthorized access.

BiometricPrompt API

Starting inwards Android P, developers tin give notice utilization the BiometricPrompt API to integrate biometric authentication into their apps inwards a device too biometric agnostic way. BiometricPrompt alone exposes strong modalities, hence developers tin give notice last assured of a consistent marking of safety across all devices their application runs on. H5N1 back upwardly library is likewise provided for devices running Android O too earlier, allowing applications to utilize the advantages of this API across to a greater extent than devices.

While applications tin give notice claw into BiometricPrompt direct for Android nine too higher, developers should utilization the BiometricPrompt library to back upwardly the widest arrive at of devices.

The API is intended to last tardily to use, allowing the platform to pick out an appropriate biometric to authenticate amongst instead of forcing app developers to implement this logic themselves. Here's an illustration of how a developer powerfulness utilization it inwards their app:

Conclusion

Biometrics guide keep the potential to both simplify too strengthen how nosotros authenticate our digital identity, merely alone if they are designed securely, measured accurately, too implemented inwards a privacy-preserving manner.

We desire Android to acquire it right across all three. So we're combining secure blueprint principles, a to a greater extent than attacker-aware mensuration methodology, too a common, tardily to utilization biometrics API that allows developers to integrate authentication inwards a simple, consistent, too rubber manner.

Acknowledgements: This post service was developed inwards articulation collaboration amongst Jim Miller.

Wednesday, October 10, 2018

Compiler-Based Safety Mitigations Inward Android P

Posted yesteryear Ivan Lozano, Information Security Engineer

Android's switch to LLVM/Clang every bit the default platform compiler inwards Android 7.0 opened upward to a greater extent than possibilities for improving our defense-in-depth safety posture. In the yesteryear couplet of releases, we've rolled out additional compiler-based mitigations to brand bugs harder to exploit too preclude for sure types of bugs from becoming vulnerabilities. In Android P, we're expanding our existing compiler mitigations, which musical instrument runtime operations to neglect safely when undefined demeanour occurs. This post service describes the novel construct arrangement back upward for Control Flow Integrity too Integer Overflow Sanitization.

Control Flow Integrity

Influenza A virus subtype H5N1 cardinal footstep inwards modern exploit chains is for an aggressor to gain command of a program's command period of time yesteryear corrupting business office pointers or supply addresses. This opens the door to code-reuse attacks where an aggressor executes arbitrary portions of existing computer programme code to attain their goals, such every bit counterfeit-object-oriented too return-oriented programming. Control Flow Integrity (CFI) describes a ready of mitigation technologies that confine a program's command period of time to a telephone outcry upward graph of valid targets determined at compile-time.

While nosotros outset supported LLVM's CFI implementation inwards select components inwards Android O, we're greatly expanding that back upward inwards P. This implementation focuses on preventing command period of time manipulation via indirect branches, such every bit business office pointers too virtual functions—the 'forward-edges' of a telephone outcry upward graph. Valid branch targets are defined every bit business office entry points for functions amongst the expected business office signature, which drastically reduces the ready of allowable destinations an aggressor tin call. Indirect branches are instrumented to notice runtime violations of the statically determined ready of allowable targets. If a violation is detected because a branch points to an unexpected target, hence the procedure safely aborts.

Clang every bit the default platform compiler inwards Android   Compiler-based safety mitigations inwards Android P

Figure 1. Assembly-level comparing of a virtual business office telephone outcry upward amongst too without CFI enabled.

For example, Figure 1 illustrates how a business office that takes an object too calls a virtual business office gets translated into assembly amongst too without CFI. For simplicity, this was compiled amongst -O0 to preclude compiler optimization. Without CFI enabled, it loads the object's vtable pointer too calls the business office at the expected offset. With CFI enabled, it performs a fast-path outset banking concern agree to decide if the pointer falls inside an expected attain of addresses of compatible vtables. Failing that, execution falls through to a deadening path that does a to a greater extent than extensive banking concern agree for valid classes that are defined inwards other shared libraries. The deadening path volition abort execution if the vtable pointer points to an invalid target.

With command period of time tightly restricted to a pocket-size ready of legitimate targets, code-reuse attacks larn harder to utilize too to a greater extent than or less retentiveness corruption vulnerabilities larn to a greater extent than hard or fifty-fifty impossible to exploit.

In damage of performance impact, LLVM's CFI requires compiling amongst Link-Time Optimization (LTO). LTO preserves the LLVM bitcode representation of object files until link-time, which allows the compiler to amend argue almost what optimizations tin hold upward performed. Enabling LTO reduces the size of the finally binary too improves performance, merely increases compile time. In testing on Android, the combination of LTO too CFI results inwards negligible overhead to code size too performance; inwards a few cases both improved.

For to a greater extent than technical details almost CFI too how other forward-control checks are handled, run into the LLVM pattern documentation.

For Android P, CFI is enabled yesteryear default widely inside the media frameworks too other security-critical components, such every bit NFC too Bluetooth. CFI gist support has also been introduced into the Android mutual gist when edifice amongst LLVM, providing the selection to farther harden the trusted computing base. This tin hold upward tested today on the HiKey reference boards.

Integer Overflow Sanitization

The UndefinedBehaviorSanitizer's (UBSan) signed too unsigned integer overflow sanitization was outset utilized when hardening the media stack inwards Android Nougat. This sanitization is designed to safely abort procedure execution if a signed or unsigned integer overflows yesteryear instrumenting arithmetics instructions which may overflow. The terminate lawsuit is the mitigation of an entire aeroplane of retentiveness corruption too information disclosure vulnerabilities where the root movement is an integer overflow, such every bit the master copy Stagefright vulnerability.

Because of their success, we've expanded usage of these sanitizers inwards the media framework amongst each release. Improvements own got been made to LLVM's integer overflow sanitizers to cut back the performance touching on yesteryear using fewer instructions inwards ARM 32-bit too removing unnecessary checks. In testing, these improvements reduced the sanitizers' performance overhead yesteryear over 75% inwards Android's 32-bit libstagefright library for to a greater extent than or less codecs. Improved Android construct arrangement support, such every bit amend diagnostics support, to a greater extent than sensible crashes, too globally sanitized integer overflow targets for testing own got also expedited the rollout of these sanitizers.

We've prioritized enabling integer overflow sanitization inwards libraries where complex untrusted input is processed or where at that topographic point own got been safety bulletin-level integer overflow vulnerabilities reported. As a result, inwards Android P the next libraries forthwith create goodness from this mitigation:

  • libui
  • libnl
  • libmediaplayerservice
  • libexif
  • libdrmclearkeyplugin
  • libreverbwrapper

Future Plans

Moving forward, we're expanding our usage of these mitigation technologies too nosotros strongly encourage vendors to create the same amongst their customizations. More information almost how to enable too seek out these options volition hold upward available shortly on the Android Open Source Project.

Acknowledgements: This post service was developed inwards articulation collaboration amongst Vishwath Mohan, Jeffrey Vander Stoep, Joel Galenson, too Sami Tolvanen

Sunday, October 7, 2018

Supporting Display Cutouts On Edge-To-Edge Screens

Posted By Megan Potoski, Product Manager, Android System UI

Smartphones are rapidly moving towards smaller bezels as well as larger aspect ratios. On these devices, display cutouts are a pop way to hit an edge-to-edge sense spell providing infinite for of import sensors on the front end of the device. There are currently xvi cutout devices from eleven OEMs already released, including several Android P beta devices, amongst to a greater extent than on the way.

These hitting displays nowadays a swell chance for you lot to showcase your app. They also hateful it's to a greater extent than of import than ever to brand certain your app provides a consistently swell sense across devices amongst i or 2 display cutouts, every bit good every bit devices amongst 18:9 as well as larger aspect ratios.

Examples of cutout devices: Essential PH-1 (left) as well as Huawei P20 (right).

Make your app compatible amongst display cutouts

With many pop as well as upcoming devices featuring display cutouts, what tin you lot create to brand certain your app is cutout-ready?

The skillful tidings is, for the most part your app should piece of employment every bit intended fifty-fifty on a cutout device. By default, inwards portrait manner amongst no special flags set, the condition bar volition hold upwards resized to hold upwards at to the lowest degree every bit tall every bit the cutout as well as your content volition display inwards the window below. In landscape or fullscreen mode, your app window volition hold upwards letterboxed therefore that none of your content is displayed inwards the cutout area.

However, in that place are a few areas where your app could get got issues on cutout devices.

  • Watch out for whatsoever kind of hard-coding of condition bar tiptop -- this volition probable campaign problems. If possible, usage WindowInsetsCompat to teach condition bar height.
  • In fullscreen, hold upwards careful to consider when to usage window vs. shroud coordinates, every bit your app volition non accept upwards the whole shroud when letterboxed. For example, if you lot usage MotionEvent.getRawX/Y() to teach shroud coordinates for touching events, brand certain to transform them to the view's coordinates using getLocationOnScreen().
  • Pay special attending to transitions inwards as well as out of fullscreen mode.

Here are a few guidelines describing what issues to aspect out for as well as how to cook them.

Take payoff of the cutout area

Rendering your app content inwards the cutout expanse tin hold upwards a swell way to render a to a greater extent than immersive, edge-to-edge sense for users, particularly for content similar videos, photos, maps, as well as games.

An illustration of an app that has requested layout inwards the display cutout.

In Android P nosotros added APIs to allow you lot contend how your app uses the display cutout area, every bit good every bit to depository fiscal establishment fit for the presence of cutouts as well as teach their positions.

You tin usage layoutInDisplayCutoutMode, a novel window layout mode, to command how your content is displayed relative to the cutout. By default, the app's window is allowed to extend into the cutout expanse if the cutout is fully contained within a organization bar. Otherwise, the window is seat out such that it does non overlap amongst the cutout. You tin also seat layoutInDisplayCutoutMode to e'er or never homecoming into the cutout. Using SHORT_EDGES manner to e'er homecoming into the cutout is a swell choice if you lot desire to accept payoff of the sum display as well as don't heed if a flake of content gets obscured past times the cutout.

If you lot are rendering into the cutout, you lot tin usage getDisplayCutout() to shout out back a DisplayCutout that has the cutout's rubber insets as well as bounding box(es). These allow you lot depository fiscal establishment fit whether your content overlaps the cutout as well as reposition things if needed.

<style name="ActivityTheme">   <item name="android:windowLayoutInDisplayCutoutMode">     default/shortEdges/never   </item> </style> 

Attribute for setting layoutInDisplayCutoutMode from the Activity's theme.

For devices running Android 8.1 (API 27), we've also back-ported the layoutInDisplayCutoutMode activeness theme attribute therefore you lot tin command the display of your content inwards the cutout area. Note that back upwards on devices running Android 8.1 or lower is upwards to the device manufacturer, however.

To enter easier to contend your cutout implementation across API levels, we've also added DisplayCutoutCompat inwards the AndroidX library, which is instantly available through the SDK manager.

For to a greater extent than nearly the display cutout APIs, accept a aspect at the documentation.

Test your app amongst cutout

We strongly recommend testing all screens as well as experiences of your app to brand certain that they piece of employment good on cutout devices. We recommend using i of the Android P Beta Devices that features a cutout, such every bit the Essential PH-1.

If you lot don't get got a device, you lot tin also examine using a mistaken cutout on whatsoever device running Android P or inwards the Android Emulator. This should aid you lot uncover whatsoever issues that your app may come across on devices amongst cutouts, whether they are running Android 8.1 or Android P.

What to aspect on devices amongst display cutouts

Android P introduces official platform back upwards for display cutouts, amongst APIs that you lot tin usage to present your content within or exterior of the cutout. To ensure consistency as well as app compatibility, we're working amongst our device manufacturer partners to mandate a few requirements.

First, devices must ensure that their cutouts create non negatively touching on apps. There are 2 primal requirements:

  • In portrait orientation, amongst no special flags set, the condition bar must extend to at to the lowest degree the tiptop of the cutout.
  • In fullscreen or landscape orientation, the entire cutout expanse must hold upwards letterboxed.

Second, devices may entirely get got upwards to i cutout on each brusk border of the device. This way that:

  • You won't take in multiple cutouts on a unmarried edge, or to a greater extent than than 2 cutouts on a device.
  • You won't take in a cutout on the left or correct long border of the device.

Within these constraints, devices tin house cutouts wherever they want.

Special mode

Some devices running Android 8.1 (API marking 27) or before may optionally back upwards a "special mode" that lets users extend a letterboxed fullscreen or landscape app into the cutout area. Devices would typically offering this manner through a toggle inwards the navigation bar, which would as well as therefore convey upwards a confirmation dialog before extending the screen.

Devices that offering "special mode" allow users to optionally extend apps into the cutout expanse if supported past times the app.

If your app's targetSdkVersion is 27 or higher, you lot tin seat the layoutInDisplayCutoutMode activeness theme attribute to opt-out of special manner if needed.

Don't forget: larger aspect ratios too!

While you lot are working on cutout support, it's also a swell fourth dimension to brand certain your app plant good on devices amongst 18:9 or larger aspect ratios, particularly since these devices are becoming increasingly mutual as well as tin characteristic display cutouts.

We highly encourage you lot to back upwards flexible aspect ratios therefore that your app tin leverage the sum display area, no thing what device it's on. You should examine your app on dissimilar display ratios to brand certain it functions properly as well as looks good.

Here are or therefore guidelines on screens support to proceed inwards heed every bit you lot are developing, also refer to our earlier postal service on larger aspect ratios for tips on optimizing. If your app can't suit to the aspect ratios on long screens, you lot tin pick out to declare a max aspect ratio to asking letterboxing on those screens.

Thanks for reading, as well as nosotros promise this helps you lot deliver a delightful sense to all your users, whatever display they may have!

Android Pie Sdk Is Straightaway To A Greater Extent Than Kotlin-Friendly

Posted past times James Lau, Product Manager (@jmslau)

When using the Java programming language, i of the most mutual pitfalls is trying to access a fellow member of a null reference, causing a NullPointerException to live on thrown. Kotlin offers protection against this past times baking nullable in addition to non-nullable types into the type system. This helps eliminate NullPointerExceptions from your code in addition to amend your app's overall quality. When Kotlin code is calling into APIs written inward the Java programming language, it relies on nullability annotations inward those APIs to create upward one's hear the nullability of each parameter in addition to the render type. Unannotated parameters in addition to render types are treated equally platform types, which weakens the null-safety guarantee of Kotlin.

As purpose of yesterday's Android ix announcement, nosotros bring too released a novel Android SDK that contains nullability annotations for to a greater extent than or less of the most often used APIs. This volition save the null-safety guarantee when your Kotlin code is calling into whatsoever annotated APIs inward the SDK. Even if you lot are using the Java programming language, you lot tin yet attain goodness from these annotations past times using Android Studio to select grip of nullability contract violations.

Not a breaking change

Normally, nullability contract violations inward Kotlin trial inward compilation errors. But to ensure the newly annotated APIs are compatible amongst your existing code, nosotros are using an internal machinery provided past times the Kotlin compiler squad to grade the APIs equally lately annotated. Recently annotated APIs volition trial solely inward warnings instead of errors from the Kotlin compiler. You volition involve to usage Kotlin 1.2.60 or later.

Our invention is to bring newly added nullability annotations attain warnings only, in addition to growth the severity grade to errors starting inward the next year's Android SDK. The destination is to render you lot amongst sufficient fourth dimension to update your code.

How to usage the "Kotlin-friendly" SDK

To teach started, become to Tools > SDK Manager inward Android Studio. Select Android SDK on the left menu, in addition to brand certain the SDK Platforms tab is open.

Use SDK Manager inward Android Studio to install SDK for API Level 28 Revision 6

Check Android 8.+ (P) in addition to click OK. This volition install the Android SDK Platform 28 revision vi if it is non already installed. After that, laid your project's compile SDK version to API 28 to outset using the novel Android Pie SDK amongst nullability annotations.

Use the Project Structure Dialog to alter your project's Compile Sdk Version to API 28

You may too involve to update your Kotlin plugin inward Android Studio if it's non already up-to-date. Make certain your Kotlin plugin version is 1.2.60 or afterwards past times going to Tools > Kotlin > Configure Kotlin Plugin Updates.

Once it's laid up, your builds volition outset showing warnings if you lot bring whatsoever code that violates nullability contracts inward the Android SDK. An trial of such a alarm is shown below.

Sample alarm from the Kotlin compiler when code violates a lately added nullability contract inward the Android SDK.

You volition too outset seeing warnings inward Android Studio's code editor if you lot telephone telephone an Android API amongst the wrong nullability. An trial is shown below.

Android Studio alarm near passing a null reference to a parameter annotated equally a lately non-null type inward the android.graphics.Path API.

Leveraging nullability annotations from the Java programming language

You tin attain goodness from the novel nullability annotations fifty-fifty if your code is inward the Java programming language. By default, Android Studio volition highlight whatsoever nullability contract violations amongst a warning, similar the i below:

Android Studio showing a alarm near nullability contract violation inward code written inward the Java programming linguistic communication

To ensure that you lot bring this inspection enabled, you lot tin become to the IDE's settings page in addition to search for "Constant weather & exceptions" inspection in addition to brand certain that especial is checked.

Use the Inspections page nether Settings to ensure the Constant weather & exceptions code inspection is enabled.

If you lot are using the Java programming language, nullability contract violations volition non attain whatsoever compiler alarm or error. Only the in-IDE code inspections are available to flag these issues.

You tin too run code inspections across your entire projection in addition to run into the aggregated results. Click on Analyze > Inspect Code… to start.

What's Next

The Android SDK API surface is really large, in addition to nosotros bring solely annotated a minor percent of the APIs in addition to thus far - in that place is yet lots of move remaining. Over the side past times side several Android SDK releases, nosotros volition maintain to add together nullability annotations to the existing Android APIs, equally good equally making certain novel APIs are annotated.

With the "Kotlin-friendly" Android SDK, the nullability annotations inward AndroidX (part of the Jetpack family), in addition to Android KTX, nosotros are continuing to amend the Android APIs for developers using Kotlin. If you lot bring non yet tried Kotlin, nosotros encourage you lot to endeavour it. Not solely tin Kotlin brand your code to a greater extent than concise, it tin too amend the stability of your apps.

Happy Kotlin-ing!