Nền tảng Android 15 có các thay đổi về hành vi có thể ảnh hưởng đến ứng dụng của bạn. Những thay đổi về hành vi sau đây áp dụng cho tất cả ứng dụng khi chạy trên Android 15, bất kể targetSdkVersion. Bạn nên kiểm thử ứng dụng rồi sửa đổi để hỗ trợ những thay đổi này cho phù hợp (nếu cần).
Ngoài ra, hãy nhớ tham khảo danh sách các thay đổi về hành vi chỉ ảnh hưởng đến những ứng dụng nhắm đến Android 15.
Chức năng cốt lõi
Android 15 sửa đổi hoặc mở rộng nhiều chức năng cốt lõi của hệ thống Android.
Thay đổi đối với trạng thái dừng gói
The intention of the package FLAG_STOPPED state (which users
can engage in AOSP builds by long-pressing an app icon and selecting "Force
Stop") has always been to keep apps in this state until the user explicitly
removes the app from this state by directly launching the app or indirectly
interacting with the app (through the sharesheet or a widget, selecting the app
as live wallpaper, etc.). In Android 15, we've updated the behavior of the
system to be aligned with this intended behavior. Apps should only be removed
from the stopped state through direct or indirect user action.
To support the intended behavior, in addition to the existing restrictions, the
system also cancels all pending intents when the app enters the
stopped state on a device running Android 15. When the user's actions remove the
app from the stopped state, the ACTION_BOOT_COMPLETED
broadcast is delivered to the app providing an opportunity to re-register any
pending intents.
You can call the new
ApplicationStartInfo.wasForceStopped()
method to confirm whether the app was put into the stopped state.
Hỗ trợ kích thước trang 16 KB
从历史上看,Android 仅支持 4 KB 内存页面大小,这优化了系统内存性能,以适应 Android 设备通常拥有的平均总内存量。从 Android 15 开始,AOSP 支持配置为使用 16 KB 页面大小的设备(16 KB 设备)。如果您的应用直接或通过 SDK 间接使用任何 NDK 库,则需要重新构建应用,才能在这些 16 KB 设备上运行。
随着设备制造商不断制造出具有更大物理内存 (RAM) 的设备,许多此类设备将采用 16 KB(最终甚至更大)的页面大小来优化设备性能。添加对 16 KB 页面大小设备的支持,可让您的应用在这些设备上运行,并帮助您的应用受益于相关的性能改进。如果不重新编译,应用将无法在未来 Android 版本的 16 KB 设备上运行。
为帮助您为应用添加支持,我们提供了相关指南,介绍了如何检查应用是否受到影响、如何重新构建应用(如果适用),以及如何使用模拟器(包括 Android 模拟器的 Android 15 系统映像)在 16 KB 环境中测试应用。
Benefits and performance gains
Các thiết bị được định cấu hình với kích thước trang 16 KB sử dụng nhiều bộ nhớ hơn một chút trung bình, nhưng cũng có nhiều điểm cải tiến về hiệu suất cho cả hệ thống và ứng dụng:
- Giảm thời gian khởi chạy ứng dụng khi hệ thống chịu áp lực về bộ nhớ: Trung bình thấp hơn 3,16%, với mức cải thiện đáng kể hơn (lên đến 30%) đối với một số ứng dụng mà chúng tôi đã thử nghiệm
- Giảm mức tiêu thụ điện năng trong quá trình khởi chạy ứng dụng: trung bình giảm 4,56%
- Khởi động máy ảnh nhanh hơn: trung bình khởi động nóng nhanh hơn 4,48% và khởi động nguội nhanh hơn 6,60%
- Cải thiện thời gian khởi động hệ thống: trung bình cải thiện 8% (khoảng 950 mili giây)
Những cải tiến này dựa trên thử nghiệm ban đầu của chúng tôi và kết quả trên các thiết bị thực tế có thể sẽ khác. Chúng tôi sẽ phân tích thêm về những lợi ích có thể xảy ra đối với ứng dụng trong quá trình kiểm thử.
Check if your app is impacted
Nếu ứng dụng của bạn sử dụng mã gốc, thì bạn nên tạo lại ứng dụng để hỗ trợ các thiết bị 16 KB. Nếu không chắc chắn liệu ứng dụng của mình có dùng mã gốc hay không, bạn có thể dùng Công cụ phân tích APK để xác định xem có mã gốc nào hay không, sau đó kiểm tra mức căn chỉnh của các phân đoạn ELF cho mọi thư viện dùng chung mà bạn tìm thấy. Android Studio cũng cung cấp các tính năng giúp bạn tự động phát hiện các vấn đề về căn chỉnh.
Nếu ứng dụng của bạn chỉ dùng mã viết bằng ngôn ngữ lập trình Java hoặc Kotlin, bao gồm tất cả các thư viện hoặc SDK, thì ứng dụng của bạn đã hỗ trợ thiết bị 16 KB. Tuy nhiên, bạn nên kiểm thử ứng dụng trong môi trường 16 KB để xác minh rằng không có hồi quy không mong muốn nào trong hành vi của ứng dụng.
Những thay đổi bắt buộc đối với một số ứng dụng để hỗ trợ không gian riêng tư
Private space is a new feature in Android 15 that lets users create a separate space on their device where they can keep sensitive apps away from prying eyes, under an additional layer of authentication. Because apps in the private space have restricted visibility, some types of apps need to take additional steps to be able to see and interact with apps in a user's private space.
All apps
Because apps in the private space are kept in a separate user profile, similar to work profiles, apps shouldn't assume that any installed copies of their app that aren't in the main profile are in the work profile. If your app has logic related to work profile apps that make this assumption, you'll need to adjust this logic.
Medical apps
When a user locks the private space, all apps in the private space are stopped, and those apps can't perform foreground or background activities, including showing notifications. This behavior might critically impact the use and function of medical apps installed in the private space.
The private space setup experience warns users that the private space is not suitable for apps that need to perform critical foreground or background activities, such as showing notifications from medical apps. However, apps can't determine whether or not they're being used in the private space, so they can't show a warning to the user for this case.
For these reasons, if you develop a medical app, review how this feature might impact your app and take appropriate actions—such as informing your users not to install your app in the private space—to avoid disrupting critical app capabilities.
Launcher apps
If you develop a launcher app, you must do the following before apps in the private space will be visible:
- Your app must be assigned as the default launcher app for the device—that
is, possessing the
ROLE_HOMErole. - Your app must declare the
ACCESS_HIDDEN_PROFILESnormal permission in your app's manifest file.
Launcher apps that declare the ACCESS_HIDDEN_PROFILES permission must handle
the following private space use cases:
- Your app must have a separate launcher container for apps installed in the
private space. Use the
getLauncherUserInfo()method to determine which type of user profile is being handled. - The user must be able to hide and show the private space container.
- The user must be able to lock and unlock the private space container. Use
the
requestQuietModeEnabled()method to lock (by passingtrue) or unlock (by passingfalse) the private space. While locked, no apps in the private space container should be visible or discoverable through mechanisms such as search. Your app should register a receiver for the
ACTION_PROFILE_AVAILABLEandACTION_PROFILE_UNAVAILABLEbroadcasts and update the UI in your app when the locked or unlocked state of the private space container changes. Both of these broadcasts includeEXTRA_USER, which your app can use to refer to the private profile user.You can also use the
isQuietModeEnabled()method to check whether the private space profile is locked or not.
App store apps
The private space includes an "Install Apps" button that launches an implicit
intent to install apps into the user's private space. In order for your app to
receive this implicit intent, declare an <intent-filter>
in your app's manifest file with a <category> of
CATEGORY_APP_MARKET.
Đã xoá phông chữ biểu tượng cảm xúc dựa trên PNG
The legacy, PNG-based emoji font file (NotoColorEmojiLegacy.ttf) has been
removed, leaving just the vector-based file. Beginning with Android 13 (API
level 33), the emoji font file used by the system emoji renderer changed from a
PNG-based file to a vector based file. The system retained
the legacy font file in Android 13 and 14 for compatibility reasons, so that
apps with their own font renderers could continue to use the legacy font file
until they were able to upgrade.
To check if your app is affected, search your app's code for references to the
NotoColorEmojiLegacy.ttf file.
You can choose to adapt your app in a number of ways:
- Use platform APIs for text rendering. You can render text to a bitmap-backed
Canvasand use that to get a raw image if necessary. - Add COLRv1 font support to your app. The FreeType open source library supports COLRv1 in version 2.13.0 and higher.
- As a last resort, you can bundle the legacy emoji font file
(
NotoColorEmoji.ttf) into your APK, although in that case your app will be missing the latest emoji updates. For more information, see the Noto Emoji GitHub project page.
Tăng phiên bản SDK mục tiêu tối thiểu từ 23 lên 24
Android 15 builds on the
the changes that were made in Android 14 and extends this
security further. In Android 15, apps with a
targetSdkVersion lower than 24 can't be installed.
Requiring apps to meet modern API levels helps to ensure better security and
privacy.
Malware often targets lower API levels in order to bypass security and privacy
protections that have been introduced in higher Android versions. For example,
some malware apps use a targetSdkVersion of 22 to avoid being subjected to the
runtime permission model introduced in 2015 by Android 6.0 Marshmallow (API
level 23). This Android 15 change makes it harder for malware to avoid security
and privacy improvements. Attempting to install an app targeting a lower API
level results in an installation failure, with a message like the following one
appearing in Logcat:
INSTALL_FAILED_DEPRECATED_SDK_VERSION: App package must target at least SDK version 24, but found 7
On devices upgrading to Android 15, any apps with a targetSdkVersion lower
than 24 remain installed.
If you need to test an app targeting an older API level, use the following ADB command:
adb install --bypass-low-target-sdk-block FILENAME.apk
Bảo mật và quyền riêng tư
Android 15 引入了强大的措施来防范动态密码 (OTP) 欺诈并保护用户的敏感内容,重点是增强通知监听器服务和屏幕共享保护措施。主要增强功能包括从可供不可信应用访问的通知中隐去 OTP、在屏幕共享期间隐藏通知,以及在发布 OTP 时保护应用 activity。这些变更旨在保护用户的敏感内容,使其免受未经授权的操作者的侵害。
开发者需要注意以下事项,以确保其应用与 Android 15 中的变更兼容:
动态密码隐去
Android 会阻止实现 NotificationListenerService 的不受信任应用读取已检测到 OTP 的通知中的未隐去的内容。配套设备管理器关联等受信任应用不受这些限制。
屏幕共享保护
- 在屏幕共享会话期间,系统会隐藏通知内容,以保护用户的隐私。如果应用实现了
setPublicVersion(),Android 会显示通知的公开版本,该版本在不安全情境中用作替换通知。否则,系统会隐去通知内容,不提供任何其他背景信息。 - 系统会向远程观看者隐藏密码输入等敏感内容,以防止泄露用户的敏感信息。
- 如果在屏幕共享期间检测到动态密码,系统会隐藏在该时间段内发布通知的应用的活动。应用内容在启动时会向远程查看器隐藏。
- 除了 Android 自动识别敏感字段之外,开发者还可以使用
setContentSensitivity手动将应用的部分标记为敏感,在屏幕共享期间,这些敏感字段会对远程观看者隐藏。 - 开发者可以选择切换开发者选项下的停用屏幕共享防护选项,以便出于演示或测试目的豁免屏幕共享防护。默认的系统屏幕录制工具不受这些更改的影响,因为录制内容会保留在设备上。
Camera và nội dung nghe nhìn
Android 15 thực hiện những thay đổi sau đối với hành vi của camera và nội dung nghe nhìn cho tất cả các ứng dụng.
Việc phát trực tiếp và phát âm thanh gián tiếp sẽ làm mất hiệu lực các bản âm thanh trực tiếp hoặc gián tiếp đã mở trước đó khi đạt đến giới hạn tài nguyên
Before Android 15, if an app requested direct or offload audio playback while
another app was playing audio and the resource limits were reached, the app
would fail to open a new AudioTrack.
Beginning with Android 15, when an app requests direct or offload
playback and the resource
limits are reached, the system invalidates any currently open
AudioTrack objects which prevent fulfilling the new track request.
(Direct and offload audio tracks are typically opened for playback of compressed audio formats. Common use-cases for playing direct audio include streaming encoded audio over HDMI to a TV. Offload tracks are typically used to play compressed audio on a mobile device with hardware DSP acceleration.)
Trải nghiệm người dùng và giao diện người dùng hệ thống
Android 15 có một số thay đổi nhằm mang đến trải nghiệm người dùng nhất quán và trực quan hơn.
Ảnh động xem trước thao tác quay lại được bật cho những ứng dụng đã chọn sử dụng
Beginning in Android 15, the developer option for predictive back animations has been removed. System animations such as back-to-home, cross-task, and cross-activity now appear for apps that have opted in to the predictive back gesture either entirely or at an activity level. If your app is affected, take the following actions:
- Ensure that your app has been properly migrated to use the predictive back gesture.
- Ensure that your fragment transitions work with predictive back navigation.
- Migrate away from animation and framework transitions and use animator and androidx transitions instead.
- Migrate away from back stacks that
FragmentManagerdoesn't know about. Use back stacks managed byFragmentManageror by the Navigation component instead.
Tiện ích bị vô hiệu hoá khi người dùng buộc dừng một ứng dụng
Nếu người dùng buộc dừng một ứng dụng trên thiết bị chạy Android 15, thì hệ thống sẽ tạm thời tắt tất cả tiện ích của ứng dụng đó. Các tiện ích có màu xám và người dùng không thể tương tác với các tiện ích đó. Lý do là kể từ Android 15, hệ thống sẽ huỷ tất cả ý định đang chờ xử lý của ứng dụng khi ứng dụng bị buộc dừng.
Hệ thống sẽ bật lại các tiện ích đó vào lần tiếp theo người dùng khởi chạy ứng dụng.
Để biết thêm thông tin, hãy xem phần Thay đổi đối với trạng thái gói đã dừng.
Chế độ cảnh báo bằng chip trên thanh trạng thái truyền nội dung nghe nhìn sẽ thông báo cho người dùng về việc chia sẻ màn hình, truyền và ghi hình
Các lỗ hổng liên quan đến tính năng chiếu màn hình làm lộ dữ liệu riêng tư của người dùng, chẳng hạn như thông tin tài chính, vì người dùng không nhận ra màn hình thiết bị của họ đang được chia sẻ.
Đối với các ứng dụng chạy trên thiết bị có Android 15 QPR1 trở lên, một khối thanh trạng thái lớn và nổi bật sẽ cảnh báo người dùng về mọi hoạt động chiếu màn hình đang diễn ra. Người dùng có thể nhấn vào khối này để ngừng chia sẻ, truyền hoặc ghi lại màn hình của họ. Ngoài ra, tính năng chiếu màn hình sẽ tự động dừng khi màn hình thiết bị bị khoá.
Kiểm tra xem ứng dụng của bạn có bị ảnh hưởng hay không
Theo mặc định, ứng dụng của bạn sẽ bao gồm khối thanh trạng thái và tự động tạm ngưng tính năng chiếu màn hình khi màn hình khoá kích hoạt.
Để tìm hiểu thêm về cách kiểm thử ứng dụng cho các trường hợp sử dụng này, hãy xem phần Khối thanh trạng thái và tính năng tự động dừng.
Hạn chế quyền truy cập mạng khi ở nền sau
In Android 15, apps that start a network request outside of a valid process
lifecycle receive an exception. Typically, an
UnknownHostException or other socket-related
IOException. Network requests that happen outside of a valid lifecycle are
usually due to apps unknowingly continuing a network request even after the app
is no longer active.
To mitigate this exception, ensure your network requests are lifecycle aware and cancelled upon leaving a valid process lifecycle by using lifecycle aware components. If it is important that the network request should happen even when the user leaves the application, consider scheduling the network request using WorkManager or continue a user visible task using Foreground Service.
Ngừng sử dụng
Với mỗi bản phát hành, một số API Android cụ thể có thể trở nên lỗi thời hoặc cần được tái cấu trúc để mang lại trải nghiệm tốt hơn cho nhà phát triển hoặc hỗ trợ các tính năng mới của nền tảng. Trong những trường hợp này, chúng tôi chính thức ngừng sử dụng các API lỗi thời và hướng dẫn nhà phát triển sử dụng các API thay thế.
Ngừng cung cấp có nghĩa là chúng tôi đã ngừng hỗ trợ chính thức cho các API này, nhưng các API này sẽ vẫn tiếp tục được cung cấp cho nhà phát triển. Để tìm hiểu thêm về những điểm ngừng sử dụng đáng chú ý trong bản phát hành Android này, hãy xem trang ngừng sử dụng.