Android8.0 屏幕旋转180度

2023-05-16

一般手机只能旋转3个方向,这里将介绍如何让手机可以旋转180度,也就是上下颠倒。

1.静态方法
frameworks/base/core/res/res/values/config.xml
config_allowAllRotations通过这个来设置。

    <!-- Auto-rotation behavior -->

    <!-- If true, enables auto-rotation features using the accelerometer.
         Otherwise, auto-rotation is disabled.  Applications may still request
         to use specific orientations but the sensor is ignored and sensor-based
         orientations are not available.  Furthermore, all auto-rotation related
         settings are omitted from the system UI.  In certain situations we may
         still use the accelerometer to determine the orientation, such as when
         docked if the dock is configured to enable the accelerometer. -->
    <bool name="config_supportAutoRotation">true</bool>

    <!-- If true, the screen can be rotated via the accelerometer in all 4
         rotations as the default behavior. -->
    <bool name="config_allowAllRotations">true</bool>

2.动态方法
在手机确认要旋转后,就会走PhoneWindowManager.java的onProposedRotationChanged。

    class MyOrientationListener extends WindowOrientationListener {
        private final Runnable mUpdateRotationRunnable = new Runnable() {
            @Override
            public void run() {
                // send interaction hint to improve redraw performance
                mPowerManagerInternal.powerHint(PowerHint.INTERACTION, 0);
                updateRotation(false);
            }
        };

        MyOrientationListener(Context context, Handler handler) {
            super(context, handler);
        }

        @Override
        public void onProposedRotationChanged(int rotation) {
            if (localLOGV) Slog.v(TAG, "onProposedRotationChanged, rotation=" + rotation);
            mHandler.post(mUpdateRotationRunnable);
        }
    }

然后走

    void updateRotation(boolean alwaysSendConfiguration) {
        try {
            //set orientation on WindowManager
            mWindowManager.updateRotation(alwaysSendConfiguration, false);
        } catch (RemoteException e) {
            // Ignore
        }
    }

再走WindowManagerService.java的updateRotation。

    /**
     * Recalculate the current rotation.
     *
     * Called by the window manager policy whenever the state of the system changes
     * such that the current rotation might need to be updated, such as when the
     * device is docked or rotated into a new posture.
     */
    @Override
    public void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout) {
        updateRotationUnchecked(alwaysSendConfiguration, forceRelayout);
    }

再走

    private void updateRotationUnchecked(boolean alwaysSendConfiguration, boolean forceRelayout) {
        if(DEBUG_ORIENTATION) Slog.v(TAG_WM, "updateRotationUnchecked:"
                + " alwaysSendConfiguration=" + alwaysSendConfiguration
                + " forceRelayout=" + forceRelayout);

        Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "updateRotation");

        long origId = Binder.clearCallingIdentity();

        try {
            // TODO(multi-display): Update rotation for different displays separately.
            final boolean rotationChanged;
            final int displayId;
            synchronized (mWindowMap) {
                final DisplayContent displayContent = getDefaultDisplayContentLocked();
                Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "updateRotation: display");
                rotationChanged = displayContent.updateRotationUnchecked(
                        false /* inTransaction */);
                Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
                if (!rotationChanged || forceRelayout) {
                    displayContent.setLayoutNeeded();
                    Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER,
                            "updateRotation: performSurfacePlacement");
                    mWindowPlacerLocked.performSurfacePlacement();
                    Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
                }
                displayId = displayContent.getDisplayId();
            }

            if (rotationChanged || alwaysSendConfiguration) {
                Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "updateRotation: sendNewConfiguration");
                sendNewConfiguration(displayId);
                Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
            }
        } finally {
            Binder.restoreCallingIdentity(origId);
            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
        }
    }

