Showing posts with label Android Developer. Show all posts
Showing posts with label Android Developer. Show all posts

12/21/17

Double Stuffed Security in Android Oreo








Posted by Gian G Spicuzza, Android Security team


Android Oreo is stuffed full of security enhancements. Over the past few months,
we've covered how we've improved the security of the Android platform and its
applications: from href="https://android-developers.googleblog.com/2017/08/making-it-safer-to-get-apps-on-android-o.html">making
it safer to get apps, dropping href="https://android-developers.googleblog.com/2017/04/android-o-to-drop-insecure-tls-version.html">insecure
network protocols, providing more href="https://android-developers.googleblog.com/2017/04/changes-to-device-identifiers-in.html">user
control over identifiers, href="https://android-developers.googleblog.com/2017/08/hardening-kernel-in-android-oreo.html">hardening
the kernel, href="https://android-developers.googleblog.com/2017/07/shut-hal-up.html">making
Android easier to update, all the way to href="https://android-developers.googleblog.com/2017/06/2017-android-security-rewards.html">doubling
the Android Security Rewards payouts. Now that Oreo is out the door, let's
take a look at all the goodness inside.


Expanding support for hardware security



Android already supports href="https://source.android.com/security/verifiedboot/">Verified Boot,
which is designed to prevent devices from booting up with software that has been
tampered with. In Android Oreo, we added a reference implementation for Verified
Boot running with href="https://source.android.com/devices/architecture/treble">Project
Treble, called Android Verified Boot 2.0 (AVB). AVB has a couple of cool
features to make updates easier and more secure, such as a common footer format
and rollback protection. Rollback protection is designed to prevent a device to
boot if downgraded to an older OS version, which could be vulnerable to an
exploit. To do this, the devices save the OS version using either special
hardware or by having the Trusted Execution Environment (TEE) sign the data.
Pixel 2 and Pixel 2 XL come with this protection and we recommend all device
manufacturers add this feature to their new devices.



Oreo also includes the new href="https://android-review.googlesource.com/#/c/platform/hardware/interfaces/+/527086/-1..1/oemlock/1.0/IOemLock.hal">OEM
Lock Hardware Abstraction Layer (HAL) that gives device manufacturers more
flexibility for how they protect whether a device is locked, unlocked, or
unlockable. For example, the new Pixel phones use this HAL to pass commands to
the bootloader. The bootloader analyzes these commands the next time the device
boots and determines if changes to the locks, which are securely stored in
Replay Protected Memory Block (RPMB), should happen. If your device is stolen,
these safeguards are designed to prevent your device from being reset and to
keep your data secure. This new HAL even supports moving the lock state to
dedicated hardware.



Speaking of hardware, we've invested support in tamper-resistant hardware, such
as the href="https://android-developers.googleblog.com/2017/11/how-pixel-2s-security-module-delivers.html">security
module found in every Pixel 2 and Pixel 2 XL. This physical chip prevents
many software and hardware attacks and is also resistant to physical penetration
attacks. The security module prevents deriving the encryption key without the
device's passcode and limits the rate of unlock attempts, which makes many
attacks infeasible due to time restrictions.



While the new Pixel devices have the special security module, all new href="https://www.android.com/gms/">GMS devices shipping with Android Oreo
are required to implement href="https://android-developers.googleblog.com/2017/09/keystore-key-attestation.html">key
attestation. This provides a mechanism for strongly href="https://source.android.com/security/keystore/attestation#id-attestation">attesting
IDs such as hardware identifiers.



We added new features for enterprise-managed devices as well. In work profiles,
encryption keys are now ejected from RAM when the profile is off or when your
company's admin remotely locks the profile. This helps secure enterprise data at
rest.


Platform hardening and process isolation



