שינויים בהתנהגות: כל האפליקציות

פלטפורמת Android 17 כוללת שינויים בהתנהגות שעשויים להשפיע על האפליקציה שלכם. שינויי ההתנהגות הבאים רלוונטיים לכל האפליקציות כשהן פועלות ב-Android 17, בלי קשר ל-targetSdkVersion. מומלץ לבדוק את האפליקציה ולשנות אותה לפי הצורך כדי לתמוך בשינויים האלה, במקרים הרלוונטיים.

חשוב גם לעיין ברשימת השינויים בהתנהגות שמשפיעים רק על אפליקציות שמטרגטות ל-Android 17.

פונקציונליות עיקרית

‫Android 17 (‏API ברמה 37) כוללת את השינויים הבאים, שמשנים או מרחיבים יכולות ליבה שונות של מערכת Android.

מגבלות זיכרון באפליקציות

Android 17 introduces app memory limits based on the device's total RAM to create a more stable and deterministic environment for your apps and Android users. In Android 17, limits are set conservatively to establish system baselines, targeting extreme memory leaks and other outliers before they trigger system-wide instability resulting in UI stuttering, higher battery drain, and apps being killed. While we anticipate minimal impact on the vast majority of app sessions, we recommend the following memory best practices, including establishing a baseline for memory.

You can determine if your app session was impacted by calling getDescription in ApplicationExitInfo; if your app was affected, the exit reason will be REASON_OTHER and the description will contain the string "MemoryLimiter:AnonSwap" along with other information. You can also use trigger-based profiling with TRIGGER_TYPE_ANOMALY to get heap dumps that are collected when the memory limit is hit.

The Manage your app's memory documentation gives information to help you diagnose your app's memory issues and optimize its resource consumption.

Test your app's behavior under the memory constraints

You can use Android Debug Bridge (adb) to adjust or disable the memory limits on any device that imposes them. The shell command am provides three subcommands to adjust the memory limits. (These commands have no effect on a device which does not impose memory limits.)

  • am memory-limiter ignore <uid>|none|all
  • am memory-limiter manual <pid> <limit>|max|none
  • am memory-limiter status
ignore

Instructs the memory limiter to ignore some or all processes. Passing a UID (Android User ID) instructs the memory limiter to ignore enforcement on all processes associated with that UID. You can also pass all (ignore all apps) or none (do not ignore any apps). Passing none overrides any previous calls to am memory-limiter ignore.

If you instruct the memory limiter to ignore a UID, you can still apply a manual memory limit to a process within the app by calling am memory-limiter manual.

manual

Instructs the system to impose a memory constraint on the process with the specified PID (Process ID). The memory constraint is specified as an integer number of MB; for example, passing 30 specifies that the process is limited to 30 MB of memory. Passing max removes all memory limits on that process. Passing none removes any manual limits set on the process, restoring the system's default limit (if any).

status

Reports the current status of the memory limiter. The status includes the memory limits imposed on visible and non-visible processes.

פרטיות

‫Android 17 כוללת את השינויים הבאים לשיפור פרטיות המשתמשים.

הגנה על OTP ב-SMS

Beginning with Android 17, Android is expanding its protection for SMS messages containing one-time passwords (OTP).

In previous versions of Android, this protection was primarily focused on the SMS Retriever format. Delivery of messages containing an SMS retriever hash was delayed for most apps for three hours. However, certain apps (like the default SMS handler) were exempt from the delay, and the app that owned the hash was also exempted.

Beginning with Android 17, the protection is also applied to WebOTP format messages. If an app has permission to read SMS messages but is not the intended recipient of a WebOTP message (as determined by domain verification), the message is not accessible to the app until three hours after the message's receipt. This change is intended to improve user security by ensuring that only apps associated with the domain mentioned in the message can programmatically read the verification code.

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. This change applies to all apps, regardless of their target API level.

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 כולל את השיפורים הבאים באבטחת המכשיר והאפליקציות.

תוכנית להוצאה משימוש של usesClearTraffic

בגרסה עתידית, אנחנו מתכננים להוציא משימוש את הרכיב usesCleartextTraffic. אפליקציות שצריכות ליצור חיבורים לא מוצפנים (HTTP) צריכות לעבור לשימוש בקובץ תצורה של אבטחת רשת, שמאפשר לכם לציין לאילו דומיינים האפליקציה צריכה ליצור חיבורים לא מוצפנים.

חשוב לדעת שקבצי הגדרות של אבטחת רשת נתמכים רק ברמות API‏ 24 ומעלה. אם רמת ה-API המינימלית של האפליקציה נמוכה מ-24, צריך לבצע את שתי הפעולות הבאות:

  • הגדרת המאפיין usesCleartextTraffic לערך true
  • שימוש בקובץ תצורת רשת

