com.taobao.weex.utils.WXSoInstallMgrSdk Java Examples

The following examples show how to use com.taobao.weex.utils.WXSoInstallMgrSdk. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IndexActivity.java    From WeexOne with MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_index);
    setContainer((ViewGroup) findViewById(R.id.index_container));
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mProgressBar = (ProgressBar) findViewById(R.id.index_progressBar);
    mTipView = (TextView) findViewById(R.id.index_tip);
    mProgressBar.setVisibility(View.VISIBLE);
    mTipView.setVisibility(View.VISIBLE);


    if (!WXSoInstallMgrSdk.isCPUSupport()) {
        mProgressBar.setVisibility(View.INVISIBLE);
        mTipView.setText(R.string.cpu_not_support_tip);
        return;
    }

    loadUrl(isLocalPage() ? AppConfig.getLocalUrl() : AppConfig.getLaunchUrl());
}
 
Example #2
Source File: WXSDKEngine.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
private static void doInitInternal(final Application application,final InitConfig config){
  WXEnvironment.sApplication = application;
  WXEnvironment.JsFrameworkInit = false;

  WXBridgeManager.getInstance().post(new Runnable() {
    @Override
    public void run() {
      long start = System.currentTimeMillis();
      WXSDKManager sm = WXSDKManager.getInstance();
      sm.onSDKEngineInitialize();
      if(config != null ) {
        sm.setInitConfig(config);
        if(config.getDebugAdapter()!=null){
          config.getDebugAdapter().initDebug(application);
        }
      }
      WXSoInstallMgrSdk.init(application,
                            sm.getIWXSoLoaderAdapter(),
                            sm.getWXStatisticsListener());
      boolean isSoInitSuccess = WXSoInstallMgrSdk.initSo(V8_SO_NAME, 1, config!=null?config.getUtAdapter():null);
      if (!isSoInitSuccess) {
        return;
      }
      sm.initScriptsFramework(config!=null?config.getFramework():null);

      WXEnvironment.sSDKInitExecuteTime = System.currentTimeMillis() - start;
      WXLogUtils.renderPerformanceLog("SDKInitExecuteTime", WXEnvironment.sSDKInitExecuteTime);
    }
  });
  register();
}
 
Example #3
Source File: WXSDKInstanceTest.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
  mockStatic(WXSoInstallMgrSdk.class);
  when(WXSoInstallMgrSdk.initSo("weexv8", 1, null)).thenReturn(true);
  WXSDKEngine.initialize(RuntimeEnvironment.application,new InitConfig.Builder().build());
  mInstance = createInstance();
  WXBridgeManagerTest.getLooper().idle();

  mockStatic(WXFileUtils.class);
  when(WXFileUtils.loadAsset(null,null)).thenReturn("{}");
}
 
Example #4
Source File: WXRenderStatementTest.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    PowerMockito.mockStatic(WXSoInstallMgrSdk.class);
    PowerMockito.mockStatic(TextUtils.class);
    PowerMockito.mockStatic(WXComponentFactory.class);
    PowerMockito.when(TextUtils.isEmpty("124")).thenReturn(true);
    PowerMockito.when(WXSoInstallMgrSdk.initSo(null, 1, null)).thenReturn(true);
    WXSDKInstance instance = Mockito.mock(WXSDKInstance.class);
    mWXRenderStatement = new RenderActionContextImpl(instance);
}
 
Example #5
Source File: WXEnvironment.java    From weex-uikit with MIT License 5 votes vote down vote up
/**
 * Tell whether Weex can run on current hardware.
 * @return true if weex can run on current hardware, otherwise false.
 */
public static boolean isHardwareSupport() {
  boolean excludeX86 = "true".equals(options.get(SETTING_EXCLUDE_X86SUPPORT));
  boolean isX86AndExcluded = WXSoInstallMgrSdk.isX86() && excludeX86;
  boolean isCPUSupport = WXSoInstallMgrSdk.isCPUSupport() && !isX86AndExcluded;
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.d("WXEnvironment.sSupport:" + isCPUSupport
                 + "isX86AndExclueded: "+ isX86AndExcluded
                 + " !WXUtils.isTabletDevice():" + !WXUtils.isTabletDevice());
  }
  return isCPUSupport && !WXUtils.isTabletDevice();
}
 
