From 84ad6ed5359bb631078d6375c1339ac0372db34b Mon Sep 17 00:00:00 2001 From: NekoInverter <42698724+NekoInverter@users.noreply.github.com> Date: Sat, 21 Mar 2020 17:18:42 +0800 Subject: [PATCH] compileSdkVersion to 29 --- app/build.gradle | 2 +- app/src/main/java/android/os/FileUtils.java | 157 +----------------- .../edxposed/manager/SettingsActivity.java | 2 +- .../meowcat/edxposed/manager/XposedApp.java | 15 +- .../adapters/CursorRecyclerViewAdapter.java | 3 +- .../manager/receivers/BootReceiver.java | 13 +- .../edxposed/manager/util/DownloadsUtil.java | 1 - 7 files changed, 7 insertions(+), 186 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ce1201bc..237261cc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,7 +23,7 @@ android { keyPassword pwd != null ? pwd : System.getenv("ALIAS_PASS") } } - compileSdkVersion 28 + compileSdkVersion 29 //noinspection GradleDependency buildToolsVersion "29.0.2" defaultConfig { diff --git a/app/src/main/java/android/os/FileUtils.java b/app/src/main/java/android/os/FileUtils.java index 3391d365..3818b162 100644 --- a/app/src/main/java/android/os/FileUtils.java +++ b/app/src/main/java/android/os/FileUtils.java @@ -1,19 +1,6 @@ package android.os; -import java.io.BufferedInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.util.regex.Pattern; -import java.util.zip.CRC32; -import java.util.zip.CheckedInputStream; - -@SuppressWarnings("ALL") +@SuppressWarnings("unused") public class FileUtils { public static final int S_IRWXU = 448; public static final int S_IRUSR = 256; @@ -27,148 +14,6 @@ public class FileUtils { public static final int S_IROTH = 4; public static final int S_IWOTH = 2; public static final int S_IXOTH = 1; - private static final Pattern SAFE_FILENAME_PATTERN = Pattern.compile("[\\w%+,./=_-]+"); public static native int setPermissions(String paramString, int paramInt1, int paramInt2, int paramInt3); - - public static native int getFatVolumeId(String paramString); - - public static boolean sync(FileOutputStream stream) { - try { - if (stream != null) - stream.getFD().sync(); - return true; - } catch (IOException e) { - return false; - } - } - - public static boolean copyFile(File srcFile, File destFile) { - boolean result = false; - try { - InputStream in = new FileInputStream(srcFile); - try { - result = copyToFile(in, destFile); - } finally { - in.close(); - } - } catch (IOException e) { - result = false; - } - return result; - } - - public static boolean copyToFile(InputStream inputStream, File destFile) { - try { - if (destFile.exists()) - destFile.delete(); - FileOutputStream out = new FileOutputStream(destFile); - try { - byte[] buffer = new byte[4096]; - int bytesRead; - while ((bytesRead = inputStream.read(buffer)) >= 0) - out.write(buffer, 0, bytesRead); - } finally { - out.flush(); - try { - out.getFD().sync(); - } catch (IOException e) { - } - out.close(); - } - return true; - } catch (IOException e) { - return false; - } - } - - public static boolean isFilenameSafe(File file) { - return SAFE_FILENAME_PATTERN.matcher(file.getPath()).matches(); - } - - public static String readTextFile(File file, int max, String ellipsis) throws IOException { - InputStream input = new FileInputStream(file); - BufferedInputStream bis = new BufferedInputStream(input); - try { - long size = file.length(); - if (max > 0 || (size > 0L && max == 0)) { - if (size > 0L && (max == 0 || size < max)) - max = (int) size; - byte[] arrayOfByte = new byte[max + 1]; - int length = bis.read(arrayOfByte); - if (length <= 0) - return ""; - if (length <= max) - return new String(arrayOfByte, 0, length); - if (ellipsis == null) - return new String(arrayOfByte, 0, max); - return new String(arrayOfByte, 0, max) + ellipsis; - } - if (max < 0) { - int len; - boolean rolled = false; - byte[] last = null, arrayOfByte1 = null; - do { - if (last != null) - rolled = true; - byte[] tmp = last; - last = arrayOfByte1; - arrayOfByte1 = tmp; - if (arrayOfByte1 == null) - arrayOfByte1 = new byte[-max]; - len = bis.read(arrayOfByte1); - } while (len == arrayOfByte1.length); - if (last == null && len <= 0) - return ""; - if (last == null) - return new String(arrayOfByte1, 0, len); - if (len > 0) { - rolled = true; - System.arraycopy(last, len, last, 0, last.length - len); - System.arraycopy(arrayOfByte1, 0, last, last.length - len, len); - } - if (ellipsis == null || !rolled) - return new String(last); - return ellipsis + new String(last); - } - ByteArrayOutputStream contents = new ByteArrayOutputStream(); - byte[] data = new byte[1024]; - while (true) { - int len = bis.read(data); - if (len > 0) - contents.write(data, 0, len); - if (len != data.length) - return contents.toString(); - } - } finally { - bis.close(); - input.close(); - } - } - - public static void stringToFile(String filename, String string) throws IOException { - FileWriter out = new FileWriter(filename); - try { - out.write(string); - } finally { - out.close(); - } - } - - public static long checksumCrc32(File file) throws FileNotFoundException, IOException { - CRC32 checkSummer = new CRC32(); - CheckedInputStream cis = null; - try { - cis = new CheckedInputStream(new FileInputStream(file), checkSummer); - byte[] buf = new byte[128]; - while (cis.read(buf) >= 0) ; - return checkSummer.getValue(); - } finally { - if (cis != null) - try { - cis.close(); - } catch (IOException e) { - } - } - } } diff --git a/app/src/main/java/org/meowcat/edxposed/manager/SettingsActivity.java b/app/src/main/java/org/meowcat/edxposed/manager/SettingsActivity.java index cf567bd4..b8fbd060 100644 --- a/app/src/main/java/org/meowcat/edxposed/manager/SettingsActivity.java +++ b/app/src/main/java/org/meowcat/edxposed/manager/SettingsActivity.java @@ -415,7 +415,7 @@ public class SettingsActivity extends BaseActivity { Activity activity = getActivity(); if (activity != null) { Intent intent = new Intent(); - intent.putExtra("compat_list",true); + intent.putExtra("compat_list", true); intent.setClass(activity, BlackListActivity.class); activity.startActivity(intent); } diff --git a/app/src/main/java/org/meowcat/edxposed/manager/XposedApp.java b/app/src/main/java/org/meowcat/edxposed/manager/XposedApp.java index ff331788..b3a8348e 100644 --- a/app/src/main/java/org/meowcat/edxposed/manager/XposedApp.java +++ b/app/src/main/java/org/meowcat/edxposed/manager/XposedApp.java @@ -9,14 +9,13 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.os.Bundle; -import android.os.Environment; import android.os.FileUtils; import android.os.Handler; -import android.preference.PreferenceManager; import android.util.Log; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; +import androidx.preference.PreferenceManager; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import org.meowcat.edxposed.manager.receivers.PackageChangeReceiver; @@ -119,7 +118,6 @@ public class XposedApp extends de.robv.android.xposed.installer.XposedApp implem de.robv.android.xposed.installer.XposedApp.getInstance().reloadXposedProp(); createDirectories(); - delete(new File(Environment.getExternalStorageDirectory() + "/Download/EdXposedManager/.temp")); NotificationUtil.init(); registerReceivers(); @@ -152,17 +150,6 @@ public class XposedApp extends de.robv.android.xposed.installer.XposedApp implem new Intent(this, PackageChangeReceiver.class), 0); } - private void delete(File file) { - if (file != null) { - if (file.isDirectory()) { - File[] files = file.listFiles(); - if (files != null) for (File f : file.listFiles()) delete(f); - } - //noinspection ResultOfMethodCallIgnored - file.delete(); - } - } - @SuppressWarnings({"JavaReflectionMemberAccess", "OctalInteger"}) @SuppressLint({"PrivateApi", "NewApi"}) private void createDirectories() { diff --git a/app/src/main/java/org/meowcat/edxposed/manager/adapters/CursorRecyclerViewAdapter.java b/app/src/main/java/org/meowcat/edxposed/manager/adapters/CursorRecyclerViewAdapter.java index 76648eaa..30a593c5 100644 --- a/app/src/main/java/org/meowcat/edxposed/manager/adapters/CursorRecyclerViewAdapter.java +++ b/app/src/main/java/org/meowcat/edxposed/manager/adapters/CursorRecyclerViewAdapter.java @@ -95,13 +95,12 @@ public abstract class CursorRecyclerViewAdapter { - if (!isOnline(context)) return; - - new CheckUpdates().execute(); - }, 60 * 60 * 1000 /*60 min*/); - } - - private boolean isOnline(Context context) { - ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - NetworkInfo netInfo = cm.getActiveNetworkInfo(); - return netInfo != null && netInfo.isConnectedOrConnecting(); + new android.os.Handler().postDelayed(() -> new CheckUpdates().execute(), 60 * 60 * 1000 /*60 min*/); } private static class CheckUpdates extends AsyncTask { @@ -47,6 +37,7 @@ public class BootReceiver extends BroadcastReceiver { NotificationUtil.showInstallerUpdateNotification(); } } catch (Exception e) { + //noinspection ConstantConditions Log.d(XposedApp.TAG, e.getMessage()); } return null; diff --git a/app/src/main/java/org/meowcat/edxposed/manager/util/DownloadsUtil.java b/app/src/main/java/org/meowcat/edxposed/manager/util/DownloadsUtil.java index 6e0f819f..19341660 100644 --- a/app/src/main/java/org/meowcat/edxposed/manager/util/DownloadsUtil.java +++ b/app/src/main/java/org/meowcat/edxposed/manager/util/DownloadsUtil.java @@ -52,7 +52,6 @@ public class DownloadsUtil { request.setDestinationUri(Uri.fromFile(destination)); DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); long id = dm.enqueue(request); - return getById(context, id); }