אם רמת ה-API המינימלית של האפליקציה היא 24 ומעלה, אפשר להשתמש בקובץ תצורה של רשת ולא צריך להגדיר את usesCleartextTraffic.

הגבלת הרשאות URI משתמעות

נכון לעכשיו, אם אפליקציה מפעילה intent עם URI שיש לו את הפעולה ACTION_SEND,‏ ACTION_SEND_MULTIPLE או ACTION_IMAGE_CAPTURE, המערכת מעניקה אוטומטית לאפליקציית היעד את הרשאות ה-URI לקריאה ולכתיבה. החל מ-Android 18, המערכת לא תעניק יותר את ההרשאות האלה באופן אוטומטי. לכן מומלץ שאפליקציות יעניקו במפורש את הרשאות ה-URI הרלוונטיות במקום להסתמך על המערכת שתעניק אותן.

כדי לזהות את השימוש בכוונות האלה באפליקציה, צריך להשתמש ב-StrictMode עם detectImplicitUriPermissionGrant() כדי להפעיל הפרה:

Kotlin

val policy = StrictMode.VmPolicy.Builder()
    .detectImplicitUriPermissionGrant()
    .penaltyLog()
    .build()
StrictMode.setVmPolicy(policy)

Java

StrictMode.VmPolicy policy = new StrictMode.VmPolicy.Builder()
    .detectImplicitUriPermissionGrant()
    .penaltyLog()
    .build();
StrictMode.setVmPolicy(policy);

אפשר גם לעקוב אחרי חריגים שנרשמו ביומן שכוללים את ההודעה Please set the grant explicitly in the app שמופיעה כשהמערכת מגדירה את ההרשאה באופן מרומז. אפשר לעקוב אחרי היומנים האלה באמצעות הפקודה הבאה של adb:

adb logcat | grep "Please set the grant explicitly in the app"

כדי להעניק במפורש את ההרשאות הנדרשות, מוסיפים את הדגל FLAG_GRANT_READ_URI_PERMISSION לכוונות ACTION_SEND ו-ACTION_SEND_MULTIPLE:

Kotlin

intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)

Java

intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

כוללים את הדגלים FLAG_GRANT_READ_URI_PERMISSION ו-FLAG_GRANT_WRITE_URI_PERMISSION עבור כוונות ACTION_IMAGE_CAPTURE:

Kotlin

intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)

Java

intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);

מגבלות על חנות מפתחות לכל אפליקציה

Apps should avoid creating excessive numbers of keys in Android Keystore, because it is a shared resource for all apps on the device. Beginning with Android 17, the system enforces a limit on the number of keys an app can own. The limit is 50,000 keys for non-system apps targeting Android 17 (API level 37) or higher, and 200,000 keys for all other apps. System apps have a limit of 200,000 keys, regardless of which API level they target.

If an app attempts to create keys beyond the limit, the creation fails with a KeyStoreException. The exception's message string contains information about the key limit. If the app calls getNumericErrorCode() on the exception, the return value depends on what API level the app targets:

  • Apps targeting Android 17 (API level 37) or higher: getNumericErrorCode() returns the new ERROR_TOO_MANY_KEYS value.
  • All other apps: getNumericErrorCode() returns ERROR_INCORRECT_USAGE.

חסימה של תנועת גולשים בלולאה חוזרת (loopback) בין פרופילים

החל מ-Android 17, תנועת לולאה חוזרת בין פרופילים לא מותרת יותר כברירת מחדל. השינוי לא משפיע על תנועת Loopback באותו פרופיל. השינוי הזה חל על כל האפליקציות שפועלות ב-Android 17 ואילך, ללא קשר לרמת ה-API שהאפליקציה מטרגטת.

חוויית המשתמש וממשק המשתמש של המערכת

‫Android 17 כוללת את השינויים הבאים, שנועדו ליצור חוויית משתמש עקבית ואינטואיטיבית יותר.

שחזור ברירת המחדל של חשיפת ה-IME אחרי סיבוב

החל מ-Android 17, כשמתרחשים שינויים בהגדרות המכשיר (לדוגמה, סיבוב), והאפליקציה לא מטפלת בשינויים האלה בעצמה, מצב החשיפה הקודם של ה-IME לא משוחזר.

אם האפליקציה עוברת שינוי בהגדרות שהיא לא מטפלת בו, והיא צריכה שהמקלדת תהיה גלויה אחרי השינוי, צריך לבקש זאת באופן מפורש. אפשר לשלוח את הבקשה באחת מהדרכים הבאות:

  • מגדירים את המאפיין android:windowSoftInputMode לערך stateAlwaysVisible.
  • מבקשים באופן פרוגרמטי את המקלדת הווירטואלית ב-method onCreate() של הפעילות, או מוסיפים את ה-method onConfigurationChanged().

