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

相关推荐
野犬寒鸦5 分钟前
Claude Code:终端AI编程助手全指南(附带指令全讲解)
开发语言·后端·面试·ai编程
淡笑沐白6 分钟前
JavaScript零基础到精通
开发语言·javascript·ecmascript
夏日听雨眠7 分钟前
数据结构(循环队列)
数据结构·算法·链表
Languorous.7 分钟前
C++智能指针详解:原理、使用及避坑指南
开发语言·c++
老马952712 分钟前
opencode7-桌面应用实战2
java·人工智能·后端
平行侠12 分钟前
30MacLaren-Marsaglia算法故事文件
数据结构·算法
广州灵眸科技有限公司19 分钟前
瑞芯微(EASY EAI)RV1126B yolov11-track多目标跟踪部署教程
linux·开发语言·网络·人工智能·yolo·机器学习·目标跟踪
灵动小溪20 分钟前
claude code工具PC安装部署
人工智能·算法
李白的天不白21 分钟前
大规模请求数据并发问题
java·前端·数据库
智慧物业老杨1 小时前
智慧物业数智化转型实战:从工单响应到业主满意度的闭环构建
java·开发语言