6

我想知道人们是否成功地在 Android 中创建/安装加密的 OBB(不透明二进制 Blob)文件?这是对这个问题 1的跟进:什么是 Android 开发网站中的 OBB(不透明二进制 Blob)?,按照该帖子中的指示,我执行了以下操作(从 ICS 4.01 基线开始,在 Ubuntu 10.10-32 位和 Ubuntu 12.4-64 位上都试过):

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 组问题

4

1 回答 1

1

您应该先格式化使用 obb 文件(out.obb)创建的虚拟设备(device-mapper 设备),然后才能挂载它。

具体来说,您应该在 VolumeManager::mountObb() 中添加一些这样的代码。

if (Fat::format(dmDevice, 0)) {
    SLOGE("OBB FAT format failed (%s)", strerror(errno));
    return -1;
}

也许这是android的错误?

于 2012-08-24T08:19:51.620 回答