Add more tests
@ -383,14 +383,14 @@ class AXMLParser:
|
||||
|
||||
# Minimum is a single ARSCHeader, which would be a strange edge case...
|
||||
if self.buff_size < 8:
|
||||
logger.error("Filesize is too small to be a valid AXML file! Filesize: {}".format(self.buff.size()))
|
||||
logger.error("Filesize is too small to be a valid AXML file! Filesize: {}".format(self.buff_size))
|
||||
self._valid = False
|
||||
return
|
||||
|
||||
# This would be even stranger, if an AXML file is larger than 4GB...
|
||||
# But this is not possible as the maximum chunk size is a unsigned 4 byte int.
|
||||
if self.buff_size > 0xFFFFFFFF:
|
||||
logger.error("Filesize is too large to be a valid AXML file! Filesize: {}".format(self.buff.size()))
|
||||
logger.error("Filesize is too large to be a valid AXML file! Filesize: {}".format(self.buff_size))
|
||||
self._valid = False
|
||||
return
|
||||
|
||||
@ -415,7 +415,7 @@ class AXMLParser:
|
||||
return
|
||||
|
||||
if self.filesize > self.buff_size:
|
||||
logger.error("This does not look like an AXML file. Declared filesize does not match real size: {} vs {}".format(self.filesize, self.buff.size()))
|
||||
logger.error("This does not look like an AXML file. Declared filesize does not match real size: {} vs {}".format(self.filesize, self.buff_size))
|
||||
self._valid = False
|
||||
return
|
||||
|
||||
@ -558,7 +558,7 @@ class AXMLParser:
|
||||
"This might be a packer.".format(s_prefix))
|
||||
|
||||
if (prefix, uri) in self.namespaces:
|
||||
logger.info("Namespace mapping ({}, {}) already seen! "
|
||||
logger.debug("Namespace mapping ({}, {}) already seen! "
|
||||
"This is usually not a problem but could indicate packers or broken AXML compilers.".format(prefix, uri))
|
||||
self.namespaces.append((prefix, uri))
|
||||
|
||||
|
@ -1,6 +1,23 @@
|
||||
# External dependecies
|
||||
import asn1crypto
|
||||
|
||||
import sys
|
||||
from loguru import logger
|
||||
|
||||
|
||||
class MyFilter:
|
||||
def __init__(self, level):
|
||||
self.level = level
|
||||
|
||||
def __call__(self, record):
|
||||
levelno = logger.level(self.level).no
|
||||
return record["level"].no >= levelno
|
||||
|
||||
def set_log(level):
|
||||
logger.remove(0)
|
||||
my_filter = MyFilter("INFO")
|
||||
logger.add(sys.stderr, filter=my_filter, level=0)
|
||||
|
||||
# Stuff that might be useful
|
||||
|
||||
def read_at(buff, offset, size=-1):
|
||||
|
13
cli.py
@ -13,6 +13,7 @@ from loguru import logger
|
||||
# local modules
|
||||
import androguard
|
||||
import androguard.core.apk
|
||||
from androguard import util
|
||||
|
||||
from main import (androarsc_main,
|
||||
androaxml_main,
|
||||
@ -24,23 +25,13 @@ from main import (androarsc_main,
|
||||
androdump_main,
|
||||
)
|
||||
|
||||
class MyFilter:
|
||||
|
||||
def __init__(self, level):
|
||||
self.level = level
|
||||
|
||||
def __call__(self, record):
|
||||
levelno = logger.level(self.level).no
|
||||
return record["level"].no >= levelno
|
||||
|
||||
@click.group(help=__doc__)
|
||||
@click.version_option(version=androguard.__version__)
|
||||
@click.option("--verbose", "--debug", 'verbosity', flag_value='verbose', help="Print more")
|
||||
def entry_point(verbosity):
|
||||
if verbosity == None:
|
||||
logger.remove(0)
|
||||
my_filter = MyFilter("INFO")
|
||||
logger.add(sys.stderr, filter=my_filter, level=0)
|
||||
util.set_log("INFO")
|
||||
logger.add("androguard.log", retention="10 days")
|
||||
|
||||
|
||||
|
BIN
tests/data/AXML/AndroidManifest-Chinese.xml
Normal file
BIN
tests/data/AXML/AndroidManifest-xmlns.xml
Normal file
BIN
tests/data/AXML/AndroidManifest.xml
Normal file
BIN
tests/data/AXML/AndroidManifestDoubleNamespace.xml
Normal file
BIN
tests/data/AXML/AndroidManifestExtraNamespace.xml
Normal file
BIN
tests/data/AXML/AndroidManifestLiapp.xml
Normal file
BIN
tests/data/AXML/AndroidManifestMaskingNamespace.xml
Normal file
BIN
tests/data/AXML/AndroidManifestNonZeroStyle.xml
Normal file
BIN
tests/data/AXML/AndroidManifestNullbytes.xml
Normal file
BIN
tests/data/AXML/AndroidManifestTextChunksXML.xml
Normal file
BIN
tests/data/AXML/AndroidManifestUTF8Strings.xml
Normal file
BIN
tests/data/AXML/AndroidManifestWithComment.xml
Normal file
BIN
tests/data/AXML/AndroidManifestWrongFilesize.xml
Normal file
BIN
tests/data/AXML/AndroidManifest_InvalidCharsInAttribute.xml
Normal file
BIN
tests/data/AXML/AndroidManifest_NamespaceInAttributeName.xml
Normal file
BIN
tests/data/AXML/AndroidManifest_NamespaceInAttributeName2.xml
Normal file
BIN
tests/data/AXML/AndroidManifest_ShortName.apk
Normal file
BIN
tests/data/AXML/AndroidManifest_StringNotTerminated.xml
Normal file
BIN
tests/data/AXML/AndroidManifest_WrongChunkStart.xml
Normal file
BIN
tests/data/AXML/test.xml
Normal file
BIN
tests/data/AXML/test1.xml
Normal file
BIN
tests/data/AXML/test2.xml
Normal file
BIN
tests/data/AXML/test3.xml
Normal file
15
tests/data/AndroguardTest/.gitignore
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
1
tests/data/AndroguardTest/app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build
|
44
tests/data/AndroguardTest/app/build.gradle
Normal file
@ -0,0 +1,44 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'androguard.test'
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
applicationId "androguard.test"
|
||||
minSdk 24
|
||||
targetSdk 33
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.5.2'
|
||||
implementation 'androidx.navigation:navigation-ui:2.5.2'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
}
|
21
tests/data/AndroguardTest/app/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
@ -0,0 +1,26 @@
|
||||
package androguard.test;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("androguard.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
28
tests/data/AndroguardTest/app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.AndroguardTest"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.AndroguardTest">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -0,0 +1,36 @@
|
||||
package androguard.test;
|
||||
|
||||
public class Eratosthene {
|
||||
public static int[] eratosthenes(int n) {
|
||||
boolean a[] = new boolean[n+1];
|
||||
a[0] = true;
|
||||
a[1] = true;
|
||||
|
||||
int sqn = (int)Math.sqrt(n);
|
||||
for(int i = 2; i <= sqn; i++) {
|
||||
if(!a[i]) {
|
||||
int j = i*i;
|
||||
while(j <= n) {
|
||||
a[j] = true;
|
||||
j += i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int cnt = 0;
|
||||
for(boolean b: a) {
|
||||
if(!b) {
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
int[] primes = new int[cnt];
|
||||
for(int i = 0; i < a.length; i++) {
|
||||
if(!a[i]) {
|
||||
primes[j++] = i;
|
||||
}
|
||||
}
|
||||
return primes;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package androguard.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
|
||||
import androguard.test.databinding.FragmentFirstBinding;
|
||||
|
||||
public class FirstFragment extends Fragment {
|
||||
|
||||
private FragmentFirstBinding binding;
|
||||
|
||||
@Override
|
||||
public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState
|
||||
) {
|
||||
|
||||
binding = FragmentFirstBinding.inflate(inflater, container, false);
|
||||
return binding.getRoot();
|
||||
|
||||
}
|
||||
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
binding.buttonFirst.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
NavHostFragment.findNavController(FirstFragment.this)
|
||||
.navigate(R.id.action_FirstFragment_to_SecondFragment);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package androguard.test;
|
||||
|
||||
public class Lzss {
|
||||
public static int lzss_decompress(byte[] in, byte[] out) {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int flags = 0;
|
||||
int cnt = 7;
|
||||
|
||||
while(j < out.length) {
|
||||
|
||||
if(++cnt == 8) {
|
||||
if(i >= in.length) {
|
||||
break;
|
||||
}
|
||||
flags = in[i++] & 0xFF;
|
||||
cnt = 0;
|
||||
}
|
||||
|
||||
if((flags & 1) == 0) {
|
||||
if(i >= in.length) {
|
||||
break;
|
||||
}
|
||||
out[j] = in[i];
|
||||
j++;
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
if((i + 1) >= in.length) {
|
||||
return -1;
|
||||
}
|
||||
int v = (in[i] & 0xFF) | (in[i+1] & 0xFF) << 8;
|
||||
i += 2;
|
||||
|
||||
int offset = (v >> 4) + 1;
|
||||
int length = (v & 0xF) + 3;
|
||||
|
||||
// not enough data decoded
|
||||
if(offset > j) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// output buffer is too small
|
||||
if((out.length - j) < length) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(int k = 0; k < length; k++) {
|
||||
out[j+k] = out[j+k-offset];
|
||||
}
|
||||
j += length;
|
||||
}
|
||||
|
||||
flags >>= 1;
|
||||
}
|
||||
|
||||
return j;
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package androguard.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.navigation.ui.AppBarConfiguration;
|
||||
import androidx.navigation.ui.NavigationUI;
|
||||
|
||||
import androguard.test.databinding.ActivityMainBinding;
|
||||
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private AppBarConfiguration appBarConfiguration;
|
||||
private ActivityMainBinding binding;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
setSupportActionBar(binding.toolbar);
|
||||
|
||||
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main);
|
||||
appBarConfiguration = new AppBarConfiguration.Builder(navController.getGraph()).build();
|
||||
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
|
||||
|
||||
binding.fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
||||
.setAnchorView(R.id.fab)
|
||||
.setAction("Action", null).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (id == R.id.action_settings) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSupportNavigateUp() {
|
||||
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main);
|
||||
return NavigationUI.navigateUp(navController, appBarConfiguration)
|
||||
|| super.onSupportNavigateUp();
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package androguard.test;
|
||||
|
||||
public class RC4 {
|
||||
public static void rc4_crypt(byte[] key, byte[] data) {
|
||||
int keylen = key.length;
|
||||
int datalen = data.length;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
// key scheduling
|
||||
byte[] sbox = new byte[256];
|
||||
for(i = 0; i < 256; i++) {
|
||||
sbox[i] = (byte)i;
|
||||
}
|
||||
j = 0;
|
||||
for(i = 0; i < 256; i++) {
|
||||
j = ((j + sbox[i] + key[i % keylen]) % 256) & 0xFF;
|
||||
byte tmp = sbox[i];
|
||||
sbox[i] = sbox[j];
|
||||
sbox[j] = tmp;
|
||||
}
|
||||
|
||||
// generate output
|
||||
i = 0;
|
||||
j = 0;
|
||||
int index = 0;
|
||||
while(index < datalen) {
|
||||
i = ((i + 1) % 256) & 0xFF;
|
||||
j = ((j + sbox[i]) % 256) & 0xFF;
|
||||
|
||||
byte tmp = sbox[i];
|
||||
sbox[i] = sbox[j];
|
||||
sbox[j] = tmp;
|
||||
|
||||
byte k = (byte)(sbox[((sbox[i] + sbox[j]) % 256) & 0xFF]);
|
||||
data[index] ^= k;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package androguard.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
|
||||
import androguard.test.databinding.FragmentSecondBinding;
|
||||
|
||||
public class SecondFragment extends Fragment {
|
||||
|
||||
private FragmentSecondBinding binding;
|
||||
|
||||
@Override
|
||||
public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState
|
||||
) {
|
||||
|
||||
binding = FragmentSecondBinding.inflate(inflater, container, false);
|
||||
return binding.getRoot();
|
||||
|
||||
}
|
||||
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
binding.buttonSecond.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
NavHostFragment.findNavController(SecondFragment.this)
|
||||
.navigate(R.id.action_SecondFragment_to_FirstFragment);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package androguard.test;
|
||||
|
||||
public class TestArr$ays {
|
||||
public static class InternField {
|
||||
public static byte[] b;
|
||||
}
|
||||
|
||||
private byte[] b;
|
||||
public byte[] d;
|
||||
|
||||
public TestArr$ays( ) {
|
||||
b = new byte[5];
|
||||
}
|
||||
|
||||
public TestArr$ays( byte [] b ) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
public TestArr$ays( int i ) {
|
||||
byte [] a = { 1, 2, 3, 4, 5 };
|
||||
b = a;
|
||||
}
|
||||
|
||||
public void testEmptyArrayByte( ) {
|
||||
byte [] b = new byte[5];
|
||||
InternField.b = b;
|
||||
}
|
||||
|
||||
public void testFullArrayByte( ) {
|
||||
byte[] b = { 1, 2, 4, 39, 20 };
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
public void testModifArrayByte( ) {
|
||||
b[2000000] = 2;
|
||||
}
|
||||
|
||||
public void testInstanceInternArrayByte( ){
|
||||
InternField f = new InternField();
|
||||
f.b = new byte[5];
|
||||
f.b[2] = 40;
|
||||
}
|
||||
}
|
@ -0,0 +1,432 @@
|
||||
package androguard.test;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class TestDefault {
|
||||
|
||||
public int value;
|
||||
public int value2;
|
||||
private int test = 10;
|
||||
private static final int test2 = 20;
|
||||
public int test3 = 30;
|
||||
public int tab[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
|
||||
static long [] test_;
|
||||
private class TestInnerClass {
|
||||
private int a, b;
|
||||
|
||||
private TestInnerClass(int a, int b)
|
||||
{
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
public void Test(int d)
|
||||
{
|
||||
System.out.println("Test2: " + this.a + d + this.b);
|
||||
}
|
||||
|
||||
private class TestInnerInnerClass {
|
||||
private int a, c;
|
||||
|
||||
private TestInnerInnerClass(int a, int c)
|
||||
{
|
||||
this.a = a;
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
public void Test(int b)
|
||||
{
|
||||
System.out.println("Test: " + this.a * b + this.c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void const4()
|
||||
{
|
||||
byte _ = -8;
|
||||
byte a = -7;
|
||||
byte b = -6;
|
||||
byte c = -5;
|
||||
byte d = -4;
|
||||
byte e = -3;
|
||||
byte f = -2;
|
||||
byte g = -1;
|
||||
byte h = 0;
|
||||
byte i = 1;
|
||||
byte j = 2;
|
||||
byte k = 3;
|
||||
byte l = 4;
|
||||
byte m = 5;
|
||||
byte n = 6;
|
||||
byte o = 7;
|
||||
System.out.println("" + _ + a + b + c + d + e + f + g + h + i + j + k + l + m + n + o);
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
int t = 5;
|
||||
System.out.println("foobar");
|
||||
}
|
||||
|
||||
public TestDefault() {
|
||||
value = 100;
|
||||
value2 = 200;
|
||||
}
|
||||
|
||||
public TestDefault(int value, int value2) {
|
||||
this.value = value;
|
||||
this.value2 = value2;
|
||||
}
|
||||
|
||||
public TestDefault(double value, double value2) {
|
||||
this.test = 5;
|
||||
this.value = (int) value;
|
||||
this.value2 = (int) value2;
|
||||
}
|
||||
|
||||
public int test_base(int _value, int _value2) {
|
||||
int y = 0;
|
||||
double sd = -6;
|
||||
double zz = -5;
|
||||
double yy = -4;
|
||||
double xx = -3;
|
||||
double w = -2;
|
||||
double x = -1;
|
||||
double k = 0.0;
|
||||
double d = 1;
|
||||
double b = 2;
|
||||
double c = 3;
|
||||
double f = 4;
|
||||
double z = 5;
|
||||
double cd = 6;
|
||||
float g = 4.20f;
|
||||
|
||||
double useless = g * c + b - y + d;
|
||||
|
||||
System.out.println("VALUE = " + this.value + " VALUE 2 = "
|
||||
+ this.value2);
|
||||
|
||||
for (int i = 0; i < (_value + _value2); i++) {
|
||||
y = this.value + y - this.value2;
|
||||
y = y & 200 * test1(20);
|
||||
|
||||
y = this.value2 - y;
|
||||
}
|
||||
|
||||
try {
|
||||
int[] t = new int[5];
|
||||
t[6] = 1;
|
||||
} catch (java.lang.ArrayIndexOutOfBoundsException e) {
|
||||
System.out.println("boom");
|
||||
}
|
||||
|
||||
if (this.value > 0) {
|
||||
this.value2 = y;
|
||||
}
|
||||
|
||||
switch (this.value) {
|
||||
case 0:
|
||||
this.value2 = this.pouet();
|
||||
break;
|
||||
default:
|
||||
this.value2 = this.pouet2();
|
||||
}
|
||||
|
||||
switch (this.value) {
|
||||
case 1:
|
||||
this.value2 = this.pouet();
|
||||
break;
|
||||
case 2:
|
||||
this.value2 = this.pouet2();
|
||||
break;
|
||||
case 3:
|
||||
this.value2 = this.pouet3();
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
public int foo(int i, int j) {
|
||||
while (true) {
|
||||
try {
|
||||
while (i < j)
|
||||
i = j++ / i;
|
||||
} catch (RuntimeException re) {
|
||||
i = 10;
|
||||
continue;
|
||||
}
|
||||
if (i == 0)
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
||||
public int foobis(int i, int j) {
|
||||
while (i < j && i != 10) {
|
||||
try {
|
||||
i = j++ / i;
|
||||
} catch (RuntimeException re) {
|
||||
i = 10;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return j;
|
||||
|
||||
}
|
||||
|
||||
public int foo2(int i, int j) {
|
||||
while (true) {
|
||||
if (i < j) {
|
||||
try {
|
||||
i = j++ / i;
|
||||
} catch (RuntimeException re) {
|
||||
i = 10;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (i == 0)
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
||||
public int foo4(int i, int j) {
|
||||
while (i < j) {
|
||||
try {
|
||||
i = j++ / i;
|
||||
} catch (RuntimeException re) {
|
||||
i = 10;
|
||||
}
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
public int test1(int val) {
|
||||
int a = 0x10;
|
||||
|
||||
return val + a - 60 * this.value;
|
||||
}
|
||||
|
||||
public int pouet() {
|
||||
int v = this.value;
|
||||
return v;
|
||||
}
|
||||
|
||||
public void testVars(int z, char y) {
|
||||
int a = this.value * 2;
|
||||
int b = 3;
|
||||
int c = 4;
|
||||
int d = c + b * a - 1 / 3 * this.value;
|
||||
int e = c + b - a;
|
||||
int f = e + 2;
|
||||
int g = 3 * d - c + f - 8;
|
||||
int h = 10 + this.value + a + b + c + d + e + f + g;
|
||||
int i = 150 - 40 + 12;
|
||||
int j = h - i + g;
|
||||
int k = 10;
|
||||
int l = 5;
|
||||
int m = 2;
|
||||
int n = 10;
|
||||
int o = k * l + m - n * this.value + c / e - f * g + h - j;
|
||||
int p = a + b + c;
|
||||
int q = p - k + o - l;
|
||||
int r = a + b - c * d / e - f + g - h * i + j * k * l - m - n + o / p
|
||||
* q;
|
||||
System.out.println(" meh " + r);
|
||||
System.out.println(y);
|
||||
y += 'a';
|
||||
this.testVars(a, y);
|
||||
this.test1(10);
|
||||
pouet2();
|
||||
this.pouet2();
|
||||
int s = pouet2();
|
||||
}
|
||||
|
||||
public static void testDouble() {
|
||||
double f = -5;
|
||||
double g = -4;
|
||||
double h = -3;
|
||||
double i = -2;
|
||||
double j = -1;
|
||||
double k = 0;
|
||||
double l = 1;
|
||||
double m = 2;
|
||||
double n = 3;
|
||||
double o = 4;
|
||||
double p = 5;
|
||||
|
||||
long ff = -5;
|
||||
long gg = -4;
|
||||
long hh = -3;
|
||||
long ii = -2;
|
||||
long jj = -1;
|
||||
long kk = 0;
|
||||
long ll = 1;
|
||||
long mm = 2;
|
||||
long nn = 3;
|
||||
long oo = 4;
|
||||
long pp = 5;
|
||||
|
||||
float fff = -5;
|
||||
float ggg = -4;
|
||||
float hhh = -3;
|
||||
float iii = -2;
|
||||
float jjj = -1;
|
||||
float kkk = 0;
|
||||
float lll = 1;
|
||||
float mmm = 2;
|
||||
float nnn = 3;
|
||||
float ooo = 4;
|
||||
float ppp = 5;
|
||||
|
||||
double abc = 65534;
|
||||
double def = 65535;
|
||||
double ghi = 65536;
|
||||
double jkl = 65537;
|
||||
|
||||
double mno = 32769;
|
||||
double pqr = 32768;
|
||||
double stu = 32767;
|
||||
double vwx = 32766;
|
||||
|
||||
long aabc = 65534;
|
||||
long adef = 65535;
|
||||
long aghi = 65536;
|
||||
long ajkl = 65537;
|
||||
|
||||
long amno = 32769;
|
||||
long apqr = 32768;
|
||||
long astu = 32767;
|
||||
long avwx = 32766;
|
||||
|
||||
float babc = 65534;
|
||||
float bdef = 65535;
|
||||
float bghi = 65536;
|
||||
float bjkl = 65537;
|
||||
|
||||
float bmno = 32769;
|
||||
float bpqr = 32768;
|
||||
float bstu = 32767;
|
||||
float bvwx = 32766;
|
||||
|
||||
double abcd = 5346952;
|
||||
long dcba = 5346952;
|
||||
float cabd = 5346952;
|
||||
|
||||
double zabc = 65534.50;
|
||||
double zdef = 65535.50;
|
||||
double zghi = 65536.50;
|
||||
double zjkl = 65537.50;
|
||||
|
||||
double zmno = 32769.50;
|
||||
double zpqr = 32768.50;
|
||||
double zstu = 32767.50;
|
||||
double zvwx = 32766.50;
|
||||
|
||||
float xabc = 65534.50f;
|
||||
float xdef = 65535.50f;
|
||||
float xghi = 65536.50f;
|
||||
float xjkl = 65537.50f;
|
||||
|
||||
float xmno = 32769.50f;
|
||||
float xpqr = 32768.50f;
|
||||
float xstu = 32767.50f;
|
||||
float xvwx = 32766.50f;
|
||||
|
||||
float ymno = -5f;
|
||||
float ypqr = -65535f;
|
||||
float ystu = -65536f;
|
||||
float yvwx = -123456789123456789.555555555f;
|
||||
double yvwx2 = -123456789123456789.555555555;
|
||||
int boom = -606384730;
|
||||
float reboom = -123456790519087104f;
|
||||
float gettype = boom + 2 + 3.5f;
|
||||
System.out.println(gettype);
|
||||
}
|
||||
|
||||
public static void testCall1(float b) {
|
||||
System.out.println("k" + b);
|
||||
}
|
||||
|
||||
public static void testCall2(long i) {
|
||||
new PrintStream(System.out).println("k" + i);
|
||||
}
|
||||
|
||||
public static void testCalls(TestIfs d) {
|
||||
testCall2(3);
|
||||
TestIfs.testIF(5);
|
||||
System.out.println(d.getClass());
|
||||
}
|
||||
|
||||
public static void testLoop(double a) {
|
||||
while (a < 10) {
|
||||
System.out.println(a);
|
||||
a *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
public void testVarArgs(int p, long[] p2, String... p3) {
|
||||
|
||||
}
|
||||
|
||||
public void testString( )
|
||||
{
|
||||
String a = "foo";
|
||||
String b = new String("bar");
|
||||
System.out.println(a + b);
|
||||
}
|
||||
|
||||
public synchronized int pouet2() {
|
||||
int i = 0, j = 10;
|
||||
System.out.println("test");
|
||||
|
||||
while (i < j) {
|
||||
try {
|
||||
i = j++ / i;
|
||||
} catch (RuntimeException re) {
|
||||
i = 10;
|
||||
}
|
||||
}
|
||||
this.value = i;
|
||||
return 90;
|
||||
}
|
||||
|
||||
public int pouet3() {
|
||||
return 80;
|
||||
}
|
||||
|
||||
public int go() {
|
||||
System.out.println(" test_base(500, 3) " + this.test_base(500, 3));
|
||||
return test + test2 + 10;
|
||||
}
|
||||
|
||||
public void testAccessField() {
|
||||
TestArr$ays a = new TestArr$ays();
|
||||
a.d = new byte[5];
|
||||
a.d[2] = 'c';
|
||||
System.out.println("test :" + a.d[2]);
|
||||
}
|
||||
|
||||
public static void main(String [] z)
|
||||
{
|
||||
int a = 5;
|
||||
switch(a)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
System.out.println("1 || 2");
|
||||
break;
|
||||
case 3:
|
||||
System.out.print("3 || ");
|
||||
case 4:
|
||||
default:
|
||||
System.out.println("4");
|
||||
break;
|
||||
case 5:
|
||||
System.out.println("5");
|
||||
}
|
||||
TestDefault p = new TestDefault();
|
||||
TestInnerClass t = p.new TestInnerClass(3, 4);
|
||||
TestInnerClass.TestInnerInnerClass t2 = t.new TestInnerInnerClass(3, 4);
|
||||
System.out.println("t.a = " + t.a);
|
||||
}
|
||||
}
|
@ -0,0 +1,145 @@
|
||||
package androguard.test;
|
||||
|
||||
public class TestExceptions {
|
||||
public int testException1( int a )
|
||||
{
|
||||
try {
|
||||
a = 5 / 0;
|
||||
} catch ( ArithmeticException e ) {
|
||||
a = 3;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
public static int testException2( int a, int b ) throws ArrayIndexOutOfBoundsException
|
||||
{
|
||||
int [] t = new int[b];
|
||||
|
||||
if ( b == 10 )
|
||||
b++;
|
||||
|
||||
for( int i = 0; i < b; i++ )
|
||||
{
|
||||
t[i] = 5;
|
||||
}
|
||||
|
||||
return a + t[0];
|
||||
}
|
||||
|
||||
public int testException3( int a, int[] t )
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if ( a % 2 == 0 )
|
||||
{
|
||||
try {
|
||||
result = t[a];
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
result = 1337;
|
||||
}
|
||||
}
|
||||
else if ( a % 3 == 0 ) {
|
||||
result = a * 2;
|
||||
} else {
|
||||
result = t[0] - 10;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public int testException4( int a )
|
||||
{
|
||||
int res = 15;
|
||||
|
||||
res += a;
|
||||
|
||||
try {
|
||||
Runtime b = Runtime.getRuntime();
|
||||
b.notifyAll();
|
||||
} catch( RuntimeException e ) {
|
||||
System.out.println("runtime " + e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
Runtime c = Runtime.getRuntime();
|
||||
c.wait();
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
System.out.println("runtime " + e.getMessage());
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("exception e " + e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
res /= a;
|
||||
} catch (Exception e) {
|
||||
System.out.println("exception e " + e.getMessage());
|
||||
}
|
||||
|
||||
System.out.println("end");
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
public static void testTry1(int b)
|
||||
{
|
||||
int a = 15;
|
||||
try {
|
||||
if ( b % 2 == 0)
|
||||
{
|
||||
a = a / b;
|
||||
if ( a - 3 == 4 )
|
||||
System.out.println("lll");
|
||||
}
|
||||
else {
|
||||
a = a * b;
|
||||
System.out.println("ppp");
|
||||
}
|
||||
} catch(ArithmeticException e){
|
||||
System.out.println("oupla");
|
||||
}
|
||||
}
|
||||
|
||||
public static void testCatch1(int b)
|
||||
{
|
||||
int a = 15;
|
||||
try {
|
||||
if ( b % 2 == 0 )
|
||||
{
|
||||
a = a / b;
|
||||
if ( a - 3 == 4 )
|
||||
System.out.println("mmm");
|
||||
} else {
|
||||
a = a * b;
|
||||
System.out.println("qqq");
|
||||
}
|
||||
} catch(ArithmeticException e)
|
||||
{
|
||||
if ( a == 12 )
|
||||
System.out.println("test");
|
||||
else {
|
||||
b += 3 * a;
|
||||
System.out.println("test2 " + b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void testExceptions( String [] z )
|
||||
{
|
||||
System.out.println( "Result test1 : " + new TestExceptions().testException1( 10 ) );
|
||||
|
||||
System.out.println( "=================================" );
|
||||
try {
|
||||
System.out.println( "Result test2 : " + testException2( 5, 10 ) );
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
System.out.println( "Result test2 : " + testException2( 5, 9 ) );
|
||||
}
|
||||
|
||||
System.out.println( "=================================" );
|
||||
int [] t = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
System.out.println( "Result test3 : " + new TestExceptions().testException3( 8, t ) );
|
||||
System.out.println( "Result test3 : " + new TestExceptions().testException3( 9, t ) );
|
||||
System.out.println( "Result test3 : " + new TestExceptions().testException3( 7, t ) );
|
||||
}
|
||||
}
|
@ -0,0 +1,145 @@
|
||||
package androguard.test;
|
||||
|
||||
public class TestIfs {
|
||||
private boolean P, Q, R, S, T;
|
||||
|
||||
public static int testIF(int p) {
|
||||
int i;
|
||||
|
||||
if (p > 0) {
|
||||
i = p * 2;
|
||||
} else {
|
||||
i = p + 2;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public static int testIF2(int p) {
|
||||
int i = 0;
|
||||
|
||||
if (p > 0) {
|
||||
i = p * 2;
|
||||
} else {
|
||||
i = p + 2;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public static int testIF3(int p) {
|
||||
int i = 0;
|
||||
if (p > 0) {
|
||||
i = p * 2;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public static int testIF4(int p, int i) {
|
||||
if (p > 0 && p % 2 == 3) {
|
||||
i += p * 3;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public static int testIF5(int p, int i) {
|
||||
if ((p <= 0 && i == 0) || (p == i * 2 || i == p / 3)) {
|
||||
i = -p;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public static int testIfBool(int p, boolean b) {
|
||||
int i = 0;
|
||||
if ( p > 0 && b )
|
||||
i += p * 3;
|
||||
else if (b)
|
||||
i += 5;
|
||||
else
|
||||
i = 2;
|
||||
return i;
|
||||
}
|
||||
|
||||
public static int testShortCircuit(int p) {
|
||||
int i = 0;
|
||||
if (p > 0 && p % 2 == 3) {
|
||||
i = p + 1;
|
||||
} else {
|
||||
i = -p;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public static int testShortCircuit2(int p) {
|
||||
int i = 0;
|
||||
if (p <= 0 || p % 2 != 3)
|
||||
i = -p;
|
||||
else
|
||||
i = p + 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
public static int testShortCircuit3(int p, int i) {
|
||||
if ((p <= 0 && i == 0) || (p == i * 2 || i == p / 3)) {
|
||||
i = -p;
|
||||
} else {
|
||||
i = p + 1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public static int testShortCircuit4(int p, int i) {
|
||||
if ((p <= 0 || i == 0) && (p == i * 2 || i == p / 3))
|
||||
i = -p;
|
||||
else
|
||||
i = p + 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
public void testCFG() {
|
||||
int I = 1, J = 1, K = 1, L = 1;
|
||||
|
||||
do {
|
||||
if (P) {
|
||||
J = I;
|
||||
if (Q)
|
||||
L = 2;
|
||||
else
|
||||
L = 3;
|
||||
K++;
|
||||
} else {
|
||||
K += 2;
|
||||
}
|
||||
System.out.println(I + "," + J + "," + K + "," + L);
|
||||
do {
|
||||
if (R)
|
||||
L += 4;
|
||||
} while (!S);
|
||||
I += 6;
|
||||
} while (!T);
|
||||
}
|
||||
|
||||
public void testCFG2(int a, int b, int c) {
|
||||
a += 5;
|
||||
b += a * 5;
|
||||
if (a < b) {
|
||||
if (b < c) {
|
||||
System.out.println("foo");
|
||||
} else {
|
||||
System.out.println("bar");
|
||||
}
|
||||
}
|
||||
a = 10;
|
||||
while (a < c) {
|
||||
a += c;
|
||||
do {
|
||||
b = a++;
|
||||
System.out.println("baz");
|
||||
} while (c < b);
|
||||
b++;
|
||||
}
|
||||
System.out.println("foobar");
|
||||
if (a >= 5 || b * c <= c + 10) {
|
||||
System.out.println("a = " + 5);
|
||||
}
|
||||
System.out.println("end");
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package androguard.test;
|
||||
|
||||
public class TestInvoke {
|
||||
public TestInvoke( ) {
|
||||
TestInvoke1(42 );
|
||||
}
|
||||
|
||||
public int TestInvoke1( int a )
|
||||
{
|
||||
return TestInvoke2( a, 42 );
|
||||
}
|
||||
|
||||
public int TestInvoke2( int a, int b )
|
||||
{
|
||||
return TestInvoke3( a, b, 42 );
|
||||
}
|
||||
|
||||
public int TestInvoke3( int a, int b, int c )
|
||||
{
|
||||
return TestInvoke4( a, b, c, 42 );
|
||||
}
|
||||
|
||||
public int TestInvoke4( int a, int b, int c, int d )
|
||||
{
|
||||
return TestInvoke5( a, b, c, d, 42 );
|
||||
}
|
||||
|
||||
public int TestInvoke5(int a, int b, int c, int d, int e)
|
||||
{
|
||||
return TestInvoke6( a, b, c, d, e, 42 );
|
||||
}
|
||||
|
||||
public int TestInvoke6( int a, int b, int c, int d, int e, int f )
|
||||
{
|
||||
return TestInvoke7( a, b, c, d, e, f, 42);
|
||||
}
|
||||
|
||||
public int TestInvoke7( int a, int b, int c, int d, int e, int f, int g )
|
||||
{
|
||||
return TestInvoke8( a, b, c, d, e, f, g, 42);
|
||||
}
|
||||
|
||||
public int TestInvoke8( int a, int b, int c, int d, int e, int f, int g, int h )
|
||||
{
|
||||
return a * b * c * d * e *f * g *h;
|
||||
}
|
||||
}
|
@ -0,0 +1,237 @@
|
||||
package androguard.test;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
public class TestLoops {
|
||||
|
||||
protected static class Loop {
|
||||
public static int i;
|
||||
public static int j;
|
||||
}
|
||||
|
||||
public void testWhile() {
|
||||
int i = 5, j = 10;
|
||||
while (i < j) {
|
||||
j += i / 2.0 + j;
|
||||
i += i * 2;
|
||||
}
|
||||
Loop.i = i;
|
||||
Loop.j = j;
|
||||
}
|
||||
|
||||
public void testWhile2() {
|
||||
while(true)
|
||||
System.out.println("toto");
|
||||
}
|
||||
|
||||
public void testWhile3(int i, int j)
|
||||
{
|
||||
while ( i < j && i % 2 == 0 )
|
||||
{
|
||||
i += j / 3;
|
||||
}
|
||||
}
|
||||
|
||||
public void testWhile4(int i, int j)
|
||||
{
|
||||
while ( i < j || i % 2 == 0 )
|
||||
{
|
||||
i += j / 3;
|
||||
}
|
||||
}
|
||||
|
||||
public void testWhile5(int i, int j, int k )
|
||||
{
|
||||
while ( ( i < j || i % 2 == 0 ) && ( j < k || k % 2 == 0) )
|
||||
i += k - j;
|
||||
}
|
||||
|
||||
public void testFor() {
|
||||
int i, j;
|
||||
for (i = 5, j = 10; i < j; i += i * 2) {
|
||||
j += i / 2.0 + j;
|
||||
}
|
||||
Loop.i = i;
|
||||
Loop.j = j;
|
||||
}
|
||||
|
||||
public void testDoWhile() {
|
||||
int i = 5, j = 10;
|
||||
do {
|
||||
j += i / 2.0 + j;
|
||||
i += i * 2;
|
||||
} while (i < j);
|
||||
Loop.i = i;
|
||||
Loop.j = j;
|
||||
}
|
||||
|
||||
public int testNestedLoops(int a) {
|
||||
if (a > 1000) {
|
||||
return testNestedLoops(a / 2);
|
||||
} else {
|
||||
while (a > 0) {
|
||||
a += 1;
|
||||
while (a % 2 == 0) {
|
||||
a *= 2;
|
||||
while (a % 3 == 0) {
|
||||
a -= 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
public void testMultipleLoops() {
|
||||
int a = 0;
|
||||
while (a < 50)
|
||||
a += 2;
|
||||
while (a % 3 == 0)
|
||||
a *= 5;
|
||||
while (a < 789 && a > 901)
|
||||
System.out.println("woo");
|
||||
}
|
||||
|
||||
public int testDoWhileTrue(int n) {
|
||||
do {
|
||||
n--;
|
||||
if (n == 2)
|
||||
return 5;
|
||||
if (n < 2)
|
||||
n = 500;
|
||||
} while (true);
|
||||
}
|
||||
|
||||
public int testWhileTrue(int n) {
|
||||
while (true) {
|
||||
n--;
|
||||
if (n == 2)
|
||||
return 5;
|
||||
if (n < 2)
|
||||
n = 500;
|
||||
}
|
||||
}
|
||||
|
||||
public int testDiffWhileDoWhile(int n) {
|
||||
while (n != 2) {
|
||||
if (n < 2)
|
||||
n = 500;
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
|
||||
public void testReducible(boolean x, boolean y) {
|
||||
int a = 0, b = 0;
|
||||
if (x)
|
||||
while (y) {
|
||||
a = b + 1;
|
||||
b++;
|
||||
}
|
||||
else
|
||||
while (y) {
|
||||
b++;
|
||||
a = b + 1;
|
||||
}
|
||||
Loop.i = a;
|
||||
Loop.j = b;
|
||||
}
|
||||
|
||||
public void testIrreducible(int a, int b) {
|
||||
while (true) {
|
||||
if (b < a) {
|
||||
Log.i("test", "In BasicBlock A");
|
||||
}
|
||||
b = a - 1;
|
||||
Log.i("test2", "In BasicBlock B");
|
||||
}
|
||||
}
|
||||
|
||||
public int testBreak( boolean b ) {
|
||||
int a = 0, c = 0;
|
||||
while(true) {
|
||||
System.out.println("foo");
|
||||
a += c;
|
||||
c += 5;
|
||||
if ( a == 50 )
|
||||
b = true;
|
||||
if ( b )
|
||||
break;
|
||||
}
|
||||
return a + c;
|
||||
}
|
||||
|
||||
public int testBreakbis( boolean b ) {
|
||||
int a = 0, c = 0;
|
||||
do {
|
||||
System.out.println("foo");
|
||||
a += c;
|
||||
c += 5;
|
||||
if ( a == 50 )
|
||||
b = true;
|
||||
if ( b )
|
||||
break;
|
||||
} while(true);
|
||||
return a + c;
|
||||
}
|
||||
|
||||
public int testBreakMid( boolean b ) {
|
||||
int a = Loop.i, c = Loop.j;
|
||||
while(true) {
|
||||
System.out.println("foo");
|
||||
a += c;
|
||||
c += 5;
|
||||
if ( a == 50 )
|
||||
b = !b;
|
||||
if ( b ) break;
|
||||
System.out.println("bar");
|
||||
a *= 2;
|
||||
}
|
||||
return a + c;
|
||||
}
|
||||
|
||||
public int testBreakDoWhile( boolean b ) {
|
||||
int a = 0, c = 0;
|
||||
do {
|
||||
System.out.println("foo");
|
||||
a += c;
|
||||
c += 5;
|
||||
if ( a == 50 )
|
||||
b = true;
|
||||
}while ( b );
|
||||
return a + c;
|
||||
}
|
||||
|
||||
public int testBreak2( boolean b ) {
|
||||
int a = 0, c = 0;
|
||||
while (true) {
|
||||
System.out.println("foo");
|
||||
a += c;
|
||||
c += 5;
|
||||
if ( a == 50 && b )
|
||||
break;
|
||||
}
|
||||
return a + c;
|
||||
}
|
||||
|
||||
public void testBreak3( boolean b ) {
|
||||
int a = 0, c = 0;
|
||||
while ( true ){
|
||||
System.out.println("foo");
|
||||
a += c;
|
||||
c += 5;
|
||||
if ( a == 50 && b )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void testBreak4( boolean b, int d ) {
|
||||
int a = 0, c = 0;
|
||||
while ( c < 50 ) {
|
||||
System.out.println("foo");
|
||||
a += c;
|
||||
c +=5;
|
||||
if ( a == d )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package androguard.test;
|
||||
|
||||
public class TestQuickSort {
|
||||
public int a = 10;
|
||||
|
||||
public static void Main(String[] args) {
|
||||
int[] intArray = new int[args.length];
|
||||
for (int i = 0; i < intArray.length; i++) {
|
||||
intArray[i] = Integer.parseInt(args[i]);
|
||||
}
|
||||
QuickSort(intArray, 0, intArray.length - 1);
|
||||
for (int i = 0; i < intArray.length; i++) {
|
||||
System.out.println(intArray[i] + " ");
|
||||
}
|
||||
}
|
||||
|
||||
public static void QuickSort(int[] array, int left, int right) {
|
||||
if (right > left) {
|
||||
int pivotIndex = (left + right) / 2;
|
||||
int pivotNew = Partition(array, left, right, pivotIndex);
|
||||
QuickSort(array, left, pivotNew - 1);
|
||||
QuickSort(array, pivotNew + 1, right);
|
||||
}
|
||||
}
|
||||
|
||||
static int Partition(int[] array, int left, int right, int pivotIndex) {
|
||||
int pivotValue = array[pivotIndex];
|
||||
Swap(array, pivotIndex, right);
|
||||
int storeIndex = left;
|
||||
for (int i = left; i < right; i++) {
|
||||
if (array[i] <= pivotValue) {
|
||||
Swap(array, storeIndex, i);
|
||||
storeIndex++;
|
||||
}
|
||||
}
|
||||
Swap(array, right, storeIndex);
|
||||
return storeIndex;
|
||||
}
|
||||
|
||||
static void Swap(int[] array, int index1, int index2) {
|
||||
int tmp = array[index1];
|
||||
array[index1] = array[index2];
|
||||
array[index2] = tmp;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package androguard.test;
|
||||
|
||||
public class TestQuickSort2 {
|
||||
public int a = 10;
|
||||
|
||||
public static void Main(String[] args) {
|
||||
int[] intArray = new int[args.length];
|
||||
for (int i = 0; i < intArray.length; i++) {
|
||||
intArray[i] = Integer.parseInt(args[i]);
|
||||
}
|
||||
quicksort(intArray, 0, intArray.length - 1);
|
||||
for (int i = 0; i < intArray.length; i++) {
|
||||
System.out.println(intArray[i] + " ");
|
||||
}
|
||||
}
|
||||
|
||||
public static void quicksort(int[] array, int lo, int hi) {
|
||||
int i = lo;
|
||||
int j = hi;
|
||||
|
||||
int pivot = array[lo + (hi - lo) / 2];
|
||||
|
||||
while(i <= j) {
|
||||
|
||||
while(array[i] < pivot) {
|
||||
i++;
|
||||
}
|
||||
|
||||
while(array[j] > pivot) {
|
||||
j--;
|
||||
}
|
||||
|
||||
if(i <= j) {
|
||||
int temp = array[i];
|
||||
array[i] = array[j];
|
||||
array[j] = temp;
|
||||
i++;
|
||||
j--;
|
||||
}
|
||||
}
|
||||
|
||||
if(lo < j) {
|
||||
quicksort(array, lo, j);
|
||||
}
|
||||
|
||||
if(i < hi) {
|
||||
quicksort(array, i, hi);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package androguard.test;
|
||||
|
||||
public class TestSynthetic {
|
||||
|
||||
public static void TestSynthetic1( ){
|
||||
final Object o = new Object();
|
||||
|
||||
new Thread(){
|
||||
public void run(){
|
||||
System.out.println( "o : " + o.hashCode() );
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
public static void TestSynthetic2() {
|
||||
System.out.println( "o : " +
|
||||
new Object(){
|
||||
public int toto(char c){
|
||||
return Integer.parseInt("" + c);
|
||||
}
|
||||
}.toto('k')
|
||||
);
|
||||
}
|
||||
|
||||
public static void TestSynthetic3( ){
|
||||
Integer o = Integer.valueOf(5);
|
||||
|
||||
new Thread(){
|
||||
Integer o = this.o;
|
||||
public void run(){
|
||||
System.out.println( "o : " + o.hashCode() );
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
public static void TestSynthetic4( final int t ) {
|
||||
final Object o = new Object();
|
||||
|
||||
new Thread(){
|
||||
public void run(){
|
||||
synchronized(o){
|
||||
if ( t == 0 ) {
|
||||
TestSynthetic1();
|
||||
}
|
||||
else {
|
||||
TestSynthetic2();
|
||||
}
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
|
||||
System.out.println("end");
|
||||
}
|
||||
|
||||
|
||||
public class Bridge<T> {
|
||||
public T getT(T arg){
|
||||
return arg;
|
||||
}
|
||||
}
|
||||
|
||||
public class BridgeExt extends Bridge<String>{
|
||||
public String getT(String arg){
|
||||
return arg;
|
||||
}
|
||||
}
|
||||
|
||||
public static void TestBridge( ){
|
||||
TestSynthetic p = new TestSynthetic();
|
||||
TestSynthetic.Bridge<Integer> x = p.new Bridge<Integer>();
|
||||
System.out.println("bridge<integer> " + x.getT(5));
|
||||
TestSynthetic.Bridge<String> w = p.new BridgeExt();
|
||||
System.out.println("bridgeext " + w.getT("toto"));
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_main" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_marginEnd="@dimen/fab_margin"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:srcCompat="@android:drawable/ic_dialog_email" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_host_fragment_content_main"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:defaultNavHost="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navGraph="@navigation/nav_graph" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".FirstFragment">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="16dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_first"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/next"
|
||||
app:layout_constraintBottom_toTopOf="@id/textview_first"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textview_first"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/lorem_ipsum"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/button_first" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".SecondFragment">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="16dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_second"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/previous"
|
||||
app:layout_constraintBottom_toTopOf="@id/textview_second"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textview_second"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/lorem_ipsum"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/button_second" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
@ -0,0 +1,10 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="androguard.test.MainActivity">
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/action_settings"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 982 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 7.6 KiB |
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/nav_graph"
|
||||
app:startDestination="@id/FirstFragment">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/FirstFragment"
|
||||
android:name="androguard.test.FirstFragment"
|
||||
android:label="@string/first_fragment_label"
|
||||
tools:layout="@layout/fragment_first">
|
||||
|
||||
<action
|
||||
android:id="@+id/action_FirstFragment_to_SecondFragment"
|
||||
app:destination="@id/SecondFragment" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/SecondFragment"
|
||||
android:name="androguard.test.SecondFragment"
|
||||
android:label="@string/second_fragment_label"
|
||||
tools:layout="@layout/fragment_second">
|
||||
|
||||
<action
|
||||
android:id="@+id/action_SecondFragment_to_FirstFragment"
|
||||
app:destination="@id/FirstFragment" />
|
||||
</fragment>
|
||||
</navigation>
|
@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<dimen name="fab_margin">48dp</dimen>
|
||||
</resources>
|
@ -0,0 +1,7 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.AndroguardTest" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your dark theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
||||
</style>
|
||||
</resources>
|
@ -0,0 +1,9 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<style name="Theme.AndroguardTest" parent="Base.Theme.AndroguardTest">
|
||||
<!-- Transparent system bars for edge-to-edge. -->
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>
|
||||
</style>
|
||||
</resources>
|
@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<dimen name="fab_margin">200dp</dimen>
|
||||
</resources>
|
@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<dimen name="fab_margin">48dp</dimen>
|
||||
</resources>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
</resources>
|
@ -0,0 +1,46 @@
|
||||
<resources>
|
||||
<string name="app_name">AndroguardTest</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<!-- Strings used for fragments for navigation -->
|
||||
<string name="first_fragment_label">First Fragment</string>
|
||||
<string name="second_fragment_label">Second Fragment</string>
|
||||
<string name="next">Next</string>
|
||||
<string name="previous">Previous</string>
|
||||
|
||||
<string name="lorem_ipsum">
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam in scelerisque sem. Mauris
|
||||
volutpat, dolor id interdum ullamcorper, risus dolor egestas lectus, sit amet mattis purus
|
||||
dui nec risus. Maecenas non sodales nisi, vel dictum dolor. Class aptent taciti sociosqu ad
|
||||
litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse blandit eleifend
|
||||
diam, vel rutrum tellus vulputate quis. Aliquam eget libero aliquet, imperdiet nisl a,
|
||||
ornare ex. Sed rhoncus est ut libero porta lobortis. Fusce in dictum tellus.\n\n
|
||||
Suspendisse interdum ornare ante. Aliquam nec cursus lorem. Morbi id magna felis. Vivamus
|
||||
egestas, est a condimentum egestas, turpis nisl iaculis ipsum, in dictum tellus dolor sed
|
||||
neque. Morbi tellus erat, dapibus ut sem a, iaculis tincidunt dui. Interdum et malesuada
|
||||
fames ac ante ipsum primis in faucibus. Curabitur et eros porttitor, ultricies urna vitae,
|
||||
molestie nibh. Phasellus at commodo eros, non aliquet metus. Sed maximus nisl nec dolor
|
||||
bibendum, vel congue leo egestas.\n\n
|
||||
Sed interdum tortor nibh, in sagittis risus mollis quis. Curabitur mi odio, condimentum sit
|
||||
amet auctor at, mollis non turpis. Nullam pretium libero vestibulum, finibus orci vel,
|
||||
molestie quam. Fusce blandit tincidunt nulla, quis sollicitudin libero facilisis et. Integer
|
||||
interdum nunc ligula, et fermentum metus hendrerit id. Vestibulum lectus felis, dictum at
|
||||
lacinia sit amet, tristique id quam. Cras eu consequat dui. Suspendisse sodales nunc ligula,
|
||||
in lobortis sem porta sed. Integer id ultrices magna, in luctus elit. Sed a pellentesque
|
||||
est.\n\n
|
||||
Aenean nunc velit, lacinia sed dolor sed, ultrices viverra nulla. Etiam a venenatis nibh.
|
||||
Morbi laoreet, tortor sed facilisis varius, nibh orci rhoncus nulla, id elementum leo dui
|
||||
non lorem. Nam mollis ipsum quis auctor varius. Quisque elementum eu libero sed commodo. In
|
||||
eros nisl, imperdiet vel imperdiet et, scelerisque a mauris. Pellentesque varius ex nunc,
|
||||
quis imperdiet eros placerat ac. Duis finibus orci et est auctor tincidunt. Sed non viverra
|
||||
ipsum. Nunc quis augue egestas, cursus lorem at, molestie sem. Morbi a consectetur ipsum, a
|
||||
placerat diam. Etiam vulputate dignissim convallis. Integer faucibus mauris sit amet finibus
|
||||
convallis.\n\n
|
||||
Phasellus in aliquet mi. Pellentesque habitant morbi tristique senectus et netus et
|
||||
malesuada fames ac turpis egestas. In volutpat arcu ut felis sagittis, in finibus massa
|
||||
gravida. Pellentesque id tellus orci. Integer dictum, lorem sed efficitur ullamcorper,
|
||||
libero justo consectetur ipsum, in mollis nisl ex sed nisl. Donec maximus ullamcorper
|
||||
sodales. Praesent bibendum rhoncus tellus nec feugiat. In a ornare nulla. Donec rhoncus
|
||||
libero vel nunc consequat, quis tincidunt nisl eleifend. Cras bibendum enim a justo luctus
|
||||
vestibulum. Fusce dictum libero quis erat maximus, vitae volutpat diam dignissim.
|
||||
</string>
|
||||
</resources>
|
@ -0,0 +1,9 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.AndroguardTest" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your light theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.AndroguardTest" parent="Base.Theme.AndroguardTest" />
|
||||
</resources>
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample backup rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/guide/topics/data/autobackup
|
||||
for details.
|
||||
Note: This file is ignored for devices older that API 31
|
||||
See https://developer.android.com/about/versions/12/backup-restore
|
||||
-->
|
||||
<full-backup-content>
|
||||
<!--
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="device.xml"/>
|
||||
-->
|
||||
</full-backup-content>
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample data extraction rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||
for details.
|
||||
-->
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
-->
|
||||
</cloud-backup>
|
||||
<!--
|
||||
<device-transfer>
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
</device-transfer>
|
||||
-->
|
||||
</data-extraction-rules>
|
@ -0,0 +1,17 @@
|
||||
package androguard.test;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
5
tests/data/AndroguardTest/build.gradle
Normal file
@ -0,0 +1,5 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
id 'com.android.application' version '8.0.2' apply false
|
||||
id 'com.android.library' version '8.0.2' apply false
|
||||
}
|
21
tests/data/AndroguardTest/gradle.properties
Normal file
@ -0,0 +1,21 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
BIN
tests/data/AndroguardTest/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
tests/data/AndroguardTest/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
#Sun Jun 11 18:36:44 CEST 2023
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
185
tests/data/AndroguardTest/gradlew
vendored
Normal file
@ -0,0 +1,185 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
89
tests/data/AndroguardTest/gradlew.bat
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
16
tests/data/AndroguardTest/settings.gradle
Normal file
@ -0,0 +1,16 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
rootProject.name = "AndroguardTest"
|
||||
include ':app'
|
@ -2,12 +2,15 @@ import unittest
|
||||
|
||||
from xml.dom import minidom
|
||||
from lxml import etree
|
||||
import io
|
||||
|
||||
import sys
|
||||
sys.path.append("./")
|
||||
|
||||
from androguard.core import axml
|
||||
from androguard.core import bytecode
|
||||
from androguard.util import set_log
|
||||
|
||||
|
||||
def is_valid_manifest(tree):
|
||||
# We can not really check much more...
|
||||
@ -182,23 +185,23 @@ class AXMLTest(unittest.TestCase):
|
||||
def testArscHeader(self):
|
||||
"""Test if wrong arsc headers are rejected"""
|
||||
with self.assertRaises(axml.ResParserError) as cnx:
|
||||
axml.ARSCHeader(bytecode.BuffHandle(b"\x02\x01"))
|
||||
axml.ARSCHeader(io.BufferedReader(io.BytesIO(b"\x02\x01")))
|
||||
self.assertIn("Can not read over the buffer size", str(cnx.exception))
|
||||
|
||||
with self.assertRaises(axml.ResParserError) as cnx:
|
||||
axml.ARSCHeader(bytecode.BuffHandle(b"\x02\x01\xFF\xFF\x08\x00\x00\x00"))
|
||||
axml.ARSCHeader(io.BufferedReader(io.BytesIO(b"\x02\x01\xFF\xFF\x08\x00\x00\x00")))
|
||||
self.assertIn("smaller than header size", str(cnx.exception))
|
||||
|
||||
with self.assertRaises(axml.ResParserError) as cnx:
|
||||
axml.ARSCHeader(bytecode.BuffHandle(b"\x02\x01\x01\x00\x08\x00\x00\x00"))
|
||||
axml.ARSCHeader(io.BufferedReader(io.BytesIO(b"\x02\x01\x01\x00\x08\x00\x00\x00")))
|
||||
self.assertIn("declared header size is smaller than required size", str(cnx.exception))
|
||||
|
||||
with self.assertRaises(axml.ResParserError) as cnx:
|
||||
axml.ARSCHeader(bytecode.BuffHandle(b"\x02\x01\x08\x00\x04\x00\x00\x00"))
|
||||
axml.ARSCHeader(io.BufferedReader(io.BytesIO(b"\x02\x01\x08\x00\x04\x00\x00\x00")))
|
||||
self.assertIn("declared chunk size is smaller than required size", str(cnx.exception))
|
||||
|
||||
a = axml.ARSCHeader(bytecode.BuffHandle(b"\xCA\xFE\x08\x00\x10\x00\x00\x00"
|
||||
b"\xDE\xEA\xBE\xEF\x42\x42\x42\x42"))
|
||||
a = axml.ARSCHeader(io.BufferedReader(io.BytesIO(b"\xCA\xFE\x08\x00\x10\x00\x00\x00"
|
||||
b"\xDE\xEA\xBE\xEF\x42\x42\x42\x42")))
|
||||
|
||||
self.assertEqual(a.type, 0xFECA)
|
||||
self.assertEqual(a.header_size, 8)
|
||||
@ -209,22 +212,22 @@ class AXMLTest(unittest.TestCase):
|
||||
|
||||
def testAndroidManifest(self):
|
||||
filenames = [
|
||||
"examples/axml/AndroidManifest.xml",
|
||||
"examples/axml/AndroidManifest-Chinese.xml",
|
||||
"examples/axml/AndroidManifestDoubleNamespace.xml",
|
||||
"examples/axml/AndroidManifestExtraNamespace.xml",
|
||||
"examples/axml/AndroidManifest_InvalidCharsInAttribute.xml",
|
||||
"examples/axml/AndroidManifestLiapp.xml",
|
||||
"examples/axml/AndroidManifestMaskingNamespace.xml",
|
||||
"examples/axml/AndroidManifest_NamespaceInAttributeName.xml",
|
||||
"examples/axml/AndroidManifest_NamespaceInAttributeName2.xml",
|
||||
"examples/axml/AndroidManifestNonZeroStyle.xml",
|
||||
"examples/axml/AndroidManifestNullbytes.xml",
|
||||
"examples/axml/AndroidManifestTextChunksXML.xml",
|
||||
"examples/axml/AndroidManifestUTF8Strings.xml",
|
||||
"examples/axml/AndroidManifestWithComment.xml",
|
||||
"examples/axml/AndroidManifest_WrongChunkStart.xml",
|
||||
"examples/axml/AndroidManifest-xmlns.xml",
|
||||
"tests/data/AXML/AndroidManifest.xml",
|
||||
"tests/data/AXML/AndroidManifest-Chinese.xml",
|
||||
"tests/data/AXML/AndroidManifestDoubleNamespace.xml",
|
||||
"tests/data/AXML/AndroidManifestExtraNamespace.xml",
|
||||
"tests/data/AXML/AndroidManifest_InvalidCharsInAttribute.xml",
|
||||
"tests/data/AXML/AndroidManifestLiapp.xml",
|
||||
"tests/data/AXML/AndroidManifestMaskingNamespace.xml",
|
||||
"tests/data/AXML/AndroidManifest_NamespaceInAttributeName.xml",
|
||||
"tests/data/AXML/AndroidManifest_NamespaceInAttributeName2.xml",
|
||||
"tests/data/AXML/AndroidManifestNonZeroStyle.xml",
|
||||
"tests/data/AXML/AndroidManifestNullbytes.xml",
|
||||
"tests/data/AXML/AndroidManifestTextChunksXML.xml",
|
||||
"tests/data/AXML/AndroidManifestUTF8Strings.xml",
|
||||
"tests/data/AXML/AndroidManifestWithComment.xml",
|
||||
"tests/data/AXML/AndroidManifest_WrongChunkStart.xml",
|
||||
"tests/data/AXML/AndroidManifest-xmlns.xml",
|
||||
]
|
||||
|
||||
for filename in filenames:
|
||||
@ -238,26 +241,26 @@ class AXMLTest(unittest.TestCase):
|
||||
e = minidom.parseString(ap.get_buff())
|
||||
self.assertIsNotNone(e)
|
||||
|
||||
def testFileCompare(self):
|
||||
"""
|
||||
Compare the binary version of a file with the plain text
|
||||
"""
|
||||
binary = "examples/axml/AndroidManifest.xml"
|
||||
plain = "examples/android/TC/AndroidManifest.xml"
|
||||
#def testFileCompare(self):
|
||||
# """
|
||||
# Compare the binary version of a file with the plain text
|
||||
# """
|
||||
# binary = "tests/data/AXML/AndroidManifest.xml"
|
||||
# plain = "tests/data/android/TC/AndroidManifest.xml"
|
||||
|
||||
with open(plain, "rb") as fp:
|
||||
x1 = etree.fromstring(fp.read())
|
||||
with open(binary, "rb") as fp:
|
||||
x2 = axml.AXMLPrinter(fp.read()).get_xml_obj()
|
||||
# with open(plain, "rb") as fp:
|
||||
# x1 = etree.fromstring(fp.read())
|
||||
# with open(binary, "rb") as fp:
|
||||
# x2 = axml.AXMLPrinter(fp.read()).get_xml_obj()
|
||||
|
||||
self.assertTrue(xml_compare(x1, x2, reporter=print))
|
||||
# self.assertTrue(xml_compare(x1, x2, reporter=print))
|
||||
|
||||
def testNonManifest(self):
|
||||
filenames = [
|
||||
"examples/axml/test.xml",
|
||||
"examples/axml/test1.xml",
|
||||
"examples/axml/test2.xml",
|
||||
"examples/axml/test3.xml",
|
||||
"tests/data/AXML/test.xml",
|
||||
"tests/data/AXML/test1.xml",
|
||||
"tests/data/AXML/test2.xml",
|
||||
"tests/data/AXML/test3.xml",
|
||||
]
|
||||
|
||||
for filename in filenames:
|
||||
@ -275,7 +278,7 @@ class AXMLTest(unittest.TestCase):
|
||||
Test if a nonzero style offset in the string section causes problems
|
||||
if the counter is 0
|
||||
"""
|
||||
filename = "examples/axml/AndroidManifestNonZeroStyle.xml"
|
||||
filename = "tests/data/AXML/AndroidManifestNonZeroStyle.xml"
|
||||
|
||||
with open(filename, "rb") as f:
|
||||
ap = axml.AXMLPrinter(f.read())
|
||||
@ -290,7 +293,7 @@ class AXMLTest(unittest.TestCase):
|
||||
Test if non-null terminated strings are detected.
|
||||
This sample even segfaults aapt...
|
||||
"""
|
||||
filename = "examples/axml/AndroidManifest_StringNotTerminated.xml"
|
||||
filename = "tests/data/AXML/AndroidManifest_StringNotTerminated.xml"
|
||||
|
||||
with self.assertRaises(axml.ResParserError) as cnx:
|
||||
with open(filename, "rb") as f:
|
||||
@ -301,7 +304,7 @@ class AXMLTest(unittest.TestCase):
|
||||
"""
|
||||
Test if extra namespaces cause problems
|
||||
"""
|
||||
filename = "examples/axml/AndroidManifestExtraNamespace.xml"
|
||||
filename = "tests/data/AXML/AndroidManifestExtraNamespace.xml"
|
||||
|
||||
with open(filename, "rb") as f:
|
||||
ap = axml.AXMLPrinter(f.read())
|
||||
@ -315,7 +318,7 @@ class AXMLTest(unittest.TestCase):
|
||||
"""
|
||||
Test for Text chunks containing XML
|
||||
"""
|
||||
filename = "examples/axml/AndroidManifestTextChunksXML.xml"
|
||||
filename = "tests/data/AXML/AndroidManifestTextChunksXML.xml"
|
||||
|
||||
with open(filename, "rb") as f:
|
||||
ap = axml.AXMLPrinter(f.read())
|
||||
@ -329,7 +332,7 @@ class AXMLTest(unittest.TestCase):
|
||||
"""
|
||||
Assert that files with a broken filesize are not parsed
|
||||
"""
|
||||
filename = "examples/axml/AndroidManifestWrongFilesize.xml"
|
||||
filename = "tests/data/AXML/AndroidManifestWrongFilesize.xml"
|
||||
|
||||
with open(filename, "rb") as f:
|
||||
a = axml.AXMLPrinter(f.read())
|
||||
@ -339,7 +342,7 @@ class AXMLTest(unittest.TestCase):
|
||||
"""
|
||||
Assert that Strings with nullbytes are handled correctly
|
||||
"""
|
||||
filename = "examples/axml/AndroidManifestNullbytes.xml"
|
||||
filename = "tests/data/AXML/AndroidManifestNullbytes.xml"
|
||||
|
||||
with open(filename, "rb") as f:
|
||||
ap = axml.AXMLPrinter(f.read())
|
||||
@ -354,7 +357,7 @@ class AXMLTest(unittest.TestCase):
|
||||
Assert that Namespaces which are used in a tag and the tag is closed
|
||||
are actually correctly parsed.
|
||||
"""
|
||||
filename = "examples/axml/AndroidManifestMaskingNamespace.xml"
|
||||
filename = "tests/data/AXML/AndroidManifestMaskingNamespace.xml"
|
||||
|
||||
with open(filename, "rb") as f:
|
||||
ap = axml.AXMLPrinter(f.read())
|
||||
@ -368,7 +371,7 @@ class AXMLTest(unittest.TestCase):
|
||||
"""
|
||||
Test if weird namespace constelations cause problems
|
||||
"""
|
||||
filename = "examples/axml/AndroidManifestDoubleNamespace.xml"
|
||||
filename = "tests/data/AXML/AndroidManifestDoubleNamespace.xml"
|
||||
|
||||
with open(filename, "rb") as f:
|
||||
ap = axml.AXMLPrinter(f.read())
|
||||
@ -382,7 +385,7 @@ class AXMLTest(unittest.TestCase):
|
||||
"""
|
||||
Assert that Packed files are read
|
||||
"""
|
||||
filename = "examples/axml/AndroidManifestLiapp.xml"
|
||||
filename = "tests/data/AXML/AndroidManifestLiapp.xml"
|
||||
|
||||
with open(filename, "rb") as f:
|
||||
ap = axml.AXMLPrinter(f.read())
|
||||
@ -393,4 +396,5 @@ class AXMLTest(unittest.TestCase):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
set_log("INFO")
|
||||
unittest.main()
|
||||
|