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

相关推荐
西瓜本瓜@6 分钟前
在Android开发中实现静默拍视频
android·java·开发语言·学习·音视频
_.Switch11 分钟前
高效网络自动化:Python在网络基础中的应用
运维·开发语言·网络·python·数据分析·自动化
2301_80220193关注我14 分钟前
Parameters参数、增删改标签、事务、typeAliases
java·数据库·windows
清灵xmf20 分钟前
JavaScript 中如何识别异步函数?
开发语言·javascript·async·异步函数
南巷逸清风22 分钟前
LeetCode 101.对称二叉树
c++·python·算法·leetcode
听潮阁34 分钟前
【SSM详细教程】-13-SpringMVC详解
java·spring boot·spring·java-ee·tomcat·maven·mybatis
纪怽ぅ36 分钟前
浅谈——深度学习和马尔可夫决策过程
人工智能·python·深度学习·算法·机器学习
七月巫山晴36 分钟前
QChart中柱形图的简单使用并实现【Qt】
开发语言·数据结构·c++·qt·算法·排序算法
阿丁小哥39 分钟前
【Python各个击破】numpy
开发语言·python·numpy