增加排查问题效率工具
This commit is contained in:
parent
963c6d135d
commit
9cf570410b
|
|
@ -25,6 +25,6 @@ android {
|
|||
dependencies {
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
testImplementation 'junit:junit:4.12'
|
||||
api 'androidx.appcompat:appcompat:1.0.0'
|
||||
api 'androidx.appcompat:appcompat:1.3.0'
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -149,7 +149,9 @@ dependencies {
|
|||
implementation 'com.umeng.umsdk:share-core:7.3.3'//分享核心库,必选
|
||||
//在线依赖目前支持QQ、微信、新浪微博、支付宝、钉钉、抖音;若需支持其他平台,请选择手动下载SDK
|
||||
implementation 'com.umeng.umsdk:share-wx:7.3.3' //微信完整版
|
||||
implementation 'com.tencent.mm.opensdk:wechat-sdk-android:6.8.24' //微信官方依赖库
|
||||
implementation 'com.tencent.mm.opensdk:wechat-sdk-android:6.8.24'//微信官方依赖库
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
|
||||
//友盟分享
|
||||
// implementation files('libs/umeng_social_sdk.jar')
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -18,6 +18,8 @@ import android.view.Window;
|
|||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.ifish.basebean.BaseBean;
|
||||
import com.ifish.basebean.FinishMainActivity;
|
||||
import com.ifish.basebean.Version;
|
||||
|
|
@ -41,7 +43,7 @@ import java.io.File;
|
|||
import java.lang.reflect.Field;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
import com.ifish.activity.BuildConfig;
|
||||
/**
|
||||
* ---------------------------
|
||||
* 丨你存在 我某一行代码里丨
|
||||
|
|
@ -49,7 +51,7 @@ import de.greenrobot.event.EventBus;
|
|||
* ---------------------------
|
||||
*
|
||||
* @author Jacky dada
|
||||
* @Description: TODO
|
||||
* @Description: 设置页面
|
||||
* @date 2017/4/18 21:46
|
||||
*/
|
||||
public class MySettingActivity extends BaseActivity {
|
||||
|
|
@ -62,6 +64,7 @@ public class MySettingActivity extends BaseActivity {
|
|||
NotificationManager mNotificationManager;
|
||||
private SPUtil sp;
|
||||
|
||||
private TextView tvDebug;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
@ -70,6 +73,21 @@ public class MySettingActivity extends BaseActivity {
|
|||
sp = SPUtil.getInstance(getApplicationContext());
|
||||
initListener();
|
||||
init();
|
||||
initDebug();
|
||||
}
|
||||
|
||||
private void initDebug() {
|
||||
if (BuildConfig.DEBUG){
|
||||
tvDebug = findMyViewById(R.id.tv_debug);
|
||||
tvDebug.setVisibility(View.VISIBLE);
|
||||
tvDebug.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(MySettingActivity.this,PhoneInfoActivity.class));
|
||||
// ToastUtil.show(MySettingActivity.this,"跳转到debug页面");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,176 @@
|
|||
package com.ifish.activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class PhoneInfoActivity extends AppCompatActivity {
|
||||
|
||||
private TextView textViewModel;
|
||||
private TextView textViewNetworkInfo;
|
||||
private TextView tvWifiInfo;
|
||||
private static final int REQUEST_WIFI_PERMISSION = 1;
|
||||
private static final int REQUEST_PHONE_PERMISSION = 2;
|
||||
|
||||
private WifiManager wifiManager;
|
||||
private TelephonyManager telephonyManager;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_phone_info);
|
||||
textViewModel = findViewById(R.id.tvModel);
|
||||
textViewNetworkInfo = findViewById(R.id.tvNetworkInfo);
|
||||
tvWifiInfo = findViewById(R.id.tvWifiInfo);
|
||||
|
||||
wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
||||
telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
||||
|
||||
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
// Permission is not granted
|
||||
ActivityCompat.requestPermissions(this,
|
||||
new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION},
|
||||
REQUEST_WIFI_PERMISSION);
|
||||
} else {
|
||||
// Permission has already been granted
|
||||
getPhoneInfo();
|
||||
}
|
||||
}
|
||||
|
||||
private void getPhoneInfo() {
|
||||
// 获取设备型号
|
||||
String model = Build.MODEL;
|
||||
textViewModel.setText("设备型号: " + model + "\n");
|
||||
// 获取移动网络信息(可选)
|
||||
if (telephonyManager != null) {
|
||||
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
|
||||
// Permission is not granted
|
||||
ActivityCompat.requestPermissions(this,
|
||||
new String[]{android.Manifest.permission.READ_PHONE_STATE},
|
||||
REQUEST_PHONE_PERMISSION);
|
||||
return;
|
||||
}
|
||||
int networkType = telephonyManager.getNetworkType();
|
||||
String networkTypeName = getNetworkTypeName(networkType);
|
||||
textViewModel.append(networkTypeName + "\n");
|
||||
}
|
||||
|
||||
// 检查网络连接状态
|
||||
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||
boolean isConnected = activeNetwork != null && activeNetwork.isConnected();
|
||||
// 显示网络情况
|
||||
String networkInfo = isConnected ? "已连接到网络" : "未连接到网络";
|
||||
textViewNetworkInfo.setText("网络信息:\n" + "网络情况: " + networkInfo);
|
||||
// 如果需要,你还可以检查具体的网络类型(如Wi-Fi、移动数据等)
|
||||
if (isConnected) {
|
||||
NetworkInfo.State state = activeNetwork.getState();
|
||||
if (state == NetworkInfo.State.CONNECTED || state == NetworkInfo.State.CONNECTING) {
|
||||
if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
|
||||
networkInfo = "连接到Wi-Fi网络";
|
||||
} else if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
|
||||
networkInfo = "连接到移动网络";
|
||||
}
|
||||
}
|
||||
}
|
||||
textViewNetworkInfo.setText("网络情况: " + networkInfo);
|
||||
|
||||
// 获取WiFi信息
|
||||
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo info = wifiManager.getConnectionInfo();
|
||||
String ssid = info.getSSID();
|
||||
int frequency = info.getFrequency();
|
||||
|
||||
tvWifiInfo.append("SSID: " + ssid + "\n");
|
||||
|
||||
// 判断WiFi频段(2.4G或5G)
|
||||
if (frequency >= 2400 && frequency <= 2500) {
|
||||
tvWifiInfo.append("WiFi Band: 2.4GHz\n");
|
||||
} else if (frequency >= 5000 && frequency <= 6000) {
|
||||
tvWifiInfo.append("WiFi Band: 5GHz\n");
|
||||
} else {
|
||||
tvWifiInfo.append("WiFi Band: Unknown\n");
|
||||
}
|
||||
}
|
||||
|
||||
public String getNetworkTypeName(int networkType) {
|
||||
String typeName;
|
||||
String description;
|
||||
|
||||
switch (networkType) {
|
||||
case TelephonyManager.NETWORK_TYPE_GPRS:
|
||||
typeName = "GPRS";
|
||||
description = "GPRS 是一种基于 GSM 的无线分组交换技术,提供了比传统 GSM 电路交换数据服务更快的数据传输速度。它是 2G 和 2.5G 移动通信技术的一部分。";
|
||||
break;
|
||||
|
||||
case TelephonyManager.NETWORK_TYPE_EDGE:
|
||||
typeName = "EDGE";
|
||||
description = "EDGE 是 GPRS 的一个增强版本,提供了更高的数据传输速率,被认为是 2.75G 技术。";
|
||||
break;
|
||||
|
||||
case TelephonyManager.NETWORK_TYPE_UMTS:
|
||||
typeName = "UMTS";
|
||||
description = "UMTS 是一种 3G 移动通信技术,包括多种标准,如 WCDMA,提供了更高的数据传输速率和更先进的多媒体服务。";
|
||||
break;
|
||||
|
||||
case TelephonyManager.NETWORK_TYPE_HSDPA:
|
||||
typeName = "HSDPA";
|
||||
description = "HSDPA 是 UMTS 家族中的一个增强技术,专注于提供更高的下行链路数据传输速率。它是 3.5G 技术的一部分。";
|
||||
break;
|
||||
|
||||
case TelephonyManager.NETWORK_TYPE_HSUPA:
|
||||
typeName = "HSUPA";
|
||||
description = "HSUPA 类似于 HSDPA,但专注于提供更高的上行链路数据传输速率。它也是 3.5G 技术的一部分。";
|
||||
break;
|
||||
|
||||
case TelephonyManager.NETWORK_TYPE_HSPA:
|
||||
typeName = "HSPA";
|
||||
description = "HSPA 通常是指结合了 HSDPA 和 HSUPA 的技术,提供了同时增强的上行和下行数据传输速率。";
|
||||
break;
|
||||
|
||||
case TelephonyManager.NETWORK_TYPE_LTE:
|
||||
typeName = "LTE";
|
||||
description = "LTE 是一种 4G 无线通信标准,旨在提供比 3G 技术更快的数据传输速率、更低的延迟和更高的系统容量。";
|
||||
break;
|
||||
|
||||
// 添加其他网络类型的 case 语句...
|
||||
|
||||
default:
|
||||
typeName = "未知";
|
||||
description = "无法识别的网络类型。";
|
||||
break;
|
||||
}
|
||||
|
||||
return "手机网络类型:" + typeName + " || " + description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == REQUEST_WIFI_PERMISSION) {
|
||||
if (grantResults.length > 0
|
||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
// Permission has been granted, update the UI
|
||||
getPhoneInfo();
|
||||
} else {
|
||||
// Permission denied, Disable the functionality that depends on this permission.
|
||||
Toast.makeText(this, "Permission Denied", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -15,6 +15,11 @@ import android.graphics.Color;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.multidex.MultiDexApplication;
|
||||
|
||||
|
|
@ -24,6 +29,7 @@ import com.alibaba.sdk.android.push.PushControlService;
|
|||
import com.alibaba.sdk.android.push.huawei.HuaWeiRegister;
|
||||
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
|
||||
import com.alibaba.sdk.android.push.register.MiPushRegister;
|
||||
import com.ifish.activity.BuildConfig;
|
||||
import com.ifish.utils.SystemUtil;
|
||||
import com.p2p.core.P2PSpecial.P2PSpecial;
|
||||
//import com.tencent.bugly.crashreport.CrashReport;
|
||||
|
|
@ -71,11 +77,15 @@ public class BaseApplication extends MultiDexApplication {
|
|||
initLog();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示当前Acitivity名字
|
||||
*/
|
||||
private void initLog() {
|
||||
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
|
||||
@Override
|
||||
public void onActivityCreated(Activity activity, Bundle bundle) {
|
||||
Log.i("ifish7", "LHD" + "---" + activity.getLocalClassName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -85,7 +95,27 @@ public class BaseApplication extends MultiDexApplication {
|
|||
|
||||
@Override
|
||||
public void onActivityResumed(Activity activity) {
|
||||
if (BuildConfig.DEBUG){
|
||||
Log.i("ifish7", "LHD" + "debug模式显示当前页面路径:"+activity.getLocalClassName());
|
||||
// 创建一个新的TextView
|
||||
TextView textView = new TextView(activity);
|
||||
textView.setText(activity.getLocalClassName());
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
|
||||
textView.setTextColor(Color.YELLOW);
|
||||
// 设置TextView的布局参数,确保它有一个合适的大小
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT,
|
||||
Gravity.TOP | Gravity.START);
|
||||
// 可以设置具体的边距和位置
|
||||
layoutParams.setMargins(10, 10, 10, 10);
|
||||
textView.setLayoutParams(layoutParams);
|
||||
// 获取根布局容器
|
||||
ViewGroup rootLayout = (ViewGroup) activity.getWindow().getDecorView().findViewById(android.R.id.content);
|
||||
|
||||
// 在布局容器的顶部添加TextView
|
||||
rootLayout.addView(textView); // 0 表示将视图添加到容器的顶部
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp"
|
||||
tools:context=".PhoneInfoActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:text="设备信息" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvModel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="设备型号:" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/black"
|
||||
android:layout_marginTop="12dp"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:text="网络信息" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvNetworkInfo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="网络情况:" />
|
||||
<TextView
|
||||
android:id="@+id/tvWifiInfo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="WiFi信息:" />
|
||||
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
|
@ -282,5 +282,16 @@
|
|||
android:src="@drawable/ic_back_right_black" />
|
||||
</RelativeLayout>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_debug"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/mine_fragment_item"
|
||||
android:layout_marginTop="@dimen/mine_fragment_gray_size"
|
||||
android:text="手机环境"
|
||||
android:visibility="gone"
|
||||
android:textSize="17sp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/minefragment_bg_select"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
|||
Loading…
Reference in New Issue