Skip to content

Commit

Permalink
Support to use assets in server apk if assets_dir is not assigned in …
Browse files Browse the repository at this point in the history
…render-service-config.json (cocos#31)
  • Loading branch information
dumganhar committed May 22, 2023
1 parent 26db7ab commit 29b30c3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ scripts/typedoc-plugin/lib/
@types/consts.d.ts
native/render-service/client-demo-with-aar
native/render-service/dist-debug
native/render-service/server-app/src/main/assets
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,7 @@ public boolean start() {
}

if (mRenderServiceInfo.assetDirs == null) {
Log.e(TAG, "Could not find asset_dirs");
return false;
Log.i(TAG, "asset_dirs is not assigned, use resource in server apk");
}

if (mRenderServiceInfo.configs == null && !mRenderServiceConfigName.equals("default")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,20 @@ public RenderServiceInfo getRenderServiceInfo(String serviceFullClassName) {

try {
info.className = renderServiceConfig.getString("class_name");
JSONArray assetDirs = renderServiceConfig.getJSONArray("asset_dirs");
info.assetDirs = new String[assetDirs.length()];
for (int i = 0, len = assetDirs.length(); i < len; ++i) {
info.assetDirs[i] = assetDirs.getString(i);
}
} catch (JSONException e) {
e.printStackTrace();
return null;
}

// Optional
JSONArray assetDirs = renderServiceConfig.optJSONArray("asset_dirs");
if (assetDirs != null) {
info.assetDirs = new String[assetDirs.length()];
for (int i = 0, len = assetDirs.length(); i < len; ++i) {
info.assetDirs[i] = assetDirs.optString(i);
}
}

try {
JSONArray pluginList = renderServiceConfig.optJSONArray("plugins");
if (pluginList != null) {
Expand Down

0 comments on commit 29b30c3

Please sign in to comment.