Remove unused code for IOUtils

This commit is contained in:
zhangjiongxuan 2017-07-18 11:28:05 +08:00
parent 56617cab52
commit 723a7682b6
3 changed files with 1 additions and 91 deletions

View File

@ -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

View File

@ -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;
}
}

View File

@ -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;
}
}