Android Framework开发知识点整理

临时打开或关闭SeLinux。

复制代码
adb root
adb shell setenforce 0    // 开SELinux,设置成模式permissive
adb shell setenforce 1    // 关SELinux,设置成模式enforce
adb shell getenforce      // 获取当前SELinux状态

代码上关闭SeLinux。

Android_source/system/core/init/selinux.cpp

复制代码
bool IsEnforcing() {
    return false;
    // if (ALLOW_PERMISSIVE_SELINUX) {
    //     return StatusFromProperty() == SELINUX_ENFORCING;
    // }
    // return true;
}

替换默认的桌面背景。

/qssi14/frameworks/base/core/res/res/drawable-sw600dp-nodpi drawable-nodpi 等 文件夹下的

里的 default_wallpaper 图片资源

修改SeLinux权限:

UM.9.15/device/qcom/sepolicy_vndr/generic/vendor/common/system_app.te platform_app.te 等文件。

SELinux(或SEAndroid)将app划分为主要三种类型(根据user不同,也有其他的domain类型):

1)untrusted_app 第三方app,没有android平台签名,没有system权限

2)platform_app 有android平台签名,没有system权限

3)system_app 有android平台签名和system权限

从上面划分,权限等级,理论上:untrusted_app < platform_app < system_app

可以通过 ps -Z 查看 进程的 类型。

复制代码
bengal_515:/ $ ps -Z
LABEL                          USER           PID  PPID        VSZ    RSS WCHAN            ADDR S NAME                       
u:r:shell:s0                   shell         8083  1785   12389340   3604 __do_sys_+          0 S sh
u:r:shell:s0                   shell         8087  8083   12369728   4940 0                   0 R ps

设置分辨率: adb shell wm density 320

查看设备分辨参数:

adb shell dumpsys window displays

