Android9.0 MTKフラット横画面変更(アプリ風景強制+パワーロゴ/オフチャージ横画面アニメーション+ + RecoveryUIランドスケープ)

これは、長い記事のコレクションを見てお勧めします

解体ステップ

screenOrientation =「ポートレート」プロパティ:1、アプリはアンドロイドを無視して、クロススクリーン表示を強制しました

図2に示すように、タッチスクリーンのスクリーン座標は、クロス修飾されています

3、ブートアニメーションの風景

4、起動ロゴ、横画面オフ充電アニメーション

5、RecoveryUI横屏

コード

1、アプリ強制クロススクリーンディスプレイ

rotationForOrientationLw()変更された、デフォルトの270に戻します

フレームワーク\ベース\サービス\コア\のJava \ COMアンドロイド\サーバー\ポリシー\のPhoneWindowManager.java \

 @Override
    public int rotationForOrientationLw(int orientation, int lastRotation, boolean defaultDisplay) {
        ....

        synchronized (mLock) {
        ...

        default:
                    // For USER, UNSPECIFIED, NOSENSOR, SENSOR and FULL_SENSOR,
                    // just return the preferred orientation we already calculated.
                    if (preferredRotation >= 0) {
                        return preferredRotation;
                    }
                    
                    // return Surface.ROTATION_0;
                    return Surface.ROTATION_270;//cczheng add for land scap
            }
        }
  }

デフォルトの属性は必須の活動SCREEN_ORIENTATION_LANDSCAPEです

フレームワーク\ベース\サービス\コア\のJava \ COMアンドロイド\サーバー\ \ WM \ WindowManagerService.java

boolean updateOrientationFromAppTokensLocked(int displayId, boolean forceUpdate) {
        long ident = Binder.clearCallingIdentity();
        try {
            final DisplayContent dc = mRoot.getDisplayContent(displayId);
            // final int req = dc.getOrientation();
            int req = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;//cczheng add for land scap
            if (req != dc.getLastOrientation() || forceUpdate) {
                if (DEBUG_ORIENTATION) {
                    Slog.v(TAG, "updateOrientation: req= " + req + ", mLastOrientation= "
                        + dc.getLastOrientation(), new Throwable("updateOrientation"));
                }
                dc.setLastOrientation(req);
                //send a message to Policy indicating orientation change to take
                //action like disabling/enabling sensors etc.,
                // TODO(multi-display): Implement policy for secondary displays.
                if (dc.isDefaultDisplay) {
                    mPolicy.setCurrentOrientationLw(req);
                }
                return dc.updateRotationUnchecked(forceUpdate);
            }
            return false;
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
    }

3へDisPlayContentデフォルトの表示mRotation(270)

フレームワーク\ベース\サービス\コア\のJava \ COMアンドロイド\サーバー\ \ WM \ DisplayContent.java

/**
     * Current rotation of the display.
     * Constants as per {@link android.view.Surface.Rotation}.
     *
     * @see #updateRotationUnchecked()
     */
    // private int mRotation = 0;
    private int mRotation = 3;//cczheng add for land scap

ディスプレイの真の、フリップ角にデフォルト値を変更Config_reverseDefaultRotation

フレームワーク\ベース\コア\ RES \ RES \値\ config.xmlに

<!-- If true, the direction rotation is applied to get to an application's requested
         orientation is reversed.  Normally, the model is that landscape is
         clockwise from portrait; thus on a portrait device an app requesting
         landscape will cause a clockwise rotation, and on a landscape device an
         app requesting portrait will cause a counter-clockwise rotation.  Setting
         true here reverses that logic. -->
    <!-- cczheng add for land scap -->
    <bool name="config_reverseDefaultRotation">true</bool> 

    <!-- The number of degrees to rotate the display when the keyboard is open.
         A value of -1 means no change in orientation by default. -->
    <!-- cczheng add for land scap -->
    <integer name="config_lidOpenRotation">270</integer>

図2に示すように、タッチスクリーンのスクリーン座標は、クロス修飾されています

スワップフレームの幅と高さ、方向270を設定します

ネイティブ\サービス\ SurfaceFlingerの\ DisplayDevice.cpp \枠組み


void DisplayDevice::setProjection(int orientation,
        const Rect& newViewport, const Rect& newFrame) {
    Rect viewport(newViewport);
    Rect frame(newFrame);

    const int w = mDisplayWidth;
    const int h = mDisplayHeight;

    Transform R;
    DisplayDevice::orientationToTransfrom(orientation, w, h, &R);

    if (!frame.isValid()) {
        // the destination frame can be invalid if it has never been set,
        // in that case we assume the whole display frame.
        //cczheng add for land scap
        // frame = Rect(w, h);
        if (w < h)
            frame = Rect(h, w);
        else
            frame = Rect(w, h);
    }
    ....

}

// clang-format off
DisplayDevice::DisplayDevice(
        const sp<SurfaceFlinger>& flinger,
        DisplayType type,
        int32_t hwcId,
        bool isSecure,
        const wp<IBinder>& displayToken,
        const sp<ANativeWindow>& nativeWindow,
        const sp<DisplaySurface>& displaySurface,
        std::unique_ptr<RE::Surface> renderSurface,
        int displayWidth,
        int displayHeight,
        bool hasWideColorGamut,
        const HdrCapabilities& hdrCapabilities,
        const int32_t supportedPerFrameMetadata,
        const std::unordered_map<ColorMode, std::vector<RenderIntent>>& hwcColorModes,
        int initialPowerMode)

      .....

    mHdrCapabilities = HdrCapabilities(types, maxLuminance, maxAverageLuminance, minLuminance);

    // initialize the display orientation transform.
    // setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
    //cczheng add for land scap
    setProjection(DisplayState::eOrientation270, mViewport, mFrame);
#ifdef MTK_SF_DEBUG_SUPPORT
    mFps = FpsCounterLoader::getInstance().create();
#endif
}

