Android 17 wprowadza nowe, świetne funkcje i interfejsy API dla deweloperów. W kolejnych sekcjach znajdziesz podsumowanie tych funkcji, które pomoże Ci rozpocząć korzystanie z powiązanych interfejsów API.
Szczegółową listę nowych, zmodyfikowanych i usuniętych interfejsów API znajdziesz w raporcie o różnicach w interfejsach API. Szczegółowe informacje o nowych interfejsach API znajdziesz w dokumentacji API Androida. Nowe interfejsy API są wyróżnione w celu zapewnienia widoczności.
Sprawdź też obszary, na które zmiany na platformie mogą mieć wpływ. Więcej informacji znajdziesz na tych stronach:
- Zmiany w działaniu, które wpływają na aplikacje kierowane na Androida 17
- Zmiany w działaniu, które wpływają na wszystkie aplikacje niezależnie od
targetSdkVersion.
Główna funkcja
Android 17 wprowadza te nowe funkcje związane z podstawową funkcjonalnością Androida:
Nowe aktywatory ProfilingManager
Android 17 adds several new system triggers to ProfilingManager to
help you collect in-depth data to debug performance issues.
The new triggers are:
TRIGGER_TYPE_COLD_START: Trigger occurs during app cold start. It provides both a call stack sample and a system trace in the response.TRIGGER_TYPE_OOM: Trigger occurs when an app throws anOutOfMemoryErrorand provides a Java Heap Dump in response.TRIGGER_TYPE_KILL_EXCESSIVE_CPU_USAGE: Trigger occurs when an app is killed due to abnormal and excessive CPU usage and provides a call stack sample in response.TRIGGER_TYPE_ANOMALY: Detect system performance anomalies such as excessive binder calls and excessive memory usage.
To understand how to set up the system trigger, see the documentation on trigger-based profiling and how to retrieve and analyze profiling data documentation.
Profiling trigger for app anomalies
Android 17
introduces an on-device anomaly detection service that monitors for
resource-intensive behaviors and potential compatibility regressions. Integrated
with ProfilingManager, this service allows your app to receive profiling
artifacts triggered by specific system-detected events.
Use the TRIGGER_TYPE_ANOMALY trigger to detect system performance issues
such as excessive binder calls and excessive memory usage. When an app breaches
OS-defined memory limits, the anomaly trigger allows developers to receive
app-specific heap dumps to help identify and fix memory issues. Additionally,
for excessive binder spam, the anomaly trigger provides a stack sampling profile
on binder transactions.
This API callback occurs prior to any system imposed enforcements. For example, it can help developers collect debug data before the app is terminated by the system for exceeding memory limits.
val profilingManager =
applicationContext.getSystemService(ProfilingManager::class.java)
val triggers = ArrayList<ProfilingTrigger>()
triggers.add(ProfilingTrigger.Builder(ProfilingTrigger.TRIGGER_TYPE_ANOMALY))
val mainExecutor: Executor = Executors.newSingleThreadExecutor()
val resultCallback = Consumer<ProfilingResult> { profilingResult ->
if (profilingResult.errorCode != ProfilingResult.ERROR_NONE) {
// upload profile result to server for further analysis
setupProfileUploadWorker(profilingResult.resultFilePath)
}
profilingManager.registerForAllProfilingResults(mainExecutor,
resultCallback)
profilingManager.addProfilingTriggers(triggers)
}
Interfejsy JobDebugInfo API
Android 17 introduces new JobDebugInfo APIs to help developers debug
their JobScheduler jobs--why they aren't running, how long they ran for, and
other aggregated information.
The first method of the expanded JobDebugInfo APIs is
getPendingJobReasonStats(), which returns a map of reasons why the job was in
a pending execution state and their respective cumulative pending
durations. This method joins the getPendingJobReasonsHistory() and
getPendingJobReasons() methods to give you insight into why a scheduled
job is not running as expected, but simplifies information retrieval by making
both duration and job reason available in a single method.
For example, for a specified jobId, the method might return
PENDING_JOB_REASON_CONSTRAINT_CHARGING and a duration of 60000 ms, indicating
the job was pending for 60000ms due to the charging constraint not being
satisfied.
Ograniczanie blokad uśpienia dzięki obsłudze odbiorników dla alarmów zezwalających na działanie w trybie bezczynności
Android 17
introduces a new variant of AlarmManager.setExactAndAllowWhileIdle that
accepts an OnAlarmListener instead of a PendingIntent. This new
callback-based mechanism is ideal for apps that currently rely on continuous
wakelocks to perform periodic tasks, such as messaging apps maintaining socket
connections.
Prywatność
Android 17 zawiera te nowe funkcje, które zwiększają prywatność użytkowników.
Obsługa platformy Encrypted Client Hello (ECH)
Android 17 wprowadza obsługę platformy Encrypted Client Hello (ECH), co znacznie zwiększa prywatność komunikacji sieciowej. ECH to rozszerzenie protokołu TLS 1.3, które szyfruje rozszerzenie SNI (Server Name Indication) podczas początkowego uzgadniania połączenia TLS. Szyfrowanie to pomaga chronić prywatność użytkowników, ponieważ utrudnia pośrednikom sieciowym identyfikowanie konkretnej domeny, z którą łączy się aplikacja.
Platforma zawiera teraz interfejsy API niezbędne do implementacji ECH w bibliotekach sieciowych. Obejmuje to nowe funkcje w DnsResolver, które umożliwiają wysyłanie zapytań o rekordy DNS HTTPS zawierające konfiguracje ECH, oraz nowe metody w klasach SSLEngines i SSLSockets biblioteki Conscrypt, które umożliwiają włączenie ECH przez przekazywanie tych konfiguracji podczas łączenia się z domeną. Deweloperzy mogą konfigurować ustawienia ECH, np. włączać je w miarę możliwości lub wymagać ich używania, za pomocą nowego elementu <domainEncryption> w pliku konfiguracji zabezpieczeń sieciowych, który ma zastosowanie globalnie lub w przypadku poszczególnych domen.
Popularne biblioteki sieciowe, takie jak HttpEngine, WebView i OkHttp, mają w przyszłych aktualizacjach zintegrować te interfejsy API platformy, co ułatwi aplikacjom wdrażanie ECH i zwiększanie prywatności użytkowników.
Więcej informacji znajdziesz w dokumentacji Encrypted Client Hello.
Selektor kontaktów na Androidzie
Selektor kontaktów na Androidzie to standardowy interfejs przeglądania, który umożliwia użytkownikom udostępnianie kontaktów w aplikacji. Jest on dostępny na urządzeniach z Androidem 17 (API na poziomie 37) lub nowszym i stanowi alternatywę dla szerokiego uprawnienia READ_CONTACTS, która zapewnia ochronę prywatności. Zamiast prosić o dostęp do całej książki adresowej użytkownika, aplikacja określa potrzebne pola danych, takie jak numery telefonów lub adresy e-mail, a użytkownik wybiera konkretne kontakty do udostępnienia. Dzięki temu aplikacja będzie mieć dostęp do odczytu tylko wybranych danych, co zapewni szczegółową kontrolę, a jednocześnie spójne wrażenia użytkownika dzięki wbudowanym funkcjom wyszukiwania, przełączania profili i wielokrotnego wyboru bez konieczności tworzenia interfejsu użytkownika ani zarządzania nim.
Więcej informacji znajdziesz w dokumentacji selektora kontaktów.
Bezpieczeństwo
Android 17 zawiera te nowe funkcje, które zwiększają bezpieczeństwo urządzenia i aplikacji:
Tryb ochrony zaawansowanej na Androidzie (AAPM)
Android Advanced Protection Mode offers Android users a powerful new set of security features, marking a significant step in safeguarding users—particularly those at higher risk—from sophisticated attacks. Designed as an opt-in feature, AAPM is activated with a single configuration setting that users can turn on at any time to apply an opinionated set of security protections.
These core configurations include blocking app installation from unknown sources
(sideloading), restricting USB data signaling, and mandating Google Play Protect
scanning, which significantly reduces the device's attack surface area.
Developers can integrate with this feature using the
AdvancedProtectionManager API to detect the mode's status, enabling
applications to automatically adopt a hardened security posture or restrict
high-risk functionality when a user has opted in.
Podpisywanie plików APK za pomocą kryptografii postkwantowej
Android now supports a hybrid APK signature scheme to future-proof your app's signing identity against the potential threat of attacks that make use of quantum computing. This feature introduces a new APK Signature Scheme, which lets you pair a classical signing key (such as RSA or EC) with a new post-quantum cryptography (PQC) algorithm (ML-DSA).
This hybrid approach ensures your app remains secure against future quantum attacks while maintaining full backward compatibility with older Android versions and devices that rely on classical signature verification.
Impact on developers
- Apps using Play App Signing: If you use Play App Signing, you can wait for Google Play to give you the option to upgrade a hybrid signature using a PQC key generated by Google Play, ensuring your app is protected without requiring manual key management.
- Apps using self-managed keys: Developers who manage their own signing keys can utilize updated Android build tools (like apksigner) to rotate to a hybrid identity, combining a PQC key with a new classical key. (You must create a new classical key, you cannot reuse the older one.)
Łączność
Android 17 wprowadza te funkcje, aby poprawić łączność urządzeń i aplikacji.
Sieci satelitarne o ograniczonej przepustowości
Wprowadza optymalizacje, które umożliwiają skuteczne działanie aplikacji w sieciach satelitarnych o niskiej przepustowości.
Wrażenia użytkowników i interfejs systemu
W Androidzie 17 wprowadziliśmy te zmiany, aby zwiększyć wygodę użytkowników.
Osobny strumień głośności Asystenta
Android 17 wprowadza dedykowany strumień głośności Asystenta dla aplikacji Asystenta, który umożliwia odtwarzanie dźwięku za pomocą USAGE_ASSISTANT. Ta zmiana oddziela dźwięk Asystenta od standardowego strumienia multimediów, dzięki czemu użytkownicy mają niezależną kontrolę nad obydwoma poziomami głośności. Umożliwia to na przykład wyciszenie odtwarzania multimediów przy zachowaniu słyszalności odpowiedzi Asystenta i odwrotnie.
Aplikacje Asystenta z dostępem do nowego trybu audio MODE_ASSISTANT_CONVERSATION mogą dodatkowo poprawić spójność sterowania głośnością. Aplikacje Asystenta mogą używać tego trybu, aby przekazywać systemowi wskazówkę o aktywnej sesji Asystenta. Dzięki temu strumień Asystenta może być kontrolowany poza aktywnym odtwarzaniem USAGE_ASSISTANT lub za pomocą podłączonych urządzeń peryferyjnych Bluetooth.
Handoff
Przekazywanie to nowa funkcja i interfejs API, które pojawią się w Androidzie 17. Deweloperzy aplikacji mogą je zintegrować, aby zapewnić użytkownikom ciągłość działania na różnych urządzeniach. Umożliwia użytkownikowi rozpoczęcie działania w aplikacji na jednym urządzeniu z Androidem i przeniesienie go na inne urządzenie z Androidem. Przekazywanie działa w tle na urządzeniu użytkownika i wyświetla dostępne działania z innych pobliskich urządzeń użytkownika w różnych punktach wejścia, takich jak program uruchamiający i pasek zadań na urządzeniu odbierającym.
Aplikacje mogą wyznaczyć przekazywanie, aby uruchamiać tę samą natywną aplikację na Androida, jeśli jest ona zainstalowana i dostępna na urządzeniu odbierającym. W tym przepływie między aplikacjami użytkownik jest przekierowywany za pomocą precyzyjnego linku do wyznaczonej aktywności. Alternatywnie przekazywanie z aplikacji do przeglądarki może być oferowane jako opcja rezerwowa lub bezpośrednio wdrażane za pomocą przekazywania z użyciem adresu URL.
Obsługa funkcji Handoff jest wdrażana w przypadku poszczególnych aktywności. Aby włączyć przekazywanie, wywołaj metodę
setHandoffEnabled()
w przypadku aktywności. Wraz z przekazaniem może być konieczne przesłanie dodatkowych danych, aby odtworzona aktywność na urządzeniu odbierającym mogła przywrócić odpowiedni stan. Zaimplementuj wywołanie zwrotne onHandoffActivityDataRequested(), aby zwrócić obiekt HandoffActivityData zawierający szczegóły określające, jak funkcja przekazywania powinna obsługiwać i odtwarzać aktywność na urządzeniu odbierającym.
Aktualizacja na żywo – interfejs Semantic Color API
With Android 17, Live Update launches the Semantic Coloring APIs to support colors with universal meaning.
The following classes support semantic coloring:
NotificationNotification.MetricNotification.ProgressStyle.PointNotification.ProgressStyle.Segment
Coloring
- Green: Associated with safety. This color should be used for the case where it lets people know you are in the safe situation.
- Orange: For designating caution and marking physical hazards. This color should be used in the situation where users need to pay attention to set better protection setting.
- Red: Generally indicates danger, stop. It should be presented for the case where need people's attention urgently.
- Blue: Neutral color for content that is informational and should stand out from other content.
The following example shows how to apply semantic styles to text in a notification:
val ssb = SpannableStringBuilder()
.append("Colors: ")
.append("NONE", Notification.createSemanticStyleAnnotation(SEMANTIC_STYLE_UNSPECIFIED), 0)
.append(", ")
.append("INFO", Notification.createSemanticStyleAnnotation(SEMANTIC_STYLE_INFO), 0)
.append(", ")
.append("SAFE", Notification.createSemanticStyleAnnotation(SEMANTIC_STYLE_SAFE), 0)
.append(", ")
.append("CAUTION", Notification.createSemanticStyleAnnotation(SEMANTIC_STYLE_CAUTION), 0)
.append(", ")
.append("DANGER", Notification.createSemanticStyleAnnotation(SEMANTIC_STYLE_DANGER), 0)
Notification.Builder(context, channelId)
.setSmallIcon(R.drawable.ic_icon)
.setContentTitle("Hello World!")
.setContentText(ssb)
.setOngoing(true)
.setRequestPromotedOngoing(true)
UWB Downlink-TDoA API for Android 17
Downlink Time Difference of Arrival (DL-TDoA) ranging lets a device determine its position relative to multiple anchors by measuring the relative arrival times of signals.The following snippet demonstrates how to initialize the Ranging Manager, verify device capabilities, and start a DL-TDoA session:
Kotlin
class RangingApp {
fun initDlTdoa(context: Context) {
// Initialize the Ranging Manager
val rangingManager = context.getSystemService(RangingManager::class.java)
// Register for device capabilities
val capabilitiesCallback = object : RangingManager.RangingCapabilitiesCallback {
override fun onRangingCapabilities(capabilities: RangingCapabilities) {
// Make sure Dl-TDoA is supported before starting the session
if (capabilities.uwbCapabilities != null && capabilities.uwbCapabilities!!.isDlTdoaSupported) {
startDlTDoASession(context)
}
}
}
rangingManager.registerCapabilitiesCallback(Executors.newSingleThreadExecutor(), capabilitiesCallback)
}
fun startDlTDoASession(context: Context) {
// Initialize the Ranging Manager
val rangingManager = context.getSystemService(RangingManager::class.java)
// Create session and configure parameters
val executor = Executors.newSingleThreadExecutor()
val rangingSession = rangingManager.createRangingSession(executor, RangingSessionCallback())
val rangingRoundIndexes = byteArrayOf(0)
val config: ByteArray = byteArrayOf() // OOB config data
val params = DlTdoaRangingParams.createFromFiraConfigPacket(config, rangingRoundIndexes)
val rangingDevice = RangingDevice.Builder().build()
val rawTagDevice = RawRangingDevice.Builder()
.setRangingDevice(rangingDevice)
.setDlTdoaRangingParams(params)
.build()
val dtTagConfig = RawDtTagRangingConfig.Builder(rawTagDevice).build()
val preference = RangingPreference.Builder(DEVICE_ROLE_DT_TAG, dtTagConfig)
.setSessionConfig(SessionConfig.Builder().build())
.build()
// Start the ranging session
rangingSession.start(preference)
}
}
private class RangingSessionCallback : RangingSession.Callback {
override fun onDlTdoaResults(peer: RangingDevice, measurement: DlTdoaMeasurement) {
// Process measurement results here
}
}
Java
public class RangingApp {
public void initDlTdoa(Context context) {
// Initialize the Ranging Manager
RangingManager rangingManager = context.getSystemService(RangingManager.class);
// Register for device capabilities
RangingManager.CapabilitiesCallback capabilitiesCallback = new RangingManager.RangingCapabilitiesCallback() {
@Override
public void onRangingCapabilities(RangingCapabilities capabilities) {
// Make sure Dl-TDoA is supported before starting the session
if (capabilities.getUwbCapabilities() != null && capabilities.getUwbCapabilities().isDlTdoaSupported()) {
startDlTDoASession(context);
}
}
};
rangingManager.registerCapabilitiesCallback(Executors.newSingleThreadExecutor(), capabilitiesCallback);
}
public void startDlTDoASession(Context context) {
RangingManager rangingManager = context.getSystemService(RangingManager.class);
// Create session and configure parameters
Executor executor = Executors.newSingleThreadExecutor();
RangingSession rangingSession = rangingManager.createRangingSession(executor, new RangingSessionCallback());
byte[] rangingRoundIndexes = new byte[] {0};
byte[] config = new byte[0]; // OOB config data
DlTdoaRangingParams params = DlTdoaRangingParams.createFromFiraConfigPacket(config, rangingRoundIndexes);
RangingDevice rangingDevice = new RangingDevice.Builder().build();
RawRangingDevice rawTagDevice = new RawRangingDevice.Builder()
.setRangingDevice(rangingDevice)
.setDlTdoaRangingParams(params)
.build();
RawDtTagRangingConfig dtTagConfig = new RawDtTagRangingConfig.Builder(rawTagDevice).build();
RangingPreference preference = new RangingPreference.Builder(DEVICE_ROLE_DT_TAG, dtTagConfig)
.setSessionConfig(new SessionConfig.Builder().build())
.build();
// Start the ranging session
rangingSession.start(preference);
}
private static class RangingSessionCallback implements RangingSession.Callback {
@Override
public void onDlTdoaResults(RangingDevice peer, DlTdoaMeasurement measurement) {
// Process measurement results here
}
}
}
Out-of-Band (OOB) Configurations
The following snippet provides an example of DL-TDoA OOB configuration data for Wi-Fi and BLE:
Java
// Wifi Configuration
byte[] wifiConfig = {
(byte) 0xDD, (byte) 0x2D, (byte) 0x5A, (byte) 0x18, (byte) 0xFF, // Header
(byte) 0x5F, (byte) 0x19, // FiRa Sub-Element
(byte) 0x02, (byte) 0x00, // Profile ID
(byte) 0x06, (byte) 0x02, (byte) 0x20, (byte) 0x08, // MAC Address
(byte) 0x14, (byte) 0x01, (byte) 0x0C, // Preamble Index
(byte) 0x27, (byte) 0x02, (byte) 0x08, (byte) 0x07, // Vendor ID
(byte) 0x28, (byte) 0x06, (byte) 0xCA, (byte) 0xC8, (byte) 0xA6, (byte) 0xF7, (byte) 0x6F, (byte) 0x08, // Static STS IV
(byte) 0x08, (byte) 0x02, (byte) 0x60, (byte) 0x09, // Slot Duration
(byte) 0x1B, (byte) 0x01, (byte) 0x0A, // Slots per RR
(byte) 0x09, (byte) 0x04, (byte) 0xE8, (byte) 0x03, (byte) 0x00, (byte) 0x00, // Duration
(byte) 0x9F, (byte) 0x04, (byte) 0x67, (byte) 0x45, (byte) 0x23, (byte) 0x01 // Session ID
};
// BLE Configuration
byte[] bleConfig = {
(byte) 0x2D, (byte) 0x16, (byte) 0xF4, (byte) 0xFF, // Header
(byte) 0x5F, (byte) 0x19, // FiRa Sub-Element
(byte) 0x02, (byte) 0x00, // Profile ID
(byte) 0x06, (byte) 0x02, (byte) 0x20, (byte) 0x08, // MAC Address
(byte) 0x14, (byte) 0x01, (byte) 0x0C, // Preamble Index
(byte) 0x27, (byte) 0x02, (byte) 0x08, (byte) 0x07, // Vendor ID
(byte) 0x28, (byte) 0x06, (byte) 0xCA, (byte) 0xC8, (byte) 0xA6, (byte) 0xF7, (byte) 0x6F, (byte) 0x08, // Static STS IV
(byte) 0x08, (byte) 0x02, (byte) 0x60, (byte) 0x09, // Slot Duration
(byte) 0x1B, (byte) 0x01, (byte) 0x0A, // Slots per RR
(byte) 0x09, (byte) 0x04, (byte) 0xE8, (byte) 0x03, (byte) 0x00, (byte) 0x00, // Duration
(byte) 0x9F, (byte) 0x04, (byte) 0x67, (byte) 0x45, (byte) 0x23, (byte) 0x01 // Session ID
};
If you can't use an OOB configuration because it is missing, or if you need to
change default values that aren't in the OOB config, you can build parameters
with DlTdoaRangingParams.Builder as shown in the following snippet. You can
use these parameters in place of
DlTdoaRangingParams.createFromFiraConfigPacket():
Kotlin
val dlTdoaParams = DlTdoaRangingParams.Builder(1)
.setComplexChannel(UwbComplexChannel.Builder()
.setChannel(9).setPreambleIndex(10).build())
.setDeviceAddress(deviceAddress)
.setSessionKeyInfo(byteArrayOf(0x01, 0x02, 0x03, 0x04))
.setRangingIntervalMillis(240)
.setSlotDuration(UwbRangingParams.DURATION_2_MS)
.setSlotsPerRangingRound(20)
.setRangingRoundIndexes(byteArrayOf(0x01, 0x05))
.build()
Java
DlTdoaRangingParams dlTdoaParams = new DlTdoaRangingParams.Builder(1)
.setComplexChannel(new UwbComplexChannel.Builder()
.setChannel(9).setPreambleIndex(10).build())
.setDeviceAddress(deviceAddress)
.setSessionKeyInfo(new byte[]{0x01, 0x02, 0x03, 0x04})
.setRangingIntervalMillis(240)
.setSlotDuration(UwbRangingParams.DURATION_2_MS)
.setSlotsPerRangingRound(20)
.setRangingRoundIndexes(new byte[]{0x01, 0x05})
.build();