version:2.6

fix:修复userdebug报错
add:
This commit is contained in:
2022-07-07 16:53:50 +08:00
parent b0d7d0d32f
commit f4da62595d
6 changed files with 50 additions and 16 deletions

View File

@@ -22,6 +22,8 @@
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<!--百度-->
<!-- 这个权限用于进行网络定位-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

View File

@@ -110,18 +110,6 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
NetworkUtils.registerNetworkStatusChangedListener(this);
if (BuildConfig.DEBUG) {
// ApkUtils.openApp(this, "com.android.settings");
//静音
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
int ringMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_RING);
audioManager.setStreamVolume(AudioManager.STREAM_RING, ringMax, 0);
int musicMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_MUSIC);
int voiceMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_VOICE_CALL);
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, voiceMax, 0);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, musicMax, 0); //音乐音量
}
setOnClickListener();
tv_customversion.setText(JGYUtils.getCustomVersion());
tv_sn.setText("SN:" + Utils.getSerial());

View File

@@ -1,6 +1,9 @@
package com.uiui.sn.base;
import android.app.Application;
import android.content.Context;
import android.media.AudioManager;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
@@ -34,6 +37,21 @@ public class BaseApplication extends Application {
super.onCreate();
//非主进程不初始化
// if (SystemUtils.isMainProcessName(this, android.os.Process.myPid())) {
if (BuildConfig.DEBUG) {
// ApkUtils.openApp(this, "com.android.settings");
//静音
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
int ringMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_RING);
audioManager.setStreamVolume(AudioManager.STREAM_RING, ringMax, 0);
int musicMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_MUSIC);
int voiceMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_VOICE_CALL);
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, voiceMax, 0);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, musicMax, 0); //音乐音量
Log.e(TAG, "debugTest: " + getExternalCacheDir());
Log.e(TAG, "debugTest: " + getExternalFilesDir("cache"));
Log.e(TAG, "debugTest: " + getCacheDir());
Log.e(TAG, "debugTest: " + Environment.getExternalStorageDirectory());
}
utilsInint();
// }
}

View File

@@ -457,7 +457,13 @@ public class CacheHelper {
String cachePath;
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
|| !Environment.isExternalStorageRemovable()) {
cachePath = context.getExternalCacheDir().getPath();
if (context.getExternalCacheDir() != null) {
cachePath = context.getExternalCacheDir().getPath();
} else if (context.getExternalFilesDir("cache") != null) {
cachePath = context.getExternalFilesDir("cache").getPath();
} else {
cachePath = context.getCacheDir().getPath();
}
} else {
cachePath = context.getCacheDir().getPath();
}

View File

@@ -203,7 +203,7 @@ public class NetInterfaceManager {
// builder.addNetworkInterceptor(mRequestInterceptor);
// 设置缓存文件路径
String cacheDirectory = mContext.getExternalCacheDir().getAbsolutePath() + "/OkHttpCache";
String cacheDirectory = getCacheDir() + "/OkHttpCache";
Cache cache = new Cache(new File(cacheDirectory), cacheSize);
builder.cache(cache);// 设置缓存
okHttpClient = builder.build();
@@ -226,7 +226,27 @@ public class NetInterfaceManager {
// }
}
private String getCacheDir() {
String cachePath;
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
|| !Environment.isExternalStorageRemovable()) {
if (mContext.getExternalCacheDir() != null) {
cachePath = mContext.getExternalCacheDir().getPath();
} else if (mContext.getExternalFilesDir("cache") != null) {
cachePath = mContext.getExternalFilesDir("cache").getPath();
} else {
cachePath = mContext.getCacheDir().getPath();
}
} else {
cachePath = mContext.getCacheDir().getPath();
}
return cachePath;
}
public static void init(Context context) {
if (context == null) {
throw new RuntimeException("context is NULL");
}
if (INSTANCE == null) {
INSTANCE = new NetInterfaceManager(context);
}