ネイティブ\サービス\ SurfaceFlingerの\ SurfaceFlinger.cpp \枠組み

void SurfaceFlinger::onInitializeDisplays() {
    // reset screen orientation and use primary layer stack
    Vector<ComposerState> state;
    Vector<DisplayState> displays;
    DisplayState d;
    d.what = DisplayState::eDisplayProjectionChanged |
             DisplayState::eLayerStackChanged;
    d.token = mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY];
    d.layerStack = 0;
    //d.orientation = DisplayState::eOrientationDefault;
    //cczheng add for land scap
    d.orientation = DisplayState::eOrientation270;
    d.frame.makeInvalid();
    d.viewport.makeInvalid();
    d.width = 0;
    d.height = 0;
    displays.add(d);

    ....
}

3、ブートアニメーションの風景

wとhのCreateSurfaceスワップ()

フレームワーク\ベース\ CMDS \ bootanimation \ BootAnimation.cpp

status_t BootAnimation::readyToRun() {
    mAssets.addDefaultAssets();

    sp<IBinder> dtoken(SurfaceComposerClient::getBuiltInDisplay(
            ISurfaceComposer::eDisplayIdMain));
    DisplayInfo dinfo;
    status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &dinfo);
    if (status)
        return -1;

    // create the native surface
    /*sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"),
            dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);*/

    //cczheng add for land scap  [S]
    sp<SurfaceControl> control;
    if(dinfo.w < dinfo.h)
        control = session()->createSurface(String8("BootAnimation"),
            dinfo.h, dinfo.w, PIXEL_FORMAT_RGB_565);
    else
        control = session()->createSurface(String8("BootAnimation"),
            dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);
    //cczheng add for land scap  [E]

    SurfaceComposerClient::Transaction t;
    t.setLayer(control, 0x40000000)
        .apply();

    .....

}

サプリメントの後ろのブートアニメーションの交換。

4、起動ロゴ、横画面オフ充電アニメーション

起動ロゴ画面解像度は、リソースフォルダの場所に対応するように定義されています

ベンダー\テック\独自\ブート可能\ブートローダ\ LK \プロジェクト\のxxxx.mkは、以下を参照してくださいません

デバイス\ mediateksample \ XXXX \ ProjectConfig.mk

MK BOOT_LOGO = WXGA

ベンダー/メディアテック/独自仕様/ブート可能/ブートローダー/ LKは/ dev /ロゴ/ WXGA内の場所に対応するリソースファイル

あなたは絵のWXGAで見ることができる縦画面で、wxganlはすでにクロススクリーンの映像です

ubWkNt.png