Example #6
Source File: WXSDKEngine.java    From weex-uikit with MIT License 5 votes vote down vote up
private static void doInitInternal(final Application application,final InitConfig config){
  WXEnvironment.sApplication = application;
  WXEnvironment.JsFrameworkInit = false;

  WXBridgeManager.getInstance().post(new Runnable() {
    @Override
    public void run() {
      long start = System.currentTimeMillis();
      WXSDKManager sm = WXSDKManager.getInstance();
      if(config != null ) {
        sm.setInitConfig(config);
        if(config.getDebugAdapter()!=null){
          config.getDebugAdapter().initDebug(application);
        }
      }
      WXSoInstallMgrSdk.init(application);
      boolean isSoInitSuccess = WXSoInstallMgrSdk.initSo(V8_SO_NAME, 1, config!=null?config.getUtAdapter():null);
      if (!isSoInitSuccess) {
        return;
      }
      sm.initScriptsFramework(config!=null?config.getFramework():null);

      WXEnvironment.sSDKInitExecuteTime = System.currentTimeMillis() - start;
      WXLogUtils.renderPerformanceLog("SDKInitExecuteTime", WXEnvironment.sSDKInitExecuteTime);
    }
  });
  register();
}
 
Example #7
Source File: WXSDKInstanceTest.java    From weex-uikit with MIT License 5 votes vote down vote up
@Before
public void setup() throws Exception {
  mockStatic(WXSoInstallMgrSdk.class);
  when(WXSoInstallMgrSdk.initSo("weexv8", 1, null)).thenReturn(true);
  WXSDKEngine.initialize(RuntimeEnvironment.application,new InitConfig.Builder().build());
  mInstance = createInstance();
  WXBridgeManagerTest.getLooper().idle();

  mockStatic(WXFileUtils.class);
  when(WXFileUtils.loadAsset(null,null)).thenReturn("{}");
}
 
Example #8
Source File: WXRenderStatementTest.java    From weex-uikit with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    PowerMockito.mockStatic(WXSoInstallMgrSdk.class);
    PowerMockito.mockStatic(TextUtils.class);
    PowerMockito.mockStatic(WXComponentFactory.class);
    PowerMockito.when(TextUtils.isEmpty("124")).thenReturn(true);
    PowerMockito.when(WXSoInstallMgrSdk.initSo(null, 1, null)).thenReturn(true);
    WXSDKInstance instance = Mockito.mock(WXSDKInstance.class);
    mWXRenderStatement = new WXRenderStatement(instance);
}
 
Example #9
Source File: WXEnvironment.java    From weex with Apache License 2.0 5 votes vote down vote up
public static boolean isSupport() {
  boolean excludeX86 = "true".equals(options.get(SETTING_EXCLUDE_X86SUPPORT));
  boolean isX86AndExcluded = WXSoInstallMgrSdk.isX86()&&excludeX86;
  boolean isCPUSupport = WXSoInstallMgrSdk.isCPUSupport()&&!isX86AndExcluded;
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.d("WXEnvironment.sSupport:" + isCPUSupport
                 + " WXSDKEngine.isInitialized():" + WXSDKEngine.isInitialized()
                 + " !WXUtils.isTabletDevice():" + !WXUtils.isTabletDevice());
  }
  return isCPUSupport && WXSDKEngine.isInitialized() && !WXUtils.isTabletDevice();
}
 
