Skip to content

Commit

Permalink
接入新库
Browse files Browse the repository at this point in the history
  • Loading branch information
running-libo committed Jun 25, 2021
1 parent 6281808 commit d7dbf39
Show file tree
Hide file tree
Showing 523 changed files with 2,078,943 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ dependencies {
debugImplementation 'com.didichuxing.doraemonkit:dokitx:3.3.5'
releaseImplementation 'com.didichuxing.doraemonkit:dokitx-no-op:3.3.5'

// debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.5'
implementation 'com.github.markzhai:blockcanary-android:1.5.0'

debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.5'



}
repositories {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bytedance.tiktok">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application
android:name=".application.App"
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ class MainActivity : BaseActivity() {
}

override fun init() {

try {
Thread.sleep(2000)
} catch(e: Exception) {
e.printStackTrace()
}


fragments.add(mainFragment)
fragments.add(personalHomeFragment)
pagerAdapter = CommPagerAdapter(supportFragmentManager, fragments, arrayOf("", ""))
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/bytedance/tiktok/application/App.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.bytedance.tiktok.application

import android.app.Application
import com.bytedance.tiktok.base.AppBlockCanaryContext
import com.didichuxing.doraemonkit.DoraemonKit
import com.github.moduth.blockcanary.BlockCanary

/**
* create by libo
Expand All @@ -13,5 +15,9 @@ class App : Application() {
super.onCreate()

DoraemonKit.install(this, "pId")

BlockCanary.install(this, AppBlockCanaryContext()).start()

Thread.setDefaultUncaughtExceptionHandler(MyExceptionHandler())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.bytedance.tiktok.application;

import androidx.annotation.NonNull;

import java.io.File;

/**
* create by apple
* create on 2021/5/28
* description
*/
class MyExceptionHandler implements Thread.UncaughtExceptionHandler {

@Override
public void uncaughtException(@NonNull Thread t, @NonNull Throwable e) {
File file = dealException(thread, throwable);
//上传服务器

}

/*** 导出异常信息到SD卡 ** @param e */
private File dealException(Thread thread, Throwable throwable) {
String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
File crashFolder = new File(mContext.getExternalCacheDir().getAbsoluteFile(), CrashMonitor.DEFAULT_JAVA_CRASH_FOLDER_NAME);
if (!crashFolder.exists()) {
crashFolder.mkdirs();
}
File crashFile = new File(crashFolder, time + FILE_NAME_SUFFIX);
try {
// 往文件中写入数据
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(crashFile)));
pw.println(time);
pw.println(thread);
pw.println(getPhoneInfo());
throwable.printStackTrace(pw); //将异常信息堆栈写入文件
// 写入crash堆栈
pw.close();
} catch (IOException ex) {
ex.printStackTrace();
}
return crashFile;
}

private String getPhoneInfo() {
PackageManager pm = mContext.getPackageManager();
PackageInfo pi = null;
StringBuilder sb = new StringBuilder();

try {
pi = pm.getPackageInfo(mContext.getPackageName(), PackageManager.GET_ACTIVITIES);

// App版本
sb.append("App Version: ");
sb.append(pi.versionName);
sb.append("_");
sb.append(pi.versionCode + "\n");
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}

// Android版本号
sb.append("OS Version: ");
sb.append(Build.VERSION.RELEASE);
sb.append("_");
sb.append(Build.VERSION.SDK_INT + "\n");

// 手机制造商
sb.append("Vendor: ");
sb.append(Build.MANUFACTURER + "\n");

// 手机型号
sb.append("Model: ");
sb.append(Build.MODEL + "\n");

// CPU架构
sb.append("CPU: ");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
sb.append(Arrays.toString(Build.SUPPORTED_ABIS));
} else {
sb.append(Build.CPU_ABI);
}
return sb.toString();
}
}
160 changes: 160 additions & 0 deletions app/src/main/java/com/bytedance/tiktok/base/AppBlockCanaryContext.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
package com.bytedance.tiktok.base

import android.content.Context
import com.github.moduth.blockcanary.BlockCanaryContext
import com.github.moduth.blockcanary.internal.BlockInfo
import java.io.File
import java.util.*

