本文整理汇总了Java中com.lody.virtual.helper.utils.ArrayUtils类的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtils类的具体用法?Java ArrayUtils怎么用?Java ArrayUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArrayUtils类属于com.lody.virtual.helper.utils包,在下文中一共展示了ArrayUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import com.lody.virtual.helper.utils.ArrayUtils; //导入依赖的package包/类
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
String pkg = (String) args[0];
if (getHostPkg().equals(pkg)) {
return method.invoke(who, args);
}
int notificationIndex = ArrayUtils.indexOfFirst(args, Notification.class);
int idIndex = ArrayUtils.indexOfFirst(args, Integer.class);
int id = (int) args[idIndex];
id = VNotificationManager.get().dealNotificationId(id, pkg, null, getAppUserId());
args[idIndex] = id;
Notification notification = (Notification) args[notificationIndex];
if (!VNotificationManager.get().dealNotification(id, notification, pkg)) {
return 0;
}
VNotificationManager.get().addNotification(id, null, pkg, getAppUserId());
args[0] = getHostPkg();
return method.invoke(who, args);
}
示例2: read
import com.lody.virtual.helper.utils.ArrayUtils; //导入依赖的package包/类
/**
* java.io thinks that a read at EOF is an error and should return -1, contrary to traditional
* Unix practice where you'd read until you got 0 bytes (and any future read would return -1).
*/
public static int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws IOException {
ArrayUtils.checkOffsetAndCount(bytes.length, byteOffset, byteCount);
if (byteCount == 0) {
return 0;
}
try {
int readCount = Os.read(fd, bytes, byteOffset, byteCount);
if (readCount == 0) {
return -1;
}
return readCount;
} catch (ErrnoException errnoException) {
if (errnoException.errno == OsConstants.EAGAIN) {
// We return 0 rather than throw if we try to read from an empty non-blocking pipe.
return 0;
}
throw new IOException(errnoException);
}
}
示例3: write
import com.lody.virtual.helper.utils.ArrayUtils; //导入依赖的package包/类
/**
* java.io always writes every byte it's asked to, or fails with an error. (That is, unlike
* Unix it never just writes as many bytes as happens to be convenient.)
*/
public static void write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws IOException {
ArrayUtils.checkOffsetAndCount(bytes.length, byteOffset, byteCount);
if (byteCount == 0) {
return;
}
try {
while (byteCount > 0) {
int bytesWritten = Os.write(fd, bytes, byteOffset, byteCount);
byteCount -= bytesWritten;
byteOffset += bytesWritten;
}
} catch (ErrnoException errnoException) {
throw new IOException(errnoException);
}
}
示例4: uninstallPackageAsUser
import com.lody.virtual.helper.utils.ArrayUtils; //导入依赖的package包/类
@Override
public synchronized boolean uninstallPackageAsUser(String packageName, int userId) {
if (!VUserManagerService.get().exists(userId)) {
return false;
}
PackageSetting ps = PackageCacheManager.getSetting(packageName);
if (ps != null) {
int[] userIds = getPackageInstalledUsers(packageName);
if (!ArrayUtils.contains(userIds, userId)) {
return false;
}
if (userIds.length == 1) {
uninstallPackageFully(ps);
} else {
// Just hidden it
VActivityManagerService.get().killAppByPkg(packageName, userId);
ps.setInstalled(userId, false);
notifyAppUninstalled(ps, userId);
mPersistenceLayer.save();
FileUtils.deleteDir(VEnvironment.getDataUserPackageDirectory(userId, packageName));
}
return true;
}
return false;
}
示例5: realStartActivitiesLocked
import com.lody.virtual.helper.utils.ArrayUtils; //导入依赖的package包/类
private void realStartActivitiesLocked(IBinder resultTo, Intent[] intents, String[] resolvedTypes, Bundle options) {
Class<?>[] types = IActivityManager.startActivities.paramList();
Object[] args = new Object[types.length];
if (types[0] == IApplicationThread.TYPE) {
args[0] = ActivityThread.getApplicationThread.call(VirtualCore.mainThread());
}
int pkgIndex = ArrayUtils.protoIndexOf(types, String.class);
int intentsIndex = ArrayUtils.protoIndexOf(types, Intent[].class);
int resultToIndex = ArrayUtils.protoIndexOf(types, IBinder.class, 2);
int optionsIndex = ArrayUtils.protoIndexOf(types, Bundle.class);
int resolvedTypesIndex = intentsIndex + 1;
if (pkgIndex != -1) {
args[pkgIndex] = VirtualCore.get().getHostPkg();
}
args[intentsIndex] = intents;
args[resultToIndex] = resultTo;
args[resolvedTypesIndex] = resolvedTypes;
args[optionsIndex] = options;
ClassUtils.fixArgs(types, args);
IActivityManager.startActivities.call(ActivityManagerNative.getDefault.call(),
(Object[]) args);
}
示例6: call
import com.lody.virtual.helper.utils.ArrayUtils; //导入依赖的package包/类
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
if (isFakeLocationEnable()) {
Object transport = ArrayUtils.getFirst(args, mirror.android.location.LocationManager.GpsStatusListenerTransport.TYPE);
Object locationManager = mirror.android.location.LocationManager.GpsStatusListenerTransport.this$0.get(transport);
mirror.android.location.LocationManager.GpsStatusListenerTransport.onGpsStarted.call(transport);
mirror.android.location.LocationManager.GpsStatusListenerTransport.onFirstFix.call(transport, 0);
if (mirror.android.location.LocationManager.GpsStatusListenerTransport.mListener.get(transport) != null) {
MockLocationHelper.invokeSvStatusChanged(transport);
} else {
MockLocationHelper.invokeNmeaReceived(transport);
}
GPSListenerThread.get().addListenerTransport(locationManager);
return true;
}
return super.call(who, method, args);
}
示例7: call
import com.lody.virtual.helper.utils.ArrayUtils; //导入依赖的package包/类
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
//enqueueNotification(pkg, id, notification, idOut);
String pkg = (String) args[0];
int notificationIndex = ArrayUtils.indexOfFirst(args, Notification.class);
int idIndex = ArrayUtils.indexOfFirst(args, Integer.class);
int id = (int) args[idIndex];
id = VNotificationManager.get().dealNotificationId(id, pkg, null, getVUserId());
args[idIndex] = id;
Notification notification = (Notification) args[notificationIndex];
if (!VNotificationManager.get().dealNotification(id, notification, pkg)) {
return 0;
}
VNotificationManager.get().addNotification(id, null, pkg, getVUserId());
args[0] = getHostPkg();
return method.invoke(who, args);
}
示例8: realStartActivityLocked
import com.lody.virtual.helper.utils.ArrayUtils; //导入依赖的package包/类
private void realStartActivityLocked(IBinder resultTo, Intent intent, String resultWho, int requestCode,
Bundle options) {
Class<?>[] types = mirror.android.app.IActivityManager.startActivity.paramList();
Object[] args = new Object[types.length];
if (types[0] == IApplicationThread.TYPE) {
args[0] = ActivityThread.getApplicationThread.call(VirtualCore.mainThread());
}
int intentIndex = ArrayUtils.protoIndexOf(types, Intent.class);
int resultToIndex = ArrayUtils.protoIndexOf(types, IBinder.class, 2);
int optionsIndex = ArrayUtils.protoIndexOf(types, Bundle.class);
int resolvedTypeIndex = intentIndex + 1;
int resultWhoIndex = resultToIndex + 1;
int requestCodeIndex = resultToIndex + 2;
args[intentIndex] = intent;
args[resultToIndex] = resultTo;
args[resultWhoIndex] = resultWho;
args[requestCodeIndex] = requestCode;
if (optionsIndex != -1) {
args[optionsIndex] = options;
}
args[resolvedTypeIndex] = intent.getType();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
args[intentIndex - 1] = VirtualCore.get().getHostPkg();
}
ClassUtils.fixArgs(types, args);
mirror.android.app.IActivityManager.startActivity.call(ActivityManagerNative.getDefault.call(),
(Object[]) args);
}
示例9: beforeCall
import com.lody.virtual.helper.utils.ArrayUtils; //导入依赖的package包/类
@Override
public boolean beforeCall(Object who, Method method, Object... args) {
int index = ArrayUtils.indexOfLast(args, Integer.class);
if (index != -1) {
int uid = (int) args[index];
if (uid == Process.myUid()) {
args[index] = getRealUid();
}
}
return super.beforeCall(who, method, args);
}
示例10: beforeCall
import com.lody.virtual.helper.utils.ArrayUtils; //导入依赖的package包/类
@Override
public boolean beforeCall(Object who, Method method, Object... args) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && args[0] instanceof String) {
args[0] = getHostPkg();
}
int index = ArrayUtils.indexOfFirst(args, WorkSource.class);
if (index >= 0) {
args[index] = null;
}
return true;
}
示例11: call
import com.lody.virtual.helper.utils.ArrayUtils; //导入依赖的package包/类
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
int index = ArrayUtils.indexOfFirst(args, WindowManager.LayoutParams.class);
if (index != -1) {
WindowManager.LayoutParams attrs = (WindowManager.LayoutParams) args[index];
if (attrs != null) {
attrs.packageName = getHostPkg();
}
}
return method.invoke(who, args);
}
示例12: call
import com.lody.virtual.helper.utils.ArrayUtils; //导入依赖的package包/类
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
if (args.length == 2 && args[0] instanceof String && args[1] instanceof String) {
PackageManager pm = VirtualCore.getPM();
String pkgNameOne = (String) args[0], pkgNameTwo = (String) args[1];
try {
PackageInfo pkgOne = pm.getPackageInfo(pkgNameOne, PackageManager.GET_SIGNATURES);
PackageInfo pkgTwo = pm.getPackageInfo(pkgNameTwo, PackageManager.GET_SIGNATURES);
Signature[] one = pkgOne.signatures;
Signature[] two = pkgTwo.signatures;
if (ArrayUtils.isEmpty(one)) {
if (!ArrayUtils.isEmpty(two)) {
return PackageManager.SIGNATURE_FIRST_NOT_SIGNED;
} else {
return PackageManager.SIGNATURE_NEITHER_SIGNED;
}
} else {
if (ArrayUtils.isEmpty(two)) {
return PackageManager.SIGNATURE_SECOND_NOT_SIGNED;
} else {
// 走到了这里说明两个包的签名都在
if (Arrays.equals(one, two)) {
return PackageManager.SIGNATURE_MATCH;
} else {
return PackageManager.SIGNATURE_NO_MATCH;
}
}
}
} catch (Throwable e) {
// Ignore
}
}
return method.invoke(who, args);
}
示例13: call
import com.lody.virtual.helper.utils.ArrayUtils; //导入依赖的package包/类
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
if (noEditorInfo == null) {
editorInfoIndex = ArrayUtils.indexOfFirst(args, EditorInfo.class);
noEditorInfo = editorInfoIndex == -1;
}
if (!noEditorInfo) {
EditorInfo attribute = (EditorInfo) args[editorInfoIndex];
if (attribute != null) {
attribute.packageName = getHostPkg();
}
}
return method.invoke(who, args);
}
示例14: replaceFirstAppPkg
import com.lody.virtual.helper.utils.ArrayUtils; //导入依赖的package包/类
public static String replaceFirstAppPkg(Object[] args) {
if (args == null) {
return null;
}
int index = ArrayUtils.indexOfFirst(args, String.class);
if (index != -1) {
String pkg = (String) args[index];
args[index] = VirtualCore.get().getHostPkg();
return pkg;
}
return null;
}
示例15: replaceLastAppPkg
import com.lody.virtual.helper.utils.ArrayUtils; //导入依赖的package包/类
public static String replaceLastAppPkg(Object[] args) {
int index = ArrayUtils.indexOfLast(args, String.class);
if (index != -1) {
String pkg = (String) args[index];
args[index] = VirtualCore.get().getHostPkg();
return pkg;
}
return null;
}