동작 변경사항: Android 15 이상을 타겟팅하는 앱

이전 버전과 마찬가지로 Android 15에는 앱에 영향을 줄 수 있는 동작 변경사항이 포함되어 있습니다. 다음 동작 변경사항은 Android 15 이상을 타겟팅하는 앱에만 적용됩니다. 앱이 Android 15 이상을 타겟팅한다면 이러한 동작을 올바르게 지원하도록 앱을 수정해야 합니다(해당하는 경우).

앱의 targetSdkVersion와 관계없이 Android 15에서 실행되는 모든 앱에 영향을 미치는 동작 변경사항 목록도 검토해야 합니다.

핵심 기능

Android 15는 Android 시스템의 다양한 핵심 기능을 수정하거나 확장합니다.

포그라운드 서비스 변경사항

Android 15의 포그라운드 서비스가 다음과 같이 변경됩니다.

새 미디어 처리 포그라운드 서비스 유형

Android 15 引入了一种新的前台服务类型 mediaProcessing。此服务类型适用于对媒体文件进行转码等操作。例如,媒体应用可能下载音频文件,并且需要将其转换为其他格式才能播放。您可以使用 mediaProcessing 前台服务来确保即使应用在后台运行,转换也会继续进行。

如需详细了解 mediaProcessing 服务类型,请参阅 Android 15 前台服务类型变更

포그라운드 서비스를 실행하는 BOOT_COMPLETED broadcast receiver에 관한 제한사항

포그라운드 서비스를 실행하는 BOOT_COMPLETED broadcast receiver에 새로운 제한사항이 있습니다. BOOT_COMPLETED 수신기는 다음 유형의 포그라운드 서비스를 실행할 수 없습니다.

BOOT_COMPLETED 수신기가 이러한 유형의 포그라운드 서비스를 실행하려고 하면 시스템에서 ForegroundServiceStartNotAllowedException이 발생합니다.

앱이 방해 금지 모드의 전체 상태를 수정할 수 있는 경우에 대한 변경사항

Android 15를 타겟팅하는 앱은 사용자 설정을 수정하거나 DND 모드를 사용 중지하여 기기에서 방해 금지 모드(DND)의 전체 상태 또는 정책을 더 이상 변경할 수 없습니다. 대신 앱은 AutomaticZenRule를 제공해야 합니다. 시스템은 이 시스템에서 기존의 'most-restrictive-policy-wins' 체계가 적용된 전역 정책에 이를 결합합니다. 이전에 전역 상태 (setInterruptionFilter, setNotificationPolicy)에 영향을 미쳤던 기존 API를 호출하면 암시적 AutomaticZenRule이 생성되거나 업데이트됩니다. 이 AutomaticZenRule는 이러한 API 호출의 호출 주기에 따라 사용 설정되거나 사용 중지됩니다.

이 변경사항은 앱이 setInterruptionFilter(INTERRUPTION_FILTER_ALL)를 호출하고 소유자가 이전에 활성화한 AutomaticZenRule를 비활성화하기 위한 호출이 예상되는 경우에만 관찰 가능한 동작에만 영향을 미칩니다.

OpenJDK 17 변경사항

Android 15에서는 최신 OpenJDK LTS 출시의 기능에 맞게 Android의 핵심 라이브러리를 새로고침하는 작업을 계속합니다.

