Android 16، مانند نسخههای قبلی، شامل تغییرات رفتاری است که ممکن است بر برنامه شما تأثیر بگذارد. تغییرات رفتاری زیر منحصراً برای برنامههایی اعمال میشود که Android 16 یا بالاتر را هدف قرار میدهند. اگر برنامه شما Android 16 یا بالاتر را هدف قرار میدهد، باید برنامه خود را برای پشتیبانی از این رفتارها، درصورت لزوم، اصلاح کنید.
حتماً فهرست تغییرات رفتاری را که بر همه برنامههای
اجراشده در Android 16 تأثیر میگذارد، صرفنظر از targetSdkVersion برنامهتان، مرور کنید.
تجربه کاربری و واسط کاربر سیستم
Android 16 (سطح API ۳۶) شامل تغییرات زیر است که هدف از آنها ایجاد تجربه کاربری یکپارچهتر و شهودیتر است.
انصراف از لبهبهلبه درحال حذف شدن است
Android 15 enforced edge-to-edge for apps targeting Android 15 (API
level 35), but your app could opt-out by setting
R.attr#windowOptOutEdgeToEdgeEnforcement to true. For apps
targeting Android 16 (API level 36),
R.attr#windowOptOutEdgeToEdgeEnforcement is deprecated and disabled, and your
app can't opt-out of going edge-to-edge.
- If your app targets Android 16 (API level 36) and is running on an
Android 15 device,
R.attr#windowOptOutEdgeToEdgeEnforcementcontinues to work. - If your app targets Android 16 (API level 36) and is running on an
Android 16 device,
R.attr#windowOptOutEdgeToEdgeEnforcementis disabled.
For testing in Android 16, ensure your app supports edge-to-edge and
remove any use of R.attr#windowOptOutEdgeToEdgeEnforcement so that your app
also supports edge-to-edge on an Android 15 device. To support edge-to-edge,
see the Compose and Views guidance.
برای اشاره برگشت پیشگویانه، انتقال یا انصراف دادن لازم است
برای برنامههایی که Android 16 (سطح میانای برنامهسازی کاربردی ۳۶) یا بالاتر را هدف قرار میدهند و در دستگاهی با Android 16 یا بالاتر اجرا میشوند، پویانماییهای سیستم برگشت پیشبینانه (برگشت به صفحه اصلی، بینتکلیفی، و بینفعالیتی) بهطور پیشفرض فعال هستند.
علاوهبراین، onBackPressed فراخوانی نمیشود و
KeyEvent.KEYCODE_BACK دیگر ارسال نمیشود.
اگر برنامهتان رویداد برگشت را رهگیری میکند و هنوز به برگشت پیشبینانه
منتقل نشدهاید، برنامهتان را بهروز کنید تا از میاناهای برنامهسازی کاربردی پیمایش به عقب پشتیبانیشده استفاده کند، یا
با تنظیم کردن مشخصه
android:enableOnBackInvokedCallback روی false در
برچسب <application> یا <activity> فایل AndroidManifest.xml برنامهتان، موقتاً انصراف دهید.
میاناهای برنامهسازی کاربردی قلم Elegant منسوخ و غیرفعال شدهاند
برنامههایی که Android 15 را هدف قرار میدهند (سطح API 35) دارای ویژگی elegantTextHeight TextView بهطور پیشفرض روی true تنظیم شدهاند و فونت فشرده را با فونتی که بسیار خواناتر است جایگزین میکند. میتوانید با تنظیم ویژگی elegantTextHeight روی false این مورد را لغو کنید.
Android 16 ویژگی elegantTextHeight را منسوخ میکند، و زمانی که برنامه شما Android 16 را هدف قرار دهد، این ویژگی نادیده گرفته میشود. «فونتهای UI» که توسط این APIها کنترل میشوند، متوقف میشوند، بنابراین باید هر گونه طرحبندی را برای اطمینان از ارائه متن ثابت و ثابت در آینده به زبانهای عربی، لائوس، میانمار، تامیل، گجراتی، مالزی، تایلندی، تلهآلو، کانا تطبیق دهید.