复制代码
WINDOW MANAGER DISPLAY CONTENTS (dumpsys window displays)
  Display: mDisplayId=0 (organized)
    init=1200x1920 360dpi mMinSizeOfResizeableTaskDp=220 base=1200x1920 320dpi cur=1920x1200 app=1920x1104 rng=1200x1056-1920x1776
    deferred=false mLayoutNeeded=false mTouchExcludeRegion=SkRegion((0,0,1920,1200))

  mLastOrientationSource=WindowedMagnification:0:31@213375944
  deepestLastOrientationSource=ActivityRecord{2dc78b8 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher t7}
  overrideConfig={1.0 ?mcc0mnc [en_US] ldltr sw600dp w960dp h528dp 320dpi lrg long land finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1920, 1200) mAppBounds=Rect(0, 0 - 1920, 1104) mMaxBounds=Rect(0, 0 - 1920, 1200) mDisplayRotation=ROTATION_90 mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_90} as.2 s.290 fontWeightAdjustment=0}
  mLayoutSeq=313
  mCurrentFocus=Window{797caa5 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher}
  mFocusedApp=ActivityRecord{2dc78b8 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher t7}

  mHoldScreenWindow=null
  mObscuringWindow=Window{e60d5b0 u0 com.android.systemui.wallpapers.ImageWallpaper}
  mLastWakeLockHoldingWindow=null
  mLastWakeLockObscuringWindow=null

  displayId=0
  mWallpaperTarget=Window{797caa5 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher}
  mLastWallpaperX=0.0 mLastWallpaperY=0.5

  Display areas in top down Z order:
    * Leaf:38:38
    * HideDisplayCutout:32:37
      * OneHanded:34:37
        * FullscreenMagnification:34:37
          * Leaf:34:37
      * FullscreenMagnification:33:33
        * Leaf:33:33
      * OneHanded:32:32
        * Leaf:32:32
    * WindowedMagnification:0:31
      * HideDisplayCutout:26:31
        * OneHanded:26:31
          * FullscreenMagnification:29:31
            * Leaf:29:31
          * Leaf:28:28
          * FullscreenMagnification:26:27
            * Leaf:26:27
      * Leaf:24:25
      * HideDisplayCutout:18:23
        * OneHanded:18:23
          * FullscreenMagnification:18:23
            * Leaf:18:23
      * OneHanded:17:17
        * FullscreenMagnification:17:17
          * Leaf:17:17
      * HideDisplayCutout:16:16
        * OneHanded:16:16
          * FullscreenMagnification:16:16
            * Leaf:16:16
      * OneHanded:15:15
        * FullscreenMagnification:15:15
          * Leaf:15:15
      * HideDisplayCutout:0:14
        * OneHanded:0:14
          * ImePlaceholder:13:14
            * ImeContainer
          * FullscreenMagnification:0:12
            * Leaf:3:12
            * DefaultTaskDisplayArea (organized)
            * Leaf:0:1

  Task display areas in top down Z order:
    TaskDisplayArea DefaultTaskDisplayArea
      overrideConfig={0.0 ?mcc0mnc ?localeList ?layoutDir ?swdp ?wdp ?hdp ?density ?lsize ?long ?ldr ?wideColorGamut ?orien ?uimode ?night ?touch ?keyb/?/? ?nav/? winConfig={ mBounds=Rect(0, 0 - 0, 0) mAppBounds=null mMaxBounds=Rect(0, 0 - 0, 0) mDisplayRotation=undefined mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=undefined} ?fontWeightAdjustment}
      mLastFocusedRootTask=Task{b52ec74 #1 type=home}
      Application tokens in top down Z order:
      * Task{b52ec74 #1 type=home U=0 visible=true visibleRequested=true mode=fullscreen translucent=false sz=1}
        bounds=[0,0][1920,1200]
        * Task{b3c6864 #7 type=home I=com.android.launcher3/com.android.searchlauncher.SearchLauncher U=0 rootTaskId=1 visible=true visibleRequested=true mode=fullscreen translucent=false sz=1}
          bounds=[0,0][1920,1200]
          * ActivityRecord{2dc78b8 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher t7}
      * Task{e7c53d #2 type=undefined U=0 visible=false visibleRequested=false mode=fullscreen translucent=true sz=2}
        bounds=[0,0][1920,1200]
        * Task{2ec9487 #4 type=undefined U=0 rootTaskId=2 visible=false visibleRequested=false mode=multi-window translucent=true sz=0}
          bounds=[1920,0][2880,1200]
        * Task{cdd48c7 #3 type=undefined U=0 rootTaskId=2 visible=false visibleRequested=false mode=multi-window translucent=true sz=0}
          bounds=[0,0][1920,1200]
      * Task{67ee977 #13 type=standard A=1000:com.android.settings.root U=0 visible=false visibleRequested=false mode=fullscreen translucent=true sz=2}
        bounds=[0,0][1920,1200]
        * TaskFragment{41d3a03 mode=multi-window organizerUid=1000 organizerProc=com.android.settings adjacent=TaskFragment{ab58414 mode=multi-window}}
          bounds=[698,0][1920,1200]
          * ActivityRecord{4a4afb9 u0 com.android.settings/.Settings$NetworkDashboardActivity t13}
        * TaskFragment{ab58414 mode=multi-window organizerUid=1000 organizerProc=com.android.settings adjacent=TaskFragment{41d3a03 mode=multi-window}}
          bounds=[0,0][698,1200]
          * ActivityRecord{5d8ff76 u0 com.android.settings/.Settings t13}

  no ScreenRotationAnimation 

  rootHomeTask=Task=1

  PinnedTaskController
    mIsImeShowing=false
    mImeHeight=0
    mMinAspectRatio=0.41841003
    mMaxAspectRatio=2.39

  DisplayFrames w=1920 h=1200 r=1

  DisplayPolicy
    mCarDockEnablesAccelerometer=true mDeskDockEnablesAccelerometer=true
    mDockMode=EXTRA_DOCK_STATE_UNDOCKED mLidState=LID_ABSENT
    mAwake=true mScreenOnEarly=true mScreenOnFully=true
    mKeyguardDrawComplete=true mWindowManagerDrawComplete=true
    mHdmiPlugged=false
    mLastBehavior=DEFAULT
    mShowingDream=false mDreamingLockscreen=false
    mStatusBar=Window{ec1dcb3 u0 StatusBar}
    mExpandedPanel=Window{44695b1 u0 NotificationShade}
    isKeyguardShowing=false
    mNavigationBar=Window{67a9157 u0 NavigationBar0}
    mNavBarOpacityMode=0
    mNavigationBarCanMove=false
    mNavigationBarPosition=4
    mTopGestureHost=Window{ec1dcb3 u0 StatusBar}
    mBottomGestureHost=Window{67a9157 u0 NavigationBar0}
    mFocusedWindow=Window{797caa5 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher}
    mTopFullscreenOpaqueWindowState=Window{797caa5 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher}
    mSystemBarColorApps={ActivityRecord{2dc78b8 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher t7}}
    mNavBarColorWindowCandidate=Window{797caa5 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher}
    mNavBarBackgroundWindow=Window{797caa5 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher}
    mLastStatusBarAppearanceRegions=
      AppearanceRegion{ bounds=[0,0][1920,1200]}
    mLastLetterboxDetails=
    mStatusBarBackgroundWindows=
      Window{797caa5 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher}
    mTopIsFullscreen=false
    mForceShowNavigationBarEnabled=false mAllowLockscreenWhenOn=false
    mRemoteInsetsControllerControlsSystemBars=false
    mDecorInsetsInfo:
      ROTATION_0={nonDecorInsets=[0,0][0,96], configInsets=[0,48][0,96], nonDecorFrame=[0,0][1200,1824], configFrame=[0,48][1200,1824]}
      ROTATION_90={nonDecorInsets=[0,0][0,96], configInsets=[0,48][0,96], nonDecorFrame=[0,0][1920,1104], configFrame=[0,48][1920,1104]}
      ROTATION_180={nonDecorInsets=[0,0][0,96], configInsets=[0,48][0,96], nonDecorFrame=[0,0][1200,1824], configFrame=[0,48][1200,1824]}
      ROTATION_270={nonDecorInsets=[0,0][0,96], configInsets=[0,48][0,96], nonDecorFrame=[0,0][1920,1104], configFrame=[0,48][1920,1104]}
    SystemGestures:
      mDisplayCutoutTouchableRegionSize=0
      mSwipeStartThreshold=Rect(48, 48 - 48, 48)
      mSwipeDistanceThreshold=48
    Looper state:
      Looper (android.ui, tid 22) {72be8d2}
        (Total messages: 0, polling=true, quitting=false)

  DisplayRotation
    mCurrentAppOrientation=SCREEN_ORIENTATION_NOSENSOR
    mLastOrientation=5
    mRotation=1 mDeferredRotationPauseCount=0
    mLandscapeRotation=ROTATION_90 mSeascapeRotation=ROTATION_270
    mPortraitRotation=ROTATION_0 mUpsideDownRotation=ROTATION_180
    mSupportAutoRotation=true
    WindowOrientationListener
      mEnabled=true
      mCurrentRotation=ROTATION_0
      mSensorType=null
      mSensor={Sensor name="Device Orientation  Wakeup", vendor="qualcomm", version=1, type=27, maxRange=1.0, resolution=1.0, power=0.025, minDelay=0}
      mRate=2
      OrientationSensorJudge
        mDesiredRotation=ROTATION_0
        mProposedRotation=ROTATION_0
        mTouching=false
        mTouchEndedTimestampNanos=859711548040
        mLastRotationResolution=0

    mCarDockRotation=-1 mDeskDockRotation=-1
    mUserRotationMode=USER_ROTATION_LOCKED mUserRotation=ROTATION_90 mCameraRotationMode=0 mAllowAllRotations=unknown
    mDemoHdmiRotation=ROTATION_90 mDemoHdmiRotationLock=false mUndockedHdmiRotation=-1
    mLidOpenRotation=-1
    mFixedToUserRotation=false

  InputConsumers:
    name=recents_animation_input_consumer pid=3364 user=UserHandle{0}

  WindowInsetsStateController
    InsetsState
      mDisplayFrame=Rect(0, 0 - 1920, 1200)
      mDisplayCutout=DisplayCutout{insets=Rect(0, 0 - 0, 0) waterfall=Insets{left=0, top=0, right=0, bottom=0} boundingRect={Bounds=[Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0)]} cutoutPathParserInfo={CutoutPathParserInfo{displayWidth=0 displayHeight=0 physicalDisplayWidth=0 physicalDisplayHeight=0 density={0.0} cutoutSpec={} rotation={0} scale={0.0} physicalPixelDisplaySizeRatio={0.0}}}}
      mRoundedCorners=RoundedCorners{[RoundedCorner{position=TopLeft, radius=0, center=Point(0, 0)}, RoundedCorner{position=TopRight, radius=0, center=Point(0, 0)}, RoundedCorner{position=BottomRight, radius=0, center=Point(0, 0)}, RoundedCorner{position=BottomLeft, radius=0, center=Point(0, 0)}]}
      mRoundedCornerFrame=Rect(0, 0 - 0, 0)
      mPrivacyIndicatorBounds=PrivacyIndicatorBounds {static bounds=Rect(1728, 0 - 1892, 48) rotation=1}
      mDisplayShape=DisplayShape{ spec=1237991957 displayWidth=1200 displayHeight=1920 physicalPixelDisplaySizeRatio=1.0 rotation=1 offsetX=0 offsetY=0 scale=1.0}
        InsetsSource id=abe50000 type=statusBars frame=[0,0][1920,48] visible=true flags= insetsRoundedCornerFrame=false
        InsetsSource id=abe50005 type=mandatorySystemGestures frame=[0,0][1920,48] visible=true flags= insetsRoundedCornerFrame=false
        InsetsSource id=abe50006 type=tappableElement frame=[0,0][1920,48] visible=true flags= insetsRoundedCornerFrame=false
        InsetsSource id=df770001 type=navigationBars frame=[0,1104][1920,1200] visible=true flags= insetsRoundedCornerFrame=false
        InsetsSource id=df770004 type=systemGestures frame=[0,0][0,0] visible=true flags= insetsRoundedCornerFrame=false
        InsetsSource id=df770005 type=mandatorySystemGestures frame=[0,1104][1920,1200] visible=true flags= insetsRoundedCornerFrame=false
        InsetsSource id=df770006 type=tappableElement frame=[0,1104][1920,1200] visible=true flags= insetsRoundedCornerFrame=false
        InsetsSource id=df770024 type=systemGestures frame=[0,0][0,0] visible=true flags= insetsRoundedCornerFrame=false
        InsetsSource id=3 type=ime frame=[0,0][0,0] visible=false flags= insetsRoundedCornerFrame=false
    Control map:
      Window{797caa5 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher}:
        InsetsSourceControl: {3 mType=ime mSurfacePosition=Point(0, 54) mInsetsHint=Insets{left=0, top=0, right=0, bottom=0}}
        InsetsSourceControl: {abe50000 mType=statusBars initiallyVisible mSurfacePosition=Point(0, 0) mInsetsHint=Insets{left=0, top=48, right=0, bottom=0}}
        InsetsSourceControl: {df770001 mType=navigationBars initiallyVisible mSurfacePosition=Point(0, 1104) mInsetsHint=Insets{left=0, top=0, right=0, bottom=96}}
    InsetsSourceProviders:
      ImeInsetsSourceProvider
        mSource=InsetsSource id=3 type=ime frame=[0,0][0,0] visible=false flags= insetsRoundedCornerFrame=false
        mSourceFrame=Rect(0, 1104 - 1920, 1200)
        mControl=InsetsSourceControl mId=3 mType=ime mLeash=Surface(name=Surface(name=326e581 InputMethod)/@0x98db180 - animation-leash of insets_animation)/@0xbec615e mInitiallyVisible=false mSurfacePosition=Point(0, 54) mInsetsHint=Insets{left=0, top=0, right=0, bottom=0} mSkipAnimationOnce=false
        mIsLeashReadyForDispatching=true
        mWindowContainer=Window{326e581 u0 InputMethod}
        mAdapter=ControlAdapter mCapturedLeash=Surface(name=Surface(name=326e581 InputMethod)/@0x98db180 - animation-leash of insets_animation)/@0xbec615e
        mControlTarget=Window{797caa5 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher}
        mImeShowing=false
      InsetsSourceProvider
        mSource=InsetsSource id=df770024 type=systemGestures frame=[0,0][0,0] visible=true flags= insetsRoundedCornerFrame=false
        mSourceFrame=Rect(0, 0 - 0, 0)
        mIsLeashReadyForDispatching=true
        mWindowContainer=Window{67a9157 u0 NavigationBar0}
      InsetsSourceProvider
        mSource=InsetsSource id=df770006 type=tappableElement frame=[0,1104][1920,1200] visible=true flags= insetsRoundedCornerFrame=false
        mSourceFrame=Rect(0, 1104 - 1920, 1200)
        mIsLeashReadyForDispatching=true
        mWindowContainer=Window{67a9157 u0 NavigationBar0}
      InsetsSourceProvider
        mSource=InsetsSource id=df770005 type=mandatorySystemGestures frame=[0,1104][1920,1200] visible=true flags= insetsRoundedCornerFrame=false
        mSourceFrame=Rect(0, 1104 - 1920, 1200)
        mIsLeashReadyForDispatching=true
        mWindowContainer=Window{67a9157 u0 NavigationBar0}
      InsetsSourceProvider
        mSource=InsetsSource id=df770004 type=systemGestures frame=[0,0][0,0] visible=true flags= insetsRoundedCornerFrame=false
        mSourceFrame=Rect(0, 0 - 0, 0)
        mIsLeashReadyForDispatching=true
        mWindowContainer=Window{67a9157 u0 NavigationBar0}
      InsetsSourceProvider
        mSource=InsetsSource id=df770001 type=navigationBars frame=[0,1104][1920,1200] visible=true flags= insetsRoundedCornerFrame=false
        mSourceFrame=Rect(0, 1104 - 1920, 1200)
        mOverrideFrames={2011=Rect(0, 1104 - 1920, 1200)}
        mControl=InsetsSourceControl mId=df770001 mType=navigationBars mLeash=Surface(name=Surface(name=67a9157 NavigationBar0)/@0x5e3ce62 - animation-leash of insets_animation)/@0x604493f mInitiallyVisible=true mSurfacePosition=Point(0, 1104) mInsetsHint=Insets{left=0, top=0, right=0, bottom=96} mSkipAnimationOnce=false
        mIsLeashReadyForDispatching=true
        mWindowContainer=Window{67a9157 u0 NavigationBar0}
        mAdapter=ControlAdapter mCapturedLeash=Surface(name=Surface(name=67a9157 NavigationBar0)/@0x5e3ce62 - animation-leash of insets_animation)/@0x604493f
        mControlTarget=Window{797caa5 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher}
      InsetsSourceProvider
        mSource=InsetsSource id=abe50006 type=tappableElement frame=[0,0][1920,48] visible=true flags= insetsRoundedCornerFrame=false
        mSourceFrame=Rect(0, 0 - 1920, 48)
        mIsLeashReadyForDispatching=true
        mWindowContainer=Window{ec1dcb3 u0 StatusBar}
      InsetsSourceProvider
        mSource=InsetsSource id=abe50005 type=mandatorySystemGestures frame=[0,0][1920,48] visible=true flags= insetsRoundedCornerFrame=false
        mSourceFrame=Rect(0, 0 - 1920, 48)
        mIsLeashReadyForDispatching=true
        mWindowContainer=Window{ec1dcb3 u0 StatusBar}
      InsetsSourceProvider
        mSource=InsetsSource id=abe50000 type=statusBars frame=[0,0][1920,48] visible=true flags= insetsRoundedCornerFrame=false
        mSourceFrame=Rect(0, 0 - 1920, 48)
        mControl=InsetsSourceControl mId=abe50000 mType=statusBars mLeash=Surface(name=Surface(name=ec1dcb3 StatusBar)/@0x513bb7a - animation-leash of insets_animation)/@0x3de920c mInitiallyVisible=true mSurfacePosition=Point(0, 0) mInsetsHint=Insets{left=0, top=48, right=0, bottom=0} mSkipAnimationOnce=false
        mIsLeashReadyForDispatching=true
        mWindowContainer=Window{ec1dcb3 u0 StatusBar}
        mAdapter=ControlAdapter mCapturedLeash=Surface(name=Surface(name=ec1dcb3 StatusBar)/@0x513bb7a - animation-leash of insets_animation)/@0x3de920c
        mControlTarget=Window{797caa5 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher}

source ./build/envsetup.sh // 初始化环境

fastboot flash splash splash-a110-land.img //更新开机画面

fastboot flash boot boot.img //product 下的boot.img

========================================================================

./build_sm6115.sh --qfil-full --打包命令

./build_sm6115.sh --all --编译命令

d6115_all.sh --刷机命令

build_sm6115.sh命令:

复制代码
#--all 默认是GKI
#--kernel-debug 单独编译kernel和打包vendor_boot.img
#--kernle 是单独编译kernel
#--abl 单独编译abl并进行签名
#--super 进行最后的super打包

set -e -o pipefail

build_path=$PWD

###### secboot related code ######
#Expected script name and base line name
EXPECTED_SCRIPT_NAME="build_sm6115_sc200u.sh"
EXPECTED_SECBOOT_ENABLED_PLAT_NAME="SC682A_SC200U"
SECBOOT_ENABLED_PLAT_NAMES_FILE="./Unpacking_Tool/secboot_enabled_plat_names.txt"
# get the name of current script's name
SCRIPT_NAME=$(basename "$0")
echo "SCRIPT_NAME:$SCRIPT_NAME"

if [ "$SCRIPT_NAME" = "$EXPECTED_SCRIPT_NAME" ]; then
    if [ -f "$SECBOOT_ENABLED_PLAT_NAMES_FILE" ]; then
        if grep -Fxq "$EXPECTED_SECBOOT_ENABLED_PLAT_NAME" "$SECBOOT_ENABLED_PLAT_NAMES_FILE"; then
            echo "$EXPECTED_SECBOOT_ENABLED_PLAT_NAME has been found!"
            export SEC_FLG=1
        else
            echo "$EXPECTED_SECBOOT_ENABLED_PLAT_NAME not found!"
        fi
    else
        echo "$SECBOOT_ENABLED_PLAT_NAMES_FILE not found!"
    fi
fi
###### secboot related code ######
##################################################################################
# Qssi build
##################################################################################
function build_qssi()
{
(	cd ./qssi14/
	source build/envsetup.sh && lunch qssi-userdebug && bash build.sh $j_arg dist --qssi_only |& tee qssi_makelog_$(date +%Y%m%d_%H%M%S).txt
)
}

function build_qssi_user()
{
(	cd ./qssi14/
	source build/envsetup.sh && lunch qssi-user && bash build.sh $j_arg dist --qssi_only |& tee qssi_makelog_$(date +%Y%m%d_%H%M%S).txt
)
}

##################################################################################
# Target build
##################################################################################
function build_target()
{
(	
	rm -rf target/kernel_platform/out/msm-kernel-bengal-gki/msm-kernel/arch/arm64/boot/dts/vendor/qcom/
	rm -rf target/kernel_platform/out/msm-kernel-bengal-consolidate/msm-kernel/arch/arm64/boot/dts/vendor/qcom/
	rm -rf target/device/qcom/bengal-kernel/
	rm -rf target/out/target/product/bengal_515/obj/DLKM_OBJ/vendor/qcom/proprietary/
	rm -rf target/out/target/product/bengal_515/obj/DLKM_OBJ/vendor/qcom/opensource/audio-kernel/

	cd ./target/kernel_platform
	cd ./msm-kernel/arch/arm64/boot/dts/

	#如果文件链接不存在, 则创建
	if [ ! -L vendor ]
	then
		ln -s ../../../../../qcom/proprietary/devicetree/ vendor
	fi

	cd -
	BUILD_CONFIG=./msm-kernel/build.config.msm.bengal ./build/all-variants.sh  "./build/build.sh" |& tee kernel_platform_$(date +%Y%m%d_%H%M%S).txt
	cd ../
	source build/envsetup.sh && lunch bengal_515-userdebug
	bash kernel_platform/build/android/prepare_vendor.sh bengal gki
	bash build.sh $j_arg dist --target_only 2>&1 | tee build-target_$(date +%Y%m%d_%H%M%S).txt
)
}

function build_target_user()
{
(	
	rm -rf target/kernel_platform/out/msm-kernel-bengal-gki/msm-kernel/arch/arm64/boot/dts/vendor/qcom/
	rm -rf target/kernel_platform/out/msm-kernel-bengal-consolidate/msm-kernel/arch/arm64/boot/dts/vendor/qcom/
	rm -rf target/device/qcom/bengal-kernel/
	rm -rf target/out/target/product/bengal_515/obj/DLKM_OBJ/vendor/qcom/proprietary/
	rm -rf target/out/target/product/bengal_515/obj/DLKM_OBJ/vendor/qcom/opensource/audio-kernel/

	cd ./target/kernel_platform
	cd ./msm-kernel/arch/arm64/boot/dts/

	#如果文件链接不存在, 则创建
	if [ ! -L vendor ]
	then
		ln -s ../../../../../qcom/proprietary/devicetree/ vendor
	fi

	cd -
	BUILD_CONFIG=./msm-kernel/build.config.msm.bengal ./build/all-variants.sh  "./build/build.sh" |& tee kernel_platform_$(date +%Y%m%d_%H%M%S).txt
	cd ../
	source build/envsetup.sh && lunch bengal_515-user
	bash kernel_platform/build/android/prepare_vendor.sh bengal gki
	bash build.sh $j_arg dist --target_only 2>&1 | tee build-target_$(date +%Y%m%d_%H%M%S).txt
)
}

function build_target_debug()
{
(	cd ./target/kernel_platform
	cd ./msm-kernel/arch/arm64/boot/dts/
	if [ ! -L vendor ]
	then
		ln -s ../../../../../qcom/proprietary/devicetree/ vendor
	fi
	cd -
	BUILD_CONFIG=./msm-kernel/build.config.msm.bengal ./build/all-variants.sh  "./build/build.sh" |& tee kernel_platform_$(date +%Y%m%d_%H%M%S).txt
	cd ../
	source build/envsetup.sh && lunch bengal_515-userdebug
	bash kernel_platform/build/android/prepare_vendor.sh bengal gki
	bash build.sh $j_arg dist --target_only 2>&1 | tee build-target_debug_$(date +%Y%m%d_%H%M%S).txt
)
}

function build_vendor()
{
(	cd ./target/
	source build/envsetup.sh && lunch bengal_515-userdebug
	bash kernel_platform/build/android/prepare_vendor.sh bengal gki
	bash build.sh $j_arg dist --target_only 2>&1 | tee build-vendor_$(date +%Y%m%d_%H%M%S).txt
)
}

function build_vendor_user()
{
(	cd ./target/
	source build/envsetup.sh && lunch bengal_515-user
	bash kernel_platform/build/android/prepare_vendor.sh bengal gki
	bash build.sh $j_arg dist --target_only 2>&1 | tee build-vendor_$(date +%Y%m%d_%H%M%S).txt
)
}

##################################################################################
# Kernel build
##################################################################################
function build_kernel_platform()
{
(	cd ./target/kernel_platform/
	cd msm-kernel/arch/arm64/boot/dts/
	if [ ! -L vendor ]
	then
		ln -s ../../../../../qcom/proprietary/devicetree/ vendor
	fi
	cd -
	BUILD_CONFIG=./msm-kernel/build.config.msm.bengal ./build/all-variants.sh "./build/build.sh" |& tee kernel_platform_$(date +%Y%m%d_%H%M%S).txt
)
}

function build_kernel_platform_debug()
{
(	cd ./target/kernel_platform/
	cd msm-kernel/arch/arm64/boot/dts/
	if [ ! -L vendor ]
	then
		ln -s ../../../../../qcom/proprietary/devicetree/ vendor
	fi
	cd -
	BUILD_CONFIG=./msm-kernel/build.config.msm.bengal ./build/all-variants.sh "./build/build.sh" |& tee kernel_platform_$(date +%Y%m%d_%H%M%S).txt
	#cd ../
	#echo "gki start!!!!!!"
	#bash kernel_platform/build/android/prepare_vendor.sh bengal gki
	#echo "vendorbootimage start!!!!!!"
	#source build/envsetup.sh && lunch bengal_515-userdebug
	#make $j_arg vendorbootimage 2>&1 | tee build-vendorboot_$(date +%Y%m%d_%H%M%S).txt
	cd ../
	source build/envsetup.sh && lunch bengal_515-userdebug
	RECOMPILE_KERNEL=1 kernel_platform/build/android/prepare_vendor.sh bengal gki
	make $j_arg dtboimage
	make $j_arg bootimage
	make $j_arg vendorbootimage
)
}

##################################################################################
# Selinux build
##################################################################################
function build_selinux_debug()
{
(	cd ./target/kernel_platform/
	cd msm-kernel/arch/arm64/boot/dts/
	if [ ! -L vendor ]
	then
		ln -s ../../../../../qcom/proprietary/devicetree/ vendor
	fi
	cd -
	#BUILD_CONFIG=./msm-kernel/build.config.msm.bengal ./build/all-variants.sh "./build/build.sh" |& tee kernel_platform_$(date +%Y%m%d_%H%M%S).txt
	#cd ../
	#echo "gki start!!!!!!"
	#bash kernel_platform/build/android/prepare_vendor.sh bengal gki
	#echo "vendorbootimage start!!!!!!"
	#source build/envsetup.sh && lunch bengal_515-userdebug
	#make $j_arg vendorbootimage 2>&1 | tee build-vendorboot_$(date +%Y%m%d_%H%M%S).txt
	cd ../
	source build/envsetup.sh && lunch bengal_515-userdebug
	RECOMPILE_KERNEL=1 kernel_platform/build/android/prepare_vendor.sh bengal gki
	make $j_arg selinux_policy
)
}

##################################################################################
# Abl build
##################################################################################
function build_abl()
{
(	cd ./target/kernel_platform/
	BUILD_CONFIG=./msm-kernel/build.config.msm.bengal ./build/all-variants.sh "./build/build_abl.sh" |& tee abl_$(date +%Y%m%d_%H%M%S).txt
	mv out/msm-kernel-bengal-gki/abl-userdebug/unsigned_abl.elf out/msm-kernel-bengal-gki/abl-userdebug/abl.elf
	echo "abl build done!!!"
	cd ../
	cd vendor/
	python qcom/proprietary/sectools/sectools.py secimage -i ../kernel_platform/out/msm-kernel-bengal-gki/abl-userdebug/abl.elf -c qcom/proprietary/sectools/config/kamorta/kamorta_secimage.xml -g abl -sa
	cp qcom/proprietary/sectools/secimage_output/kamorta/abl/abl.elf ../kernel_platform/out
)
}

##################################################################################
# Super build
##################################################################################
function build_super()
{
(	
	cd ./target/
	#python vendor/qcom/opensource/core-utils/build/build_image_standalone.py --no_tmp --skip_qiifa  --image super --qssi_build_path ../qssi14/ --target_build_path ./ --merged_build_path ./ --target_lunch bengal_515
	python vendor/qcom/opensource/core-utils/build/build_image_standalone.py --no_tmp  --image super --qssi_build_path ../qssi14/ --target_build_path ./ --merged_build_path ./ --target_lunch bengal_515 --output_ota
)
}

##################################################################################
# Misc build
##################################################################################

function build_rm()
{
(	 
	rm -rf target/device/qcom/bengal-kernel/
	rm -rf target/out/
	rm -rf target/kernel_platform/out/
	#rm -rf target/out/target/product/bengal_515/obj/DLKM_OBJ/vendor/qcom/opensource/audio-kernel/
	rm -rf qssi14/out/ 
)
}

build_qfil()
{
(	
	cd $build_path
	echo "link android image to unpacking tool **********"
	cd Unpacking_Tool/LA.VENDOR.13.2.1.r2/LINUX/android/	
	if [ ! -L out ]
	then
		ln -s ../../../../target/out/ ./
	fi
	cd -

	echo "restore default partition to build customer package only update android image **********"
	cp Unpacking_Tool/Kamorta_IOT.LA.1.0/common/config/emmc/partition_external_kamorta_update.xml Unpacking_Tool/Kamorta_IOT.LA.1.0/common/config/emmc/partition_external_kamorta.xml
	cp Unpacking_Tool/Kamorta_IOT.LA.1.0/common/config/ufs/partition_external_kamorta_update.xml Unpacking_Tool/Kamorta_IOT.LA.1.0/common/config/ufs/partition_external_kamorta.xml

	echo "build qfil start >>>>>>>>>>>>>>>>>"
	cd ./Unpacking_Tool/
	time ./build_sm6115_64bit.sh

	if [ $? -ne 0 ]; then
		echo "error: build qfil failed **********"
		exit 1
	else
		echo "build qfil success >>>>>>>>>>>>>>>>>"
	fi
)
}

build_qfil_full()
{
(
	cd $build_path
	echo "link android image to unpacking tool **********"
	cd Unpacking_Tool/LA.VENDOR.13.2.1.r2/LINUX/android/	
	if [ ! -L out ]
	then
		ln -s ../../../../target/out/ ./
	fi
	cd -

	echo "restore default partition to build customer package only update android image **********"
	cp Unpacking_Tool/Kamorta_IOT.LA.1.0/common/config/emmc/partition_external_kamorta_full.xml Unpacking_Tool/Kamorta_IOT.LA.1.0/common/config/emmc/partition_external_kamorta.xml
	cp Unpacking_Tool/Kamorta_IOT.LA.1.0/common/config/ufs/partition_external_kamorta_full.xml Unpacking_Tool/Kamorta_IOT.LA.1.0/common/config/ufs/partition_external_kamorta.xml

	echo "build qfil start >>>>>>>>>>>>>>>>>"
	cd ./Unpacking_Tool/
	time ./build_sm6115_64bit.sh
	if [ $? -ne 0 ]; then
		echo "error: build qfil failed **********"
		exit 1
	else
		echo "build qfil success >>>>>>>>>>>>>>>>>"
	fi
)
}

function build_help()
{
(	
echo "
buildxxx.sh --help 				# print help info 
buildxxx.sh --qssi 				# build qssi 
buildxxx.sh --target 				# build target ,include clean and rebuild kernel
buildxxx.sh --target-user 			# build target user 
buildxxx.sh --target-debug 			# only build target, don't delete kernel build temp file
buildxxx.sh --kernel 				# build kernel image
buildxxx.sh --kernel-debug  			# rebuild kernel image
buildxxx.sh --vendor 				# build vendor,don't include kernel
buildxxx.sh --vendor-user 			# build vendor user,don't include kernel
buildxxx.sh --abl 				# build abl
buildxxx.sh --super 				# generate super.img
buildxxx.sh --all 				# build all image
buildxxx.sh --user 				# build all user image
buildxxx.sh --debug				# build all image, just don't clean kernel
buildxxx.sh --rm 				# delete out dir
buildxxx.sh --qfil 				# generate qfil image
buildxxx.sh --qfil-full 			# generate qfil full image
buildxxx.sh --selinux-debug 			# build selinux 
buildxxx.sh --newkey 				# generate new secureboot key
"
)
}

build_type="--all"
j_arg="-j40"

while [ $# -gt 0 ];do
	case "$1" in
		"--help"|"--qssi"|"--qssi-user"|\
		"--target"|"--target-user"|"--vendor"|"--vendor-user"|\
		"--kernel"|"--kernel-debug"|\
		"--abl"|"--super"|"--selinux-debug"|\
		"--all"|"--user"|"--debug"|\
		"--rm"|"--qfil"|"--qfil-full"|"--newkey")
			build_type=$1
			;;
		"-j"[0-9]*)
			j_arg=$1
			;;
	esac
	case "$2" in
		"-j"[0-9]*)
			j_arg=$2
			;;
	esac
	shift
done

echo $0 "$build_type" "$j_arg"

case "$build_type" in
	"--help")
		build_help
		;;
	"--qssi")
		build_qssi $j_arg
		;;
	"--qssi-user")
		build_qssi_user $j_arg
		;;
	"--target")
		build_target $j_arg
		;;
	"--target-user")
		build_target_user $j_arg
		;;
	"--target-debug")
		build_target_debug $j_arg
		;;
	"--kernel")
		build_kernel_platform $j_arg
		;;
	"--kernel-debug")
		build_kernel_platform_debug $j_arg
		;;
	"--vendor")
		build_vendor $j_arg
		;;
	"--vendor-user")
		build_vendor_user $j_arg
		;;
	"--abl")
		build_abl
		;;
	"--super")
		build_super
		;;
	"--all")
		[[ ! -z $SEC_FLG && -f Unpacking_Tool/sign_file_SC682A_SC200U.sh  ]] && ./Unpacking_Tool/sign_file_SC682A_SC200U.sh --apstart 64bit_SC200U_AP
		build_qssi $j_arg
		build_target $j_arg
		build_super
		[[ ! -z $SEC_FLG && -f Unpacking_Tool/sign_file_SC682A_SC200U.sh  ]] && ./Unpacking_Tool/sign_file_SC682A_SC200U.sh --apend 64bit_SC200U_AP
		;;
	"--user")
		[[ ! -z $SEC_FLG && -f Unpacking_Tool/sign_file_SC682A_SC200U.sh  ]] && ./Unpacking_Tool/sign_file_SC682A_SC200U.sh --apstart 64bit_SC200U_AP
		build_qssi_user $j_arg
		build_target_user $j_arg
		build_super
		[[ ! -z $SEC_FLG && -f Unpacking_Tool/sign_file_SC682A_SC200U.sh  ]] && ./Unpacking_Tool/sign_file_SC682A_SC200U.sh --apend 64bit_SC200U_AP
		;;
	"--debug")
		build_qssi $j_arg
		build_target_debug $j_arg
		build_super
		;;
	"--rm")
		build_rm
		;;
	"--selinux-debug")
		build_selinux_debug
		;;
	"--qfil")
		build_qfil
		;;
	"--qfil-full")
		build_qfil_full
		;;
	"--newkey")
		[[ -f Unpacking_Tool/sign_file_SC682A_SC200U.sh  ]] && ./Unpacking_Tool/sign_file_SC682A_SC200U.sh --newkey 64bit-no-wifi-only
		;;
esac
相关推荐
tang_vincent1 小时前
linux 虚拟内存映射原理与启动初始化过程
linux
k***82511 小时前
图文详述:MySQL的下载、安装、配置、使用
android·mysql·adb
毕设源码-朱学姐1 小时前
【开题答辩全过程】以 个人健康管理系统为例,包含答辩的问题和答案
java·spring boot
局外人Inside1 小时前
PostProcessingBeanDeserializer 使用指南
java
郑州光合科技余经理1 小时前
基于PHP:海外版同城O2O系统多语言源码解决方案
java·开发语言·git·spring cloud·uni-app·php·uniapp
IT_Octopus1 小时前
Java GZip 压缩实践 +实践思考 +进一步压榨性能和存储方案思考:Protobuf+ GZip
java·spring boot
越来越无动于衷2 小时前
HTTP 文件服务器 Windows 开机自启动全维度总结
服务器·windows·http
赖small强2 小时前
【Linux C/C++开发】 GCC -g 调试参数深度解析与最佳实践
linux·c语言·c++·gdb·-g
小七有话说2 小时前
DevUI与企业级中后台系统融合:低代码表单构建器实战
android·rxjava·devui