다음 변경사항 중 하나가 Android 15를 타겟팅하는 앱의 앱 호환성에 영향을 줄 수 있습니다.

  • 문자열 형식 지정 API 변경사항: 이제 다음 String.format()Formatter.format() API를 사용할 때 인수 색인, 플래그, 너비, 정밀도의 유효성 검사가 더 엄격해집니다.

    예를 들어 인수 색인 0을 사용하면 (형식 문자열의 %0) 다음 예외가 발생합니다.

    IllegalFormatArgumentIndexException: Illegal format argument index = 0
    

    이 경우 인수 색인 1 (형식 문자열의 %1)을 사용하여 문제를 해결할 수 있습니다.

  • 언어 코드 처리 변경사항: Locale API를 사용하는 경우 히브리어, 이디시어, 인도네시아어의 언어 코드는 더 이상 사용되지 않는 형식(히브리어: iw, 이디시어: ji, 인도네시아어: in)으로 변환되지 않습니다. 이러한 언어 중 하나의 언어 코드를 지정하려면 대신 {ISO 639-1, 인도네시아어: he1, 인도네시아어: he, 0}, 히브리어: he, yiid

  • 임의 int 시퀀스 변경사항: https://bugs.openjdk.org/browse/JDK-8301574에 적용된 변경사항에 따라 다음 Random.ints() 메서드가 이제 Random.nextInt() 메서드와는 다른 일련의 숫자를 반환합니다.

    일반적으로 이 변경으로 인해 앱 중단 동작이 발생하지는 않지만 코드는 Random.ints() 메서드에서 생성된 시퀀스가 Random.nextInt()와 일치한다고 예상해서는 안 됩니다.

보안

Android 15에는 앱과 사용자를 악성 앱으로부터 보호하기 위해 시스템 보안을 촉진하는 변경사항이 포함되어 있습니다.

보안 백그라운드 활동 시작

Android 15 protects users from malicious apps and gives them more control over their devices by adding changes that prevent malicious background apps from bringing other apps to the foreground, elevating their privileges, and abusing user interaction. Background activity launches have been restricted since Android 10 (API level 29).

Block apps that don't match the top UID on the stack from launching activities

Malicious apps can launch another app's activity within the same task, then overlay themselves on top, creating the illusion of being that app. This "task hijacking" attack bypasses current background launch restrictions because it all occurs within the same visible task. To mitigate this risk, Android 15 adds a flag that blocks apps that don't match the top UID on the stack from launching activities. To opt in for all of your app's activities, update the allowCrossUidActivitySwitchFromBelow attribute in your app's AndroidManifest.xml file:

<application android:allowCrossUidActivitySwitchFromBelow="false" >

Other changes

In addition to the restriction for UID matching, these other changes are also included:

  • Change PendingIntent creators to block background activity launches by default. This helps prevent apps from accidentally creating a PendingIntent that could be abused by malicious actors.
  • Don't bring an app to the foreground unless the PendingIntent sender allows it. This change aims to prevent malicious apps from abusing the ability to start activities in the background. By default, apps are not allowed to bring the task stack to the foreground unless the creator allows background activity launch privileges or the sender has background activity launch privileges.
  • Control how the top activity of a task stack can finish its task. If the top activity finishes a task, Android will go back to whichever task was last active. Moreover, if a non-top activity finishes its task, Android will go back to the home screen; it won't block the finish of this non-top activity.
  • Prevent launching arbitrary activities from other apps into your own task. This change prevents malicious apps from phishing users by creating activities that appear to be from other apps.
  • Block non-visible windows from being considered for background activity launches. This helps prevent malicious apps from abusing background activity launches to display unwanted or malicious content to users. No newline at end of left file.

더 안전한 인텐트

Android 15 introduces new security measures to make intents safer and more robust. These changes are aimed at preventing potential vulnerabilities and misuse of intents that can be exploited by malicious apps. There are two main improvements to the security of intents in Android 15:

  • Match target intent-filters: Intents that target specific components must accurately match the target's intent-filter specifications. If you send an intent to launch another app's activity, the target intent component needs to align with the receiving activity's declared intent-filters.
  • Intents must have actions: Intents without an action will no longer match any intent-filters. This means that intents used to start activities or services must have a clearly defined action.

Kotlin


fun onCreate() {
    StrictMode.setVmPolicy(VmPolicy.Builder()
        .detectUnsafeIntentLaunch()
        .build()
    )
}

Java