As part of href="https://android-developers.googleblog.com/2017/05/here-comes-treble-modular-base-for.html">Project
Treble, the Android framework was re-architected to make updates easier and
less costly for device manufacturers. This separation of platform and
vendor-code was also designed to improve security. Following the href="https://en.wikipedia.org/wiki/Principle_of_least_privilege">principle of
least privilege, these HALs run in their href="https://android-developers.googleblog.com/2017/07/shut-hal-up.html">own
sandbox and only have access to the drivers and permissions that are
absolutely necessary.



Continuing with the href="https://android-developers.googleblog.com/2016/05/hardening-media-stack.html">media
stack hardening in Android Nougat, most direct hardware access has been
removed from the media frameworks in Oreo resulting in better isolation.
Furthermore, we've enabled Control Flow Integrity (CFI) across all media
components. Most vulnerabilities today are exploited by subverting the normal
control flow of an application, instead changing them to perform arbitrary
malicious activities with all the privileges of the exploited application. CFI
is a robust security mechanism that disallows arbitrary changes to the original
control flow graph of a compiled binary, making it significantly harder to
perform such attacks.



In addition to these architecture changes and CFI, Android Oreo comes with a
feast of other tasty platform security enhancements:


  • href="https://android-developers.googleblog.com/2017/07/seccomp-filter-in-android-o.html">Seccomp
    filtering
    : makes some unused syscalls unavailable to apps so that
    they can't be exploited by potentially harmful apps.
  • Hardened
    usercopy
    : A recent href="https://events.linuxfoundation.org/sites/events/files/slides/Android-%20protecting%20the%20kernel.pdf">survey
    of security bugs on Android
    revealed that invalid or missing bounds checking was seen in approximately 45%
    of kernel vulnerabilities. We've backported a bounds checking feature to Android
    kernels 3.18 and above, which makes exploitation harder while also helping
    developers spot issues and fix bugs in their code.
  • Privileged Access Never (PAN) emulation: Also backported to
    3.18 kernels and above, this feature prohibits the kernel from accessing user
    space directly and ensures developers utilize the hardened functions to access
    user space.
  • Kernel Address Space Layout Randomization (KASLR):
    Although Android has supported userspace Address Space Layout Randomization
    (ASLR) for years, we've backported KASLR to help mitigate vulnerabilities on
    Android kernels 4.4 and newer. KASLR works by randomizing the location where
    kernel code is loaded on each boot, making code reuse attacks probabilistic and
    therefore more difficult to carry out, especially remotely.

App security and device identifier changes



Android
Instant Apps
run in a restricted sandbox which limits permissions and
capabilities such as reading the on-device app list or transmitting cleartext
traffic. Although introduced during the Android Oreo release, Instant Apps
supports devices running href="https://www.android.com/versions/lollipop-5-0/">Android Lollipop and
later.



In order to handle untrusted content more safely, we've href="https://android-developers.googleblog.com/2017/06/whats-new-in-webview-security.html">isolated
WebView by splitting the rendering engine into a separate process and
running it within an isolated sandbox that restricts its resources. WebView also
supports Safe Browsing to protect
against potentially dangerous sites.



Lastly, we've made href="https://android-developers.googleblog.com/2017/04/changes-to-device-identifiers-in.html">significant
changes to device identifiers to give users more control, including:


  • Moving the static Android ID and Widevine values to an
    app-specific value, which helps limit the use of device-scoped non-resettable
    IDs.
  • In accordance with href="https://tools.ietf.org/html/rfc7844#section-3.7">IETF RFC 7844
    anonymity profile, net.hostname is now empty and the DHCP client no
    longer sends a hostname.
  • For apps that require a device ID, we've built a Build.getSerial()
    API
    and protected it behind a permission.
  • Alongside security researchers1, we designed a robust MAC address
    randomization for Wi-Fi scan traffic in various chipsets firmware.


Android Oreo brings in all of these improvements, and href="https://www.android.com/versions/oreo-8-0/">many more. As always, we
appreciate feedback and welcome suggestions for how we can improve Android.
Contact us at security@android.com.



