Android 6.0 Changes

Android 6.0 变化   Android 6.0 Changes

In this document

  1. 运行时权限
    Runtime Permissions
  2. Doze and App Standby
  3. 阿帕奇 HTTPClient 移除
  4. Apache HTTP Client Removal
  5. OpenSSL 的分支 BoringSSL
  6. BoringSSL
  7. 访问硬件标识
  8. Access to Hardware Identifiers
  9. 通知
  10. Notifications
  11. 音频管理变化
  12. AudioManager Changes
  13. 文本选择
  14. Text Selection
  15. 浏览器书签变化
  16. Browser Bookmark Changes
  17. Android 密钥库变化
  18. Android Keystore Changes
  19. Wi-Fi 和网络变化
  20. Wi-Fi and Networking Changes
  21. 像机服务变化
  22. Camera Service Changes
  23. 运行时变化
  24. Runtime
  25. APK 校验
  26. APK Validation
  27. USB 连接
  28. USB Connection
  29. Android 使用变化
  30. Android for Work Changes

API Differences

  1. API level 22 to 23 ?

See Also

  1. Android 6.0 API Overview

伴随着新特性和功能,Android 6.0 (API level 23)包含了各种各样的系统变化和 API 行为变化。本文突出一些关键的变化,这些变化在你的应用中需要考虑到和处理。
Along with new features and capabilities, Android 6.0 (API level 23) includes a variety of system changes and API behavior changes. This document highlights some of the key changes that you should understand and account for in your apps.

如果你先前发布过 Android 应用,就要了解这个平台影响你的应用的一些变化。
If you have previously published an app for Android, be aware that these changes in the platform affect your app.

运行时权限

Runtime Permissions

This release introduces a new permissions model, where users can now directly manage app permissions at runtime. This model gives users improved visibility and control over permissions, while streamlining the installation and auto-update processes for app developers. Users can grant or revoke permissions individually for installed apps.

On your apps that target Android 6.0 (API level 23) or higher, make sure to check for and request permissions at runtime. To determine if your app has been granted a permission, call the new checkSelfPermission() method. To request a permission, call the new requestPermissions() method. Even if your app is not targeting Android 6.0 (API level 23), you should test your app under the new permissions model.

For details on supporting the new permissions model in your app, see Working with System Permissions. For tips on how to assess the impact on your app, see Permissions Best Practices.

Doze and App Standby

This release introduces new power-saving optimizations for idle devices and apps. These features affect all apps so make sure to test your apps in these new modes.

  • Doze: If a user unplugs a device and leaves it stationary, with its screen off, for a period of time, the device goes intoDoze mode, where it attempts to keep the system in a sleep state. In this mode, devices periodically resume normal operations for brief periods of time so that app syncing can occur and the system can perform any pending operations.
  • App Standby: App Standby allows the system to determine that an app is idle when the user is not actively using it. The system makes this determination when the user does not touch the app for a certain period of time. If the device is unplugged, the system disables network access and suspends syncs and jobs for the apps it deems idle.

To learn more about these power-saving changes, see Optimizing for Doze and App Standby.

Apache HTTP Client Removal

Android 6.0 release removes support for the Apache HTTP client. If your app is using this client and targets Android 2.3 (API level 9) or higher, use the HttpURLConnection class instead. This API is more efficient because it reduces network use through transparent compression and response caching, and minimizes power consumption. To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:

android {
    useLibrary ‘org.apache.http.legacy‘
}

BoringSSL

Android is moving away from OpenSSL to the BoringSSL library. If you’re using the Android NDK in your app, don‘t link against cryptographic libraries that are not a part of the NDK API, such as libcrypto.so and libssl.so. These libraries are not public APIs, and may change or break without notice across releases and devices. In addition, you may expose yourself to security vulnerabilities. Instead, modify your native code to call the Java cryptography APIs via JNI or to statically link against a cryptography library of your choice.

Access to Hardware Identifier

To provide users with greater data protection, starting in this release, Android removes programmatic access to the device’s local hardware identifier for apps using the Wi-Fi and Bluetooth APIs. The WifiInfo.getMacAddress() and theBluetoothAdapter.getAddress() methods now return a constant value of 02:00:00:00:00:00.

To access the hardware identifiers of nearby external devices via Bluetooth and Wi-Fi scans, your app must now have theACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permissions:

Note: When a device running Android 6.0 (API level 23) initiates a background Wi-Fi or Bluetooth scan, the operation is visible to external devices as originating from a randomized MAC address.

Notifications

