Skip to content

Commit

Permalink
Avoid obfuscating the class name if the class contains a field annota…
Browse files Browse the repository at this point in the history
…ted with `@State`, see #43
  • Loading branch information
vRallev committed Jun 10, 2018
1 parent 91d511e commit 0ac25fe
Show file tree
Hide file tree
Showing 8 changed files with 409 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## 1.3.1

* Avoid obfuscating the class name if the class contains a field annotated with `@State`, see #43

## 1.3.0 (2018-05-28)

* Support incremental annotation processing, see #48
Expand Down
4 changes: 2 additions & 2 deletions demo-java-8/proguard.cfg
Expand Up @@ -9,12 +9,11 @@
-ignorewarnings
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*, !method/inlining/unique, !method/inlining/short


-printconfiguration "build/outputs/mapping/configuration.txt"

# Proguard rules that are applied to your test apk/code.
-keepattributes *Annotation*

-keep class com.evernote.android.state.demo.ProguardTest { *; }
-keep class junit.framework.** { *; }
-keep class junit.runner.** { *; }

Expand All @@ -23,5 +22,6 @@
-keep class org.junit.** { *; }
-keep class org.hamcrest.** { *; }
-keep class com.squareup.javawriter.JavaWriter { *; }
-keep class com.google.devtools.** { *; }
# Uncomment this if you use Mockito
#-dontwarn org.mockito.**
Expand Up @@ -6,6 +6,7 @@
import com.evernote.android.state.StateSaver;
import com.evernote.different.TestProguard;
import com.evernote.different.TestProguardBundler;
import com.evernote.different.TestProguardHelper;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -19,27 +20,29 @@ public class ProguardTest {
@Test
public void testProguardRules() {
TestProguard data = new TestProguard();
data.verifyValue(0);
data.setValue(1);
TestProguardHelper.verifyValue(data, 0);
TestProguardHelper.setValue(data, 1);

Bundle bundle = new Bundle();
StateSaver.saveInstanceState(data, bundle);

data.setValue(0);
data.verifyValue(0);
TestProguardHelper.setValue(data, 0);
TestProguardHelper.verifyValue(data, 0);

StateSaver.restoreInstanceState(data, bundle);
data.verifyValue(1);
TestProguardHelper.verifyValue(data, 1);
}

@Test
public void verifyCodeObfuscated() throws Exception {
TestProguard.class.getDeclaredField("test1"); // test1
TestProguard.class.getDeclaredField("a"); // test2
// TestProguard.class.getDeclaredField("a"); // test2
TestProguard.class.getDeclaredField("test2"); // test2
TestProguard.class.getDeclaredField("test3");
TestProguard.class.getDeclaredMethod("a"); // getTest2()

TestProguardBundler.class.getDeclaredField("a"); // mData2
// TestProguardBundler.class.getDeclaredField("a"); // mData2
TestProguardBundler.class.getDeclaredField("mData2"); // mData2
TestProguardBundler.class.getDeclaredField("mDataReflOtherName");
TestProguardBundler.class.getDeclaredMethod("a"); // getData2()
}
Expand Down

0 comments on commit 0ac25fe

Please sign in to comment.