_____________________________________________________________________



1: Glenn Wilkinson and team at Sensepost, UK, Célestin Matte, Mathieu Cunche:
University of Lyon, INSA-Lyon, CITI Lab, Inria Privatics, Mathy Vanhoef, KU
Leuven

Read more

11/10/17

Making Pixel better for Drivers


Posted by Marc Stogaitis and Tajinder Gadh, Software Engineers




Driving is an essential part of our daily activities. So at Google we spend a
lot of time thinking how we can make Android devices better and safer for our
users. How we can prevent distracted driving and together build an open
ecosystem to enable safety first smartphone experiences.


Recently we launched Driving Do-Not-Disturb on the newly announced Pixel 2
generation of devices. Once enabled, Driving Do-Not-Disturb automatically puts
your device into a do not disturb mode while driving. During this mode any
incoming messages and notifications are silenced while you can still receive
incoming calls, navigation directions and voice interactions using a connected
Car bluetooth. The product is designed to limit distractions during driving
while at the same time not getting in the way so users can continue to use
navigation or other similar apps with minimal friction.


Behind the scenes, it uses AI powered on-device Activity
Recognition
that detects when a person is driving using low power signals
from multiple sensors, bluetooth and WiFi. Activity Recognition uses the Android
Sensor Hub to ensure low latency, low power and accurate driving detection.


This is a next step in our journey, but we are far from done. Early next year
we are introducing the Activity Recognition Transition API, which is the same
API used by Driving Do Not Disturb to build distraction-free driving
experiences.


We appreciate the feedback, and will continue to listen to your feedback as the
product evolves.


If you have questions about setting up the Driving Do-Not-Disturb, check out our
Help Center.




Read more

11/2/17

Update on Kotlin for Android

Posted by James Lau, Product Manager (twitter.com/jmslau)


Today is the beginning of KotlinConf.
It's been almost 6 months since we announced Kotlin as a first-class language
for Android at Google I/O. During this period, the number of apps on Google Play
using Kotlin has more than doubled. More than 17% of the projects in Android
Studio 3.0 are now using Kotlin. We are really excited about the strong
momentum, and we are thrilled that Android developers all over the world are
discovering the joy of Kotlin programming.



Kotlin for Android is production-ready. From startups to Fortune 500 companies,
developers are already using Kotlin to build their apps. Developers from
Pinterest, to Expedia, to Basecamp -- and many others -- are finding their use
of Kotlin is increasing productivity and their overall developer happiness
levels. Take a look at some of their experiences with Kotlin below.




With the recent release of href="https://developer.android.com/studio/index.html">Android Studio 3.0,
there is now a stable version of our IDE that has Kotlin support built-in. With
href="https://developer.android.com/topic/libraries/support-library/revisions.html">Support
Library 27, we have started adding nullability annotations to make the APIs
friendlier to use in Kotlin. We recently published the href="https://android.github.io/kotlin-guides/">Android Kotlin Guides on
GitHub to provide some guidance for Android Kotlin style and interop. We
have also been porting some of our href="https://developer.android.com/samples/index.html?language=kotlin">Android
samples to Kotlin, and we are adding Kotlin to our official documentation.


Android Studio 3.0



Last week, we href="https://android-developers.googleblog.com/2017/10/android-studio-30.html">released
Android Studio 3.0 on the stable channel. This is the first stable release
of Android Studio that has Kotlin support built-in. Building on the strength of
IntelliJ's Kotlin support, many critical IDE features like code completion and
syntax highlighting work well for Kotlin. You can choose to convert Java code to
Kotlin by using CodeConvert Java File to Kotlin
File
, or you can convert snippets of code just by pasting Java code
into a Kotlin file.



Project and code templates have also been updated with Kotlin support. When you
create a new project or add a new code file, you can choose Kotlin as one of the
language options.