elegantTextHeight برای برنامههایی که Android 14 (سطح API 34) و پایینتر را هدف قرار میدهند، یا برای برنامههایی که Android 15 را هدف قرار میدهند (سطح API 35) که با تنظیم ویژگی elegantTextHeight روی false ، پیشفرض را لغو میکنند. 
elegantTextHeight برای برنامههایی که Android 16 را هدف قرار میدهند (سطح API 36)، یا برای برنامههایی که Android 15 را هدف قرار میدهند (سطح API 35) که با تنظیم ویژگی elegantTextHeight روی false ، پیشفرض را لغو نکردهاند.عملکرد اصلی
Android 16 (سطح API ۳۶) شامل تغییرات زیر است که قابلیتهای اصلی مختلف سیستم Android را اصلاح یا گسترش میدهد.
بهینهسازی زمانبندی کار با نرخ ثابت
قبل از هدف قرار دادن اندروید 16، زمانی که scheduleAtFixedRate اجرای یک کار را به دلیل خارج از چرخه حیات فرآیند معتبر از دست داد، همه اجراهای از دست رفته بلافاصله با بازگشت برنامه به چرخه حیات معتبر اجرا می شوند.
هنگام هدف قرار دادن Android 16، حداکثر یک اجرای از دست رفته scheduleAtFixedRate بلافاصله پس از بازگشت برنامه به چرخه حیات معتبر اجرا می شود. انتظار می رود این تغییر رفتار باعث بهبود عملکرد برنامه شود. این رفتار را در برنامه خود آزمایش کنید تا بررسی کنید آیا برنامه شما تحت تأثیر قرار گرفته است یا خیر. همچنین میتوانید با استفاده از چارچوب سازگاری برنامه و فعال کردن پرچم سازگار STPE_SKIP_MULTIPLE_MISSED_PERIODIC_TASKS آزمایش کنید.
ضریبهای شکل دستگاه
Android 16 (سطح API ۳۶) شامل تغییرات زیر برای برنامهها هنگام نمایش در دستگاههای دارای صفحهنمایش بزرگ است.
طرحبندیهای تطبیقی
با اجرای برنامههای Android در دستگاههای مختلف (مانند تلفن، رایانه لوحی، دستگاه تاشو، رایانه، خودرو، و تلویزیون) و حالتهای پنجرهبندی در صفحهنمایشهای بزرگ (مانند صفحهٔ دونیمه و پنجرهبندی رایانهای)، توسعهدهندگان باید برنامههای Android را بهگونهای بسازند که با هر اندازه صفحهنمایش و پنجره، صرفنظر از جهت دستگاه، سازگار باشد. الگوهایی مانند محدود کردن جهت و قابلیت تغییر اندازه در دنیای چنددستگاهی امروز بسیار محدودکننده هستند.
نادیده گرفتن محدودیتهای جهت، قابلیت تغییر اندازه، و نسبت ابعادی
برای برنامههایی که Android 16 (سطح API ۳۶) را هدف قرار میدهند، محدودیتهای جهت، قابلیت تغییر اندازه، و نسبت ابعادی دیگر در نمایشگرهایی با کوچکترین عرض >= ۶۰۰ پیکسل مستقل از تراکم اعمال نمیشود. برنامهها کل پنجره نمایش را پر میکنند، صرفنظر از نسبت ابعادی یا جهت دلخواه کاربر، و از تصویر باریک استفاده نمیشود.
این تغییر رفتار استاندارد جدیدی را برای پلاتفرم معرفی میکند. Android درحال حرکت بهسمت مدلی است که در آن انتظار میرود برنامهها با جهتها، اندازههای نمایش، و نسبتهای ابعادی مختلف سازگار شوند. محدودیتهایی مانند جهت ثابت یا قابلیت تغییر اندازه محدود مانع از سازگاری برنامه میشود. برنامهتان را تطبیقپذیر کنید تا بهترین تجربه کاربری ممکن را ارائه دهید.
همچنین میتوانید این رفتار را بااستفاده از
چارچوب سازگاری برنامه و فعال کردن
پرچم سازگاری UNIVERSAL_RESIZABLE_BY_DEFAULT آزمایش کنید.
تغییرات ناگهانی رایج
نادیده گرفتن محدودیتهای جهت، قابلیت تغییر اندازه، و نسبت ابعادی ممکن است بر واسط کاربر برنامهتان در برخی دستگاهها تأثیر بگذارد، بهویژه عناصری که برای چیدمانهای کوچک قفلشده در جهت عمودی طراحی شدهاند: برای مثال، مشکلاتی مانند چیدمانهای کشیدهشده و پویانماییها و مؤلفههای خارج از صفحه. هرگونه فرض درباره نسبت ابعادی یا جهت میتواند باعث مشکلات بصری در برنامهتان شود. درباره نحوه اجتناب از آنها و بهبود رفتار تطبیقی برنامهتان بیشتر بدانید.
اجازه دادن به چرخش دستگاه منجر به بازآفرینی فعالیت بیشتر میشود که میتواند منجر به ازدست رفتن وضعیت کاربر شود اگر بهدرستی حفظ نشود. با نحوه ذخیره کردن صحیح وضعیت میانای کاربر در ذخیره کردن وضعیتهای میانای کاربر آشنا شوید.
جزئیات پیادهسازی
مشخصههای مانیفست و میاناهای برنامهنویسی کاربردی زمان اجرای زیر در دستگاههای دارای صفحهنمایش بزرگ در حالتهای تمامصفحه و چندپنجرهای نادیده گرفته میشوند:
screenOrientationresizableActivityminAspectRatiomaxAspectRatiosetRequestedOrientation()getRequestedOrientation()
مقادیر زیر برای screenOrientation، setRequestedOrientation()، و
getRequestedOrientation() نادیده گرفته میشود:
portraitreversePortraitsensorPortraituserPortraitlandscapereverseLandscapesensorLandscapeuserLandscape
درباره تغییرپذیری اندازه نمایشگر، android:resizeableActivity="false"،
android:minAspectRatio، و android:maxAspectRatio تأثیری ندارند.
برای برنامههایی که Android 16 (سطح API ۳۶) را هدف قرار میدهند، محدودیتهای جهت، قابلیت تغییر اندازه، و نسبت ابعادی برنامه بهطور پیشفرض در صفحهنمایشهای بزرگ نادیده گرفته میشود. هر برنامهای که کاملاً آماده نباشد میتواند با انصراف دادن، موقتاً این رفتار را لغو کند که منجر به رفتار قبلی قرار گرفتن در حالت سازگاری میشود.
استثناها
محدودیتهای جهت، قابلیت تغییر اندازه، و نسبت ابعادی Android 16 در شرایط زیر اعمال نمیشود:
- بازیها (براساس پرچم
android:appCategory) - کاربران صریحاً با رفتار پیشفرض برنامه در تنظیمات نسبت ابعادی دستگاه موافقت میکنند
- صفحههای کوچکتر از
sw600dp
انصراف موقت
برای انصراف از فعالیتی خاص،
ویژگی مانیفست PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY را اعلام کنید:
<activity ...>
<property android:name="android.window.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY" android:value="true" />
...
</activity>
اگر بخشهای زیادی از برنامهتان برای Android 16 آماده نیست، میتوانید با اعمال همان ویژگی در سطح برنامه، بهطور کامل انصراف دهید:
<application ...>
<property android:name="android.window.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY" android:value="true" />
</application>
سلامتی و تناسب اندام
Android 16 (سطح API ۳۶) شامل تغییرات زیر دررابطهبا دادههای سلامتی و تناسب اندام است.
اجازههای سلامتی و تناسب اندام
For apps targeting Android 16 (API level 36) or higher,
BODY_SENSORS permissions use more granular permissions
under android.permissions.health, which Health Connect
also uses. As of Android 16, any API previously requiring BODY_SENSORS
or BODY_SENSORS_BACKGROUND requires the corresponding
android.permissions.health permission instead. This affects the following data
types, APIs, and foreground service types:
HEART_RATE_BPMfrom Health Services on Wear OSSensor.TYPE_HEART_RATEfrom Android Sensor ManagerheartRateAccuracyandheartRateBpmfromProtoLayouton Wear OSFOREGROUND_SERVICE_TYPE_HEALTHwhere the respectiveandroid.permission.healthpermission is needed in place ofBODY_SENSORS
If your app uses these APIs, it should request the respective granular permissions:
- For while-in-use monitoring of Heart Rate, SpO2, or Skin Temperature:
request the granular permission under
android.permissions.health, such asREAD_HEART_RATEinstead ofBODY_SENSORS. - For background sensor access: request
READ_HEALTH_DATA_IN_BACKGROUNDinstead ofBODY_SENSORS_BACKGROUND.
These permissions are the same as those that guard access to reading data from Health Connect, the Android datastore for health, fitness, and wellness data.
Mobile apps
Mobile apps migrating to use the READ_HEART_RATE and other granular
permissions must also declare an activity to display
the app's privacy policy. This is the same requirement as Health Connect.
اتصالپذیری
Android 16 (سطح API ۳۶) شامل تغییرات زیر در پشته بلوتوث است تا اتصالپذیری با دستگاههای جانبی را بهبود بخشد.
هدفهای جدید برای مدیریت ازدست رفتن پیوند و تغییرات رمزگذاری
As part of the Improved bond loss handling, Android 16 also introduces 2 new intents to provide apps with greater awareness of bond loss and encryption changes.
Apps targeting Android 16 can now:
- Receive an
ACTION_KEY_MISSINGintent when remote bond loss is detected, allowing them to provide more informative user feedback and take appropriate actions. - Receive an
ACTION_ENCRYPTION_CHANGEintent whenever encryption status of the link changes. This includes encryption status change, encryption algorithm change, and encryption key size change. Apps must consider the bond restored if the link is successfully encrypted upon receivingACTION_ENCRYPTION_CHANGEintent later.
Adapting to varying OEM implementations
While Android 16 introduces these new intents, their implementation and broadcasting can vary across different device manufacturers (OEMs). To ensure your app provides a consistent and reliable experience across all devices, developers should design their bond loss handling to gracefully adapt to these potential variations.
We recommend the following app behaviors:
If the
ACTION_KEY_MISSINGintent is broadcast:The ACL (Asynchronous Connection-Less) link will be disconnected by the system, but the bond information for the device will be retained (as described here).
Your app should use this intent as the primary signal for bond loss detection and guiding the user to confirm the remote device is in range before initiating device forgetting or re-pairing.
If a device disconnects after
ACTION_KEY_MISSINGis received, your app should be cautious about reconnecting, as the device may no longer be bonded with the system.If the
ACTION_KEY_MISSINGintent is NOT broadcast:The ACL link will remain connected, and the bond information for the device will be removed by the system, same to behavior in Android 15.
In this scenario, your app should continue its existing bond loss handling mechanisms as in previous Android releases, to detect and manage bond loss events.
روش جدید برای برداشتن پیوند بلوتوث
All apps targeting Android 16 are now able to unpair bluetooth devices using a
public API in CompanionDeviceManager. If a companion device is
being managed as a CDM association, then the app can trigger
bluetooth bond removal by using the new removeBond(int) API
on the associated device. The app can monitor the bond state changes by
listening to the bluetooth device broadcast event
ACTION_BOND_STATE_CHANGED.
امنیت
Android 16 (سطح میانای برنامهسازی کاربردی ۳۶) شامل تغییرات امنیتی زیر است.
قفل کردن نسخه MediaStore
For apps targeting Android 16 or higher, MediaStore#getVersion() will now
be unique to each app. This eliminates identifying properties from the version
string to prevent abuse and usage for fingerprinting techniques. Apps shouldn't
make any assumptions around the format of this version. Apps should already
handle version changes when using this API and in most cases shouldn't need to
change their current behavior, unless the developer has attempted to infer
additional information that is beyond the intended scope of this API.
قصدهای ایمنتر
ویژگی Safer Intents یک ابتکار امنیتی چندمرحلهای است که برای بهبود امنیت سازوکار حل قصد Android طراحی شده است. هدف این است که با افزودن بررسیهایی درطول پردازش قصد و فیلتر کردن قصدهایی که معیارهای خاصی را برآورده نمیکنند، از برنامهها دربرابر کنشهای مخرب محافظت شود.
در Android 15، این ویژگی بر برنامه ارسالکننده تمرکز داشت. اکنون با Android 16، کنترل به برنامه دریافتکننده منتقل میشود و به توسعهدهندگان اجازه میدهد بااستفاده از مانیفست برنامه خود، برای حلوفصل سختگیرانه هدف موافقت کنند.
دو تغییر کلیدی درحال اجرا است:
قصد صریح باید با فیلتر قصد مؤلفه هدف مطابقت داشته باشد: اگر قصدی بهطور صریح مؤلفهای را هدف قرار دهد، باید با فیلتر قصد آن مؤلفه مطابقت داشته باشد.
«قصد» بدون کنش نمیتواند با هیچ «فیلتر قصدی» مطابقت داشته باشد: «قصد»هایی که کنش مشخصی ندارند نباید به هیچ «فیلتر قصدی» ارجاع داده شوند.
این تغییرات فقط زمانی اعمال میشود که چند برنامه درگیر باشند و بر مدیریت هدف در یک برنامه تأثیری ندارد.
تأثیر
ماهیت موافقت کردن به این معنی است که توسعهدهندگان باید صریحاً آن را در مانیفست برنامه خود فعال کنند تا اعمال شود. درنتیجه، تأثیر این ویژگی به برنامههایی محدود خواهد شد که توسعهدهندگان آنها:
- با ویژگی «هدفهای ایمنتر» و مزایای آن آشنا هستند.
- فعالانه انتخاب کنند که شیوههای سختگیرانهتری را برای مدیریت هدف در برنامههایشان اعمال کنند.
این رویکرد موافقت کردن خطر خراب شدن برنامههای موجود را که ممکن است به رفتار فعلی حلوفصل هدف با امنیت کمتر متکی باشند بهحداقل میرساند.
اگرچه تأثیر اولیه در Android 16 ممکن است محدود باشد، طرح «قصدهای ایمنتر» نقشه راهی برای تأثیر گستردهتر در نسخههای آتی Android دارد. برنامه این است که درنهایت وضوح قصد سختگیرانه را به رفتار پیشفرض تبدیل کنیم.
ویژگی «هدفهای ایمنتر» این پتانسیل را دارد که با دشوارتر کردن سوءاستفاده برنامههای مخرب از آسیبپذیریهای سازوکار حل هدف، امنیت بومسازگان Android را بهطور قابلتوجهی افزایش دهد.
بااینحال، انتقال به انصراف و اجرای اجباری باید بهدقت مدیریت شود تا مشکلات احتمالی سازگاری با برنامههای موجود برطرف شود.
پیادهسازی
توسعهدهندگان باید بااستفاده از مشخصه intentMatchingFlags در مانیفست برنامه خود، مطابقت هدف سختگیرانهتر را بهطور صریح فعال کنند.
در اینجا مثالی آورده شده است که در آن ویژگی برای کل برنامه موافقت شده است،
اما در گیرنده غیرفعال/انصراف داده شده است:
<application android:intentMatchingFlags="enforceIntentFilter">
<receiver android:name=".MyBroadcastReceiver" android:exported="true" android:intentMatchingFlags="none">
<intent-filter>
<action android:name="com.example.MY_CUSTOM_ACTION" />
</intent-filter>
<intent-filter>
<action android:name="com.example.MY_ANOTHER_CUSTOM_ACTION" />
</intent-filter>
</receiver>
</application>
اطلاعات بیشتر درباره پرچمهای پشتیبانیشده:
| نام پرچم | شرح |
|---|---|
| enforceIntentFilter | مطابقت سختگیرانهتری را برای هدفهای ورودی اعمال میکند |
| هیچکدام | همه قوانین تطابق ویژه را برای مقصودهای ورودی غیرفعال میکند. هنگام مشخص کردن چند پرچم، مقادیر متناقض با اولویت دادن به پرچم «هیچکدام» حلوفصل میشوند |
| allowNullAction | قوانین مطابقت را آسانتر میکند تا به قصدها اجازه دهد بدون کنش مطابقت داشته باشند. این پرچم باید همراه با «enforceIntentFilter» استفاده شود تا رفتار خاصی حاصل شود |
آزمایش و اشکالزدایی
وقتی اجرای اجباری فعال است، اگر فراخواننده هدف، هدف را بهدرستی پر کرده باشد، برنامهها باید بهدرستی کار کنند.
بااینحال، قصد مسدودشده پیامهای گزارش هشدار مانند
"Intent does not match component's intent filter:" و "Access blocked:"
با برچسب "PackageManager." را راهاندازی میکند.
این نشاندهنده مشکل احتمالی است که میتواند بر برنامه تأثیر بگذارد و نیاز به
توجه دارد.
فیلتر Logcat:
tag=:PackageManager & (message:"Intent does not match component's intent filter:" | message: "Access blocked:")
فیلتر کردن فراخوانی سیستم GPU
To harden the Mali GPU surface, Mali GPU IOCTLs that have been deprecated or are intended solely for GPU development have been blocked in production builds. Additionally, IOCTLs used for GPU profiling have been restricted to the shell process or debuggable applications. Refer to the SAC update for more details on the platform-level policy.
This change takes place on Pixel devices using the Mali GPU (Pixel 6-9). Arm
has provided official categorization of their IOCTLs in
Documentation/ioctl-categories.rst of their r54p2 release. This
list will continue to be maintained in future driver releases.
This change does not impact supported graphics APIs (including Vulkan and OpenGL), and is not expected to impact developers or existing applications. GPU profiling tools such as the Streamline Performance Analyzer and the Android GPU Inspector won't be affected.
Testing
If you see a SELinux denial similar to the following, it is likely your application has been impacted by this change:
06-30 10:47:18.617 20360 20360 W roidJUnitRunner: type=1400 audit(0.0:85): avc: denied { ioctl }
for path="/dev/mali0" dev="tmpfs" ino=1188 ioctlcmd=0x8023
scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:gpu_device:s0 tclass=chr_file
permissive=0 app=com.google.android.selinux.pts
If your application needs to use blocked IOCTLs, please file a bug and assign it to android-partner-security@google.com.
FAQ
Does this policy change apply to all OEMs? This change will be opt-in, but available to any OEMs who would like to use this hardening method. Instructions for implementing the change can be found in the implementation documentation.
Is it mandatory to make changes in the OEM codebase to implement this, or does it come with a new AOSP release by default? The platform-level change will come with a new AOSP release by default. Vendors may opt-in to this change in their codebase if they would like to apply it.
Are SoCs responsible for keeping the IOCTL list up to date? For example, if my device uses an ARM Mali GPU, would I need to reach out to ARM for any of the changes? Individual SoCs must update their IOCTL lists per device upon driver release. For example, ARM will update their published IOCTL list upon driver updates. However, OEMs should make sure that they incorporate the updates in their SEPolicy, and add any selected custom IOCTLs to the lists as needed.
Does this change apply to all Pixel in-market devices automatically, or is a user action required to toggle something to apply this change? This change applies to all Pixel in-market devices using the Mali GPU (Pixel 6-9). No user action is required to apply this change.
Will use of this policy impact the performance of the kernel driver? This policy was tested on the Mali GPU using GFXBench, and no measurable change to GPU performance was observed.
Is it necessary for the IOCTL list to align with the current userspace and kernel driver versions? Yes, the list of allowed IOCTLs must be synchronized with the IOCTLs supported by both the userspace and kernel drivers. If the IOCTLs in the user space or kernel driver are updated, the SEPolicy IOCTL list must be updated to match.
ARM has categorized IOCTLs as 'restricted' / 'instrumentation', but we want to use some of them in production use-cases, and/or deny others. Individual OEMs/SoCs are responsible for deciding on how to categorize the IOCTLs they use, based on the configuration of their userspace Mali libraries. ARM's list can be used to help decide on these, but each OEM/SoC's use-case may be different.
حریم خصوصی
Android 16 (سطح API ۳۶) شامل تغییرات حریم خصوصی زیر است.
اجازه شبکه محلی
Devices on the LAN can be accessed by any app that has the INTERNET permission.
This makes it easy for apps to connect to local devices but it also has privacy
implications such as forming a fingerprint of the user, and being a proxy for
location.
The Local Network Protections project aims to protect the user's privacy by gating access to the local network behind a new runtime permission.
Release plan
This change will be deployed between two releases, 25Q2 and 26Q2 respectively. It is imperative that developers follow this guidance for 25Q2 and share feedback because these protections will be enforced at a later Android release. Moreover, they will need to update scenarios which depend on implicit local network access by using the following guidance and prepare for user rejection and revocation of the new permission.
Impact
At the current stage, LNP is an opt-in feature which means only the apps that opt in will be affected. The goal of the opt-in phase is for app developers to understand which parts of their app depend on implicit local network access such that they can prepare to permission guard them for the next release.
Apps will be affected if they access the user's local network using:
- Direct or library use of raw sockets on local network addresses (e.g. mDNS or SSDP service discovery protocol)
- Use of framework level classes that access the local network (e.g. NsdManager)
Traffic to and from a local network address requires local network access permission. The following table lists some common cases:
| App Low Level Network Operation | Local Network Permission Required |
|---|---|
| Making an outgoing TCP connection | yes |
| Accepting incoming TCP connections | yes |
| Sending a UDP unicast, multicast, broadcast | yes |
| Receiving an incoming UDP unicast, multicast, broadcast | yes |
These restrictions are implemented deep in the networking stack, and thus they apply to all networking APIs. This includes sockets created in native or managed code, networking libraries like Cronet and OkHttp, and any APIs implemented on top of those. Trying to resolve services on the local network (i.e. those with a .local suffix) will require local network permission.
Exceptions to the rules above:
- If a device's DNS server is on a local network, traffic to or from it (at port 53) doesn't require local network access permission.
- Applications using Output Switcher as their in-app picker won't need local network permissions (more guidance to come in 2025Q4).
Developer Guidance (Opt-in)
To opt into local network restrictions, do the following:
- Flash the device to a build with 25Q2 Beta 3 or later.
- Install the app to be tested.
Toggle the Appcompat flag in adb:
adb shell am compat enable RESTRICT_LOCAL_NETWORK <package_name>Reboot The device
Now your app's access to the local network is restricted and any attempt to access the local network will lead to socket errors. If you are using APIs that perform local network operations outside of your app process (ex: NsdManager), they won't be impacted during the opt-in phase.
To restore access, you must grant your app permission to NEARBY_WIFI_DEVICES.
- Ensure the app declares the
NEARBY_WIFI_DEVICESpermission in its manifest. - Go to Settings > Apps > [Application Name] > Permissions > Nearby devices > Allow.
Now your app's access to the local network should be restored and all your scenarios should work as they did prior to opting the app in.
Once enforcement for local network protection begins, here is how the app network traffic will be impacted.
| Permission | Outbound LAN Request | Outbound/Inbound Internet Request | Inbound LAN Request |
|---|---|---|---|
| Granted | Works | Works | Works |
| Not Granted | Fails | Works | Fails |
Use the following command to toggle-off the App-Compat flag
adb shell am compat disable RESTRICT_LOCAL_NETWORK <package_name>
Errors
Errors arising from these restrictions will be returned to the calling socket whenever it invokes send or a send variant to a local network address.
Example errors:
sendto failed: EPERM (Operation not permitted)
sendto failed: ECONNABORTED (Operation not permitted)
Local Network Definition
A local network in this project refers to an IP network that utilizes a broadcast-capable network interface, such as Wi-Fi or Ethernet, but excludes cellular (WWAN) or VPN connections.
The following are considered local networks:
IPv4:
- 169.254.0.0/16 // Link Local
- 100.64.0.0/10 // CGNAT
- 10.0.0.0/8 // RFC1918
- 172.16.0.0/12 // RFC1918
- 192.168.0.0/16 // RFC1918
IPv6:
- Link-local
- Directly-connected routes
- Stub networks like Thread
- Multiple-subnets (TBD)
Additionally, both multicast addresses (224.0.0.0/4, ff00::/8) and the IPv4 broadcast address (255.255.255.255) are classified as local network addresses.
عکسهای متعلق به برنامه
هنگامی که برنامهای که SDK 36 یا بالاتر را در دستگاههای دارای Android 16 یا بالاتر هدف قرار میدهد، مجوزهای عکس و ویدیو را درخواست میکند، کاربرانی که انتخاب میکنند دسترسی به رسانه انتخابشده را محدود کنند، هر عکسی را که متعلق به برنامه از پیش انتخاب شده در انتخابگر عکس است، میبینند. کاربران می توانند هر یک از این موارد از پیش انتخاب شده را لغو انتخاب کنند، که دسترسی برنامه به آن عکس ها و ویدیوها را لغو می کند.