本文介绍了在Android中安装加密的obb apk扩展文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用jobb工具创建了一个加密的.obb文件。我使用以下代码挂载obb文件:

  public void mountExpansion(){
final StorageManager storageManager =( StorageManager)getContext()
.getSystemService(Context.STORAGE_SERVICE);


String packageName =name.of.the.package;
String filePath = Environment.getExternalStorageDirectory()
+/ Android / obb /+ packageName +/+main。
+ version +。 + packageName +.obb;
final文件mainFile = new File(filePath);
if(mainFile.exists()){
Log.d(STORAGE,FILE:+ filePath +Exists);
} else {
Log.d(STORAGE,FILE:+ filePath +DOESNT EXIST);
}

String key =thisIsMyPassword;
if(!storageManager.isObbMounted(mainFile.getAbsolutePath())){
if(mainFile.exists()){
if(storageManager.mountObb(mainFile.getAbsolutePath(),key,
new OnObbStateChangeListener(){
@Override
public void onObbStateChange(String path,int state){
super.onObbStateChange(path,state);
Log.d (PATH =,路径);
Log.d(STATE =,state +);
expandFilePath = storageManager.getMountedObbPath(path);
if(state == OnObbStateChangeListener .MOUNTED){
expandFilePath = storageManager
.getMountedObbPath(path);
Log.d(STORAGE, - > MOUNTED);
}
else {
Log.d(##,Path:+ path +;状态:+状态;
}
}
}))
{
Log.d(STORAGE_MNT,SUCCESSFULLY QUEUED);
}
else
{
Log.d(STORAGE_MNT,FAILED);
}

} else {
日志.d(STORAGE,Patch file not found);
}
}



}

我收到以下输出:
FILE:filePath存在
SUCCESSFULLY QUEUED
/ p>

但是,OnObbStateChangeListener 中的内容没有被调用,我从自定义视图中调用此函数,并在Nexus 4 / KitKat上进行测试。 >

可能是这种行为的原因?

解决方案

似乎有与KitKat一起引入的OBB安装错误,目前还没有解决方法呃它应该用下一个增量更新来修复。




I have created an encrypted .obb file using the jobb tool. I use the following code to mount the obb file:

    public void mountExpansion() {
    final StorageManager storageManager  = (StorageManager) getContext()
        .getSystemService(Context.STORAGE_SERVICE);


    String packageName = "name.of.the.package";
    String filePath = Environment.getExternalStorageDirectory()
            + "/Android/obb/" + packageName + "/" + "main."
            + version + "." + packageName + ".obb";
    final File mainFile = new File(filePath);
    if (mainFile.exists()) {
        Log.d("STORAGE", "FILE: " + filePath + " Exists");
    } else {
        Log.d("STORAGE", "FILE: " + filePath + " DOESNT EXIST");
    }

    String key = "thisIsMyPassword";
    if (!storageManager.isObbMounted(mainFile.getAbsolutePath())) {
        if (mainFile.exists()) {
            if(storageManager.mountObb(mainFile.getAbsolutePath(), key,
                    new OnObbStateChangeListener() {
                        @Override
                        public void onObbStateChange(String path, int state) {
                            super.onObbStateChange(path, state);
                            Log.d("PATH = ",path);
                            Log.d("STATE = ", state+"");
                            expansionFilePath = storageManager.getMountedObbPath(path);
                            if (state == OnObbStateChangeListener.MOUNTED) {
                                expansionFilePath = storageManager
                                        .getMountedObbPath(path);
                                Log.d("STORAGE","-->MOUNTED");
                            }
                            else {
                                Log.d("##", "Path: " + path + "; state: " + state);
                            }
                        }
                    }))
            {
                Log.d("STORAGE_MNT","SUCCESSFULLY QUEUED");
            }
            else
            {
                Log.d("STORAGE_MNT","FAILED");
            }

        } else {
            Log.d("STORAGE", "Patch file not found");
        }
    }



}

I am getting the following output:FILE: filePath ExistsSUCCESSFULLY QUEUED

But nothing inside onObbStateChangeListener is getting called. I am calling this function from a custom view and testing this on Nexus 4/ KitKat.

What could be the reason for this behaviour?

解决方案

There seems to be a bug with OBB mounting that was introduced with KitKat. Currently no workarounds are known however it should be fixed with the next incremental update.

http://code.google.com/p/android/issues/detail?id=61881

这篇关于在Android中安装加密的obb apk扩展文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 01:24