This release removes the Notification.setLatestEventInfo() method. Use the Notification.Builder class instead to construct notifications. To update a notification repeatedly, reuse the Notification.Builder instance. Call thebuild() method to get updated Notification instances.

The adb shell dumpsys notification command no longer prints out your notification text. Use the adb shell dumpsys notification --noredact command instead to print out the text in a notification object.

AudioManager Changes

Setting the volume directly or muting specific streams via the AudioManager class is no longer supported. ThesetStreamSolo() method is deprecated, and you should call the requestAudioFocus() method instead. Similarly, thesetStreamMute() method is deprecated; instead, call the adjustStreamVolume() method and pass in the direction valueADJUST_MUTE or ADJUST_UNMUTE.

Text Selection

When users select text in your app, you can now display text selection actions such as CutCopy, and Paste in afloating toolbar. The user interaction implementation is similar to that for the contextual action bar, as described inEnabling the contextual action mode for individual views.

To implement a floating toolbar for text selection, make the following changes in your existing apps:

  1. In your View or Activity object, change yourActionMode calls from startActionMode(Callback)to startActionMode(Callback, ActionMode.TYPE_FLOATING).
  2. Take your existing implementation ofActionMode.Callback and make it extendActionMode.Callback2 instead.
  3. Override the onGetContentRect() method to provide the coordinates of the content Rect object (such as a text selection rectangle) in the view.
  4. If the rectangle positioning is no longer valid, and this is the only element to be invalidated, call theinvalidateContentRect() method.

If you are using Android Support Library revision 22.2, be aware that floating toolbars are not backward-compatible and appcompat takes control over ActionMode objects by default. This prevents floating toolbars from being displayed. To enable ActionMode support in anAppCompatActivity, call getDelegate(), then call setHandleNativeActionModesEnabled() on the returnedAppCompatDelegate object and set the input parameter to false. This call returns control of ActionMode objects to the framework. In devices running Android 6.0 (API level 23), that allows the framework to support ActionBar or floating toolbar modes, while on devices running Android 5.1 (API level 22) or lower, only the ActionBar modes are supported.

Browser Bookmark Changes

This release removes support for global bookmarks. The android.provider.Browser.getAllBookmarks() andandroid.provider.Browser.saveBookmark() methods are now removed. Likewise, the READ_HISTORY_BOOKMARKS andWRITE_HISTORY_BOOKMARKS permissions are removed. If your app targets Android 6.0 (API level 23) or higher, don‘t access bookmarks from the global provider or use the bookmark permissions. Instead, your app should store bookmarks data internally.

Android Keystore Changes

With this release, the Android Keystore provider no longer supports DSA. ECDSA is still supported.

Keys which do not require encryption at rest will no longer be deleted when secure lock screen is disabled or reset (forexample, by the user or a Device Administrator). Keys which require encryption at rest will be deleted during these events.

Wi-Fi and Networking Changes

This release introduces the following behavior changes to the Wi-Fi and networking APIs.

  • Your apps can now change the state of WifiConfiguration objects only if you created these objects. You are not permitted to modify or delete WifiConfiguration objects created by the user or by other apps.
  • Previously, if an app forced the device to connect to a specific Wi-Fi network by using enableNetwork() with thedisableAllOthers=true setting, the device disconnected from other networks such as cellular data. In This release, the device no longer disconnects from such other networks. If your app’s targetSdkVersion is “20” or lower, it is pinned to the selected Wi-Fi network. If your app’s targetSdkVersion is “21” or higher, use the multinetwork APIs (such as openConnection()bindSocket(), and the new bindProcessToNetwork() method) to ensure that its network traffic is sent on the selected network.

Camera Service Changes

In This release, the model for accessing shared resources in the camera service has been changed from the previous “first come, first serve” access model to an access model where high-priority processes are favored. Changes to the service behavior include:

  • Access to camera subsystem resources, including opening and configuring a camera device, is awarded based on the “priority” of the client application process. Application processes with user-visible or foreground activities are generally given a higher-priority, making camera resource acquisition and use more dependable.
  • Active camera clients for lower priority apps may be “evicted” when a higher priority application attempts to use the camera. In the deprecated Camera API, this results in onError() being called for the evicted client. In the Camera2API, it results in onDisconnected() being called for the evicted client.
  • On devices with appropriate camera hardware, separate application processes are able to independently open and use separate camera devices simultaneously. However, multi-process use cases, where simultaneous access causes significant degradation of performance or capabilities of any of the open camera devices, are now detected and disallowed by the camera service. This change may result in “evictions” for lower priority clients even when no other app is directly attempting to access the same camera device.
  • Changing the current user causes active camera clients in apps owned by the previous user account to be evicted. Access to the camera is limited to user profiles owned by the current device user. In practice, this means that a “Guest” account, for example, will not be able to leave running processes that use the camera subsystem when the user has switched to a different account.

