bugfixes:增加设置壁纸
This commit is contained in:
2024-12-10 17:19:43 +08:00
parent c360344acc
commit 816753a500
22 changed files with 431 additions and 106 deletions

View File

@@ -48,6 +48,7 @@ import android.widget.Toast;
import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting;
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
import com.aoleyun.sn.BuildConfig;
import com.aoleyun.sn.R;
import com.aoleyun.sn.comm.CommonConfig;
@@ -109,7 +110,7 @@ import static android.content.Context.WIFI_SERVICE;
public class Utils {
private static String TAG = "Utils";
private static final String TAG = "Utils";
// MD5 设备地址标识
public static String getMAC(Context context) {
@@ -795,7 +796,7 @@ public class Utils {
* @return
*/
public static String getSerial(Context context) {
if ("HL500".equals(Build.MODEL)){
if ("HL500".equals(Build.MODEL)) {
return getIMEI(context);
}
if (TECLAST_BRAND.equalsIgnoreCase(Build.BRAND)) {
@@ -1470,8 +1471,8 @@ public class Utils {
jsonObject.addProperty("screen_rate", screen_rate);
jsonObject.addProperty("working_time", SystemClock.elapsedRealtime() / 1000);
jsonObject.addProperty("restart_count", (int) SPUtils.get(context, "restart_count", 0));
jsonObject.addProperty("storage_usable", getRemnantSize(context));
jsonObject.addProperty("storage_total", getDataTotalSize(context));
jsonObject.addProperty("storage_usable", getDataTotalSizeGb(context));
jsonObject.addProperty("storage_total", getDataTotalSizeGb(context));
String jsonString = jsonObject.toString();
Log.e(TAG, "getMachine: " + jsonString);
return jsonString;
@@ -1486,9 +1487,12 @@ public class Utils {
String storage = getRemnantSize(context) + "/" + getDataTotalSize(context);
int CPU = getNumCores();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("electric", electric);
jsonObject.addProperty("charging", charging);
jsonObject.addProperty("memory", memory);
jsonObject.addProperty("memory_used", Utils.getSizeGb(getFreeMemory(context)));
jsonObject.addProperty("memory_total", Utils.getSizeGb(getTotalMemory(context)));
jsonObject.addProperty("storage", storage);
jsonObject.addProperty("battery_capacity", Utils.getBatterymAh(context));
jsonObject.addProperty("CPU", CPU + "核");
@@ -1509,6 +1513,15 @@ public class Utils {
jsonObject.addProperty("longitude", longitude);
jsonObject.addProperty("latitude", latitude);
String jsonString = jsonObject.toString();
Log.e(TAG, "getAddressJsonString: " + jsonString);
return jsonString;
}
public static String getOtherInfo() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("push_id", PushServiceFactory.getCloudPushService().getDeviceId());
String jsonString = jsonObject.toString();
Log.e(TAG, "getOtherInfo: push_id = " + jsonString);
return jsonString;
}
@@ -1751,6 +1764,23 @@ public class Utils {
return String.format(Locale.getDefault(), " %.2f %s", size, units[index]);
}
public static String getSizeGb(long size) {
DecimalFormat df = new DecimalFormat("#.00");
return df.format((double) size / 1073741824);
}
public static String getDataTotalSizeGb(Context context) {
StatFs sf = new StatFs(context.getCacheDir().getAbsolutePath());
long blockSize = sf.getBlockSize();
long totalBlocks = sf.getBlockCount();
return getSizeGb(blockSize * totalBlocks);
}
public static String getRemnantSizeGb(Context context) {
StatFs sf = new StatFs(context.getCacheDir().getAbsolutePath());
long availableSize = sf.getAvailableBytes();
return getSizeGb(availableSize);
}
public static String getDataTotalSize(Context context) {
StatFs sf = new StatFs(context.getCacheDir().getAbsolutePath());