Android M新特性之Behavior Changes

1、Runtime Permissions

  On your apps that target the M Preview release 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 Context.checkSelfPermission() method. To request a permission, call the new Activity.requestPermission() method. Even if your app is not targeting the M Preview release, you should test your app under the new permissions model.

2、Power-Saving Optimizations

  If a device is unplugged and left stationary with the screen off for a period of time, it goes into Doze mode where it attempts to keep the system in a sleep state.

  The following restrictions apply to your apps while in Doze:

  • Network access is disabled, unless your app receives a high priority Google Cloud Messaging tickle.
  • Wake locks are ignored.
  • Alarms scheduled with the AlarmManager class are disabled, except for alarms that you've set with thesetAlarmClock() method and AlarmManager.setAndAllowWhileIdle().
  • WiFi scans are not performed.
  • Syncs and jobs for your sync adapters and JobScheduler are not permitted to run.

3、App standby

  With this preview, the system may determine that apps are idle when they are not in active use. 

4、Adoptable Storage Devices

  With this preview, users can adopt external storage devices such as SD cards. Adopting an external storage device encrypts and formats the device to behave like internal storage. This feature allows users to move both apps and private data of those apps between storage devices. When moving apps, the system respects theandroid:installLocation preference in the manifest.

5、Apache HTTP Client Removal

  This preview 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 yourbuild.gradle file:

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

6、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 AudioManager.requestAudioFocus() method instead. Similarly, the setStreamMute() method is deprecated; instead, call theAudioManager.adjustStreamVolume() method and pass in the direction value ADJUST_MUTE orADJUST_UNMUTE.

7、Text Selection

  When users select text in your app, you can now display text selection actions such as Cut, Copy, and Paste in a floating toolbar

8、Android Keystore Changes

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

9、Wi-Fi and Networking Changes

  This preview 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 the disableAllOthers=true setting, the device disconnected from other networks such as cellular data. In this preview, 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 newConnectivityManager.bindProcessToNetwork() method) to ensure that its network traffic is sent on the selected network.

10、Camera Service Changes

  In this preview, 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. 

11、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 thenewInstance() 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 class constructors are accessible.

This preview 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). With RTLD_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).

12、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.

13、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.

14、Android for Work Changes

  This preview 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 set DevicePolicyManager.setBluetoothContactSharingDisabled() to false. By default, it is set to true.
  • WiFi configuration removal: WiFi configurations added by a Profile Owner (for example, through calls to theaddNetwork() method) are now removed if that work profile is deleted.
  • WiFi configuration lockdown: Any WiFi configuration created by an active Device Owner can no longer be modified or deleted by the user if Settings.Global.WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN is non-zero. The user can still create and modify their own WiFi configurations. Active Device Owners have the privilege of editing/removing any WiFi 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 > Accounts and in the initial device setup wizard.
  • Changes to specific DevicePolicyManager API behaviors:
    • Calling the setCameraDisabled() method affects the camera for the calling user only; calling it from the managed profile doesn’t affect camera apps running on the primary user.
    • In addition, the setKeyguardDisabledFeatures() method is now available for Profile Owners, as well as to Device Owners.
    • A Profile Owner can set these keyguard restrictions:
    • The createAndInitializeUser() and createUser() methods have been deprecated.
    • The setScreenCaptureDisabled() method now also blocks the assist structure when an app of the given user is in the foreground.
    • EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM now defaults to SHA-256. SHA-1 is still supported for backwards compatibility but will be removed in future.EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM now only accepts SHA-256.
    • Device initializer APIs which existed in the MNC preview are now removed. They will not appear in the final M release.
    • EXTRA_PROVISIONING_RESET_PROTECTION_PARAMETERS is removed so NFC bump provisioning cannot programmatically unlock a factory reset protected device.
    • Android for Work APIs are optimized for M runtime permissions, including Work profiles, assist layer, and others. New DevicePolicyManager permission APIs don't affect pre-M apps.
  • Changes to other APIs:
    • Data Usage: The android.app.usage.NetworkUsageStats class has been renamedandroid.app.usage.NetworkStats.
  • Changes to global settings:
    • These settings can no longer be set via setGlobalSettings():
      • BLUETOOTH_ON
      • DEVELOPMENT_SETTINGS_ENABLED
      • MODE_RINGER
      • NETWORK_PREFERENCE
      • WIFI_ON
    • These global settings can now be set via setGlobalSettings():
      • WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN

转载于:https://www.cnblogs.com/WalsonWang/p/4720094.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值