Runtime

The ART runtime now properly implements access rules for the newInstance() method. This change fixes a problem where Dalvik was checking access rules incorrectly in previous versions. If your app uses the newInstance() method and you want to override access checks, call the setAccessible() method with the input parameter set to true. If your app uses the v7 appcompat library or the v7 recyclerview library, you must update your app to use to the latest versions of these libraries. Otherwise, make sure that any custom classes referenced from XML are updated so that their classconstructors are accessible.

This release updates the behavior of the dynamic linker. The dynamic linker now understands the difference between a library’s soname and its path (public bug 6670), and search by soname is now implemented. Apps which previously worked that have bad DT_NEEDED entries (usually absolute paths on the build machine’s file system) may fail when loaded.

The dlopen(3) RTLD_LOCAL flag is now correctly implemented. Note that RTLD_LOCAL is the default, so calls todlopen(3) that didn’t explicitly use RTLD_LOCAL will be affected (unless your app explicitly used RTLD_GLOBAL). WithRTLD_LOCAL, symbols will not be made available to libraries loaded by later calls to dlopen(3) (as opposed to being referenced by DT_NEEDED entries).

On previous versions of Android, if your app requested the system to load a shared library with text relocations, the system displayed a warning but still allowed the library to be loaded. Beginning in this release, the system rejects this library if your app‘s target SDK version is 23 or higher. To help you detect if a library failed to load, your app should log the dlopen(3)failure, and include the problem description text that the dlerror(3) call returns. To learn more about handling text relocations, see this guide.

APK Validation

The platform now performs stricter validation of APKs. An APK is considered corrupt if a file is declared in the manifest but not present in the APK itself. An APK must be re-signed if any of the contents are removed.

USB Connection

Device connections through the USB port are now set to charge-only mode by default. To access the device and its content over a USB connection, users must explicitly grant permission for such interactions. If your app supports user interactions with the device over a USB port, take into consideration that the interaction must be explicitly enabled.

Android for Work Changes

This release includes the following behavior changes for Android for Work:

  • Work contacts in personal contexts. The Google Dialer Call Log now displays work contacts when the user views past calls. Setting setCrossProfileCallerIdDisabled() to true hides the work profile contacts in the Google Dialer Call Log. Work contacts can be displayed along with personal contacts to devices over Bluetooth only if you setsetBluetoothContactSharingDisabled() to false. By default, it is set to true.
  • Wi-Fi configuration removal: Wi-Fi configurations added by a Profile Owner (for example, through calls to theaddNetwork() method) are now removed if that work profile is deleted.
  • Wi-Fi configuration lockdown: Any Wi-Fi configuration created by an active Device Owner can no longer be modified or deleted by the user if WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN is non-zero. The user can still create and modify their own Wi-Fi configurations. Active Device Owners have the privilege of editing or removing any Wi-Fi configurations, including those not created by them.
  • Download Work Policy Controller via Google account addition: When a Google account that requires management via a Work Policy Controller (WPC) app is added to a device outside of a managed context, the add account flow now prompts the user to install the appropriate WPC. This behavior also applies to accounts added via Settings > Accountsand in the initial device setup wizard.
  • Changes to specific DevicePolicyManager API behaviors:
  • Changes to other APIs:
    • Data Usage: The android.app.usage.NetworkUsageStats class has been renamed NetworkStats.
  • Changes to global settings:
时间: 2024-10-06 08:28:55

Android 6.0 Changes的相关文章

Android 6.0 运行时权限处理完全解析

一.概述 随着Android 6.0发布以及普及,我们开发者所要应对的主要就是新版本SDK带来的一些变化,首先关注的就是权限机制的变化.对于6.0的几个主要的变化,查看查看官网的这篇文章http://developer.android.com/intl/zh-cn/about/versions/marshmallow/android-6.0-changes.html,其中当然包含Runtime Permissions. ok,本篇文章目的之一就是对运行时权限处理的一个介绍,以及对目前权限相关的库

android 6.0 系统获取权限

在Android 6.0 (API 23) 发布之前, 所有的权限都在安装应用的时候显示给用户,用户选择安装则表示全部接受这些权限, 之后无法撤销对这些权限的授权.但Android 6.0开始, 一部分比较危险的权限需要在程序运行时显式弹框,请求用户授权.所以,之前开发应用时,在manifest文件中配置对应的权限这种做法便达不到之前的效果.那么,现在要怎么做呢?提供两种思路,仅供参考: 1:判断android系统的版本,如果不是6.0及以上,按正常逻辑处理,如果是,则去打开系统弹框,请求系统权

