version:1.3.2

fix:
update:修复闪退
This commit is contained in:
2026-03-23 09:41:05 +08:00
parent 88ac4c0824
commit cee1bc5857
9 changed files with 145 additions and 19 deletions

View File

@@ -17,8 +17,8 @@ android {
minSdkVersion 23
targetSdkVersion 29
versionCode 27
versionName "1.2.6"
versionCode 33
versionName "1.3.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -90,7 +90,7 @@ android {
minifyEnabled false
//Zipalign优化
zipAlignEnabled true
buildConfigField "String", "platform", '"tuixin"'
buildConfigField "String", "platform", '"Nature"'
signingConfig signingConfigs.tuixin
applicationVariants.all { variant ->
variant.outputs.each { output ->
@@ -111,7 +111,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//签名
signingConfig signingConfigs.tuixin
buildConfigField "String", "platform", '"tuixin"'
buildConfigField "String", "platform", '"Nature"'
// 将release版本的包名重命名加上版本及日期
applicationVariants.all { variant ->
variant.outputs.each { output ->

View File

@@ -37,6 +37,11 @@ import com.xwad.os.utils.JgyUtils;
import com.xwad.os.utils.OpenApkUtils;
import com.xwad.os.utils.SystemUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class BaseApplication extends Application {
private static final String TAG = "BaseApplication";
@@ -136,6 +141,22 @@ public class BaseApplication extends Application {
Log.e("AliyunPush", "init cloudchannel success");
Log.e("AliyunPush", "init cloudchannel success " + pushService.getDeviceId());
MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE).encode(CommonConfig.ALIYUN_PUSH_ID, pushService.getDeviceId());
Set<String> tagSets = new HashSet<>();
tagSets.add(BuildConfig.platform);
String[] tag = new ArrayList<>(tagSets).toArray(new String[tagSets.size()]);
pushService.bindTag(CloudPushService.DEVICE_TARGET, tag, null, new CommonCallback() {
@Override
public void onSuccess(String s) {
Log.e("AliyunPush", "bind tag " + Arrays.toString(tag) + " success\n");
}
@Override
public void onFailed(String errorCode, String errorMsg) {
Log.e("AliyunPush", "bind tag " + Arrays.toString(tag) + " failed." +
"errorCode: " + errorCode + ", errorMsg:" + errorMsg + "\n");
}
});
}
@Override

View File

@@ -24,6 +24,7 @@ import com.xwad.os.network.NetInterfaceManager;
import com.xwad.os.utils.ActivationUtil;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Observer;
@@ -235,8 +236,8 @@ public class AmapManager {
private void saveMapResult(MapBean mapBean) {
Log.e(TAG, "saveMapResult: " + GsonUtils.toJSONString(mapBean));
mMMKV.encode(CommonConfig.MAP_LOCATION_JSON_KEY, GsonUtils.toJSONString(mapBean));
mMMKV.encode(CommonConfig.MAP_LONGITUDE_KEY, mapBean.getLongitude());
mMMKV.encode(CommonConfig.MAP_LATITUDE_KEY, mapBean.getLatitude());
mMMKV.encode(CommonConfig.MAP_LONGITUDE_KEY, doubleToStringExact(mapBean.getLongitude()));
mMMKV.encode(CommonConfig.MAP_LATITUDE_KEY, doubleToStringExact(mapBean.getLatitude()));
mMMKV.encode(CommonConfig.MAP_ADDRESS_KEY, mapBean.getAddress());
mMMKV.encode(CommonConfig.MAP_PROVINCE_KEY, mapBean.getProvince());
mMMKV.encode(CommonConfig.MAP_CITY_KEY, mapBean.getCity());
@@ -245,4 +246,8 @@ public class AmapManager {
mMMKV.encode(CommonConfig.MAP_LOCATION_DESCRIBE_KEY, mapBean.getLocationDescribe());
}
public static String doubleToStringExact(double value) {
// 使用 BigDecimal 避免科学计数法
return new BigDecimal(Double.toString(value)).toPlainString();
}
}

View File

@@ -251,7 +251,7 @@ public class ManagerService extends Service implements NetworkUtils.OnNetworkSta
if (!isServiceRunning) {
startService(new Intent(this, MainService.class));
}
bindService(new Intent(this, MainService.class), mServiceConnection, Context.BIND_IMPORTANT);
// bindService(new Intent(this, MainService.class), mServiceConnection, Context.BIND_IMPORTANT);
PushServiceFactory.getPushControlService().setConnectionChangeListener(new PushControlService.ConnectionChangeListener() {
@Override
@@ -802,7 +802,7 @@ public class ManagerService extends Service implements NetworkUtils.OnNetworkSta
soundPool.release();
soundPool = null;
}
unbindService(mServiceConnection);
// unbindService(mServiceConnection);
}
}

View File

@@ -12,6 +12,8 @@ import com.hjq.toast.Toaster;
import com.tencent.mmkv.MMKV;
import com.trello.rxlifecycle4.RxLifecycle;
import com.trello.rxlifecycle4.android.ActivityEvent;
import com.xwad.os.BuildConfig;
import com.xwad.os.activity.update.UpdateActivity;
import com.xwad.os.bean.AppInfo;
import com.xwad.os.bean.BaseResponse;
import com.xwad.os.bean.UserInfo;
@@ -285,7 +287,42 @@ public class MainSPresenter implements MainSContact.Presenter {
@Override
public void checkUpdate() {
NetInterfaceManager.getInstance().getUpdateObservable(BuildConfig.APPLICATION_ID)
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
.subscribe(new Observer<BaseResponse<AppInfo>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("checkUpdate", "onSubscribe: ");
}
@Override
public void onNext(@NonNull BaseResponse<AppInfo> appUpdateInfoBaseResponse) {
Log.e("checkUpdate", "onNext: " + appUpdateInfoBaseResponse);
if (appUpdateInfoBaseResponse.code == 200) {
AppInfo appInfo = appUpdateInfoBaseResponse.data;
if (ApkUtils.isUpdate(mContext, appInfo)) {
Intent intent = new Intent(mContext, UpdateActivity.class);
intent.putExtra("appUpdateInfo", appInfo);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
Toaster.show("有新的版本需要更新");
}
} else {
}
}
@Override
public void onError(@NonNull Throwable e) {
Log.e("checkUpdate", "onError: " + e.getMessage());
// Toaster.show("网络连接失败");
}
@Override
public void onComplete() {
Log.e("checkUpdate", "onComplete: ");
}
});
}
@Override

View File

@@ -30,10 +30,18 @@ import com.xwad.os.bean.SnInfo;
import com.xwad.os.config.CommonConfig;
import com.xwad.os.network.NetInterfaceManager;
import com.xwad.os.service.SocketService;
import com.xwad.os.utils.Utils;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.ObservableEmitter;
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
public class MainService extends BaseRxService implements MainSContact.MainSView, NetworkUtils.OnNetworkStatusChangedListener {
private static final String TAG = "MainService";
@@ -54,11 +62,54 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
@Override
public void onConnected(NetworkUtils.NetworkType networkType) {
Log.e(TAG, "onConnected: ");
// if (Utils.isScreenOn(MainService.this)) {
// mPresenter.getCloudLessonSettings();
// }
if (Utils.isScreenOn(MainService.this)) {
mPresenter.checkUpdate();
}
mInternetConnected.onConnected(networkType.name());
}
private InternetConnected mInternetConnected;
public interface InternetConnected {
void onConnected(String alias);
}
private final ObservableOnSubscribe<String> networkSubscribe = new ObservableOnSubscribe<String>() {
@Override
public void subscribe(ObservableEmitter emitter) throws Exception {
mInternetConnected = new InternetConnected() {
@Override
public void onConnected(String alias) {
Log.e(TAG, "networkSubscribe: onConnected " + alias);
emitter.onNext(alias);
}
};
}
};
private Observer<String> networkObserver = new Observer<String>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("networkObserver", "onSubscribe: ");
}
@Override
public void onNext(String action) {
Log.e("networkObserver", "onNext: " + action);
getSystemSettings();
}
@Override
public void onError(Throwable e) {
Log.e("networkObserver", "onError: " + e.getMessage());
}
@Override
public void onComplete() {
Log.e("networkObserver", "onComplete: ");
}
};
@Override
public IBinder onBind(Intent intent) {
Log.e(TAG, "onBind: ");
@@ -88,7 +139,11 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
Log.e(TAG, "setDefault: startServices time = " + (System.currentTimeMillis() - time) + "ms");
getSystemSettings();
mPresenter.checkUpdate();
Observable.create(networkSubscribe)
.throttleFirst(1, TimeUnit.HOURS)
.subscribe(networkObserver);
}
private void getSystemSettings() {

View File

@@ -82,11 +82,13 @@ public class JgyUtils {
public static final int HONOR_PLATFORM = 1;
public static final int LENOVO_PLATFORM = 2;
public static final int NATURE_PLATFORM = 3;
public static final int UNKNOW_PLATFORM = 0;
public static final String HONOR_TAG = "HONOR";
public static final String LENOVO_TAG = "lenovo";
public static final String NATURE_TAG = "Nature";
private HashSet<String> ownApp = new HashSet<String>() {{
@@ -475,8 +477,11 @@ public class JgyUtils {
Log.i(TAG, "checkAppPlatform: " + "honer");
return HONOR_PLATFORM;
} else if (LENOVO_TAG.equalsIgnoreCase(platform)) {
Log.i(TAG, "checkAppPlatform: " + "6gen1s");
Log.i(TAG, "checkAppPlatform: " + "lenovo");
return LENOVO_PLATFORM;
} else if (NATURE_TAG.equalsIgnoreCase(platform)) {
Log.i(TAG, "checkAppPlatform: " + "nature");
return NATURE_PLATFORM;
} else {
Log.i(TAG, "checkAppPlatform: " + "没有数据");
return UNKNOW_PLATFORM;
@@ -493,6 +498,8 @@ public class JgyUtils {
getAppPlatformCallback.AppPlatform(HONOR_PLATFORM);
} else if (LENOVO_TAG.equalsIgnoreCase(platform)) {
getAppPlatformCallback.AppPlatform(LENOVO_PLATFORM);
} else if (NATURE_TAG.equalsIgnoreCase(platform)) {
getAppPlatformCallback.AppPlatform(NATURE_PLATFORM);
} else {
getAppPlatformCallback.AppPlatform(UNKNOW_PLATFORM);
}
@@ -1287,7 +1294,7 @@ public class JgyUtils {
// mContext.startForegroundService(new Intent(mContext, MainService.class));
// Log.e(TAG, "setDefault: startServices time = " + (System.currentTimeMillis() - time) + "ms");
// } else {
mContext.startService(new Intent(mContext, MainService.class));
mContext.startService(new Intent(mContext, MainService.class));
// }
// }
}

View File

@@ -783,12 +783,12 @@ public class Utils {
// Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
// context.startActivity(intent);
} else {
Set<BluetoothDevice> devices = bluetoothAdapter.getBondedDevices();
// Set<BluetoothDevice> devices = bluetoothAdapter.getBondedDevices();
StringBuilder stringBuilder = new StringBuilder();
for (Iterator<BluetoothDevice> iterator = devices.iterator(); iterator.hasNext(); ) {
BluetoothDevice device = iterator.next();
stringBuilder.append(device.getAlias()).append(";");
}
// for (Iterator<BluetoothDevice> iterator = devices.iterator(); iterator.hasNext(); ) {
// BluetoothDevice device = iterator.next();
// stringBuilder.append(device.getAlias()).append(";");
// }
Log.e(TAG, "getBluetoothList: " + stringBuilder.toString());
return stringBuilder.toString();
}

View File

@@ -98,7 +98,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="80dp"
android:layout_marginEnd="80dp"
android:layout_marginBottom="8dp"
android:layout_marginBottom="24dp"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@+id/download_ok">
@@ -170,6 +170,7 @@
android:text="点击一键下载必备组件"
android:textColor="#ffffff"
android:textSize="12sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />