1、退出程序返回到主界面
//back home to disable as video,games etc. Intent intent = new Intent(Intent.ACTION_MAIN); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addCategory(Intent.CATEGORY_HOME); context.startActivity(intent);========================================================================================
代码位置:frameworks/base/services/java/com/android/server/power/ShutdownThread.java
在beginShutdownSequence里
//gsensor tmp private static boolean mUpdateRotation = false; private static int mSensorState = 0; private static IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); private static int mUserRotation = Surface.ROTATION_0; private static int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_LOCKED; . . . /*Add by Xandy*/ /*Configure rotation lock.*/ ContentResolver resolver = context.getContentResolver(); int userRotation = Settings.System.getIntForUser(resolver, Settings.System.USER_ROTATION, Surface.ROTATION_0, UserHandle.USER_CURRENT); if (mUserRotation != userRotation) { mUserRotation = userRotation; mUpdateRotation = true; } int userRotationMode = Settings.System.getIntForUser(resolver, Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? WindowManagerPolicy.USER_ROTATION_FREE : WindowManagerPolicy.USER_ROTATION_LOCKED; if (mUserRotationMode != userRotationMode) { mUserRotationMode = userRotationMode; mUpdateRotation = true; } //lock ROTATION_0 for shutanimation if(mUpdateRotation) wm.freezeRotation(Surface.ROTATION_0);然后在run里面:
// User rotation: to be used when all else fails in assigning an orientation to the device private static void setUserRotationMode(int mode, int rot) { ContentResolver res = mContext.getContentResolver(); // mUserRotationMode and mUserRotation will be assigned by the content observer if (mode == WindowManagerPolicy.USER_ROTATION_LOCKED) { Settings.System.putIntForUser(res, Settings.System.USER_ROTATION, rot, UserHandle.USER_CURRENT); Settings.System.putIntForUser(res, Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT); } else { Settings.System.putIntForUser(res, Settings.System.ACCELEROMETER_ROTATION, 1, UserHandle.USER_CURRENT); } } . . . public void run() { . . . //save screen rotation state before shutdown setUserRotationMode(mUserRotationMode, mUserRotation); rebootOrShutdown(mReboot, mRebootReason); }========================================================================================
4、预置默认输入法
a、安装需要用的默认输入法(.apk)到system/app
b、修改文件 frameworks/base/packages/SettingsProvider/res/values/defaults.xml
<string name="default_input_method" translatable="false">默认输入法 ID</string>
c、\packages\apps\settings\src\com\android\settings\LanguageSettings.java中加上ID
红色标记表示输入法 ID,比如 PinyinIME 为:com.android.inputmethod.pinyin/.PinyinIME
搜狗输入法ID:com.sohu.inputmethod.sogou/SogouIME
百度输入法ID:com.baidu.input/.ImeService
ID一定要正确
==========================================================================================
5、系统预装必需放在data目录下的文件,但不允许每次刷机或者恢复出厂设置的时候文件丢失
a、将需要预装到data目录的文件先放置在system目录下,如/system/backup
b、在init.rc中将放置在system目录的文件通过链接的方式链接到data目录下
如:
#backup data
symlink /system/backup/app/Adobe_Flash_Player.apk /data/app/Adobe_Flash_Player.apk
symlink /system/backup/mrvl_gps.conf /data/mrvl_gps.conf
这样就算恢复出厂设置,只要system目录下的原文件存在,等系统重启之后,所需要的文件会乖乖的加到data目录下了
==========================================================================================
6、解压分卷文件
利用split来分卷,cat来合并分卷
split -d -b 4m xx.tar.gz
cat x* > xx.tar.gz
tar zxvf xx.tar.gz
==========================================================================================
7、app压力测试
monkey -p com.android.xx (包名) -v 500(随机事件次数)