我想知道人們是否成功地在Android中創建/加載加密的OBB(不透明二進制Blob)文件?這是一個跟進這個question 1:What is OBB(Opaque Binary Blob) in Android develop site?,繼那個帖子我執行下面的方向(從ICS 4.01基線,在Ubuntu 10.10-32bit和Ubuntu 12.4-64bit嘗試都):在Android中使用加密的OBB文件
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的開發者羣體的問題here
obb應該已經用mkobb.sh步驟進行了格式化,在該腳本中它調用了mkfs.vfat。其次,如果你在每個mount上格式化obb,每次掛載時都會擦除數據!感謝您的回覆。 – user931366
首先,使用腳本(mkfs.vfat)格式化的設備實際上是Linux機器中的設備,而不是Android中的設備(例如您的手機)。其次,對於模糊性我感到抱歉,我的意思是你應該只在一次格式化虛擬設備,然後像往常一樣安裝它。 – user1482130