The tooling experience with Kotlin is by no means perfect yet. We are aware of
several href="https://developer.android.com/studio/preview/kotlin-issues.html">known
issues, and we will continue to improve the IDE support for Kotlin in future
releases.


Android Kotlin Guides



There are two separate Android Kotlin Guides:


  1. Style guide
    - details a set of rules and coding standards that Google recommends when
    writing Kotlin for Android. The guide addresses naming conventions, formatting,
    structure of the source contents, and much more.


  2. Interop
    guide
    - provides a set of rules for creating APIs in the Java and Kotlin
    programming languages, so that the consuming code in the other language will
    feel idiomatic.


We intend these guides to be living documents and will evolve them over time.
They are hosted on GitHub and we welcome your href="https://android.github.io/kotlin-guides/contribute.html">contributions.


Nullability Annotations



Null-safety is an important feature of the Kotlin language. It helps developers
avoid NullPointerExceptions and improves the quality of their apps. Null-safety
is a bit more complicated when using Java code from Kotlin. Since any reference
in Java may be null, Kotlin's requirement for strict null-safety becomes
impractical for Java objects. Types declared in Java that do not contain
nullability annotations are called platform types - this means the Kotlin
compiler does not know whether it is nullable or not. When calling methods with
variables of platform types, the Kotlin compiler relaxes null-safety checks.
That means the overall null-safety of your app is weakened.



To let developers take more advantage of Kotlin's strict null-safety, we have
started adding nullability annotations in href="https://developer.android.com/topic/libraries/support-library/revisions.html">Support
Library 27. The Support Library contains a huge API surface area, and we
will continue to expand the nullability annotation coverage in the next several
releases. In addition, we will also be adding nullability annotations to other
Android APIs over time.



While the Kotlin adoption growth is fantastic, our commitment to the Java and
C++ programming languages remains unchanged. We've added href="https://developer.android.com/studio/write/java8-support.html">Java 8
language features support in Android Studio 3.0, and we've added more href="https://developer.android.com/about/versions/oreo/android-8.0.html#java">Java
8 language APIs in Android Oreo. We are also continuing to improve our
support for C++17 in the NDK. So even if you are not using Kotlin, your language
support will continue to improve.



It's an exciting time to be an Android developer. If you haven't had a chance to
try Kotlin, you can get started by learning the href="http://kotlinlang.org/docs/reference/basic-syntax.html">basic syntax
and by playing with the excellent Kotlin
Koans
. When you are ready to use Kotlin in your Android app, you can jump to
the Android Kotlin page for
more resources. With Kotlin's Java interoperability and Android Studio's Java to
Kotlin converter, it's easy to start using Kotlin in your project.



Happy Kotlin-ing!





Read more

8/11/17

Next-generation Dex Compiler Now in Preview

Posted by James Lau, Product
Manager



Android developers know that dex compilation is a key step in building an APK.
This is the process of transforming .class bytecode into .dex bytecode for the
Android Runtime (or Dalvik, for older versions of Android). The dex compiler
mostly works under the hood in your day-to-day app development, but it directly
impacts your app's build time, .dex file size, and runtime performance.



That's why we are investing in making important improvements in the dex
compiler. We're excited to announce that the next-generation dex compiler, D8,
is now available for preview as part of href="https://developer.android.com/studio/preview/index.html">Android Studio
3.0 Beta release.



When comparing with the current DX compiler, D8 compiles faster and outputs
smaller .dex files, while having the same or better app runtime performance.








* Tested with benchmark project href="https://github.com/jmslau/perf-android-large/tree/android-30">here.







*Tested with benchmark project href="https://github.com/jmslau/perf-android-large/tree/android-30">here.



How to try it?




D8 is available for your preview starting with href="https://developer.android.com/studio/preview/index.html">Android Studio
3.0 Beta. To try it, set the following in your project's gradle.properties
file:




android.enableD8=true


We have tested D8's correctness and performance on a number of apps, and the
results are encouraging. We're confident enough with the results that we are switching to use D8 as the default dex compiler for building href="https://source.android.com/source/">AOSP.