public void onCreate() {
    StrictMode.setVmPolicy(new VmPolicy.Builder()
            .detectUnsafeIntentLaunch()
            .build());
}

사용자 환경 및 시스템 UI

Android 15에는 더 일관되고 직관적인 사용자 환경을 만들기 위한 몇 가지 변경사항이 포함되어 있습니다.

창 인셋 변경사항

Android 15에서는 창 인셋과 관련된 두 가지 변경사항이 있습니다. 베타 1에서는 더 넓은 화면 범위가 적용됩니다. 시스템 표시줄의 기본 구성을 비롯한 향후 구성 변경사항도 있습니다.

더 넓은 화면 적용

默认情况下,如果应用以 Android 15 为目标平台,则在搭载 Android 15 的设备上会无边框。

应用以 Android 14 为目标平台且在 Android 15 设备上并非全屏显示的应用。


一个以 Android 15 为目标平台且在 Android 15 设备上实现无边框的应用。此应用主要使用可自动应用边衬区的 Material 3 Compose 组件。此屏幕不会受到 Android 15 无边框强制执行的影响。

这是一项重大变更,可能会对应用的界面产生负面影响。变更如下:

  • 手势手柄导航栏
    • 默认为透明。
    • 由于底部偏移已停用,因此内容绘制在系统导航栏后面,除非应用边衬区。
    • setNavigationBarColorR.attr#navigationBarColor 已废弃,不会影响手势导航。
    • setNavigationBarContrastEnforcedR.attr#navigationBarContrastEnforced 仍然对手势导航没有影响。
  • “三按钮”导航
    • 不透明度默认设置为 80%,颜色可能与窗口背景匹配。
    • 已停用底部偏移,因此内容绘制在系统导航栏后面,除非应用边衬区。
    • 默认情况下,setNavigationBarColorR.attr#navigationBarColor 设置为与窗口背景匹配。窗口背景必须是彩色可绘制对象,才能应用此默认设置。此 API 已废弃,但会继续影响三按钮导航。
    • setNavigationBarContrastEnforcedR.attr#navigationBarContrastEnforced 默认情况下为 true,这会在“三按钮”导航中添加 80% 的不透明背景。
  • 状态栏
    • 默认为透明。
    • 顶部偏移量已停用,因此,除非应用边衬区,否则内容将绘制在状态栏后面。
    • setStatusBarColorR.attr#statusBarColor 已废弃,对 Android 15 没有任何影响。
    • setStatusBarContrastEnforcedR.attr#statusBarContrastEnforced 已废弃,但在 Android 15 上仍产生影响。
  • 刘海屏
    • 非浮动窗口的 layoutInDisplayCutoutMode 必须为 LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS。在 Android 15 Beta 1 中,如果使用 SHORT_EDGESNEVERDEFAULT(例如 LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT),应用将会崩溃并出现 IllegalArgumentException。在 Android 15 Beta 版 2 中,SHORT_EDGESNEVERDEFAULT 将被解释为 ALWAYS,这样用户就不会看到由刘海屏导致的黑色条形,而无边框。

以下示例展示了以 Android 15 为目标平台之前和之后以及应用边衬区前后的应用。

应用以 Android 14 为目标平台且在 Android 15 设备上并非全屏显示的应用。
一个以 Android 15 为目标平台且在 Android 15 设备上实现无边框的应用。不过,由于 Android 15 的无边框强制措施,许多元素现在被状态栏、“三按钮”导航栏或刘海屏遮挡。被遮盖的界面包括 Material 2 TopAppBar、FAB 和列表项。
如果应用以 Android 15 为目标平台,则可以在 Android 15 设备上全屏显示,并会应用边衬区来避免界面被遮挡。