再走DisplayContent.java的updateRotationUnchecked


    /**
     * Update rotation of the display.
     *
     * Returns true if the rotation has been changed.  In this case YOU MUST CALL
     * {@link WindowManagerService#sendNewConfiguration(int)} TO UNFREEZE THE SCREEN.
     */
    boolean updateRotationUnchecked(boolean inTransaction) {
        if (mService.mDeferredRotationPauseCount > 0) {
            // Rotation updates have been paused temporarily.  Defer the update until
            // updates have been resumed.
            if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Deferring rotation, rotation is paused.");
            return false;
        }

        ScreenRotationAnimation screenRotationAnimation =
                mService.mAnimator.getScreenRotationAnimationLocked(mDisplayId);
        if (screenRotationAnimation != null && screenRotationAnimation.isAnimating()) {
            // Rotation updates cannot be performed while the previous rotation change
            // animation is still in progress.  Skip this update.  We will try updating
            // again after the animation is finished and the display is unfrozen.
            if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Deferring rotation, animation in progress.");
            return false;
        }
        if (mService.mDisplayFrozen) {
            // Even if the screen rotation animation has finished (e.g. isAnimating
            // returns false), there is still some time where we haven't yet unfrozen
            // the display. We also need to abort rotation here.
            if (DEBUG_ORIENTATION) Slog.v(TAG_WM,
                    "Deferring rotation, still finishing previous rotation");
            return false;
        }

        if (!mService.mDisplayEnabled) {
            // No point choosing a rotation if the display is not enabled.
            if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Deferring rotation, display is not enabled.");
            return false;
        }

        final int oldRotation = mRotation;
        final int lastOrientation = mLastOrientation;
        final boolean oldAltOrientation = mAltOrientation;
        int rotation = mService.mPolicy.rotationForOrientationLw(lastOrientation, oldRotation);
        final boolean rotateSeamlessly = mService.mPolicy.shouldRotateSeamlessly(oldRotation,
                rotation);

        if (rotateSeamlessly) {
            final WindowState seamlessRotated = getWindow((w) -> w.mSeamlesslyRotated);
            if (seamlessRotated != null) {
                // We can't rotate (seamlessly or not) while waiting for the last seamless rotation
                // to complete (that is, waiting for windows to redraw). It's tempting to check
                // w.mSeamlessRotationCount but that could be incorrect in the case of
                // window-removal.
                return false;
            }
        }
        。。。。。。
}