その後、我々はBOOT_LOGOにwxganlを変更します

次はまた、我々はそうでないHuaping現象があるでしょう、270の中に、まだ、角度表示を変更するために継続する必要があります

最初の写真は、ubootブート表示に対応します

ベンダー\テック\独自\ブート可能\ブートローダ\ LK \プラットフォーム\ mt6765の\のmt_logo.c

void init_fb_screen()
{
    .....

    // in JB2.MP need to allign width and height to 32 ,but jb5.mp needn't
    phical_screen.needAllign = 1;
    phical_screen.allignWidth = ALIGN_TO(CFG_DISPLAY_WIDTH, MTK_FB_ALIGNMENT);

    /* In GB, no need to adjust 180 showing logo ,for fb driver dealing the change */
    /* but in JB, need adjust it for screen 180 roration           */
    phical_screen.need180Adjust = 0;   // need sync with chip driver

    dprintf(INFO, "[lk logo: %s %d]MTK_LCM_PHYSICAL_ROTATION = %s\n",__FUNCTION__,__LINE__, MTK_LCM_PHYSICAL_ROTATION);

    if (0 == strncmp(MTK_LCM_PHYSICAL_ROTATION, "270", 3)) {
        phical_screen.rotation = 270;
    } else if (0 == strncmp(MTK_LCM_PHYSICAL_ROTATION, "90", 2)) {
        phical_screen.rotation = 90;
    } else if (0 == strncmp(MTK_LCM_PHYSICAL_ROTATION, "180", 3) && (phical_screen.need180Adjust == 1)) {
        phical_screen.rotation = 180;
    } else {
        phical_screen.rotation = 270;//cczheng add for land scap
    }

    ....

次の写真は、カーネルのブートディスプレイに対応します

ベンダー\テック\独自\外部\ libshowlogoの\のcharging_animation.cpp

int anim_fb_init(void)
{
     .....

    phical_screen.needAllign = 1;
    phical_screen.need180Adjust = 1;
    phical_screen.fb_size = fb_size;
    if (MTK_LOG_ENABLE == 1) {
        SLOGD("[libshowlogo: %s %d]MTK_LCM_PHYSICAL_ROTATION = %s\n",__FUNCTION__,__LINE__, MTK_LCM_PHYSICAL_ROTATION);
    }

    if(0 == strncmp(MTK_LCM_PHYSICAL_ROTATION, "270", 3))
    {
        phical_screen.rotation = 270;
    } else if(0 == strncmp(MTK_LCM_PHYSICAL_ROTATION, "90", 2)){
        phical_screen.rotation = 90;
    } else if(0 == strncmp(MTK_LCM_PHYSICAL_ROTATION, "180", 3) && (phical_screen.need180Adjust == 1)){
        phical_screen.rotation = 180;
    } else {
        phical_screen.rotation = 270;//cczheng add for land scap
    }
    if (MTK_LOG_ENABLE == 1) {
        SLOGD("[libshowlogo]phical_screen: width= %d,height= %d,bits_per_pixel =%d,needAllign = %d,allignWidth=%d rotation =%d ,need180Adjust = %d\n",
                phical_screen.width, phical_screen.height,
                phical_screen.bits_per_pixel, phical_screen.needAllign,
                phical_screen.allignWidth, phical_screen.rotation, phical_screen.need180Adjust);
        SLOGD("[libshowlogo: %s %d]show old animtion= 1, running show_animationm_ver %d\n",__FUNCTION__,__LINE__, show_animationm_ver);
        SLOGD("[libshowlogo: %s %d]draw_anim_mode = 1, running mode %d\n",__FUNCTION__,__LINE__, draw_anim_mode);
    }

    return 0;
}

充電アニメーション画像の転位現象場合は、主な理由は、グラフィックスレンダリングや画面のドットサイズの不一致が生じました。位置パラメータcust_display.hを調整することにより

AndroidのM後:/vendor/mediatek/proprietary/external/libshowlogo/cust_display.h

AndroidのM前:/vendor/mediatek/proprietary/bootable/bootloader/lk/target/${PROJECT}/include/target/cust_display.h

(1、次のように設定されている古いバージョンを調整するために、アニメーションの手法を使用して、

BAR_LEFT用の#define(215)
の#define BAR_TOP(156)
の#define BAR_RIGHT(265)
の#define BAR_BOTTOM(278)
描画ソフトウェアで述べた窓を備えた第一の画像点を開くために、ピクセルは、細胞境界に応じて調整されます。

ここで基準座標の原点は左上隅にあり、背景画像の左上隅には、これら四つの値は>従って右、左、BOTTOM> TOP決定座標左上隅に対するものである(0,0)である
ヒント:1)ドローソフトを開いて、選択表示- >ズーム- >絵が800%入れてカスタマイズ
2)表示を選択します。 - > showグリッド- >ズームを
使用すると、1つのピクセル見ることができるように
、新しいバージョンのアニメーションプログラムを使用して、(2次の設定を調整します。

#define CAPACITY_LEFT (278) 
#define CAPACITY_TOP (556)
#define CAPACITY_RIGHT (441)
#define CAPACITY_BOTTOM (817)

5、RecoveryUI横屏

書かれた記事を参照してくださいする前にMTKリカバリモードの風景の修正(6.0 + 8.1 + 9.0に適用されます)

図6に示すように、システムナビゲーションバーの位置調整、左画面navigationBarPositionにクロスデフォルト後

平らな項目としては、)、下に位置を変更する直接navigationBarPositionを(変更する必要はNAV_BAR_BOTTOMを返します。

フレームワーク\ベース\サービス\コア\のJava \ COMアンドロイド\サーバー\ポリシー\のPhoneWindowManager.java \

@NavigationBarPosition
    private int navigationBarPosition(int displayWidth, int displayHeight, int displayRotation) {
        //cchzneg annotaion for land scape
        /*if (mNavigationBarCanMove && displayWidth > displayHeight) {
            if (displayRotation == Surface.ROTATION_270) {
                return NAV_BAR_LEFT;
            } else {
                return NAV_BAR_RIGHT;
            }
        }*/
        return NAV_BAR_BOTTOM;
    }

そのような位置は、底部に変更したが、3つのボタンがレイアウト表示を変更するために、一緒に重畳さSystemUI

ここに画像を挿入説明

ベンダー\テック\独自\パッケージ\ APPS \ SystemUI \ SRC \ comのアンドロイド\ \ systemui \ステータスバー\電話\ NavigationBarView.java

private void updateRotatedViews() {
        //cczheng change rot0 rot90 for landscape
        mRotatedViews[Surface.ROTATION_0] =
                mRotatedViews[Surface.ROTATION_180] = findViewById(R.id.rot90);
                // mRotatedViews[Surface.ROTATION_180] = findViewById(R.id.rot0);
        mRotatedViews[Surface.ROTATION_270] =
                mRotatedViews[Surface.ROTATION_90] = findViewById(R.id.rot0);
                // mRotatedViews[Surface.ROTATION_90] = findViewById(R.id.rot90);        

        updateCurrentView();
    }

ちなみにその後、問題領域の多くをNavigationBarView戻るキーの下のデフォルトの高さを調整し、左

ベンダー\テック\独自\パッケージ\ APPS \ SystemUI \ SRC \ comのアンドロイド\ \ systemui \ステータスバー\電話\ NavigationBarInflaterView.java

private View createView(String buttonSpec, ViewGroup parent, LayoutInflater inflater) {
        View v = null;
        String button = extractButton(buttonSpec);
        if (LEFT.equals(button)) {
             //cchzheng change NAVSPACE to MENU_IME for small left back click area
            String s = Dependency.get(TunerService.class).getValue(NAV_BAR_LEFT, MENU_IME_ROTATE/*NAVSPACE*/);
            button = extractButton(s);
        } else if (RIGHT.equals(button)) {
            String s = Dependency.get(TunerService.class).getValue(NAV_BAR_RIGHT, MENU_IME_ROTATE);
            button = extractButton(s);
        }

        ...

フレームワーク\ベース\コア\ RES \ RES \値\ dimens.xml

 <!-- Height of the bottom navigation / system bar. -->
    <!--cczheng change 48dp to 30dp-->
    <dimen name="navigation_bar_height">30dp</dimen>

OK、それはそれだ、完璧な横画面アダプテーション

ここに画像を挿入説明

おすすめ

転載: www.cnblogs.com/cczheng-666/p/11689854.html