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

相关推荐
陌小呆^O^5 分钟前
Cmakelist.txt之win-c-udp-client
c语言·开发语言·udp
机器学习之心11 分钟前
一区北方苍鹰算法优化+创新改进Transformer!NGO-Transformer-LSTM多变量回归预测
算法·lstm·transformer·北方苍鹰算法优化·多变量回归预测·ngo-transformer
儿时可乖了14 分钟前
使用 Java 操作 SQLite 数据库
java·数据库·sqlite
ruleslol15 分钟前
java基础概念37:正则表达式2-爬虫
java
I_Am_Me_21 分钟前
【JavaEE进阶】 JavaScript
开发语言·javascript·ecmascript
yyt_cdeyyds21 分钟前
FIFO和LRU算法实现操作系统中主存管理
算法
重生之我是数学王子31 分钟前
QT基础 编码问题 定时器 事件 绘图事件 keyPressEvent QT5.12.3环境 C++实现
开发语言·c++·qt
xmh-sxh-131432 分钟前
jdk各个版本介绍
java
Ai 编码助手33 分钟前
使用php和Xunsearch提升音乐网站的歌曲搜索效果
开发语言·php
学习前端的小z37 分钟前
【前端】深入理解 JavaScript 逻辑运算符的优先级与短路求值机制
开发语言·前端·javascript