最后走PhoneWindowManager.java的rotationForOrientationLw

    @Override
    public int rotationForOrientationLw(int orientation, int lastRotation) {
        if (false) {
            Slog.v(TAG, "rotationForOrientationLw(orient="
                        + orientation + ", last=" + lastRotation
                        + "); user=" + mUserRotation + " "
                        + ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED)
                            ? "USER_ROTATION_LOCKED" : "")
                        );

        //Aaron add
        mAllowAllRotations = -1;

        if (mForceDefaultOrientation) {
            return Surface.ROTATION_0;
        }

        synchronized (mLock) {
            int sensorRotation = mOrientationListener.getProposedRotation(); // may be -1
            if (sensorRotation < 0) {
                sensorRotation = lastRotation;
            }

            final int preferredRotation;
            if (mLidState == LID_OPEN && mLidOpenRotation >= 0) {
                // Ignore sensor when lid switch is open and rotation is forced.
                preferredRotation = mLidOpenRotation;
            } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR
                    && (mCarDockEnablesAccelerometer || mCarDockRotation >= 0)) {
                // Ignore sensor when in car dock unless explicitly enabled.
                // This case can override the behavior of NOSENSOR, and can also
                // enable 180 degree rotation while docked.
                preferredRotation = mCarDockEnablesAccelerometer
                        ? sensorRotation : mCarDockRotation;
            } else if ((mDockMode == Intent.EXTRA_DOCK_STATE_DESK
                    || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK
                    || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK)
                    && (mDeskDockEnablesAccelerometer || mDeskDockRotation >= 0)) {
                // Ignore sensor when in desk dock unless explicitly enabled.
                // This case can override the behavior of NOSENSOR, and can also
                // enable 180 degree rotation while docked.
                preferredRotation = mDeskDockEnablesAccelerometer
                        ? sensorRotation : mDeskDockRotation;
            } else if ((mHdmiPlugged || mWifiDisplayConnected) && mDemoHdmiRotationLock) {
                // Ignore sensor when plugged into HDMI when demo HDMI rotation lock enabled.
                // Note that the dock orientation overrides the HDMI orientation.
                preferredRotation = mDemoHdmiRotation;
            } else if (mWifiDisplayConnected && (mWifiDisplayCustomRotation > -1)) {
                // Ignore sensor when WFD is active and UIBC rotation is enabled
                 preferredRotation = mWifiDisplayCustomRotation;
            } else if (mHdmiPlugged && mDockMode == Intent.EXTRA_DOCK_STATE_UNDOCKED
                    && mUndockedHdmiRotation >= 0) {
                // Ignore sensor when plugged into HDMI and an undocked orientation has
                // been specified in the configuration (only for legacy devices without
                // full multi-display support).
                // Note that the dock orientation overrides the HDMI orientation.
                preferredRotation = mUndockedHdmiRotation;
            } else if (mDemoRotationLock) {
                // Ignore sensor when demo rotation lock is enabled.
                // Note that the dock orientation and HDMI rotation lock override this.
                preferredRotation = mDemoRotation;
            } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) {
                // Application just wants to remain locked in the last rotation.
                preferredRotation = lastRotation;
            } else if (!mSupportAutoRotation) {
                // If we don't support auto-rotation then bail out here and ignore
                // the sensor and any rotation lock settings.
                preferredRotation = -1;
            } else if ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_FREE
                            && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER
                                    || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
                                    || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
                                    || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
                                    || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER))
                    || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR
                    || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR
                    || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
                    || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) {
                // Otherwise, use sensor only if requested by the application or enabled
                // by default for USER or UNSPECIFIED modes.  Does not apply to NOSENSOR.
                if (mAllowAllRotations < 0) {
                    // Can't read this during init() because the context doesn't
                    // have display metrics at that time so we cannot determine
                    // tablet vs. phone then.

                    //这里注释掉原来的 添加自己修改的
                    //Aaron change
                    /*mAllowAllRotations = mContext.getResources().getBoolean(
                            com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0;*/
                    mAllowAllRotations = Global.getInt(mContext.getContentResolver(), Global.ALLOW_ALL_ROTATION_ON,0);
                    int enable = Global.getInt(mContext.getContentResolver(), Global.AUTO_ROTATION, 0);
                    if (enable != 1)
                        mAllowAllRotations = -1;
                }
                if (sensorRotation != Surface.ROTATION_180
                        || mAllowAllRotations == 1
                        || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR
                        || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER) {
                    // In VrMode, we report the sensor as always being in default orientation so:
                    // 1) The orientation doesn't change as the user moves their head.
                    // 2) 2D apps within VR show in the device's default orientation.
                    // This only overwrites the sensor-provided orientation and does not affect any
                    // explicit orientation preferences specified by any activities.
                    preferredRotation =
                            mPersistentVrModeEnabled ? Surface.ROTATION_0 : sensorRotation;
                } else {
                    preferredRotation = lastRotation;
                }
            } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED
                    && orientation != ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) {
                // Apply rotation lock.  Does not apply to NOSENSOR.
                // The idea is that the user rotation expresses a weak preference for the direction
                // of gravity and as NOSENSOR is never affected by gravity, then neither should
                // NOSENSOR be affected by rotation lock (although it will be affected by docks).
                preferredRotation = mUserRotation;
            } else {
                // No overriding preference.
                // We will do exactly what the application asked us to do.
                preferredRotation = -1;
            }

            switch (orientation) {
                case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
                    // Return portrait unless overridden.
                    if (isAnyPortrait(preferredRotation)) {
                        return preferredRotation;
                    }
                    return mPortraitRotation;

                case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
                    // Return landscape unless overridden.
                    if (isLandscapeOrSeascape(preferredRotation)) {
                        return preferredRotation;
                    }
                    return mLandscapeRotation;

                case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT:
                    // Return reverse portrait unless overridden.
                    if (isAnyPortrait(preferredRotation)) {
                        return preferredRotation;
                    }
                    return mUpsideDownRotation;

                case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE:
                    // Return seascape unless overridden.
                    if (isLandscapeOrSeascape(preferredRotation)) {
                        return preferredRotation;
                    }
                    return mSeascapeRotation;

                case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE:
                case ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE:
                    // Return either landscape rotation.
                    if (isLandscapeOrSeascape(preferredRotation)) {
                        return preferredRotation;
                    }
                    if (isLandscapeOrSeascape(lastRotation)) {
                        return lastRotation;
                    }
                    return mLandscapeRotation;

                case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT:
                case ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT:
                    // Return either portrait rotation.
                    if (isAnyPortrait(preferredRotation)) {
                        return preferredRotation;
                    }
                    if (isAnyPortrait(lastRotation)) {
                        return lastRotation;
                    }
                    return mPortraitRotation;

                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;
            }
        }
    }

这里主要就是修改mAllowAllRotations的值,虽然每次旋转都要走这个判断要不要选择180度,但是实际上就判断一次,因为mAllowAllRotations这个值变了之后就不会再走赋值的地方了,可以看代码。所以我们要每次都要去根据要不要选择180度来改变这个值,所以每次进来先mAllowAllRotations=-1,然后就会走到赋值的那个里面,进行赋值。

