当前位置: 首页 > news >正文

android system secure,持久化修改Android模拟器的system分区

对Android的模拟器,如果要修改其system分区里的文件,除了remount之外,还需要对数据进行持久化——因为默认情况下emulator会以只读的形式加载system.img,即便remount之后对其进行的修改也不会实际被保存下来。

下面介绍一种简单的方法对数据进行持久化:

1. 创建一个AVD,在这个例子里,我们用Android 4.3.1,命名为Android4.3.1。

2. 将SDK(E:\Android\sdk\system-images\android-18\default\armeabi-v7a)下这个系统的system.img,kernel-qemu,ramdisk.img文件拷贝至emulator的目录下一份E:\Android\sdk\.android\avd\Android4.3.1.avd.目录结构如下:

8738c07b7a995371f7c18427ccc5284f.png

3.修改hardware-qemu.ini文件的kernel.path,disk.ramdisk.path ,disk.systemPartition.initPath字段路径

hw.cpu.arch = arm

hw.cpu.model = cortex-a8

hw.cpu.ncore = 2

hw.ramSize = 500

hw.screen = touch

hw.mainKeys = true

hw.trackBall = false

hw.keyboard = true

hw.keyboard.lid = false

hw.keyboard.charmap = qwerty2

hw.dPad = false

hw.gsmModem = true

hw.gps = true

hw.battery = true

hw.accelerometer = true

hw.audioInput = true

hw.audioOutput = true

hw.sdCard = true

hw.sdCard.path = E:\Android\sdk\.android\avd\Android4.3.1.avd/sdcard.img

disk.cachePartition = true

disk.cachePartition.path = E:\Android\sdk\.android\avd\Android4.3.1.avd/cache.img

disk.cachePartition.size = 66m

hw.lcd.width = 480

hw.lcd.height = 800

hw.lcd.depth = 16

hw.lcd.density = 240

hw.lcd.backlight = true

hw.gpu.enabled = false

hw.gpu.mode = auto

hw.gpu.blacklisted = no

hw.initialOrientation = portrait

hw.camera.back = none

hw.camera.front = none

vm.heapSize = 32

hw.sensors.light = true

hw.sensors.pressure = true

hw.sensors.humidity = true

hw.sensors.proximity = true

hw.sensors.magnetic_field = true

hw.sensors.orientation = true

hw.sensors.temperature = true

hw.useext4 = true

kernel.path = E:\Android\sdk\.android\avd\Android4.3.1.avd\/kernel-qemu

kernel.parameters = androidboot.hardware=goldfish android.checkjni=1

kernel.newDeviceNaming = no

kernel.supportsYaffs2 = yes

disk.ramdisk.path = E:\Android\sdk\.android\avd\Android4.3.1.avd\/ramdisk.img

disk.systemPartition.initPath = E:\Android\sdk\.android\avd\Android4.3.1.avd\/system.img

disk.systemPartition.size = 218m

disk.dataPartition.path = E:\Android\sdk\.android\avd\Android4.3.1.avd/userdata-qemu.img

disk.dataPartition.size = 500m

avd.name = Android4.3.1

4. 手工指定挂载参数地启动它:

C:\Users\Administrator>emulator -avd Android4.3.1 -qemu -nand system,size=0x1f400000,file=E:\Android\sdk\.android\avd\Android4.3.1.avd\system.img

其中,0x1f400000是指给/system分区500MB的空间。

4. 系统启动后,adb remount一下,然后通过adb shell mount可以看到system分区已经变为rw了。

C:\Users\Administrator>adb shell mount

rootfs / rootfs ro 0 0

tmpfs /dev tmpfs rw,nosuid,mode=755 0 0

devpts /dev/pts devpts rw,mode=600 0 0

proc /proc proc rw 0 0

sysfs /sys sysfs rw 0 0

none /acct cgroup rw,cpuacct 0 0

tmpfs /mnt/secure tmpfs rw,mode=700 0 0

tmpfs /mnt/asec tmpfs rw,mode=755,gid=1000 0 0

tmpfs /mnt/obb tmpfs rw,mode=755,gid=1000 0 0

none /dev/cpuctl cgroup rw,cpu 0 0

/dev/block/mtdblock0 /system yaffs2 rw 0 0

/dev/block/mtdblock2 /data yaffs2 rw,nosuid,nodev 0 0

/dev/block/mtdblock3 /cache yaffs2 rw,nosuid,nodev 0 0

