Skip to content

Loror/LororDebuger

Repository files navigation

Android辅助开发Library-LororDebuger

License

Studio中引入项目

dependencies {
    implementation 'com.github.Loror:LororDebuger:1.3.1'
}

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  • 配置代码
  • Application中
    private fun initDebugger() {
        externalCacheDir?.let {
            DebugConfig.setSaveDir(it.absolutePath + File.separator + "log" + File.separator)
            FileLogger.setSaveDir(it.absolutePath + File.separator + "log" + File.separator)
            FileLogger.clear()
            CrashHandler.getInstance().init(this)
        }
        DebugConfig.setPort(DebugConfig.Get.getPort())
        DebugConfig.setAllowRemote(true)
        DebugConfig.setDevice(Build.DEVICE)
        DebugConfig.setSdk(Build.VERSION.SDK_INT)
        DebugConfig.setVersion(BuildConfig.VERSION_NAME)
        DebugConfig.setOnCmdListener(object : OnCmdListener {
            override fun onCmd(handler: CmdHandler) {}
            override fun openFile(file: File) {
                RemoteLog.e("DEBUG", "rec open file " + file.name)
                if (file.name.endsWith(".apk")) {
                    val down = getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)
                    if (FileUtils.copy(file, File(down, file.name))) {
                        FileUtils.goInstall(this@App, File(down, file.name))
                    }
                }
            }
        })
        DebugConfig.setOnSelectClick {
            //在这里清除数据
            ActivityUtil.finishAll()
            GlobalScope.launch {
                delay(1000)
                Process.killProcess(Process.myPid())
            }
        }
        DebugConfig.setSelect(Constant.ENVIRONMENT.keyList().toArray(arrayOf<String>()))
        val sensor = SensorManagerUtil(this)
        sensor.setOnShakeListener {
            DebugService.showIcon(this)
            sensor.stop()
        }
        sensor.start()
        startService(Intent(this, DebugService::class.java))
    }

License

Copyright 2021 Loror

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.