Example #10
Source File: WXSDKEngine.java    From weex with Apache License 2.0 5 votes vote down vote up
private static void doInitInternal(final Application application,final InitConfig config){
  WXEnvironment.sApplication = application;
  WXEnvironment.JsFrameworkInit = false;

  WXBridgeManager.getInstance().getJSHandler().post(new Runnable() {
    @Override
    public void run() {
      long start = System.currentTimeMillis();
      WXSDKManager sm = WXSDKManager.getInstance();
      if(config != null ) {
        sm.setIWXHttpAdapter(config.getHttpAdapter());
        sm.setIWXImgLoaderAdapter(config.getImgAdapter());
        sm.setIWXUserTrackAdapter(config.getUtAdapter());
        sm.setIWXDebugAdapter(config.getDebugAdapter());
        if(config.getDebugAdapter()!=null){
          config.getDebugAdapter().initDebug(application);
        }
      }
      WXSoInstallMgrSdk.init(application);
      boolean isSoInitSuccess = WXSoInstallMgrSdk.initSo(V8_SO_NAME, 1, config!=null?config.getUtAdapter():null);
      if (!isSoInitSuccess) {
        return;
      }
      sm.initScriptsFramework(null);

      WXEnvironment.sSDKInitExecuteTime = System.currentTimeMillis() - start;
      WXLogUtils.renderPerformanceLog("SDKInitInvokeTime", WXEnvironment.sSDKInitInvokeTime);
      WXLogUtils.renderPerformanceLog("SDKInitExecuteTime", WXEnvironment.sSDKInitExecuteTime);
    }
  });
  register();
}
 
Example #11
Source File: WXRenderStatementTest.java    From weex with Apache License 2.0 5 votes vote down vote up
@Before
    public void setUp() throws Exception {
        PowerMockito.mockStatic(WXSoInstallMgrSdk.class);
        PowerMockito.mockStatic(TextUtils.class);
        PowerMockito.mockStatic(WXComponentFactory.class);
        PowerMockito.when(TextUtils.isEmpty("124")).thenReturn(true);
        PowerMockito.when(WXSoInstallMgrSdk.initSo(null, 1, null)).thenReturn(true);
//        WXSDKEngine.init(RuntimeEnvironment.application);
        WXSDKInstance instance = Mockito.mock(WXSDKInstance.class);
        mWXRenderStatement = new WXRenderStatement(instance, "123");
    }
 
Example #12
Source File: IndexActivity.java    From weex with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_index);
  setContainer((ViewGroup) findViewById(R.id.index_container));
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  toolbar.setTitle("WEEX");
  setSupportActionBar(toolbar);

  mProgressBar = (ProgressBar) findViewById(R.id.index_progressBar);
  mTipView = (TextView) findViewById(R.id.index_tip);
  mProgressBar.setVisibility(View.VISIBLE);
  mTipView.setVisibility(View.VISIBLE);


  if(!WXSoInstallMgrSdk.isCPUSupport()){
    mProgressBar.setVisibility(View.INVISIBLE);
    mTipView.setText(R.string.cpu_not_support_tip);
    return;
  }

  if(TextUtils.equals(CURRENT_IP,DEFAULT_IP)){
    renderPage(WXFileUtils.loadFileContent("index.js", this),WEEX_INDEX_URL);
  }else{
    renderPageByURL(WEEX_INDEX_URL);
  }
}
 
Example #13
Source File: IndexActivity.java    From incubator-weex-playground with Apache License 2.0 4 votes vote down vote up
@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_index);
    setContainer((ViewGroup) findViewById(R.id.index_container));
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getWindow().setFormat(PixelFormat.TRANSLUCENT);

    mProgressBar = (ProgressBar) findViewById(R.id.index_progressBar);
    mTipView = (TextView) findViewById(R.id.index_tip);
    mProgressBar.setVisibility(View.VISIBLE);
    mTipView.setVisibility(View.VISIBLE);


    if (!WXSoInstallMgrSdk.isCPUSupport()) {
      mProgressBar.setVisibility(View.INVISIBLE);
      mTipView.setText(R.string.cpu_not_support_tip);
      return;
    }

    if (TextUtils.equals(sCurrentIp, DEFAULT_IP)) {
      renderPage(WXFileUtils.loadAsset("landing.weex.js", this), getIndexUrl());
//      renderPageByURL("http://dotwe.org/raw/dist/2bbe1860da4669a68595c1aed01d7fd2.bundle.wx");
    } else {
      renderPageByURL(getIndexUrl());
    }


    mReloadReceiver = new BroadcastReceiver() {
      @Override
      public void onReceive(Context context, Intent intent) {
        createWeexInstance();
        if (TextUtils.equals(sCurrentIp, DEFAULT_IP)) {
          renderPage(WXFileUtils.loadAsset("landing.weex.js", getApplicationContext()), getIndexUrl());
        } else {
          renderPageByURL(getIndexUrl());
        }
        mProgressBar.setVisibility(View.VISIBLE);
      }
    };

    LocalBroadcastManager.getInstance(this).registerReceiver(mReloadReceiver, new IntentFilter(WXSDKEngine.JS_FRAMEWORK_RELOAD));

    CheckForUpdateUtil.checkForUpdate(this);
  }
 
