和先前版本一樣,Android 17 也包含可能會影響應用程式的行為變更。以下行為變更僅適用於指定 Android 17 以上版本的應用程式。如果您的應用程式指定 Android 17 以上版本,建議您視情況修改應用程式,以支援這些行為。
此外,無論應用程式的 targetSdkVersion 為何,請務必查看對所有 Android 17 應用程式有影響的行為變更清單。
使用者體驗和系統 UI
Android 17 包含下列異動項目,旨在打造更一致、直觀的使用者體驗。
記憶體限制小工具
Beginning with Android 17, for apps targeting
Android 17 (API level 37) or higher, the system enforces a strict memory
limit (1.5 * screen width * screen height * 4) against the combined memory usage
of both Bitmaps and Icons present in the RemoteViews parcel. Exceeding these
limits throws a fatal IllegalArgumentException and crashes the app's process.
For more information, see UpdateAppWidget.
核心功能
Android 17 包含下列異動項目,這類變更會修改或擴充 Android 系統的各種核心功能。
MessageQueue 的新無鎖實作
自 Android 17 起,指定 Android 17 (API 級別 37) 以上版本的應用程式會收到 android.os.MessageQueue 的新無鎖實作方式。新實作方式可提升效能並減少遺失的影格,但可能會中斷反映私有欄位和方法的用戶端。MessageQueue
如需更多資訊 (包括緩解策略),請參閱「MessageQueue 行為異動指南」。
靜態最終欄位現在無法修改
如果應用程式在 Android 17 以上版本上執行,且指定 Android 17 (API 級別 37) 以上版本,就無法變更 static final 欄位。如果應用程式嘗試使用反射功能變更 static final 欄位,就會導致 IllegalAccessException。如果嘗試透過 JNI API (例如 SetStaticLongField()) 修改其中一個欄位,應用程式就會當機。
無障礙設定
Android 17 進行下列變更,提升無障礙功能。
支援複雜 IME 實體鍵盤輸入的無障礙功能
This feature introduces new AccessibilityEvent and TextAttribute
APIs to enhance screen reader spoken feedback for CJKV language input. CJKV IME
apps can now signal whether a text conversion candidate has been selected during
text composition. Apps with edit fields can specify text change types when
sending text changed accessibility events.
For example, apps can specify that a text change occurred during text
composition, or that a text change resulted from a commit.
Doing this enables accessibility
services such as screen readers to deliver more precise feedback based on the
nature of the text modification.
App adoption
IME Apps: When setting composing text in edit fields, IMEs can use
TextAttribute.Builder.setTextSuggestionSelected()to indicate whether a specific conversion candidate was selected.Apps with Edit Fields: Apps that maintain a custom
InputConnectioncan retrieve candidate selection data by callingTextAttribute.isTextSuggestionSelected(). These apps should then callAccessibilityEvent.setTextChangeTypes()when dispatchingTYPE_VIEW_TEXT_CHANGEDevents. Apps targeting Android 17 (API level 37) that use the standardTextViewwill have this feature enabled by default. (That is,TextViewwill handle retrieving data from the IME and setting text change types when sending events to accessibility services).Accessibility Services: Accessibility services that process
TYPE_VIEW_TEXT_CHANGEDevents can callAccessibilityEvent.getTextChangeTypes()to identify the nature of the modification and adjust their feedback strategies accordingly.
隱私權
Android 17 包含下列異動項目,可提升使用者隱私權。
已啟用 ECH (Encrypted Client Hello)
Android 17 導入了經加密的 ClientHello (ECH) 平台支援功能。ECH 是 TLS 擴充功能,可加密 TLS 握手中的伺服器名稱指示 (SNI),進一步保障使用者隱私。這項加密功能可防止網路觀察員輕易識別應用程式連線的特定網域。
如果應用程式指定 Android 17 (API 級別 37) 以上版本,系統會使用 ECH 建立 TLS 連線。只有在應用程式使用的網路程式庫 (例如 HttpEngine、WebView 或 OkHttp) 已整合 ECH 支援功能,且遠端伺服器也支援 ECH 通訊協定時,ECH 才會啟用。如果無法協商 ECH,用戶端會傳送含有隨機內容的 ECH 擴充功能 (這項機制稱為 ECH GREASE)。如要進一步瞭解 ECH GREASE 的運作方式,請參閱 RFC 9849。
為允許應用程式自訂這項行為,Android 17 在網路安全性設定檔中新增了 <domainEncryption> 元素。開發人員可以在 <base-config> 或 <domain-config> 標記內使用 <domainEncryption>,以全域或網域為單位選取 ECH 模式 (例如 "enabled" 或 "disabled")。
詳情請參閱「加密用戶端問候訊息」說明文件。
以 Android 17 為目標的應用程式必須取得區域網路權限
Android 17 introduces the ACCESS_LOCAL_NETWORK runtime permission
to protect users from unauthorized local network access. Because this falls
under the existing NEARBY_DEVICES permission group, users who have already
granted other NEARBY_DEVICES permissions aren't prompted again. This new
requirement prevents malicious apps from exploiting unrestricted local network
access for covert user tracking and fingerprinting. By declaring and requesting
this permission, your app can discover and connect to devices on the local area
network (LAN), such as smart home devices or casting receivers.
Apps targeting Android 17 (API level 37) or higher now have two paths to maintain communication with LAN devices: Adopt system-mediated, privacy-preserving device pickers to skip the permission prompt, or explicitly request this new permission at runtime to maintain local network communication.
For more information, see the Local network permission documentation.
隱藏實體裝置上的密碼
如果應用程式指定 Android 17 (API 級別 37) 以上版本,且使用者使用實體輸入裝置 (例如外接鍵盤),Android 作業系統會將新的 show_passwords_physical 設定套用至密碼欄位中的所有字元。根據預設,這項設定會隱藏所有密碼字元。
Android 系統會顯示最後輸入的密碼字元,協助使用者確認密碼是否輸入錯誤。不過,使用較大的外接鍵盤時,這項功能就沒那麼必要。此外,配備外接鍵盤的裝置通常螢幕較大,因此他人更容易看到您輸入的密碼。
如果使用者正在使用裝置的觸控螢幕,系統會套用新的 show_passwords_touch 設定。
保護標準簡訊中的動態密碼
Beginning with Android 17, Android is extending its SMS OTP protection
to apply to standard SMS messages (SMS messages containing an OTP that do not
use the WebOTP or SMS Retriever formats). For most apps targeting
Android 17 (API level 37) or higher, these SMS messages do not become
available until three hours after receipt. This delay is intended to help
prevent OTP hijacking. During this three hour delay, the
SMS_RECEIVED_ACTION broadcast is withheld and
SMS provider database queries are filtered. The SMS message is
available to these apps after the delay.
Certain apps such as the default SMS assistant app, connected device companion apps, etc., are exempted from this delay. All apps that rely on reading SMS messages for OTP extraction should transition to using SMS Retriever or SMS User Consent APIs to ensure continued functionality.
安全性
Android 17 在裝置和應用程式安全性方面有以下改進。
活動安全性
In Android 17, the platform continues its shift toward a "secure-by-default" architecture, introducing a suite of enhancements designed to mitigate high-severity exploits such as phishing, interaction hijacking, and confused deputy attacks. This update requires developers to explicitly opt in to new security standards to maintain app compatibility and user protection.
Key impacts for developers include:
- BAL hardening & improved opt-in: We are refining Background Activity
Launch (BAL) restrictions by extending protections to
IntentSender. Developers must migrate away from the legacyMODE_BACKGROUND_ACTIVITY_START_ALLOWEDconstant. Instead, you should adopt granular controls likeMODE_BACKGROUND_ACTIVITY_START_ALLOW_IF_VISIBLE, which restricts activity starts to scenarios where the calling app is visible, significantly reducing the attack surface. - Adoption tools: Developers should utilize strict mode and updated lint checks to identify legacy patterns and ensure readiness for future target SDK requirements.
預設啟用 CT
If an app targets Android 17 (API level 37) or higher, certificate transparency (CT) is enabled by default. (On Android 16, CT is available but apps had to opt in.)
更安全的 Native DCL - C
If your app targets Android 17 (API level 37) or higher, the Safer Dynamic Code Loading (DCL) protection introduced in Android 14 for DEX and JAR files now extends to native libraries.
All native files loaded using System.load() must be marked as read-only.
Otherwise, the system throws UnsatisfiedLinkError.
We recommend that apps avoid dynamically loading code whenever possible, as doing so greatly increases the risk that an app can be compromised by code injection or code tampering.
限制 CP2 資料檢視中的 PII 欄位
For apps targeting Android 17 (API level Android 17 (API level 37)) and higher, Contacts Provider 2 (CP2) restricts certain columns containing Personally Identifiable Information (PII) from the data view. When this change is enabled, these columns are removed from the data view to enhance user privacy. The restricted columns include:
Apps that are using these columns from ContactsContract.Data
can extract them from ContactsContract.RawContacts
instead, by joining with RAW_CONTACT_ID.
在 CP2 中強制執行嚴格的 SQL 檢查
For apps targeting Android 17 (API level Android 17 (API level 37)) and
higher, Contacts Provider 2 (CP2) enforces strict SQL query validation when
the ContactsContract.Data table is accessed without
READ_CONTACTS permission.
With this change, if an app doesn't have READ_CONTACTS
permission, StrictColumns and
StrictGrammar options are set when querying
the ContactsContract.Data table. If a query
uses a pattern that isn't compatible with these, it will be
rejected and cause an exception to be thrown.
情報
Android 17 包含下列系統智慧功能變更。
setContentCaptureEnabled 淘汰
Content Capture is enabled by default on certain devices to allow on-device AI features to analyze screen contents for intelligent experiences.
Starting in Android 17, the
ContentCaptureManager.setContentCaptureEnabled(boolean)
API method is deprecated. For apps that target Android 17 (API level 37) or
higher, calling setContentCaptureEnabled(false) no longer disables Content
Capture.
If your app needs to continue disabling Content Capture or restrict screen
contents from being captured by the system, you must transition to using the
FLAG_SECURE window layout parameter.
To disable Content Capture, set the FLAG_SECURE flag on your window as shown
in the following example:
Kotlin
window.setFlags(
WindowManager.LayoutParams.FLAG_SECURE,
WindowManager.LayoutParams.FLAG_SECURE
)
Java
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_SECURE,
WindowManager.LayoutParams.FLAG_SECURE
);
For more details, see the
WindowManager.LayoutParams.FLAG_SECURE reference
documentation.
媒體
Android 17 包含下列媒體行為變更。
強化背景音訊
Beginning with Android 17, the audio framework enforces restrictions on background audio interactions including audio playback, audio focus requests, and volume change APIs to ensure that these changes are started intentionally by the user.
Some audio restrictions apply to all apps. However, the restrictions are more stringent if an app targets Android 17 (API level 37). If one of these apps interacts with audio while it is in the background, it must have a foreground service running. In addition, the app must meet one or both of these requirements:
- The foreground service must have while-in-use (WIU) capabilities.
- The app must have the exact alarm permission and be interacting with
USAGE_ALARMaudio streams.
For more information, including mitigation strategies, see Background audio hardening.
裝置板型規格
Android 17 包含下列異動項目,可提升各種尺寸和板型規格裝置的使用者體驗。
平台 API 異動,可忽略大螢幕 (sw>=600dp) 的螢幕方向、大小調整和顯示比例限制
我們在 Android 16 中導入了平台 API 變更,針對指定 API 級別 36 以上版本的應用程式,忽略大螢幕 (sw >= 600dp) 的螢幕方向、顯示比例和大小調整限制。開發人員可使用 SDK 36 選擇不採用這些變更,但如果應用程式的目標版本是 Android 17 (API 級別 37) 以上版本,則無法再選擇不採用。
詳情請參閱「系統會忽略螢幕方向和大小調整限制」。
連線能力
Android 17 針對藍牙 RFCOMM 通訊端導入下列變更,以提升一致性並符合標準 Java InputStream 行為。
RFCOMM 的 BluetoothSocket read() 行為一致
For apps targeting Android 17 (API level 37), the
read() method of the InputStream obtained from an
RFCOMM-based BluetoothSocket now returns -1 when the
socket is closed or the connection is dropped.
This change makes RFCOMM socket behavior consistent with LE CoC sockets and
aligns with the standard InputStream.read()
documentation, which states that -1 is returned when the end of the stream is
reached.
Apps that rely solely on catching an IOException to break out of a read loop may
be impacted by this change and should update the BluetoothSocket read loops to
explicitly check for a return value of -1. This ensures the loop terminates
correctly when the remote device disconnects or the socket is closed. For an
example of the recommended implementation, see the
code snippet in the Transfer Bluetooth data
guide.