Merge "Enable proguard for telephony library."
diff --git a/Android.bp b/Android.bp
index 7439bea..8a8ff6a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -136,4 +136,11 @@
enabled: false,
},
},
+
+ optimize: {
+ enabled: true,
+ shrink: true,
+ obfuscate: false,
+ proguard_flags_files: ["proguard.flags"],
+ },
}
diff --git a/proguard.flags b/proguard.flags
new file mode 100644
index 0000000..0f61524
--- /dev/null
+++ b/proguard.flags
@@ -0,0 +1,29 @@
+# Uncomment the following to show all included rules during build
+#-printconfiguration
+
+# Generate usage file (for shrinking)
+-printusage
+
+# Keep deprecated GSM SMS API
+-keepclasseswithmembers class android.telephony.gsm.SmsManager {
+public *;
+}
+-keepclasseswithmembers class android.telephony.gsm.SmsMessage {
+public *;
+}
+
+# Keep telephony sysprop
+-keepclasseswithmembers class android.internal.telephony.sysprop.TelephonyProperties {
+public *;
+}
+
+# Keep public classes and members
+-keepclasseswithmembers class com.android.internal.telephony.** {
+public *;
+}
+
+# Keep classes and members that have the @UnsupportedAppUsage annotation
+-keep @**.UnsupportedAppUsage class *
+-keepclassmembers class * {
+@**.UnsupportedAppUsage *;
+}
diff --git a/src/java/com/android/internal/telephony/CallManager.java b/src/java/com/android/internal/telephony/CallManager.java
index d2b1bdd..16bc287 100644
--- a/src/java/com/android/internal/telephony/CallManager.java
+++ b/src/java/com/android/internal/telephony/CallManager.java
@@ -28,6 +28,7 @@
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.imsphone.ImsPhoneConnection;
import com.android.internal.telephony.sip.SipPhone;
import com.android.telephony.Rlog;
@@ -61,14 +62,14 @@
private static final boolean VDBG = false;
private static final int EVENT_DISCONNECT = 100;
- private static final int EVENT_PRECISE_CALL_STATE_CHANGED = 101;
+ @VisibleForTesting static final int EVENT_PRECISE_CALL_STATE_CHANGED = 101;
private static final int EVENT_NEW_RINGING_CONNECTION = 102;
private static final int EVENT_UNKNOWN_CONNECTION = 103;
private static final int EVENT_INCOMING_RING = 104;
- private static final int EVENT_RINGBACK_TONE = 105;
+ @VisibleForTesting static final int EVENT_RINGBACK_TONE = 105;
private static final int EVENT_IN_CALL_VOICE_PRIVACY_ON = 106;
private static final int EVENT_IN_CALL_VOICE_PRIVACY_OFF = 107;
- private static final int EVENT_CALL_WAITING = 108;
+ @VisibleForTesting static final int EVENT_CALL_WAITING = 108;
private static final int EVENT_DISPLAY_INFO = 109;
private static final int EVENT_SIGNAL_INFO = 110;
private static final int EVENT_CDMA_OTA_STATUS_CHANGE = 111;
diff --git a/src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java b/src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java
index 0745d93..f4589dd 100755
--- a/src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java
+++ b/src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java
@@ -160,7 +160,7 @@
private static final int EVENT_DTMF_DELAY_DONE = 5;
//***** Constants
- private static final int PAUSE_DELAY_MILLIS = 3 * 1000;
+ @VisibleForTesting static final int PAUSE_DELAY_MILLIS = 3 * 1000;
private static final int WAKE_LOCK_TIMEOUT_MILLIS = 60*1000;
//***** Inner Classes
diff --git a/tests/telephonytests/src/com/android/internal/telephony/CallManagerTest.java b/tests/telephonytests/src/com/android/internal/telephony/CallManagerTest.java
index 67587d4..8ce5200 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/CallManagerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/CallManagerTest.java
@@ -46,8 +46,6 @@
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import java.lang.reflect.Field;
-
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
public class CallManagerTest extends TelephonyTest {
@@ -212,23 +210,12 @@
@Test @SmallTest
public void testRegisterEvent() throws Exception {
- Field field = CallManager.class.getDeclaredField("EVENT_CALL_WAITING");
- field.setAccessible(true);
- int mEvent = (Integer) field.get(CallManager.getInstance());
verify(mPhone, times(1)).registerForCallWaiting(isA(Handler.class),
- eq(mEvent), isNull());
-
- field = CallManager.class.getDeclaredField("EVENT_PRECISE_CALL_STATE_CHANGED");
- field.setAccessible(true);
- mEvent = (Integer) field.get(CallManager.getInstance());
+ eq(CallManager.EVENT_CALL_WAITING), isNull());
verify(mPhone, times(1)).registerForPreciseCallStateChanged(isA(Handler.class),
- eq(mEvent), isA(Object.class));
-
- field = CallManager.class.getDeclaredField("EVENT_RINGBACK_TONE");
- field.setAccessible(true);
- mEvent = (Integer) field.get(CallManager.getInstance());
+ eq(CallManager.EVENT_PRECISE_CALL_STATE_CHANGED), isA(Object.class));
verify(mPhone, times(1)).registerForRingbackTone(isA(Handler.class),
- eq(mEvent), isA(Object.class));
+ eq(CallManager.EVENT_RINGBACK_TONE), isA(Object.class));
}
@Test @SmallTest
diff --git a/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneConnectionTest.java b/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneConnectionTest.java
index 84f2672..6e816e6 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneConnectionTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneConnectionTest.java
@@ -70,7 +70,6 @@
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.concurrent.CountDownLatch;
@@ -276,13 +275,7 @@
// process post dial string during update
assertTrue(mConnectionUT.update(mImsCall, Call.State.ACTIVE));
assertEquals(Connection.PostDialState.STARTED, mConnectionUT.getPostDialState());
- try {
- Field field = ImsPhoneConnection.class.getDeclaredField("PAUSE_DELAY_MILLIS");
- field.setAccessible(true);
- moveTimeForward((Integer) field.get(null));
- } catch (Exception ex) {
- Assert.fail("unexpected exception thrown" + ex.getMessage());
- }
+ moveTimeForward(ImsPhoneConnection.PAUSE_DELAY_MILLIS);
processAllMessages();
assertEquals(Connection.PostDialState.COMPLETE, mConnectionUT.getPostDialState());
}