Example #14
Source File: WXPageActivity.java    From yanxuan-weex-demo with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_wxpage);
  mContainer = (ViewGroup) findViewById(R.id.container);
  mProgressBar = (ProgressBar) findViewById(R.id.progress);
  mTipView = (TextView) findViewById(R.id.index_tip);

  Intent intent = getIntent();
  Uri uri = intent.getData();
  String from = intent.getStringExtra("from");
  mFromSplash = "splash".equals(from);

  if (uri == null) {
    uri = Uri.parse("{}");
  }
  if (uri != null) {
    try {
      JSONObject initData = new JSONObject(uri.toString());
      String bundleUrl = initData.optString("WeexBundle", null);
      if (bundleUrl != null) {
        mUri = Uri.parse(bundleUrl);
      }

      String ws = initData.optString("Ws", null);
      if (!TextUtils.isEmpty(ws)) {
        mHotReloadManager = new HotReloadManager(ws, new HotReloadManager.ActionListener() {
          @Override
          public void reload() {
            runOnUiThread(new Runnable() {
              @Override
              public void run() {
                Toast.makeText(WXPageActivity.this, "Hot reload", Toast.LENGTH_SHORT).show();
                createWeexInstance();
                renderPage();
              }
            });
          }

          @Override
          public void render(final String bundleUrl) {
            runOnUiThread(new Runnable() {
              @Override
              public void run() {
                Toast.makeText(WXPageActivity.this, "Render: " + bundleUrl, Toast.LENGTH_SHORT).show();
                createWeexInstance();
                loadUrl(bundleUrl);
              }
            });
          }
        });
      } else {
        WXLogUtils.w("Weex", "can not get hot reload config");
      }
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }

  if (mUri == null) {
    mUri = Uri.parse(AppConfig.getLaunchUrl());
  }

  if (!WXSoInstallMgrSdk.isCPUSupport()) {
    mProgressBar.setVisibility(View.INVISIBLE);
    mTipView.setText(R.string.cpu_not_support_tip);
    return;
  }

  String url = getUrl(mUri);
  if (getSupportActionBar() != null) {
    getSupportActionBar().setTitle(url);
    getSupportActionBar().hide();
  }
  loadUrl(url);
}
 
Example #15
Source File: IndexActivity.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_index);
  setContainer((ViewGroup) findViewById(R.id.index_container));
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  toolbar.setTitle("WEEX");
  setSupportActionBar(toolbar);

  mProgressBar = (ProgressBar) findViewById(R.id.index_progressBar);
  mTipView = (TextView) findViewById(R.id.index_tip);
  mProgressBar.setVisibility(View.VISIBLE);
  mTipView.setVisibility(View.VISIBLE);


  if(!WXSoInstallMgrSdk.isCPUSupport()){
    mProgressBar.setVisibility(View.INVISIBLE);
    mTipView.setText(R.string.cpu_not_support_tip);
    return;
  }

  if(TextUtils.equals(CURRENT_IP,DEFAULT_IP)){
    renderPage(WXFileUtils.loadAsset("index.js", this),WEEX_INDEX_URL);
  }else{
    renderPageByURL(WEEX_INDEX_URL);
  }


  mReloadReceiver=new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
      createWeexInstance();
      if(TextUtils.equals(CURRENT_IP,DEFAULT_IP)){
        renderPage(WXFileUtils.loadAsset("index.js", IndexActivity.this),WEEX_INDEX_URL);
      }else{
        renderPageByURL(WEEX_INDEX_URL);
      }
      mProgressBar.setVisibility(View.VISIBLE);
    }
  };

  LocalBroadcastManager.getInstance(this).registerReceiver(mReloadReceiver,new IntentFilter(WXSDKEngine.JS_FRAMEWORK_RELOAD));
}