同步Main分支代码

nx2024
Matthew 4 months ago
parent 5ded377478
commit 0793a01b33

@ -107,6 +107,25 @@ public class JSONUtils {
return false;
}
public static JSONObject getConfigFile(String path, String fileName) {
JSONObject jsonObject = null;
File configFile = new File(Environment.getExternalStorageDirectory(), path);
if (!configFile.exists()) {
configFile.mkdirs();
}
configFile = new File(configFile, fileName);
if (!configFile.exists()) {
return jsonObject;
}
jsonObject = JSONUtils.loadJson(configFile.getAbsolutePath());
if (jsonObject == null) {
jsonObject = new JSONObject();
}
return jsonObject;
}
public static boolean updateConfigFile(String path, String fileName, String name, int fieldType, Object val) {
if (name == null) {

@ -83,7 +83,7 @@ public class MicroPhotoContext {
public static String getPrimaryStoragePath(Context context) {
try {
StorageManager sm = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
Method getVolumePathsMethod = StorageManager.class.getMethod("getVolumePaths", (Class<?>[])null);
Method getVolumePathsMethod = StorageManager.class.getMethod("getVolumePaths", (Class<?>[]) null);
Object[] args = null;
String[] paths = (String[]) getVolumePathsMethod.invoke(sm, args);
// first element in paths[] is primary storage path
@ -99,7 +99,7 @@ public class MicroPhotoContext {
public static String getSecondaryStoragePath(Context context) {
try {
StorageManager sm = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
Method getVolumePathsMethod = StorageManager.class.getMethod("getVolumePaths", (Class<?>[])null);
Method getVolumePathsMethod = StorageManager.class.getMethod("getVolumePaths", (Class<?>[]) null);
Object[] args = null;
String[] paths = (String[]) getVolumePathsMethod.invoke(sm, args);
// second element in paths[] is secondary storage path
@ -114,7 +114,7 @@ public class MicroPhotoContext {
public String getStorageState(Context context, String path) {
try {
StorageManager sm = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
Method getVolumeStateMethod = StorageManager.class.getMethod("getVolumeState", new Class[] {String.class});
Method getVolumeStateMethod = StorageManager.class.getMethod("getVolumeState", new Class[]{String.class});
String state = (String) getVolumeStateMethod.invoke(sm, path);
return state;
} catch (Exception e) {
@ -398,9 +398,9 @@ public class MicroPhotoContext {
intent.putExtra("reason", reason);
}
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent restartIntent = PendingIntent.getActivity(context, 0, intent, 0);
AlarmManager mgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
mgr.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + delayedTimeMs, restartIntent);
PendingIntent restartIntent = PendingIntent.getActivity(context, 100, intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
mgr.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + ((delayedTimeMs > 0) ? delayedTimeMs : 10), restartIntent);
}
public static void restartApp(Context context, String packageName, String reason) {

Loading…
Cancel
Save