Android 理解endcall和power组合行为

/frameworks/base/core/java/android/provider/Settings.java

/**

* What happens when the user presses the end call button if they're not

* on a call.<br/>

* <b>Values:</b><br/>

* 0 - The end button does nothing.<br/>

* 1 - The end button goes to the home screen.<br/>

* 2 - The end button puts the device to sleep and locks the keyguard.<br/>

* 3 - The end button goes to the home screen. If the user is already on the

* home screen, it puts the device to sleep.

*/
public static final String END_BUTTON_BEHAVIOR = "end_button_behavior";

/**

* END_BUTTON_BEHAVIOR value for "go home".

* @hide

*/
public static final int END_BUTTON_BEHAVIOR_HOME = 0x1;

/**

* END_BUTTON_BEHAVIOR value for "go to sleep".

* @hide

*/

public static final int END_BUTTON_BEHAVIOR_SLEEP = 0x2;

/**

* END_BUTTON_BEHAVIOR default value.

* @hide

*/

public static final int END_BUTTON_BEHAVIOR_DEFAULT = END_BUTTON_BEHAVIOR_SLEEP;

@UnsupportedAppUsage

public static final String INCALL_POWER_BUTTON_BEHAVIOR = "incall_power_button_behavior";

/**

* Whether the user allows minimal post processing or not.

*

* <p>Values:

* 0 - Not allowed. Any preferences set through the Window.setPreferMinimalPostProcessing

* API will be ignored.

* 1 - Allowed. Any preferences set through the Window.setPreferMinimalPostProcessing API

* will be respected and the appropriate signals will be sent to display.

* (Default behaviour)

*

* @hide

*/

public static final String MINIMAL_POST_PROCESSING_ALLOWED =
"minimal_post_processing_allowed";

/**

* INCALL_POWER_BUTTON_BEHAVIOR value for "turn off screen".

* @hide

*/

public static final int INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF = 0x1;

/**

* INCALL_POWER_BUTTON_BEHAVIOR value for "hang up".

* @hide

*/
public static final int INCALL_POWER_BUTTON_BEHAVIOR_HANGUP = 0x2;

/**

* INCALL_POWER_BUTTON_BEHAVIOR default value.

* @hide

*/

public static final int INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT =
INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF;

/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java

public void updateSettings() {

ContentResolver resolver = mContext.getContentResolver();

boolean updateRotation = false;

synchronized (mLock) {

mEndcallBehavior = Settings.System.getIntForUser(resolver,
Settings.System.END_BUTTON_BEHAVIOR,
Settings.System.END_BUTTON_BEHAVIOR_DEFAULT,
UserHandle.USER_CURRENT);

mIncallPowerBehavior = Settings.Secure.getIntForUser(resolver,
Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT,
UserHandle.USER_CURRENT);

以上可以根据实际需要,进行替换设置:

默认为sleep和screen off

相关推荐
※DX3906※9 分钟前
cpp实战项目—string类的模拟实现
开发语言·c++
wjs202417 分钟前
Nginx 安装配置指南
开发语言
桦说编程27 分钟前
CompletableFuture 超时功能有大坑!使用不当直接生产事故!
java·性能优化·函数式编程·并发编程
@_@哆啦A梦30 分钟前
Redis 基础命令
java·数据库·redis
美味小鱼36 分钟前
实践Rust:编写一个猜数字游戏
开发语言·游戏·rust
Joyner20181 小时前
python-leetcode-从中序与后序遍历序列构造二叉树
算法·leetcode·职场和发展
因兹菜1 小时前
[LeetCode]day9 203.移除链表元素
算法·leetcode·链表
LNsupermali1 小时前
力扣257. 二叉树的所有路径(遍历思想解决)
算法·leetcode·职场和发展
雾月551 小时前
LeetCode LCR180文件组合
算法·leetcode·职场和发展
萌の鱼1 小时前
leetcode 2080. 区间内查询数字的频率
数据结构·c++·算法·leetcode