Android 5.0特性

虽然此前Google对其已经做过了比较深入的介绍,但作为一个如此重要的升级版本,更新内容自然是海量的. Google今天很贴心地在官网上放出了Android 5.0正式版的完整更新日志,涵盖了升级的方方面面,不过说实话也只是一些重要的.大面上的概略更新介绍,还有更多细节等待挖掘. 1.Material Design 醒目的.多彩的.快速响应的UI设计,可为你所有的设备带来一致的直觉体验. - 响应快速.自然流畅的动作,真实的光照和阴影,熟悉的视觉元素,设备导航更加轻而易举. - 惊艳的新色彩,凸

解决Android 5.0中出现的警告:Service Intent must be explicit

extends:http://www.eoeandroid.com/thread-568853-1-1.html 本帖最后由 469874851 于 2015-3-11 18:15 编辑 有些时候我们使用Service的时需要采用隐私启动的方式,但是Android 5.0一出来后,其中有个特性就是Service Intent  must be explitict,也就是说从Lollipop开始,service服务必须采用显示方式启动.而android源码是这样写的(源码位置:sdk/source

修复android 5.0 Xutils的框架问题retry error, curr request is null

Android 5.0手机对xUtils-2.6.13.jar请求时会出现retry error, curr request is null 情况, 修复解决方式: 找到library/src/com/lidroid/xutils/cache/KeyExpiryMap.java 感兴趣的关注一下微信订阅号爱开发:微信号:aikaifa 或扫描一下以下二维码: jar包下载

Android 5.0 怎样正确启用isLoggable(二)__原理分析

前置文章 <Android 5.0 怎样正确启用isLoggable(一)__使用具体解释> 概要 在上文<Android 5.0 怎样正确启用isLoggable(一)__使用具体解释>中分析了isLoggable的用法,本文主要分析isLoggable实现原理以及user版系统root后永久enable isLoggable的原理,并使用脚本自己主动设置isLoggable相关属性. 本文来自http://blog.csdn.net/yihongyuelan 转载请务必注明出处

Android 7.0 Nougat(牛轧糖)---对开发者来说

android 7.0出来了.让你的app准备迎接最新的android版本吧,支持节省电量和内存,这样新的系统行为.使用多窗口UI.直接恢复通知以及其他操作来扩展你的app. android 7.0介绍了各种各样的新功能给用户和开发者, 本文重点介绍面向开发者的一些新功能. 确保检查android 7.0的行为变化,了解有关平台的变化可能会影响你的app. 如果要了解更多的关于用户的新功能,请查看www.android.com. 1.支持多窗口 在android 7.0中,我们介绍了在支持多窗口

android 5.0 受欢迎的API简介

android 5.0 作为系统的一次重大升级,给用户和开发者带来了全新的体验.Material Design不但在视觉和操作上更胜一筹,扩展UI工具包同时也引入了大量新的API. 1. 3D视图和实时阴影: 只要重新设定elevation,图像下的实时阴影就会出现,漂浮在屏幕之上的感觉. 2. Activity Transaction 主要是实现不同Activity之间的动画切换. 3. Heads-up,主要是设置通知中心以卡片的模式出现,比如可以设置heads-up讲来电提醒显示在屏幕的顶

Nexus 5 Android 6.0.1刷机、Root

Nexus 5 Android 6.0.1刷机.Root 2016-01-24   一.     准备 1.      备份通讯录等数据,切记. 2.      准备adb .fastboot.网上搜索可以下载到,如果已安装Android开发环境,可直接使用android-sdk\platform-tools目录下的adb.exe(依赖AdbWinApi.dll.AdbWinUsbApi.dll)和fastboot.exe.解压到D:\adb目录,并将D:\adb目录添加到环境变量. 3.   

Android 5.0 进程A和APK B依赖关系问题的研究

(本文来自于和博客上一个朋友的聊天,但可惜我回复后一直没收到这位朋友的回答.故在此把这个问题和大家介绍下,希望能抛砖引玉) 这位朋友的问题是这样的: 应用程序A运行时跑在进程A中,它可以在运行时通过ClassLoader加载另外一个应用程序B. 当然,应用程序B也是可以运行的,它运行在进程B中. 在Android 5.0以前,进程B和进程A是没有关系.但是5.0以后,如果进程B被stop的话,进程A一样会被干掉. 这就是Android 5.0带来的进程A/B依赖关系. 这个问题有几个关键技术点: