aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/proguard-rules.pro
blob: e37fe5af2fdd68eac418812a2c04fc6201574825 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Add project specific ProGuard rules here.
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# 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 *;
#}


# Workaround for Samsung Android 4.2 bug
# https://code.google.com/p/android/issues/detail?id=78377
# https://code.google.com/p/android/issues/detail?id=78377#c188
# https://code.google.com/p/android/issues/detail?id=78377#c302
-keepattributes **
-keep class !android.support.v7.view.menu.**,** {*;}
-dontpreverify
-dontoptimize
-dontshrink
-dontwarn **
-dontnote **
s="cp"> static void cpuid(uint32_t idx, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx, int pv_context) { asm volatile ( "test %1,%1 ; jz 1f ; ud2a ; .ascii \"xen\" ; 1: cpuid" : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) : "0" (idx), "1" (pv_context) ); } static int check_for_xen(int pv_context) { uint32_t eax, ebx, ecx, edx; char signature[13]; uint32_t base; for ( base = 0x40000000; base < 0x40010000; base += 0x100 ) { cpuid(base, &eax, &ebx, &ecx, &edx, pv_context); *(uint32_t *)(signature + 0) = ebx; *(uint32_t *)(signature + 4) = ecx; *(uint32_t *)(signature + 8) = edx; signature[12] = '\0'; if ( !strcmp("XenVMMXenVMM", signature) && (eax >= (base + 2)) ) goto found; } return 0; found: cpuid(base + 1, &eax, &ebx, &ecx, &edx, pv_context); return eax; } static jmp_buf sigill_jmp; void sigill_handler(int sig) { longjmp(sigill_jmp, 1); } static void usage(void) { printf("Usage: xen_detect [options]\n"); printf("Options:\n"); printf(" -h, --help Display this information\n"); printf(" -q, --quiet Quiesce normal informational output\n"); printf(" -P, --pv Exit status 1 if not running as PV guest\n"); printf(" -H, --hvm Exit status 1 if not running as HVM guest.\n"); printf(" -N, --none Exit status 1 if running on Xen (PV or HVM)\n"); } int main(int argc, char **argv) { enum { XEN_PV = 1, XEN_HVM = 2, XEN_NONE = 3 } detected = 0, expected = 0; uint32_t version = 0; int ch, quiet = 0; const static char sopts[] = "hqPHN"; const static struct option lopts[] = { { "help", 0, NULL, 'h' }, { "quiet", 0, NULL, 'q' }, { "pv", 0, NULL, 'P' }, { "hvm", 0, NULL, 'H' }, { "none", 0, NULL, 'N' }, { 0, 0, 0, 0} }; while ( (ch = getopt_long(argc, argv, sopts, lopts, NULL)) != -1 ) { switch ( ch ) { case 'q': quiet = 1; break; case 'P': expected = XEN_PV; break; case 'H': expected = XEN_HVM; break; case 'N': expected = XEN_NONE; break; default: usage(); exit(1); } } /* Check for execution in HVM context. */ detected = XEN_HVM; if ( (version = check_for_xen(0)) != 0 ) goto out; /* * Set up a signal handler to test the paravirtualised CPUID instruction. * If executed outside Xen PV context, the extended opcode will fault, we * will longjmp via the signal handler, and print "Not running on Xen". */ detected = XEN_PV; if ( !setjmp(sigill_jmp) && (signal(SIGILL, sigill_handler) != SIG_ERR) && ((version = check_for_xen(1)) != 0) ) goto out; detected = XEN_NONE; out: if ( quiet ) /* nothing */; else if ( detected == XEN_NONE ) printf("Not running on Xen.\n"); else printf("Running in %s context on Xen v%d.%d.\n", (detected == XEN_PV) ? "PV" : "HVM", (uint16_t)(version >> 16), (uint16_t)version); return expected && (expected != detected); }