是否要旋转180度的数据库。

mAllowAllRotations = Global.getInt(mContext.getContentResolver(), Global.ALLOW_ALL_ROTATION_ON,0);

注意:如果先把180度关闭,打开自动选择,把手机选择180度,然后再打开180度开关,这时候屏幕不会选择180度,正确的,但是当你再关闭自动旋转的时候,屏幕会先选择180度,然后再旋转回来。有问题,所以多加了个判断。

当自动旋转打开的时候才能旋转180。数据库自己加的。

                    int enable = Global.getInt(mContext.getContentResolver(), Global.AUTO_ROTATION, 0);
                    if (enable != 1)
                        mAllowAllRotations = -1;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android8.0 屏幕旋转180度 的相关文章

  • AB升级之odex文件首次开机处理

    开启AB升级方案的项目 xff0c 因为很多需要升级的镜像都有两份 xff0c 所以存储空间比较浪费 为缓解此问题 xff0c 有个针对odex的优化方案 编译版本会生成两个system镜像 xff1a system img和system
  • Android Bluetooth HCI log 详解

    0 引子 对于蓝牙开发者来说 xff0c 通过HCI log可以帮助我们更好地分析问题 xff0c 理解蓝牙协议 xff0c 就好像网络开发一定要会使用Wireshark分析网络协议一样 本篇主要介绍HCI log的作用 如何抓取一份HCI
  • imx6ull开发板调试nfs环境配置+运行hello程序

    20210314 43 imx6ull开发板nfs环境配置 1 设置git邮箱和用户名 wang 64 wang virtual machine git config global user name 34 snaking616 34 wa
  • 网络编程6:线程池简介

    1 线程池相关结构体 struct threadpool t pthread mutex t lock 用于锁住本结构体 pthread mutex t thread counter 记录忙状态线程个数de琐 busy thr num pt
  • 网络编程7:本地套接字

    1 基于UDP的网络编程 1 1 TCP通信和UDP通信各自的优缺点 TCP xff1a 面向连接的 xff0c 可靠数据包传输 对于不稳定的网络层 xff0c 采取完全弥补的通信方式 丢包重传 优点 xff1a 稳定 数据流量稳定 速度稳
  • Effectinve Python的59个有效方法中第38条使用Lock防止数据竞争中运行错误的问题

    系统 xff1a Ubuntu1804 在Jupyter Notebook中运行 xff0c 使用的anaconda下的python3 7 6 在代码运行中出现错误的问题 xff0c 源代码如下 xff1a 代码为书中样例代码 xff0c
  • 4相直流步进电机工作原理+温度PID算法

    四相步进电机原理图 https tech hqew com circuit 511266 步进电机 xff08 四相五线为例子 xff09 步进角度和工作原理介绍 https blog csdn net qq 34824576 articl
  • imx6ull-mini开发板调试环境汇总

    一 安装USB驱动 相关页面 xff1a https www silabs com developers usb to uart bridge vcp drivers 下载链接 xff1a CP210x Universal Windows
  • OrCAD Capture CIS的使用方法

    软件版本 xff1a Cadence allegro 16 5 参考教程 xff1a 于争博士 Cadence视频教程 第1讲 课程介绍 xff0c 学习方法 xff0c 了解CADENCE软件 第2讲 创建工程 xff0c 创建元件库 主
  • PCI-E 1x, 4x, 8x, 16x 接口定义

    1 PCI E插槽及金手指实物图 xff08 1 xff09 PCI E插槽 从上至下依次为PCI E 4X PCI E 16X PCI E 1X xff08 2 xff09 PCI E金手指 PCI E 1X金手指PCI E 4X金手指P
  • Lattice USB下载线使用说明及CPLD程序烧写

    目录 1 下载并安装ispLEVER Classic 软件 1 1 软件下载 1 2 软件的安装 2 Lattice USB下载线介绍 2 1 实物介绍
  • E-96系列电阻值代号对照表

    1 说明 2 E 96系列电阻值代号对照表 E 96系列 标准阻值表阻值代码阻值代码阻值代码阻值代码阻值代码阻值代码1001X10001A1 00K01B10 0K01C100K01D1M01E10 202X10202A1 02K02B10
  • Altium Designer10铺铜技巧小结

    目录 1 铜皮操作分类 2 铺铜技巧 2 1 过孔处理 2 1 1 过孔与绿油 2 1 2 过孔的十字连接与直接连接 2 2 设置灌铜安全间距 xff08 Clearance xff09 2 3 设置空心灌铜 2 4 调整灌铜形状 2 5
  • 基于MFC的USB上位机开发(3)数据传输模块

    延伸阅读 基于MFC的USB上位机开发 1 概述 基于MFC的USB上位机开发 2 速度测试模块 基于MFC的USB上位机开发 3 数据传输模块 基于MFC的USB上位机开发 4 环路模块 基于MFC的USB上位机开发 5 下环路模块 目录
  • 虚拟现实的起源、发展、爆发与沉淀

    虚拟现实的三生三世 闲来无事翻篇外文 xff0c 本博主并非故意蹭热点 xff08 奸笑 xff09 xff0c 结尾我会细说为何是三生三世 xff0c 不是五生五世 xff1a 虚拟现实远早于这个概念被创造和形式化之前 在这篇描写虚拟现实
  • 基于卷积的密度统计(一)密度图的生成

    在基于卷积的人数统计中 xff0c 一种是最后回归整张图的人数 xff0c 即输入图像 xff0c 输出人群个数 xff0c 另外一种是回归人群分布密度图 xff0c 即输入图像 xff0c 得到的是密度分布 显然得到密度分布的人数统计方法
  • Python使用国内镜像

    国内镜像地址 xff1a 阿里云 xff1a https mirrors aliyun com pypi simple 清华 xff1a https pypi tuna tsinghua edu cn simple中国科技大学 https
  • [RK3568 Android11] 开发之蓝牙(AP6275S)

    目录 前言 一 设备树dts配置 二 蓝牙打不开 三 蓝牙打开成功 四 修改蓝牙设备名称
  • XFCE菜单列表

    vim etc xdg xfce4 panel xfce4 menu 19 rc use default menu 61 true menu file 61 etc xdg menus xfce applications menu icon
  • X的DISPLAY=:0.0

    ZZ http blog 163 com caizf1987 64 126 blog static 13212128020104611592660 在Linux Unix类操作系统上 DISPLAY用来设置将图形显示到何处 直接登陆图形界面