如果您的应用:

  • 无边框并应用了边衬区,那么除了以下几种场景外,您基本上不受影响。不过,即使您认为自己不受影响,我们也建议您测试自己的应用。
    • 您有一个非浮动窗口,例如使用 SHORT_EDGES, NEVERDEFAULT(而非 LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS)的 Activity。如果您的应用在启动时崩溃,这可能是由于启动画面所致。您可以将 core splashscreen 依赖项升级到 1.2.0-alpha01 或更高版本,设置 window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutInDisplayCutoutMode.always,或使用 Android 15 Beta 版 2(而不是 Beta 版 1)进行测试。
    • 在流量较低的屏幕上,可能会出现界面被遮挡的屏幕。验证这些访问较少的屏幕没有被遮挡的界面。流量较低的屏幕包括:
      • 初始配置或登录屏幕
      • “设置”页面
  • 非无边际,那么您很有可能受到影响。除了无边框应用出现的情况之外,您还需要考虑以下因素:
    • 如果您的应用使用 Material 3 组件(Compose 中的 androidx.compose.material3,例如 TopAppBar, BottomAppBarNavigationBar),这些组件可能不受影响,因为它们会自动处理边衬区。
    • 如果您的应用使用的是 Material 2 组件(Compose 中的 androidx.compose.material),则这些组件不会自动处理边衬区。不过,您可以访问边衬区并手动应用边衬区。在 androidx.compose.material 1.6.0 及更高版本中,请使用 windowInsets 参数,为 BottomAppBarTopAppBarBottomNavigationNavigationRail 手动应用边衬区。同样,对 Scaffold 使用 contentWindowInsets 参数。
    • 如果您的应用使用 View 和 Material 组件 (com.google.android.material),则大多数基于 View 的 Material 组件(例如 BottomNavigationViewBottomAppBarNavigationRailViewNavigationView)会处理边衬区,无需执行额外的操作。不过,如果使用 AppBarLayout,则需要添加 android:fitsSystemWindows="true"
    • 对于自定义可组合项,请手动应用边衬区作为内边距。如果您的内容位于 Scaffold 内,您可以使用 Scaffold 的内边距值使用边衬区。否则,请使用 WindowInsets 之一应用内边距。
    • 如果您的应用使用的是 View 和 BottomSheet、SideSheet 或自定义容器,请使用 ViewCompat.setOnApplyWindowInsetsListener 应用内边距。对于 RecyclerView,请使用此监听器应用内边距,并添加 clipToPadding="false"
  • 必须为三按钮导航或状态栏提供自定义背景保护,那么您的应用应使用 WindowInsets.Type#tappableElement() 获取三按钮导航栏高度或 WindowInsets.Type#statusBars,将可组合项或视图放置在系统栏后面。

如需了解应用边衬区的其他注意事项,请参阅边缘视图Edge to Edge Compose 指南。

已废弃和已停用的 API 列表如下:

  • R.attr#statusBarColor
  • R.attr#navigationBarColor
  • R.attr#navigationBarDividerColor
  • 窗口#setDecorFitsSystemWindows
  • 窗口#setStatusBarColor
  • 窗口#setStatusBarContrastEnforced
  • 窗口#setNavigationBarColor
  • Window#setNavigationBarDividerColor
  • 窗口#getStatusBarColor
  • Window#getStatusBarContrastEnforced
  • 窗口#getNavigationBarColor
  • Window#getNavigationBarDividerColor

안정적인 구성

이 변경사항은 베타 1에서 테스트할 수 없지만 곧 제공될 예정입니다.

앱이 Android 15 이상을 타겟팅하면 Configuration에서 더 이상 시스템 표시줄을 제외하지 않습니다. 레이아웃 계산을 위해 Configuration 클래스에서 화면 크기를 사용하는 경우 필요에 따라 적절한 ViewGroup, WindowInsets 또는 WindowMetricsCalculator와 같은 더 나은 대안으로 대체해야 합니다.

