我想知道人们是否已成功在Android中创建/安装加密的OBB(不透明二进制Blob)文件?这是此question的后续 Activity
1:What is OBB(Opaque Binary Blob) in Android develop site?,按照那篇文章中的指示,我执行了以下操作(从ICS 4.01基线开始,在Ubuntu 10.10-32bit和Ubuntu 12.4-64bit上都尝试过):
sudo modprobe cryptoloop
sudo modprobe twofish
sudo modprobe vfat
./mkobb.sh -d /tmp/obb/ -kblahblah -o /tmp/out.obb -v
obbtool a -n com.test.blah -v 1 -s 997ff9b1516a6788 /tmp/out.obb # 997ff... is the salt from the mkobb step
obbtool i /temp/out.obb # verify the obb file
adb push /temp/out.obb /sdcard/
从这里,我将out.obb文件复制到手机上的/sdcard/中。并使用以下代码安装:
String obbFile = Environment.getExternalStorageDirectory() + "/out.obb";
mgr = (StorageManager) getSystemService(Context.STORAGE_SERVICE); // mgr is a member varible of my main activity
Log.i("OBB", "trying to mount : " + obbFile + " does it exist? " + new File(obbFile).exists());
if (mgr.mountObb(obbFile, "blahblah", new OnObbStateChangeListener(){
@Override
public void onObbStateChange(String path, int state) {
Log.i("OBB", String.format("onObbStateChange:Path [%s] State=%d", path, state));
if (state == OnObbStateChangeListener.ERROR_COULD_NOT_MOUNT){
Log.i("OBB", "THIS IS THE ERROR I GET");
}
}}))
{
Log.i("OBB", "Attempting to mount");
} else {
Log.i("OBB", "Mount failed"); // this isn't happening
}
最终结果是:
E/MountService( 2004): Couldn't mount OBB file: -1
I/OBB (21219): onObbStateChange:Path [/mnt/sdcard/out.obb] State=21
I/OBB (21219): THIS IS THE ERROR I GET
有人看到这个有什么问题吗?好像它应该工作!
注意:我确实有android.permission.WRITE_EXTERNAL_STORAGE,而且我从以下位置得到了预期的信息:
ObbInfo info = ObbScanner.getObbInfo("/sdcard/out.obb"); // this returns expected info, so the file is there and able to be read.
编辑:链接到Android-Developer组问题here
最佳答案
您应该首先格式化使用obb文件(out.obb)创建的虚拟设备(设备映射器设备),然后再挂载它。
具体来说,您应该在VolumeManager::mountObb()中添加一些代码。
if (Fat::format(dmDevice, 0)) {
SLOGE("OBB FAT format failed (%s)", strerror(errno));
return -1;
}
也许这是Android的错误?