There is currently a known issue around 64-bit devices running Lollipop. Give D8 a try but please don't use it to deploy your app to Google Play. We would love to hear your feedback. You can file a bug report using
href="https://issuetracker.google.com/issues/new?component=317603&template=1018721">this
link.



What's next?




We plan to preview D8 over the next several months with the Android Studio 3.0
release. During this time, we will focus on addressing any critical bug reports
we receive from the community. We plan to bring D8 out of preview and enable it
as the default dex compiler in Android Studio 3.1. At that time, the DX compiler
will officially be put in maintenance mode. Only critical issues with DX will be
fixed moving forward.



Beyond D8, we are also working on R8, which is a Proguard replacement for whole
program minification and optimization. While the R8 project has already been href="https://r8.googlesource.com/r8">open sourced, it has not yet been
integrated with the Android Gradle plugin. We will provide more details about R8
in the near future when we are ready to preview it with the community.



Tool developers: get your bytecode tools Java 8 ready




In April, we href="https://android-developers.googleblog.com/2017/04/java-8-language-features-support-update.html">announced
Java 8 language features with desugaring. The desugaring step currently
happens immediately after Java compilation (javac) and before any bytecode
reading or rewriting tools are run. Over the next couple of months, the desugar
step will move to a later stage in the pipeline, as part of D8. This will allow
us to further reduce the overall build time and produce more optimized code.
This change means that any bytecode reading or rewriting tools will run before
the desugar step. If you develop .class bytecode reading or rewriting tools for
Android, you will need to make sure they can handle the Java 8 bytecode format
so they can continue to work properly when we move desugaring into D8.



Happy dex'ing!



Read more

6/17/17

Semantic Time support now available on the Awareness APIs

Posted by Ritesh Nayak M, Product Manager





Last year at I/O we launched the href="https://developers.google.com/awareness/">Awareness API, a simple yet
powerful API that let developers use signals such as Location, Weather, Time and
User Activity to build contextually relevant app experiences.



Available via Google Play services, the Awareness API offers two ways to take
advantage of context signals within your app. The href="https://developers.google.com/awareness/android-api/snapshot-api-overview">Snapshot
API lets your app request information about the user's current context,
while the href="https://developers.google.com/awareness/android-api/fence-api-overview">Fence
API lets your app react to changes in user's context, and when it matches a
certain set of conditions. For example, "tell me whenever the user is walking
and their headphone is plugged in".



Until now, you could specify a time fence on the Awareness APIs but were
restricted to using absolute/canonical representation of time. Based on
developer feedback, we realized that the flexibility of the API in regards to
building time fences did not support higher level abstractions people use when
they think and talk about time. "This weekend", "on the next
holiday
", "after sunset", are all very common and colloquial ways
of expressing time. That's why we're adding Semantic time support to these APIs
starting today



For e.g., if you were building a fitness app and wanted a way to prompt users
everyday morning to start their routine, or if you're a reading app that wants
to turn on night mode after dusk; you would have to query a 3p API for
sunrise/sunset information at the user location and then write up an Awareness
fence with those canonical time values. With our latest update, you can use our
href="https://developers.google.com/android/reference/com/google/android/gms/awareness/fence/TimeFence.html#TIME_INSTANT_SUNRISE">TIME_INSTANT_SUNRISE
and href="https://developers.google.com/android/reference/com/google/android/gms/awareness/fence/TimeFence.html#TIME_INSTANT_SUNSET">TIME_INSTANT_SUNSET
constants and let the platform manage all the complexity for you.



Let's look at an example. Suppose you're building a fitness app which prompts
users on Tuesday, and Thursday around sunrise to begin their morning work out.
You can set up this triggering using the following lines of code.




