Skip to content

Commit

Permalink
feat(android): add bugly app id register
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli2018 authored and hippy-actions[bot] committed Jan 8, 2024
1 parent 152c907 commit 94c6bbe
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.tencent.mtt.hippy.bridge.HippyCoreAPI;
import com.tencent.mtt.hippy.bridge.bundleloader.HippyBundleLoader;
import com.tencent.mtt.hippy.bridge.libraryloader.LibraryLoader;
import com.tencent.mtt.hippy.utils.BuglyUtils;
import com.tencent.mtt.hippy.v8.V8;
import com.tencent.mtt.hippy.common.HippyJsException;
import com.tencent.mtt.hippy.common.HippyMap;
Expand Down Expand Up @@ -84,11 +85,12 @@ public static HippyEngine create(EngineInitParams params) {
if (params == null) {
throw new RuntimeException("Hippy: initParams must no be null");
}
LibraryLoader.loadLibraryIfNeed(params.soLoader);
LibraryLoader.loadLibraryIfNeeded(params.soLoader);
if (sLogAdapter == null && params.logAdapter != null) {
setNativeLogHandler(params.logAdapter);
}
ContextHolder.initAppContext(params.context);
BuglyUtils.registerSdkAppIdIfNeeded(params.context);
params.check();
LogUtils.enableDebugLog(params.enableLog);
HippyEngine hippyEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class LibraryLoader {
"hippy", "flexbox"
};

public static void loadLibraryIfNeed(HippySoLoaderAdapter soLoaderAdapter) {
public static void loadLibraryIfNeeded(HippySoLoaderAdapter soLoaderAdapter) {
if (hasLoaded || BuildConfig.ENABLE_SO_DOWNLOAD) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* Tencent is pleased to support the open source community by making Hippy available.
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.tencent.mtt.hippy.utils;

import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.Nullable;
import com.tencent.mtt.hippy.BuildConfig;

public class BuglyUtils {

private static final String BUGLY_KEY = "BuglySdkInfos";
private static final String SDK_APP_ID = "8aa644f958";
private static boolean sHasCommitted = false;

public static void registerSdkAppIdIfNeeded(@Nullable Context context) {
if (sHasCommitted || context == null) {
return;
}
Context appContext = context.getApplicationContext();
SharedPreferences settings = appContext.getSharedPreferences(BUGLY_KEY, Context.MODE_PRIVATE);
String version = settings.getString(SDK_APP_ID, null);
if (!BuildConfig.LIBRARY_VERSION.equals(version)) {
SharedPreferences.Editor editor = settings.edit();
editor.putString(SDK_APP_ID, BuildConfig.LIBRARY_VERSION);
sHasCommitted = editor.commit();
} else {
sHasCommitted = true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void handleBackgroundTracing(String details) {

}
list[1] = sb.toString();
LibraryLoader.loadLibraryIfNeed(initParams.soLoader);
LibraryLoader.loadLibraryIfNeeded(initParams.soLoader);
HippyBridgeImpl.createSnapshotFromScript(list,
basePath,
snapshotPath,
Expand Down
2 changes: 1 addition & 1 deletion layout/android/java/com/tencent/smtt/flexbox/FlexNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

public class FlexNode implements FlexNodeAPI<FlexNode> {
static {
LibraryLoader.loadLibraryIfNeed("flexbox");
LibraryLoader.loadLibraryIfNeeded("flexbox");
}
private FlexNode mParent;
private List<FlexNode> mChildren;
Expand Down

0 comments on commit 94c6bbe

Please sign in to comment.