随机推荐

  • 国外服务器上玩游戏延迟很高,什么原因造成的?

    在国外服务器玩游戏为什么延迟很高 有的比较热门的国际游戏 xff0c 为了玩家通常都会将整个游戏的区服划分为亚服 欧服 美服 东南亚服 韩服等等 xff0c 这主要是为了玩家有个良好的游戏体验 xff0c 那为什么在外服 国外服务器 上玩游
  • 公司抽奖小程序(自定义名单,空格控制滚动、抽奖,可作弊,可满足千人团队, 带可执行程序下载及源代码)

    内含 抽奖小程序 及 名单生成工具 使用时将两个小程序放在 同一目录下 先用名单生成工具生成名单 打开工具 按照提示输入要创建的参与抽奖的人数 输入每个人的编号及姓名 每行一个编号 空格 姓名 打开程序 复制粘贴即可 先用excel或者tx
  • 大厂面试之JAVA核心技能:Slipped Conditions

    聊聊Splipped Condtion 定义一个更现实的例子解决Slipped Conditions问题 定义 所谓Slipped conditions xff0c 就是说 xff0c 从一个线程检查某一特定条件到该线程操作此条件期间 xf
  • 一文带你彻底搞懂Docker中的cgroup

    前言 进程在系统中使用CPU 内存 磁盘等计算资源或者存储资源还是比较随心所欲的 xff0c 我们希望对进程资源利用进行限制 xff0c 对进程资源的使用进行追踪 这就让cgroup的出现成为了可能 xff0c 它用来统一将进程进行分组 x
  • 一文彻底搞懂Docker中的namespace

    什么是namespace namespace是对全局系统资源的一种封装隔离 这样可以让不同namespace的进程拥有独立的全局系统资源 这样改变一个namespace的系统资源只会影响当前namespace中的进程 xff0c 对其它na
  • 带你玩转多进程编程(一)

    前言 之前用加法器的例子一文带你轻松掌握多种范式讲解了多种范式的封装差异得到了很多童鞋的阅读 这次我再通过对进程的封装来给大家继续加深讲解下关于这几种编程范式的差异吧 结构化设计 相对于pthread create 函数 xff0c for
  • 【网易面试题】如何实现一个线程安全的shared_ptr智能指针

    题目描述 网易一面遇到过这么一个题目 xff0c 面试官要求自己实现一个线程安全的shared ptr智能指针 题目分析 可能很多人只知道shared ptr是C 43 43 11模块库的头文件定义的一个智能指针 xff0c 即shared
  • Ubuntu命令行安装Teamviewer

    1 预备安装 更新32位架构 sudo dpkg add architecture i386 更新安装 sudo apt get update 2 使用deb安装 官网下载 xff1a https www teamviewer com en
  • 阿里云数据湖分析急招实习生

    团队介绍 OSS 对象存储的概念可能对很多同学相对比较陌生 xff0c 但其实和大家紧密相关 xff0c 因为整个阿里集团业务以及阿里云外部客户的视频 图片 JS和CSS等资源全部都存储在我们这里 xff0c 可以说国内每天使用互联网应用的
  • 源码剖析Redis中如何使用跳表的

    前言 阿里云今年春招校招面试题 xff0c 面试官问Redis在是如何使用跳表的 xff1f 让很多同学赶到很头疼 今天我们就来讲一讲吧 Sorted Set的结构 redis的数据类型中有序集合 xff08 sorted set xff0
  • 多进程生产者消费者框架设计

    前言 介绍了进程如何基于面向对象的封装 xff0c 本章我们基于封装好的Process类来实现一种无锁版的生产者和消费者框架 xff0c 用它实现了高性能文件拷贝功能 读这篇文章之前大家可以想一下如果是你 xff0c 你会怎么设计这样的框架
  • golang实现简单rpc调用

    RPC通信过程 RPC的通信过程网上介绍很多 xff0c 这里就不在单独介绍了 xff0c 具体过程如下 xff1a 1 Client以本地调用的方式发起调用 xff1b 2 Client stub收到调用后负责将被调用的方法名 参数等打包
  • 一文彻底搞懂leveldb架构

    leveldb leveldb是一个写性能十分优秀的存储引擎 xff0c 是典型的LSM tree的实现 LSM的核心思想是为了换取最大的写性能而放弃掉部分读性能 那么 xff0c 为什么leveldb写性能高 xff1f 简单来说它就是尽
  • flink核心之watermarker

    背景介绍 xff1a 现在的社会 xff0c 人们产生越来越多的数据 xff0c 而数据对每个人人都产生了巨大的影响 比如你去银行贷款 xff0c 那么必然银行要对你做信用评估 xff0c 会涉及到大数据画像等数据分析 比如美团外卖 xff
  • 我在华为度过的 “两辈子”(学习那些在大厂表现优秀的人)

    七 是一个很神奇的数字 生物学中认为组成身体的细胞 xff0c 七年会彻底更新一遍 xff1b 李笑来说 xff0c 七年就是一辈子 xff0c 每一辈子至少要习得一个重要的技能 xff0c 进而获得不可逆的重生 xff1b 白居易写道 x
  • 【Effective Java】大厂实战之考虑以静态工厂方法代替构造方法

    图片 Item1 考虑以静态工厂方法代替构造方法 Item1 考虑以静态工厂方法代替构造方法 缺点1 只提供静态工厂方法的话 xff0c 该类就无法被继承 xff08 子类化 xff09 缺点2 API的查找比较麻烦 常见静态工厂方法的命名
  • 一文搞懂leveldb写操作

    前言 leveldb一直也它优秀的写性能而文明 xff0c 本篇文章我们就来分析下leveldb的写流程 来搞懂为什么它的写性能如此优秀 整理流程 leveldb一次写入分为两部分 xff1a 第一步先将写操作写入日志 第二步将写操作应用到
  • 来聊聊对象文件网关和分布式文件存储的区别

    前言 大家都知道 xff0c 存储系统一般分为块存储 对象存储和文件存储三种 其中文件存储的使用最广泛 xff0c 个人电脑 NAS 大到传统的HPC 大数据平台等等 这些都是以使用文件接口为主 最近几年 xff0c 由于成本低 存储空间大
  • Ubuntu中文件属性以及所属用户问题

    1 xff0c 查看文件属性 xff0c 命令如下 xff1a 查看当前目录下某个文件属性 ls l lt file name gt 查看当前目录下文件属性 ls l 查看所有当前文件下属性 ls al 在开始的 rwxr xr x 为该文
  • Android8.0 屏幕旋转180度

    一般手机只能旋转3个方向 xff0c 这里将介绍如何让手机可以旋转180度 xff0c 也就是上下颠倒 1 静态方法 frameworks base core res res values config xml config allowAl