Android Binder——Parcel数据处理流程(二十二)

        上一篇我们对 Parcel 进行了简单的介绍。这里我们选两个代表性的数据类型(String 和 Binder)来分析 Parcel 的处理流程,对应的接口分别是:writeString() / readString() 和 writeStrongBinder() / readStrongBinder() 。接着上一篇从 Parcel C++ 类的构造过程开始分析。

一、源码分析

1、Parcel.cpp

源码位置:frameworks/native/libs/binder/Parcel.cpp。

Parcel::Parcel()
{
    LOG_ALLOC("Parcel %p: constructing", this);
    initState();
}

void Parcel::initState()
{
    LOG_ALLOC("Parcel %p: initState", this);
    mError = NO_ERROR; // 错误码
    mData = nullptr; // Parcel中存储的数据,注意它是一个uint8_t类型指针
    mDataSize = 0; // Parcel中已经存储的数据大小
    mDataCapacity = 0; // 最大存储能力
    mDataPos = 0; //数据指针
    ALOGV("initState Setting data size of %p to %zu", this, mDataSize);
    ALOGV("initState Setting data pos of %p to %zu", this, mDataPos);
    mSession = nullptr;
    mObjects = nullptr;
    mObjectsSize = 0;
    mO

相关推荐

  1. Android Binder——Parcel数据处理流程

    2024-04-27 11:48:04       30 阅读
  2. SpringMVC原理分析()--异常处理流程

    2024-04-27 11:48:04       29 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-27 11:48:04       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-27 11:48:04       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-27 11:48:04       87 阅读
  4. Python语言-面向对象

    2024-04-27 11:48:04       96 阅读

热门阅读

  1. Codeforces Round 934 (Div. 2) D

    2024-04-27 11:48:04       37 阅读
  2. Go语言中,常用的同步机制

    2024-04-27 11:48:04       34 阅读
  3. c++day4

    c++day4

    2024-04-27 11:48:04      26 阅读
  4. 【Redis 开发】分布式锁中的常见问题和Lua脚本

    2024-04-27 11:48:04       28 阅读
  5. 使用 NVM 管理 Node.js 版本

    2024-04-27 11:48:04       32 阅读
  6. leetcode 27 原地删除有序数组

    2024-04-27 11:48:04       32 阅读