From d9ce79763aec655793307c226b55cb57b8d85c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Gjesse?= Date: Wed, 21 Mar 2018 15:13:29 +0100 Subject: [PATCH] Enable R8 for settings Keep constructor which is only used directly from test. Update Proguard configuration to include information on checked exceptions for Mockity to mock thorwn exception. Bug: 74756073 Test: atest com.android.settings.deviceinfo.storage.StorageAsyncLoaderTest#testRemovedPackageDoesNotCrash Utf8ByteLengthFilterTest Change-Id: Iae87e6647b28ee69d38bd8891df46239779c459c --- Android.mk | 3 --- proguard.flags | 4 ++++ src/com/android/settings/bluetooth/Utf8ByteLengthFilter.java | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Android.mk b/Android.mk index 86abeda7bd7..61851cf1b6d 100644 --- a/Android.mk +++ b/Android.mk @@ -11,9 +11,6 @@ include $(BUILD_STATIC_JAVA_LIBRARY) # Build the Settings APK include $(CLEAR_VARS) -# See b/74756073. -LOCAL_USE_R8 := false - LOCAL_PACKAGE_NAME := Settings LOCAL_PRIVATE_PLATFORM_APIS := true LOCAL_CERTIFICATE := platform diff --git a/proguard.flags b/proguard.flags index 21c5cfda9cd..b1b8a516ec9 100644 --- a/proguard.flags +++ b/proguard.flags @@ -1,6 +1,10 @@ # This is a configuration file for ProGuard. # http://proguard.sourceforge.net/index.html#manual/usage.html +# Some tests use thenThrow from Mockito which require information on +# checked exceptions. +-keepattributes Exceptions + # Keep all Fragments in this package, which are used by reflection. -keep public class com.android.settings.** extends android.app.Fragment diff --git a/src/com/android/settings/bluetooth/Utf8ByteLengthFilter.java b/src/com/android/settings/bluetooth/Utf8ByteLengthFilter.java index ab498183bc7..536f4cc9391 100644 --- a/src/com/android/settings/bluetooth/Utf8ByteLengthFilter.java +++ b/src/com/android/settings/bluetooth/Utf8ByteLengthFilter.java @@ -16,6 +16,7 @@ package com.android.settings.bluetooth; +import android.support.annotation.Keep; import android.text.InputFilter; import android.text.Spanned; @@ -40,6 +41,7 @@ import android.text.Spanned; public class Utf8ByteLengthFilter implements InputFilter { private final int mMaxBytes; + @Keep Utf8ByteLengthFilter(int maxBytes) { mMaxBytes = maxBytes; }