1.修改android 系统/system/下面文件时权限不够问题
下面提到的方式目前在Bobcat的userdebug image上测试可行,还没有在user上测试过.
修改前:
leif@leif:~$ adb root
restarting adbd as root
leif@leif:~$ adb disable-verity
verity is already disabled
using overlayfs
Now reboot your device for settings to take effect
重启机器后:
leif@leif:~$ adb root
restarting adbd as root
leif@leif:~$ adb remount
[libfs_mgr]dt_fstab: Skip disabled entry for partition vendor
[libfs_mgr]dt_fstab: Skip disabled entry for partition vendor
[libfs_mgr]dt_fstab: Skip disabled entry for partition vendor
[libfs_mgr]dt_fstab: Skip disabled entry for partition vendor
[libfs_mgr]dt_fstab: Skip disabled entry for partition vendor
remount succeeded
2.添加公共的系統資源
添加公共的系統資源, 有兩種方法
-
將需要的資源添加到SDK中進行使用 比如添加資源到SDK中的Settings和BatteryManager中。添加資源後在開始編譯前, 需要將此資源聲明為@hide或執行make update-api操作, Android 10以後須執行make api-stubs-docs-update-current-api
-
將需要添加的資源作為私有的標識來使用, 添加資源後,需要在frameworks/base/core/res/res/symbols.xml中聲明此資源, 然後在java代碼中使用com.android.internal.R.來使用
3.查找某一個控件的ID
有的時候我們在debug某一個bug的時候需要查找其中的一个控件的ID,这个时候我们可以使用SDK中提供的tool进行查找,运行SDK/tools/monitor 脚本,在打开的Android Device Monitor中选中左上角的设备,再点击Dump View Hierarchy for UI Automator , 在中间出现的Device UI中用鼠標点击需要查找的控件的区域,在右侧会把当前点击区域的所有控件都列出来。
4.關於Snapdragon camera中的一些問題修改
4.1 菜單提示位置不正確
XXX機器由橫屏轉爲豎屏後,snapdragon camera的filters 和 scene mode提示位置不正確。修改位置:packages/apps/SnapdragonCamera/src/com/android/camera/ui/MenuHelp.java
在setLocation中修改方向值
private void setLocation(int w, int h) {int rotation = getUnifiedRotation();toIndex(mHelp0_0, w, h, rotation, 1, 3, HELP_0_0_INDEX);toIndex(mHelp1_0, w, h, rotation, 2, 2, HELP_1_0_INDEX);if(TsMakeupManager.HAS_TS_MAKEUP)toIndex(mHelp3_0, w, h, rotation, 3, 1, HELP_3_0_INDEX);if (!forCamera2) {toIndex(mHelp4_6, w, h, rotation, 3, 4, HELP_4_6_INDEX);} else {mHelp4_6.setVisibility(View.GONE);}toIndex(mOk2_4, w, h, rotation, 1, 5, OK_2_4_INDEX);fillArrows(w, h, rotation);}
修改方向後如果發現箭頭的弧度有問題,可以在fillArrows中修改
private void fillArrows(int w, int h, int rotation) {View v1 = new View(mContext);View v2 = new View(mContext);View v3 = new View(mContext);{toIndex(v1, w, h, rotation, 1, 3, -1);toIndex(v2, w, h, rotation, 0, 1, -1);toIndex(v3, w, h, rotation, 0, 0, -1);float[] x = {v1.getX()-POINT_MARGIN, v2.getX(), v3.getX()};float[] y = {v1.getY()-POINT_MARGIN, v2.getY(), v3.getY()};mArrows.addPath(x, y);}{toIndex(v1, w, h, rotation, 2, 2, -1);toIndex(v2, w, h, rotation, 1, 1, -1);toIndex(v3, w, h, rotation, 1, 0, -1);float[] x = {v1.getX()-POINT_MARGIN, v2.getX(), v3.getX()};float[] y = {v1.getY()-POINT_MARGIN, v2.getY(), v3.getY()};mArrows.addPath(x, y);}if(TsMakeupManager.HAS_TS_MAKEUP) {toIndex(v1, w, h, rotation, 3, 1, -1);toIndex(v2, w, h, rotation, 3, 0, -1);float[] x = {v1.getX(), v2.getX()};float[] y = {v1.getY()-POINT_MARGIN*2, v2.getY()+POINT_MARGIN};mArrows.addPath(x, y);}if (!forCamera2) {toIndex(v1, w, h, rotation, 3, 4, -1);toIndex(v2, w, h, rotation, 3, 5, -1);toIndex(v3, w, h, rotation, 4, 6, -1);float[] x = {v1.getX(), v2.getX(), v3.getX()};float[] y = {v1.getY()+POINT_MARGIN, v2.getY(), v3.getY()-POINT_MARGIN};mArrows.addPath(x, y);}}
4.2修改菜單的位置
Snapdragon camera中把菜單的位置從上/下改爲左/右,修改位置: packages/apps/SnapdragonCamera/src/com/android/camera/ui/OneUICameraControls.java
調整位置到左右, 修改setLocation方法
private void setLocation(int w, int h) {int rotation = getUnifiedRotation();setLocationRight(mSceneModeSwitcher, false, 4);setLocationRight(mFilterModeSwitcher, false, 3);if (mIsVideoMode) {setLocationRight(mMute, false, 2);setLocationRight(mFlashButton, false, 1);setLocationRight(mPauseButton, true, 3);setLocationRight(mShutter, true , 2.15f);setLocationRight(mVideoShutter, true, 0.9f);setLocationRight(mExitBestPhotpMode ,true, 0);} else {setLocation(mFrontBackSwitcher, true, 2);setLocationRight(mFlashButton, false, 1);if (mIntentMode == CaptureModule.INTENT_MODE_CAPTURE) {setLocationRight(mShutter, true, 2.15f);setLocation(mCancelButton, false, 0.85f);} else if (mIntentMode == CaptureModule.INTENT_MODE_VIDEO) {setLocationRight(mVideoShutter, true, 0.9f);setLocation(mCancelButton, false, 0.85f);} else {setLocationRight(mShutter, true, 2.15f);setLocationRight(mPreview, true, 4);setLocationRight(mVideoShutter, true, 0.9f);}setLocationRight(mExitBestPhotpMode ,true, 0);}setLocationCustomBottom(mMakeupSeekBarLayout, 0, 1);setLocationRight(mProModeCloseButton, true, 0);layoutToast(mRefocusToast, w, h, rotation);}private void setLocationRight(View view, boolean right,float index){if(view == null){return;}int w = view.getMeasuredWidth();int h = view.getMeasuredHeight();float bW = mWidth / 5f;if(right){view.setX(bW * 4 + (bW - w) / 4 * 3);}else {view.setX((bW - w) / 4);}float bH = mHeight / 5f;view.setY(bH * index + (bH - h)/2);}
filters菜單與filters點擊按鈕重合了,修改位置:packages/apps/SnapdragonCamera/src/com/android/camera/CaptureUI.java文件中的addFilterMode方法
public void addFilterMode() {if (mSettingsManager.getValue(SettingsManager.KEY_COLOR_EFFECT) == null)return;......if (!portrait) {params = new ViewGroup.LayoutParams(size, FrameLayout.LayoutParams.MATCH_PARENT);mFilterLayout.setLayoutParams(params);((ViewGroup) mRootView).addView(mFilterLayout);mFilterLayout.setX(size/2); 修改坐標x的位置} else {
打開Premode後,Premode菜單與左右兩邊的菜單有重合。
修改:packages/apps/SnapdragonCamera/src/com/android/camera/ui/ProMode.java文件中的onLayout方法:
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {super.onLayout(changed, left, top, right, bottom);mWidth = right - left;mHeight = bottom - top;mCurveLeft = mWidth / 10 *2 ;mCurveRight = mWidth - mCurveLeft;mCurveHeight = mWidth / 7;mCurveY = (int) (mHeight * 0.67);float cx = (mCurveLeft + mCurveRight) / 2;mCurvePath.reset();mCurvePath.moveTo(mCurveLeft, mCurveY);mCurvePath.quadTo(cx, mCurveY - mCurveHeight, mCurveRight, mCurveY);mCurveMeasure = new PathMeasure(mCurvePath, false);}
修改packages/apps/SnapdragonCamera/src/com/android/camera/ui/OneUICameraControls.java 文件中的setProModeParameters和initializeProMode方法:
private void setProModeParameters() {ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(mWidth/ 5, mWidth/8);mExposureText.setLayoutParams(lp);mManualText.setLayoutParams(lp);mWhiteBalanceText.setLayoutParams(lp);mIsoText.setLayoutParams(lp);}private void initializeProMode(boolean promode) {if (!promode) {mProMode.setMode(ProMode.NO_MODE);mProModeLayout.setVisibility(INVISIBLE);mProModeCloseButton.setVisibility(INVISIBLE);return;}mProModeLayout.setVisibility(VISIBLE);mProModeCloseButton.setVisibility(VISIBLE);mProModeLayout.setY((mHeight - mBottom - mProModeLayout.getHeight()) / 3);if (mOrientation == 0 || mOrientation == 180) {mProModeLayout.setX(mWidth / 10);} else {mProModeLayout.setX((mWidth - mWidth / 8 * 4) / 2);}}
修改錄音時間Text位置:/res/layout/capture_module.xml
<FrameLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"><com.android.camera.ui.RotateLayoutandroid:id="@+id/recording_time_rect"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_alignParentTop="true"android:layout_alignParentLeft="true"android:visibility="gone"android:layout_marginLeft="128dp"android:layout_marginBottom="150dp"><includeandroid:id="@+id/labels"layout="@layout/viewfinder_labels_video"/></com.android.camera.ui.RotateLayout></FrameLayout>
修改Filters和Premode Text位置:/res/layout/scene_mode_label.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_marginBottom="30dp"android:layout_marginLeft="100dp"android:gravity="bottom">.......
</LinearLayout>