class="prettyprint">// A sun-state-based fence that is TRUE only on Tuesday and Thursday during Sunrise
AwarenessFence.and(
TimeFence.aroundTimeInstant(TimeFence.TIME_INSTANT_SUNRISE,
-10 * ONE_MINUTE_MILLIS, 5 * ONE_MINUTE_MILLIS),
AwarenessFence.or(
TimeFence.inIntervalOfDay(TimeFence.DAY_OF_WEEK_TUESDAY,
0, ONE_DAY_MILLIS),
TimeFence.inIntervalOfDay(TimeFence.DAY_OF_WEEK_THURSDAY,
0, ONE_DAY_MILLIS)));



One of our favorite semantic time features is public holidays. Every country and
regions within it have different holidays. Assume you were a local hiking &
adventure app that wants to show users activities they can indulge in on a
holiday that falls on a Friday or a Monday. You can use a combination of Days
and Holiday flags to identify this state for all your users around the world.
You can do this with just 3 lines of code and have this work in any part of the
world.




class="prettyprint">// A local-time fence that is TRUE only on public holidays in the
// device locale that fall on Fridays or Mondays.
AwarenessFence.and(
TimeFence.inTimeInterval(TimeFence.TIME_INTERVAL_HOLIDAY),
AwarenessFence.or(
TimeFence.inIntervalOfDay(TimeFence.DAY_OF_WEEK_FRIDAY,
9 * ONE_HOUR_MILLIS, 11 * ONE_HOUR_MILLIS),
TimeFence.inIntervalOfDay(TimeFence.DAY_OF_WEEK_MONDAY,
9 * ONE_HOUR_MILLIS, 11 * ONE_HOUR_MILLIS)));


In both example cases, Awareness does the heavy lifting of localizing time and
holidays based on the device locale settings.



We're excited to see what problems you'll solve using this powerful API. Please
join our href="https://groups.google.com/forum/#!forum/google-context-apis/join">mailing
list to get updates about this and other Context APIs at Google.



Read more

4/15/17

Java 8 Language Features Support Update


Posted by James Lau, Product Manager



Yesterday, we released Android Studio
2.4 Preview 6
. Java 8 language features are now supported by the Android
build system in the javac/dx compilation path. Android Studio's Gradle plugin
now desugars Java 8 class files to Java 7-compatible class files, so you can use
lambdas,
method references and other features
of Java 8.




For those of you who tried the Jack compiler, we now support the same set of
Java 8 language features but with faster build speed. You can use Java 8
language features together with tools that rely on bytecode, including Instant
Run. Using libraries written with Java 8 is also supported.




We first added Java 8 desugaring in Android Studio 2.4 Preview 4. Preview 6
includes important bug fixes related to Java 8 language features support. Many
of these fixes were made in response to bug reports you filed. We really
appreciate your help in improving Android development tools for the community!




It's easy to try using Java 8 language features in your Android project. Just
download Android Studio
2.4 Preview 6
, and update your project's target and source compatibility to
Java version 1.8. You can find more information in our preview
documentation
.




Happy lambda'ing!

Read more

3/28/17

Calling all early adopters for Android Studio previews

Posted by Scott Main, Technical Writer



If you love trying out all of the newest features in Android Studio and helping us make it a better IDE, we're making it even easier to download early preview builds with a new website. Here, you can download and stay up to date on all the latest Android Studio previews and other tools announcements.







Android Studio previews give you early access to new features in all aspects of the IDE, plus early versions of other tools such as the Android Emulator and platform SDK previews. You can install multiple versions of Android Studio side-by-side, so if a bug in the preview build blocks your app development, you can keep working on the same project from the stable version.



The latest preview for Android Studio 2.4 just came out last week, and it includes new features to support development with the Android O Developer Preview. You can download and set up the O preview SDK from inside Android Studio, and then use Android O’s XML font resources and autosizing TextView in the Layout Editor.



By building your apps with the Android Studio preview, you're also helping us create a better version of Android Studio. We want to hear from you if you encounter any bugs.
Read more
loading...