/**
* create by apple
* create on 2021/5/28
* description BlockCanary监测卡顿方案
*/
class AppBlockCanaryContext : BlockCanaryContext() {

/**
* Implement in your project.
*
* @return Qualifier which can specify this installation, like version + flavor.
*/
override fun provideQualifier(): String? {
return "unknown"
}

/**
* Implement in your project.
*
* @return user id
*/
override fun provideUid(): String? {
return "uid"
}

/**
* Network type
*
* @return [String] like 2G, 3G, 4G, wifi, etc.
*/
override fun provideNetworkType(): String? {
return "unknown"
}

/**
* Config monitor duration, after this time BlockCanary will stop, use
* with `BlockCanary`'s isMonitorDurationEnd
*
* @return monitor last duration (in hour)
*/
override fun provideMonitorDuration(): Int {
return -1
}

/**
* config block threshold (in millis), dispatch over this duration is regarded as a block. you may set it
* from performance of device.
*
* @return threshold in mills
*/
override fun provideBlockThreshold(): Int {
return 1000
}

/**
* Thread stack dump interval, use when block happens, BlockCanary will dump on main thread
* stack according to current sample cycle.
*
*
* Because the implementation mechanism of Looper, real dump interval would be longer than
* the period specified here (especially when cpu is busier).
*
*
* @return dump interval (in millis)
*/
override fun provideDumpInterval(): Int {
return provideBlockThreshold()
}

/**
* Path to save log, like "/blockcanary/", will save to sdcard if can.
*
* @return path of log files
*/
override fun providePath(): String? {
return "/blockcanary/"
}

/**
* If need notification to notice block.
*
* @return true if need, else if not need.
*/
override fun displayNotification(): Boolean {
return true
}

/**
* Implement in your project, bundle files into a zip file.
*
* @param src files before compress
* @param dest files compressed
* @return true if compression is successful
*/
override fun zip(src: Array<File?>?, dest: File?): Boolean {
return false
}

/**
* Implement in your project, bundled log files.
*
* @param zippedFile zipped file
*/
override fun upload(zippedFile: File?) {
throw UnsupportedOperationException()
}


/**
* Packages that developer concern, by default it uses process name,
* put high priority one in pre-order.
*
* @return null if simply concern only package with process name.
*/
override fun concernPackages(): List<String?>? {
return null
}

/**
* Filter stack without any in concern package, used with @{code concernPackages}.
*
* @return true if filter, false it not.
*/
override fun filterNonConcernStack(): Boolean {
return false
}

/**
* Provide white list, entry in white list will not be shown in ui list.
*
* @return return null if you don't need white-list filter.
*/
override fun provideWhiteList(): List<String?>? {
val whiteList: LinkedList<String?> = LinkedList()
whiteList.add("org.chromium")
return whiteList
}

/**
* Whether to delete files whose stack is in white list, used with white-list.
*
* @return true if delete, false it not.
*/
override fun deleteFilesInWhiteList(): Boolean {
return true
}

/**
* Block interceptor, developer may provide their own actions.
*/
override fun onBlock(context: Context?, blockInfo: BlockInfo?) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ class RecommendFragment : BaseFragment() {
setRefreshEvent()

//监听播放或暂停事件
RxBus.getDefault().toObservable(PauseVideoEvent::class.java)
val subscribe = RxBus.getDefault().toObservable(PauseVideoEvent::class.java)
.subscribe(Action1 { event: PauseVideoEvent ->
if (event.isPlayOrPause) {
videoView!!.start()
} else {
videoView!!.pause()
}
} as Action1<PauseVideoEvent>)
// subscribe.unsubscribe()
}

override fun onResume() {
Expand Down
39 changes: 39 additions & 0 deletions app/src/main/java/com/bytedance/tiktok/utils/AnrFileObserver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.bytedance.tiktok.utils;

import android.os.FileObserver;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.io.File;

/**
* create by apple
* create on 2021/5/28
* description
*/
class AnrFileObserver extends FileObserver {

public AnrFileObserver(String path) {
super(path);
}

public AnrFileObserver(@NonNull File file) {
super(file);
}

@Override
public void onEvent(int event, @Nullable String path) {
switch (event) {
case FileObserver.ACCESS:

break;
case FileObserver.CREATE:

break;
case FileObserver.MODIFY:

break;
}
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
btb_vibrate_test;btb_fall_test;motor;linear_motor;linear_motor_life_test;charge_test;light_sensor_angle;lcm_three_base_color;lcm_watermark_test;camera_front_main_test;camera_rear_main_test;camera_pdaf;camera_rear_rtb_test;camera_rear_wide_test;camera_rear_wide_micro_distance_test;camera_rear_wide_near_focus_test;cool_light;calibrations_test;sim1_btb_test;sim2_btb_test;dark_light_sensor;bright_light_sensor;gsensor;gyroscope;infrared;electronic_compass;bad_screen;hand_write;back_light_setting;wakeup;lcm_noise;music;simulate_call;hifi;sound_recoder;electric_sound;main_echo;sub_echo;video_recoder;film;back_camera_sub_leak;card_slot;siminout_test;otg_test;udfp_calibration;udfp_spi;udfp_snr;electric_torch_test;sidekey_self_check;sidekey_test_right;button;cool_light;nfc_uicc_check;nfc_cplc_check;nfc_test;AI_test;b_double_camera;go_back_home;debug_log_switch;Quick_sampling;diag_socket;diag_socket_5g;volt_current;ps_wave_test;als_wave_test;gravity_direction_test;lcm_verify_test;lcm_display_mode_test;otp_data;camera_material_code;items_analyze;items_after_sale;open_camera_eeprom_permission;close_camera_eeprom_permission;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
#Tue Jul 02 08:10:02 GMT+08:00 2019
atcid_socket=0
connected_timeout=600
ssid_list="SoftAP"
wifi_level="SoftAP,-35,0"
light_value="SoftAP,0,30"
infrared_value="SoftAP,0,8000"
gsensor_value="SoftAP,-200,200,-200,200,-2000,2000"
qrcode_enable=0
Loading

0 comments on commit d7dbf39

Please sign in to comment.