mirror of
https://github.com/oasisfeng/deagle.git
synced 2025-01-08 11:47:36 +08:00
UPDATE: Minor additions and tweaks.
This commit is contained in:
parent
7df83723ab
commit
61ea0bcd85
@ -6,10 +6,11 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.UserHandle;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
import static android.os.Build.VERSION_CODES.LOLLIPOP;
|
||||
import static android.os.Build.VERSION_CODES.N;
|
||||
@ -34,15 +35,19 @@ import static android.os.Build.VERSION_CODES.O;
|
||||
return info;
|
||||
}
|
||||
|
||||
@RequiresApi(N) @SuppressLint("NewApi")
|
||||
@RequiresApi(N)
|
||||
public ApplicationInfo getApplicationInfoNoThrows(final String pkg, final int flags, final UserHandle user) {
|
||||
return getApplicationInfoNoThrows(mLauncherApps, pkg, flags, user);
|
||||
}
|
||||
|
||||
@RequiresApi(N) @SuppressLint("NewApi")
|
||||
public static ApplicationInfo getApplicationInfoNoThrows(final LauncherApps la, final String pkg, final int flags, final UserHandle user) {
|
||||
try {
|
||||
return mLauncherApps.getApplicationInfo(pkg, flags, user);
|
||||
return la.getApplicationInfo(pkg, flags, user);
|
||||
} catch (final PackageManager.NameNotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public final LauncherApps get() {
|
||||
return mLauncherApps;
|
||||
}
|
||||
|
@ -38,6 +38,10 @@ import static android.os.Build.VERSION_CODES.LOLLIPOP;
|
||||
Builder(final Context context) { super(context, android.R.style.Theme_Material_Light_Dialog_Alert); }
|
||||
}
|
||||
|
||||
public static @CheckResult FluentProgressDialog buildProgress(final Activity activity, final @StringRes int message) {
|
||||
return buildProgress(activity, activity.getText(message));
|
||||
}
|
||||
|
||||
public static @CheckResult FluentProgressDialog buildProgress(final Activity activity, final CharSequence message) {
|
||||
final FluentProgressDialog dialog = new FluentProgressDialog(activity);
|
||||
dialog.setMessage(message);
|
||||
|
@ -20,6 +20,10 @@ public class Toasts {
|
||||
|
||||
private final static Looper MAIN_LOOPER = Looper.getMainLooper();
|
||||
|
||||
public static void showLong(final Context context, final CharSequence text) {
|
||||
show(context, text, Toast.LENGTH_LONG);
|
||||
}
|
||||
|
||||
public static void showLong(final Context context, final @StringRes int text) {
|
||||
show(context, text, Toast.LENGTH_LONG);
|
||||
}
|
||||
|
@ -5,6 +5,9 @@ import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@ -16,7 +19,7 @@ import androidx.annotation.Nullable;
|
||||
public class PseudoContentProvider extends ContentProvider {
|
||||
|
||||
/** Helper method to eliminate the nullness check. Be ware, never call it in the constructor! */
|
||||
protected Context context() { return getContext(); }
|
||||
@SuppressWarnings("ConstantConditions") protected @Nonnull Context context() { return getContext(); }
|
||||
|
||||
/* PseudoContentProvider does not provide resolver actions */
|
||||
|
||||
|
@ -7,7 +7,6 @@ import org.junit.Test;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import static com.oasisfeng.hack.Hack.ANY_TYPE;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@ -141,12 +140,8 @@ public class HackTest {
|
||||
assertEquals(-1, (int) fallback_field.get(simple));
|
||||
}
|
||||
|
||||
@Test public void testLazy() throws NoSuchFieldException, IllegalAccessException {
|
||||
//noinspection JavaReflectionMemberAccess
|
||||
final Field Hack_LAZY_RESOLVE = Hack.class.getDeclaredField("LAZY_RESOLVE");
|
||||
Hack_LAZY_RESOLVE.setAccessible(true);
|
||||
Hack_LAZY_RESOLVE.set(null, true);
|
||||
|
||||
@Test public void testLazy() {
|
||||
Hack.LAZY_RESOLVE = true;
|
||||
Hack.setAssertionFailureHandler(e -> fail(e.toString()));
|
||||
final Hack.HackedMethod0<Void, Object, Unchecked, Unchecked, Unchecked> method = Hack.into("nonexistent.Class").method("foo").fallbackReturning(null).withoutParams();
|
||||
Hack.setAssertionFailureHandler(null);
|
||||
|
Loading…
Reference in New Issue
Block a user