קלט אנושי

‫Android 17 כוללת את השינויים הבאים שמשפיעים על האינטראקציה של אפליקציות עם מכשירי קלט אנושיים כמו מקלדות ומשטחי מגע.

משטחי מגע מספקים אירועים יחסיים כברירת מחדל במהלך לכידת מצביע

החל מ-Android 17, אם אפליקציה מבקשת ללכוד את מצביע העכבר באמצעות View.requestPointerCapture() והמשתמש משתמש במשטח מגע, המערכת מזהה את תנועת המצביע ומחוות הגלילה מהמגעים של המשתמש ומדווחת עליהן לאפליקציה באותו אופן כמו תנועות של מצביע וגלגל העכבר מעכבר שנלכד. ברוב המקרים, זה מייתר את הצורך באפליקציות שתומכות בעכברים שנתפסו כדי להוסיף לוגיקה מיוחדת לטיפול במשטחי מגע. פרטים נוספים זמינים במאמרי העזרה בנושא View.POINTER_CAPTURE_MODE_RELATIVE.

בעבר, המערכת לא ניסתה לזהות תנועות מלוח המגע, אלא העבירה לאפליקציה את המיקומים המוחלטים של האצבעות בפורמט דומה לזה של מגעים במסך מגע. אם אפליקציה עדיין דורשת את הנתונים האלה, היא צריכה להפעיל את ה-method החדש View.requestPointerCapture(int) עם View.POINTER_CAPTURE_MODE_ABSOLUTE במקום זאת.

מדיה

‫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.

If the app tries to call audio APIs while the app is not in a valid lifecycle, the audio playback and volume change APIs fail silently without throwing an exception or providing a failure message. The audio focus API fails with the result code AUDIOFOCUS_REQUEST_FAILED.

For more information, including mitigation strategies, see Background audio hardening.

קישוריות

‫Android 17 כוללת את השינויים הבאים לשיפור הקישוריות של המכשיר.

התאמה אוטונומית מחדש במקרה של אובדן קישוריות Bluetooth

ב-Android 17 מוצגת התאמה חוזרת אוטונומית, שיפור ברמת המערכת שנועד לפתור באופן אוטומטי בעיות של אובדן קישוריות Bluetooth.

בעבר, אם נוצר ניתוק בין המכשירים, המשתמשים היו צריכים לעבור להגדרות באופן ידני כדי לבטל את ההתאמה ואז להתאים מחדש את הציוד ההיקפי. התכונה הזו מבוססת על שיפור האבטחה ב-Android 16, ומאפשרת למערכת ליצור מחדש קישוריות ברקע בלי שהמשתמשים יצטרכו לנווט ידנית אל ההגדרות כדי לבטל את ההתאמה של ציוד היקפי ולהתאים אותו מחדש.

למרות שברוב האפליקציות לא יהיה צורך בשינויים בקוד, המפתחים צריכים להיות מודעים לשינויים הבאים בהתנהגות של מחסנית Bluetooth:

  • הקשר חדש של צימוד: ACTION_PAIRING_REQUEST כולל עכשיו את התוסף EXTRA_PAIRING_CONTEXT, שמאפשר לאפליקציות להבחין בין בקשת צימוד רגילה לבין ניסיון חוזר לצימוד שהופעל על ידי מערכת אוטונומית.
  • עדכוני מפתחות מותנים: מפתחות אבטחה קיימים יוחלפו רק אם ההתאמה מחדש תצליח והחיבור החדש יעמוד בדרישות האבטחה של החיבור הקודם או יעלה עליהן.
  • שינוי בתזמון של כוונת המשתמש: כוונת המשתמש ACTION_KEY_MISSING משודרת עכשיו רק אם הניסיון לצימוד אוטונומי נכשל. כך מצמצמים את הצורך בטיפול בשגיאות לא נחוצות באפליקציה, אם המערכת משחזרת את הקישור ברקע.
  • התראה למשתמש: המערכת מנהלת את ההתאמה מחדש באמצעות התראות ודיאלוגים חדשים בממשק המשתמש. המשתמשים יתבקשו לאשר את הניסיון לשיוך מחדש כדי לוודא שהם מודעים לחיבור מחדש.

יצרני מכשירים היקפיים ומפתחי אפליקציות נלוות צריכים לוודא שהחומרה והאפליקציה מטפלות בצורה חלקה במעברים בין מצבי ההתאמה. כדי לבדוק את ההתנהגות הזו, אפשר לדמות ניתוק של חיבור מרוחק באחת מהשיטות הבאות:

  • הסרה ידנית של פרטי ההתאמה מהציוד ההיקפי
  • מבטלים את ההתאמה של המכשיר באופן ידני דרך 'הגדרות' > 'מכשירים מחוברים'.