Skip to content

Commit

Permalink
feat(android): add BaseEngineContext interface
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli2018 committed Mar 28, 2024
1 parent b38e990 commit 5981a8b
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,25 @@
import com.tencent.devtools.DevtoolsManager;
import com.tencent.mtt.hippy.HippyEngine.ModuleLoadStatus;
import com.tencent.mtt.hippy.bridge.HippyBridgeManager;
import com.tencent.mtt.hippy.common.BaseEngineContext;
import com.tencent.mtt.hippy.common.HippyMap;
import com.tencent.mtt.hippy.common.ThreadExecutor;
import com.tencent.mtt.hippy.devsupport.DevSupportManager;
import com.tencent.mtt.hippy.modules.HippyModuleManager;
import com.tencent.mtt.hippy.utils.TimeMonitor;
import com.tencent.vfs.VfsManager;
import java.util.HashMap;

public interface HippyEngineContext {
public interface HippyEngineContext extends BaseEngineContext {

String getComponentName();

@Nullable
HashMap<String, Object> getNativeParams();

@Nullable
HippyMap getJsParams();

@NonNull
VfsManager getVfsManager();

Expand Down Expand Up @@ -73,8 +78,6 @@ public interface HippyEngineContext {

void handleException(Throwable throwable);

int getEngineId();

int getDomManagerId();

int getVfsId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,12 @@ public HashMap<String, Object> getNativeParams() {
return mNativeParams;
}

@Override
@Nullable
public HippyMap getJsParams() {
return moduleLoadParams != null ? moduleLoadParams.jsParams : null;
}

@Override
public HippyGlobalConfigs getGlobalConfigs() {
return mGlobalConfigs;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* 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.common;

public interface BaseEngineContext {

int getEngineId();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.tencent.mtt.hippy.common.BaseEngineContext;
import com.tencent.mtt.hippy.common.LogAdapter;
import com.tencent.renderer.component.image.ImageDecoderAdapter;
import com.tencent.renderer.component.text.FontAdapter;
Expand Down Expand Up @@ -47,6 +48,9 @@ public interface FrameworkProxy {
@Nullable
String getBundlePath();

@NonNull
BaseEngineContext getEngineContext();

int getEngineId();

void onFirstPaint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import androidx.annotation.Nullable;

import com.tencent.mtt.hippy.HippyInstanceLifecycleEventListener;
import com.tencent.mtt.hippy.common.BaseEngineContext;
import com.tencent.mtt.hippy.uimanager.RenderManager;

import com.tencent.renderer.component.image.ImageDecoderAdapter;
Expand Down Expand Up @@ -63,6 +64,9 @@ public interface NativeRender extends RenderExceptionHandler, RenderLogHandler {
@Nullable
Executor getBackgroundExecutor();

@Nullable
BaseEngineContext getEngineContext();

int getEngineId();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.tencent.mtt.hippy.common.BaseEngineContext;
import com.tencent.mtt.hippy.common.Callback;
import com.tencent.mtt.hippy.common.LogAdapter;
import com.tencent.mtt.hippy.serialization.nio.reader.BinaryReader;
Expand Down Expand Up @@ -280,12 +281,15 @@ public void onReceiveRenderLogMessage(int level, @NonNull String tag, @NonNull S
}
}

@Override
@Nullable
public BaseEngineContext getEngineContext() {
return (mFrameworkProxy != null) ? mFrameworkProxy.getEngineContext() : null;
}

@Override
public int getEngineId() {
if (mFrameworkProxy != null) {
return mFrameworkProxy.getEngineId();
}
return -1;
return (mFrameworkProxy != null) ? mFrameworkProxy.getEngineId() : -1;
}

@Override
Expand Down

0 comments on commit 5981a8b

Please sign in to comment.