在JB/JB2版本上找不到Camera图标
[DESCRIPTION]
在JB/JB2版本上找不到CAMERA图标,无法进入Camera
[ANALYSE]
此问题是由于Google在android4.1之后,即JB版本后在Camera App会侦测是否有Camera sensor,如没有则不会show Camera图标。
具体是在download完成第一次开机后侦测当前是否有Camera Sensor,如果没有就将Camera图标隐藏。
注:此行为只会在Download开机第一次执行,之后便不会侦测。即使后续侦测到sensor,Camera图标一样不会出现,只能恢复出厂设置。
[SOLUTION]
此行为并不会对MP版本有影响,因为MP版本如果有Camera sensor则会出现图标,如果没有则不出现图标。
但在porting sensor过程中,此行为有诸多不便,可以通过如下修改保证Camera图标一直存在:
在packages/apps/Camera/src/com/android/camera/DisableCameraReceive.java文件中
将onReceive方法内code完全注释掉:
public void onReceive(Context context, Intent intent) {
// Disable camera-related activities if there is no camera.
boolean needCameraActivity = CHECK_BACK_CAMERA_ONLY
? hasBackCamera()
: hasCamera();
if (!needCameraActivity) {
Log.i(TAG, "disable all camera activities");
for (int i = 0; i < ACTIVITIES.length; i++) {
disableComponent(context, ACTIVITIES);
}
}
// Disable this receiver so it won't run again.
disableComponent(context, "com.android.camera.DisableCameraReceiver");
}
改为:
public void onReceive(Context context, Intent intent) {
/*
// Disable camera-related activities if there is no camera.
boolean needCameraActivity = CHECK_BACK_CAMERA_ONLY
? hasBackCamera()
: hasCamera();
if (!needCameraActivity) {
Log.i(TAG, "disable all camera activities");
for (int i = 0; i < ACTIVITIES.length; i++) {
disableComponent(context, ACTIVITIES);
}
}
// Disable this receiver so it won't run again.
disableComponent(context, "com.android.camera.DisableCameraReceiver");
*/
}
然后采用mm命令编译:
./mk mm packages/apps/Gallery2
将out/target/product/<project>/system/app/Gallery2.apk push到手机/system/app目录下
然后恢复出厂设置即可。
注:建议在MP之前将注释取消保持Google Default行为。