Android源码去除锁屏及应用程序开机自动运行不锁屏全屏显示

针对RealV210提供的源码 android_gingerbread_realv210_ver_1_2 2.3.1

设置默认锁屏时间

frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
private void loadSystemSettings(SQLiteDatabase db) {
loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT,
R.integer.def_screen_off_timeout);
frameworks/base/packages/SettingsProvider/res/values/defaults.xml
<integer name="def_screen_off_timeout">-1</integer>
以毫秒为单位,设为-1即可,重新编译Setting Provider模块
但是只是这样修改的话,启动后依旧会进入锁屏状态,解锁之后就再也不会锁屏了

开机不锁屏
frameworks/base/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
/**
* External apps (like the phone app) can tell us to disable the keygaurd.
*/
private boolean mExternallyEnabled = true;
改为false
$ source build/envsetup.sh
$ mmm frameworks/base/policy/
Install: out/target/product/generic/data/app/FrameworkPolicyTests.apk
为了打开锁屏功能,可调用函数setKeyguardEnabled()



应用程序开机自动运行

新建文件
public class AutoBoot extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent arg1) {
if (arg1.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Intent helloActivityIntent = new Intent(arg0, HelloActivity.class);
helloActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
arg0.startActivity(helloActivityIntent);
}
}
}
修改AndroidManifest.xml
在<application>中加入(AutoBoot为上面的类名)
<receiver android:name=".AutoBoot">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
加入
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />


应用程序开机不锁屏

<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
onCreate中加入,最好在setContentView(R.layout.main)之前
getWindow().setFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD,
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);


应用程序全屏显示
在配置文件的<application>中加入
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
应用程序部分摘自http://www.cnblogs.com/ikakawa/archive/2011/08/30/2159418.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值