mirror of
https://gitee.com/replugin/RePlugin.git
synced 2024-11-30 02:38:34 +08:00
Remove unused code for IOUtils
This commit is contained in:
parent
56617cab52
commit
723a7682b6
@ -44,26 +44,6 @@ public class AssetsUtils {
|
||||
|
||||
private static final String TAG = LogDebug.PLUGIN_TAG;
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static final String readUTF8(Context context, String name) {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = context.getAssets().open(name);
|
||||
return IOUtils.toString(is, Charsets.UTF_8);
|
||||
} catch (Throwable e) {
|
||||
if (LOGR) {
|
||||
LogRelease.e(TAG, e.getMessage(), e);
|
||||
}
|
||||
} finally {
|
||||
CloseableUtils.closeQuietly(is);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取文件到目标位置
|
||||
* @param context
|
||||
|
@ -16,17 +16,11 @@
|
||||
|
||||
package com.qihoo360.loader.utils;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.qihoo360.replugin.helper.LogRelease;
|
||||
|
||||
import com.qihoo360.replugin.utils.CloseableUtils;
|
||||
import com.qihoo360.replugin.utils.IOUtils;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static com.qihoo360.replugin.helper.LogDebug.LOG;
|
||||
import static com.qihoo360.replugin.helper.LogRelease.LOGR;
|
||||
|
||||
/**
|
||||
@ -38,6 +32,7 @@ public final class SysUtils {
|
||||
|
||||
/**
|
||||
* 返回当前的进程名
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getCurrentProcessName() {
|
||||
@ -64,39 +59,4 @@ public final class SysUtils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测是否模拟器(Release版本不做任何处理,总是返回false)
|
||||
* @return
|
||||
*/
|
||||
public static boolean isEmulator() {
|
||||
if (LOG) {
|
||||
try {
|
||||
Process pr = Runtime.getRuntime().exec("getprop ro.hardware");
|
||||
int code = pr.waitFor();
|
||||
if (code == 0) {
|
||||
InputStream in = pr.getInputStream();
|
||||
byte buffer[] = new byte[1024];
|
||||
try {
|
||||
int rc = IOUtils.read(in, buffer, 0, buffer.length);
|
||||
String str = new String(buffer, 0, rc, "UTF-8");
|
||||
if (!TextUtils.isEmpty(str) && str.contains("goldfish")) {
|
||||
return true;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
if (LOGR) {
|
||||
LogRelease.e(TAG, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
CloseableUtils.closeQuietly(in);
|
||||
}
|
||||
pr.destroy();
|
||||
} catch (Throwable e) {
|
||||
if (LOGR) {
|
||||
LogRelease.e(TAG, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -269,34 +269,4 @@ public class IOUtils {
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads bytes from an input stream.
|
||||
* This implementation guarantees that it will read as many bytes
|
||||
* as possible before giving up; this may not always be the case for
|
||||
* subclasses of {@link InputStream}.
|
||||
*
|
||||
* @param input where to read input from
|
||||
* @param buffer destination
|
||||
* @param offset initial offset into buffer
|
||||
* @param length length to read, must be >= 0
|
||||
* @return actual length read; may be less than requested if EOF was reached
|
||||
* @throws IOException if a read error occurs
|
||||
*/
|
||||
public static int read(final InputStream input, final byte[] buffer, final int offset, final int length)
|
||||
throws IOException {
|
||||
if (length < 0) {
|
||||
throw new IllegalArgumentException("Length must not be negative: " + length);
|
||||
}
|
||||
int remaining = length;
|
||||
while (remaining > 0) {
|
||||
final int location = length - remaining;
|
||||
final int count = input.read(buffer, offset + location, remaining);
|
||||
if (EOF == count) { // EOF
|
||||
break;
|
||||
}
|
||||
remaining -= count;
|
||||
}
|
||||
return length - remaining;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user