Configuration는 API 1부터 사용할 수 있었습니다. 일반적으로 Activity.onConfigurationChanged에서 가져옵니다. 창 밀도, 방향, 크기와 같은 정보를 제공합니다. Configuration에서 반환되는 창 크기에 관한 한 가지 중요한 특징은 이전에 시스템 표시줄을 제외했다는 것입니다.

구성 크기는 일반적으로 리소스 선택(예: /res/layout-h500dp)에 사용되며 여전히 유효한 사용 사례입니다. 그러나 레이아웃 계산에 사용하는 것은 항상 권장되지 않습니다. 그렇게 한다면 이제 그만두어야 합니다. Configuration 사용을 사용 사례에 따라 더 적합한 값으로 바꿔야 합니다.

이 메서드를 사용하여 레이아웃을 계산하는 경우 CoordinatorLayout 또는 ConstraintLayout와 같은 적절한 ViewGroup를 사용하세요. 이 메서드를 사용하여 시스템 탐색 메뉴의 높이를 결정한다면 WindowInsets를 사용하세요. 앱 창의 현재 크기를 알아보려면 computeCurrentWindowMetrics를 사용하세요.

다음 목록에서는 이 변경사항의 영향을 받는 필드를 설명합니다.

  • Configuration.screenWidthDpscreenHeightDp 크기에서 더 이상 시스템 표시줄을 제외하지 않습니다.
  • Configuration.smallestScreenWidthDpscreenWidthDpscreenHeightDp의 변경사항의 간접적인 영향을 받습니다.
  • Configuration.orientation는 정사각형에 가까운 기기에서 screenWidthDpscreenHeightDp의 변경사항으로 간접적인 영향을 받습니다.
  • Display.getSize(Point)는 구성 변경사항의 간접적인 영향을 받습니다. 이 기능은 API 수준 30부터 지원 중단되었습니다.
  • Display.getMetrics()는 API 수준 33부터 이미 이와 같이 작동했습니다.

UltraTextHeight 속성의 기본값이 true로 설정됩니다.

For apps targeting Android 15, the elegantTextHeight TextView attribute becomes true by default, replacing the compact font used by default with some scripts that have large vertical metrics with one that is much more readable. The compact font was introduced to prevent breaking layouts; Android 13 (API level 33) prevents many of these breakages by allowing the text layout to stretch the vertical height utilizing the fallbackLineSpacing attribute.

In Android 15, the compact font still remains in the system, so your app can set elegantTextHeight to false to get the same behavior as before, but it is unlikely to be supported in upcoming releases. So, if your app supports the following scripts: Arabic, Lao, Myanmar, Tamil, Gujarati, Kannada, Malayalam, Odia, Telugu or Thai, test your app by setting elegantTextHeight to true.

elegantTextHeight behavior for apps targeting Android 14 (API level 34) and lower.
elegantTextHeight behavior for apps targeting Android 15.

복잡한 문자 도형의 TextView 너비 변경

在以前的 Android 版本中,一些采用复杂形状的草体字体或语言可能会在上一个或下一个字符区域中绘制字母。在某些情况下,此类字母会在开始或结束位置被截断。从 Android 15 开始,TextView 会分配宽度来为此类字母绘制足够的空间,并允许应用请求左侧添加额外的内边距以防止被裁剪。

由于此变更会影响 TextView 确定宽度的方式,因此如果应用以 Android 15 或更高版本为目标平台,TextView 会默认分配更多宽度。您可以通过对 TextView 调用 setUseBoundsForWidth API 来启用或停用此行为。

由于添加左侧内边距可能会导致现有布局未对齐,因此默认情况下,系统不会添加内边距,即使对于以 Android 15 或更高版本为目标平台的应用也是如此。不过,您可以通过调用 setShiftDrawingOffsetForStartOverhang 添加额外的内边距以防止裁剪。

以下示例展示了这些更改如何改进某些字体和语言的文本布局。

以手写体字体显示的英语文本的标准布局。部分字母会被截断。相应的 XML 如下:

<TextView
    android:fontFamily="cursive"
    android:text="java" />
包含额外宽度和内边距的相同英文文本的布局。相应的 XML 如下:

<TextView
    android:fontFamily="cursive"
    android:text="java"
    android:useBoundsForWidth="true"
    android:shiftDrawingOffsetForStartOverhan="true" />
泰语文字的标准版式。部分字母被截断。 相应的 XML 如下:

<TextView
    android:text="คอมพิวเตอร์" />
相同泰语文本的布局,但有额外的宽度和内边距。相应的 XML 如下:

<TextView
    android:text="คอมพิวเตอร์"
    android:useBoundsForWidth="true"
    android:shiftDrawingOffsetForStartOverhan="true" />

EditText의 언어 인식 기본 줄 높이

In previous versions of Android, the text layout stretched the height of the text to meet the line height of the font that matched the current locale. For example, if the content was in Japanese, because the line height of the Japanese font is slightly larger than the one of a Latin font, the height of the text became slightly larger. However, despite these differences in line heights, the EditText element was sized uniformly, regardless of the locale being used, as illustrated in the following image:

Three boxes representing EditText elements that can contain text from English (en), Japanese (ja), and Burmese (my). The height of the EditText is the same, even though these languages have different line heights from each other.

For apps targeting Android 15, a minimum line height is now reserved for EditText to match the reference font for the specified Locale, as shown in the following image:

Three boxes representing EditText elements that can contain text from English (en), Japanese (ja), and Burmese (my). The height of the EditText now includes space to accommodate the default line height for these languages' fonts.

If needed, your app can restore the previous behavior by specifying the useLocalePreferredLineHeightForMinimum attribute to false, and your app can set custom minimum vertical metrics using the setMinimumFontMetrics API in Kotlin and Java.

카메라 및 미디어

Android 15에서는 Android 15 이상을 타겟팅하는 앱의 카메라 및 미디어 동작을 다음과 같이 변경합니다.

오디오 포커스 요청 제한사항

Android 15를 타겟팅하는 앱은 오디오 포커스를 요청하려면 최상위 앱이거나 오디오 관련 포그라운드 서비스를 실행해야 합니다. 앱이 이러한 요구사항 중 하나를 충족하지 않을 때 포커스를 요청하려고 하면 호출은 AUDIOFOCUS_REQUEST_FAILED를 반환합니다.

포그라운드 서비스는 유형이 mediaPlayback, camera, microphone 또는 phoneCall인 경우 오디오와 관련된 것으로 간주됩니다.

오디오 포커스 관리에서 오디오 포커스에 관해 자세히 알아보세요.

업데이트된 비 SDK 제한사항

Android 15 包含更新后的受限非 SDK 接口列表(基于与 Android 开发者之间的协作以及最新的内部测试)。在限制使用非 SDK 接口之前,我们会尽可能确保有可用的公开替代方案。

如果您的应用并非以 Android 15 为目标平台,其中一些变更可能不会立即对您产生影响。不过,虽然您的应用可以访问某些非 SDK 接口(具体取决于应用的目标 API 级别),但使用任何非 SDK 方法或字段始终存在导致应用出问题的显著风险。

如果您不确定自己的应用是否使用了非 SDK 接口,则可以测试该应用进行确认。如果您的应用依赖于非 SDK 接口,则应开始计划迁移到 SDK 替代方案。不过,我们知道某些应用具有使用非 SDK 接口的有效用例。如果您无法为应用中的功能找到无需使用非 SDK 接口的替代方案,则应请求新的公共 API

<

이 Android 버전의 변경사항을 자세히 알아보려면 Android 15의 비 SDK 인터페이스 제한사항 업데이트를 참고하세요. 비 SDK 인터페이스에 관한 일반적인 내용을 자세히 알아보려면 비 SDK 인터페이스 제한사항을 참고하세요.