0%

Android12

后台限制

  • 沉浸模式下的手势导航改进
  • 前台服务通知延迟 10s显示,排除以下情况
    • 包含操作按钮通知
    • [foregroundServiceType](https://developer.android.com/guide/topics/manifest/service-element#foregroundservicetype) 为connectedDevice;mediaPlayback;mediaProjection;phoneCall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
public final void startForeground(int id, @NonNull Notification notification,
@ForegroundServiceType int foregroundServiceType) {
try {
mActivityManager.setServiceForeground(
new ComponentName(this, mClassName), mToken, id,
notification, 0, foregroundServiceType);
} catch (RemoteException ex) {
}
}


/**
* Constant corresponding to <code>mediaPlayback</code> in
* the {@link android.R.attr#foregroundServiceType} attribute.
* Music, video, news or other media playback.
*/
public static final int FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK = 1 << 1;
/**
* Constant corresponding to <code>phoneCall</code> in
* the {@link android.R.attr#foregroundServiceType} attribute.
* Ongoing phone call or video conference.
*/
public static final int FOREGROUND_SERVICE_TYPE_PHONE_CALL = 1 << 2;
/**
* Constant corresponding to <code>connectedDevice</code> in
* the {@link android.R.attr#foregroundServiceType} attribute.
* Auto, bluetooth, TV or other devices connection, monitoring and interaction.
*/
public static final int FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE = 1 << 4;

/**
* Constant corresponding to {@code mediaProjection} in
* the {@link android.R.attr#foregroundServiceType} attribute.
* Managing a media projection session, e.g for screen recording or taking screenshots.
*/
public static final int FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION = 1 << 5;

  • Notification category 为 通话、导航或媒体播放
    1
    2
    3
    4
    5
    /**
    * Notification category: incoming call (voice or video) or similar synchronous communication request.
    */
    public static final String CATEGORY_CALL = "call";

  • android 12 Notification setShowForegroundImmediately

    隐私设置

  • mac 地址的限制

  • 如果应用以 Android 12 为目标平台,则该 API 会返回 null。

  • 如果应用以 Android 11 或更低版本为目标平台,则该 API 将返回硬编码占位值:02:00:00:00:00:00

  • 推荐使用 [ConnectivityManager](https://developer.android.com/reference/android/net/ConnectivityManager) 不是 [NetworkInterface](https://developer.android.com/reference/java/net/NetworkInterface) getifaddrs(), NetlinkSocketAddress

    安全性 窗口

  • 关键字

    1
    Untrusted touch due to occlusion by PACKAGE_NAME
  • [ACTION_CLOSE_SYSTEM_DIALOGS](https://developer.android.com/reference/android/content/Intent#ACTION_CLOSE_SYSTEM_DIALOGS) 

    • target >= 31调用抛出安全异常
  • target < 31 则系统不会执行 intent 关注日志 Permission Denial android.intent.action.CLOSE_SYSTEM_DIALOGS broadcast from com.package.name requires android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS

  • exclude : 插桩测试;

target 31 限制

  • SameSite

image.png