/dev/block/vold/179:0 /storage/sdcard vfat rw,dirsync,nosuid,nodev,noexec,uid=10

00,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8

859-1,shortname=mixed,utf8,errors=remount-ro 0 0

/dev/block/vold/179:0 /mnt/secure/asec vfat rw,dirsync,nosuid,nodev,noexec,uid=1

000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso

8859-1,shortname=mixed,utf8,errors=remount-ro 0 0

tmpfs /storage/sdcard/.android_secure tmpfs ro,size=0k,mode=000 0 0

5. 现在可以对/system分区做持久化修改。

6. 修改完成后,关掉模拟器。之后启动即可。

emulator说明如下:

C:\Users\Administrator>emulator -help-disk-images

The emulator needs several key image files to run appropriately.

Their exact location depends on whether you're using the emulator

from the Android SDK, or not (more details below).

The minimal required image files are the following:

kernel-qemu the emulator-specific Linux kernel image

ramdisk.img the ramdisk image used to boot the system

system.img the *initial* system image

userdata.img the *initial* data partition image

It will also use the following writable image files:

userdata-qemu.img the persistent data partition image

system-qemu.img an *optional* persistent system image

cache.img an *optional* cache partition image

sdcard.img an *optional* SD Card partition image

snapshots.img an *optional* state snapshots image

If you use a virtual device, its content directory should store

all writable images, and read-only ones will be found from the

corresponding platform/add-on directories. See -help-sdk-images

for more details.

If you are building from the Android build system, you should

have ANDROID_PRODUCT_OUT defined in your environment, and the

emulator shall be able to pick-up the right image files automatically.

See -help-build-images for more details.

If you're neither using the SDK or the Android build system, you

can still run the emulator by explicitely providing the paths to

*all* required disk images through a combination of the following

options: -sysdir, -datadir, -kernel, -ramdisk, -system, -data, -cache

-sdcard and -snapstorage.

The actual logic being that the emulator should be able to find all

images from the options you give it.

For more detail, see the corresponding -help-entry.

Other related options are:

-init-data Specify an alternative *initial* user data image

-wipe-data Copy the content of the *initial* user data image

(userdata.img) into the writable one (userdata-qemu.img)

-no-cache do not use a cache partition, even if one is available.

-no-snapstorage do not use a state snapshot image, even if one is available.

http://www.xdnf.cn/news/840601.html

相关文章:

  • 《吸血鬼猎人D》观后感
  • 绝地求生PUBGerror是什么意思/error报错解决办法
  • 华为手机鸿蒙系统怎么报名,鸿蒙2.0系统怎么报名?鸿蒙系统官网2.0报名教程介绍...
  • 【办公自动化】Window电脑如何设置定时任务计划
  • 独角数卡 搭建个人发卡平台保姆级教程n .
  • 游戏行业洞察必看 | 中国网络游戏市场规模及发展趋势
  • CET-6 六级考试必备范文10篇
  • 一个简单的WEB网页制作作业——黑色的山河旅行社网站(5个页面)HTML+CSS+JavaScript
  • 蓝桥杯 算法提高 9-3摩尔斯电码(Java解题)
  • 一、三分钟学会计算机基础知识
  • 深蓝儿童的预言
  • VOB文件解析
  • 【视频】网友恶搞360版大腕《红衣疯人院》
  • Linux学习路线图及常逛自学网站推荐
  • Exchange企业实战技巧(11)新建用户及邮箱管理
  • Android四大组件————广播简单案例
  • 2023韩顺平java从入门到精通151G 视频教程 下载
  • qq农场,不开通牧场也能给好友添加牧草(数据抓包分析,实现源码,图片讲解)
  • nodejs下载安装以及npm、yarn安装及配置教程
  • 开心的小明(dp)
  • DELL BIOS 中英文對照表
  • 中国十大最狠的流氓网站曝光!
  • 使用Easyswoole 搭建简单的Websoket服务
  • 【年度总结】互联网不行了?对IT技术行业的深度思考
  • Visual Studio 2017 : client version 1.22 is too old
  • 初识Lazarus和Free Pascal Compiler
  • OS X10.10.3正式版和Xcode 6.3正式版下载
  • 计算机u盘设备无法启动不了,系统提示“该设备无法启动(代码:10)”,USB设备不能开始工作怎么办?...
  • Android基础入门
  • 中文乱码另类解决办法,简单,方便!