Merge "Fix google-explicit-constructor warnings." am: b23201035c
am: 59e5291c1f

* commit '59e5291c1f9b67c3ec825a8f8413671a7f600fa1':
  Fix google-explicit-constructor warnings.

Change-Id: Ib09bd22b244364c5056d911d521cae0c241fb4b0
diff --git a/src/java/android/net/sip/SipManager.java b/src/java/android/net/sip/SipManager.java
index b483d5d..0cb1feb 100644
--- a/src/java/android/net/sip/SipManager.java
+++ b/src/java/android/net/sip/SipManager.java
@@ -171,8 +171,17 @@
     }
 
     private void createSipService() {
-        IBinder b = ServiceManager.getService(Context.SIP_SERVICE);
-        mSipService = ISipService.Stub.asInterface(b);
+        if (mSipService == null) {
+            IBinder b = ServiceManager.getService(Context.SIP_SERVICE);
+            mSipService = ISipService.Stub.asInterface(b);
+        }
+    }
+
+    private void checkSipServiceConnection() throws SipException {
+        createSipService();
+        if (mSipService == null) {
+            throw new SipException("SipService is dead and is restarting...", new Exception());
+        }
     }
 
     /**
@@ -188,6 +197,7 @@
      */
     public void open(SipProfile localProfile) throws SipException {
         try {
+            checkSipServiceConnection();
             mSipService.open(localProfile, mContext.getOpPackageName());
         } catch (RemoteException e) {
             throw new SipException("open()", e);
@@ -231,6 +241,7 @@
                     "incomingCallPendingIntent cannot be null");
         }
         try {
+            checkSipServiceConnection();
             mSipService.open3(localProfile, incomingCallPendingIntent,
                     createRelay(listener, localProfile.getUriString()),
                     mContext.getOpPackageName());
@@ -251,6 +262,7 @@
     public void setRegistrationListener(String localProfileUri,
             SipRegistrationListener listener) throws SipException {
         try {
+            checkSipServiceConnection();
             mSipService.setRegistrationListener(
                     localProfileUri, createRelay(listener, localProfileUri),
                     mContext.getOpPackageName());
@@ -268,6 +280,7 @@
      */
     public void close(String localProfileUri) throws SipException {
         try {
+            checkSipServiceConnection();
             mSipService.close(localProfileUri, mContext.getOpPackageName());
         } catch (RemoteException e) {
             throw new SipException("close()", e);
@@ -284,6 +297,7 @@
      */
     public boolean isOpened(String localProfileUri) throws SipException {
         try {
+            checkSipServiceConnection();
             return mSipService.isOpened(localProfileUri, mContext.getOpPackageName());
         } catch (RemoteException e) {
             throw new SipException("isOpened()", e);
@@ -305,6 +319,7 @@
      */
     public boolean isRegistered(String localProfileUri) throws SipException {
         try {
+            checkSipServiceConnection();
             return mSipService.isRegistered(localProfileUri, mContext.getOpPackageName());
         } catch (RemoteException e) {
             throw new SipException("isRegistered()", e);
@@ -407,6 +422,7 @@
         }
 
         try {
+            checkSipServiceConnection();
             ISipSession session = mSipService.getPendingSession(callId,
                     mContext.getOpPackageName());
             if (session == null) {
@@ -489,6 +505,7 @@
     public void register(SipProfile localProfile, int expiryTime,
             SipRegistrationListener listener) throws SipException {
         try {
+            checkSipServiceConnection();
             ISipSession session = mSipService.createSession(localProfile,
                     createRelay(listener, localProfile.getUriString()),
                     mContext.getOpPackageName());
@@ -515,6 +532,7 @@
     public void unregister(SipProfile localProfile,
             SipRegistrationListener listener) throws SipException {
         try {
+            checkSipServiceConnection();
             ISipSession session = mSipService.createSession(localProfile,
                     createRelay(listener, localProfile.getUriString()),
                     mContext.getOpPackageName());
@@ -541,6 +559,7 @@
     public SipSession getSessionFor(Intent incomingCallIntent)
             throws SipException {
         try {
+            checkSipServiceConnection();
             String callId = getCallId(incomingCallIntent);
             ISipSession s = mSipService.getPendingSession(callId,
                     mContext.getOpPackageName());
@@ -566,6 +585,7 @@
     public SipSession createSipSession(SipProfile localProfile,
             SipSession.Listener listener) throws SipException {
         try {
+            checkSipServiceConnection();
             ISipSession s = mSipService.createSession(localProfile, null,
                     mContext.getOpPackageName());
             if (s == null) {
@@ -583,8 +603,9 @@
      * (username, password and display name) are crossed out.
      * @hide
      */
-    public SipProfile[] getListOfProfiles() {
+    public SipProfile[] getListOfProfiles() throws SipException {
         try {
+            checkSipServiceConnection();
             return mSipService.getListOfProfiles(mContext.getOpPackageName());
         } catch (RemoteException e) {
             return new SipProfile[0];
diff --git a/src/java/com/android/server/sip/SipService.java b/src/java/com/android/server/sip/SipService.java
index 6e1f428..97abfb7 100644
--- a/src/java/com/android/server/sip/SipService.java
+++ b/src/java/com/android/server/sip/SipService.java
@@ -100,9 +100,11 @@
      */
     public static void start(Context context) {
         if (SipManager.isApiSupported(context)) {
-            ServiceManager.addService("sip", new SipService(context));
-            context.sendBroadcast(new Intent(SipManager.ACTION_SIP_SERVICE_UP));
-            if (DBG) slog("start:");
+            if (ServiceManager.getService("sip") == null) {
+                ServiceManager.addService("sip", new SipService(context));
+                context.sendBroadcast(new Intent(SipManager.ACTION_SIP_SERVICE_UP));
+                if (DBG) slog("start:");
+            }
         }
     }
 
diff --git a/src/jni/rtp/AmrCodec.cpp b/src/jni/rtp/AmrCodec.cpp
index e2d820e..06914c4 100644
--- a/src/jni/rtp/AmrCodec.cpp
+++ b/src/jni/rtp/AmrCodec.cpp
@@ -128,7 +128,7 @@
     return length;
 }
 
-int AmrCodec::decode(int16_t *samples, int count, void *payload, int length)
+int AmrCodec::decode(int16_t *samples, int /* count */, void *payload, int length)
 {
     unsigned char *bytes = (unsigned char *)payload;
     Frame_Type_3GPP type;
@@ -208,7 +208,7 @@
         }
     }
 
-    int set(int sampleRate, const char *fmtp) {
+    int set(int sampleRate, const char */* fmtp */) {
         return (sampleRate == 8000 && mEncoder && mDecoder) ? 160 : -1;
     }
 
diff --git a/src/jni/rtp/Android.mk b/src/jni/rtp/Android.mk
index 15b8587..3401d9e 100644
--- a/src/jni/rtp/Android.mk
+++ b/src/jni/rtp/Android.mk
@@ -53,8 +53,7 @@
 	frameworks/av/media/libstagefright/codecs/amrnb/dec/src \
 	$(call include-path-for, audio-effects)
 
-LOCAL_CFLAGS += -fvisibility=hidden
-
-
+# getInput() is deprecated but we want to continue to track the usage of it elsewhere
+LOCAL_CFLAGS += -fvisibility=hidden -Wall -Wextra -Wno-deprecated-declarations -Werror
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/src/jni/rtp/AudioGroup.cpp b/src/jni/rtp/AudioGroup.cpp
index 0204e21..da02861 100644
--- a/src/jni/rtp/AudioGroup.cpp
+++ b/src/jni/rtp/AudioGroup.cpp
@@ -502,7 +502,7 @@
 
     int mMode;
     int mSampleRate;
-    int mSampleCount;
+    size_t mSampleCount;
     int mDeviceSocket;
     bool mPlatformHasAec;
 
@@ -786,7 +786,7 @@
 {
     int mode = mGroup->mMode;
     int sampleRate = mGroup->mSampleRate;
-    int sampleCount = mGroup->mSampleCount;
+    size_t sampleCount = mGroup->mSampleCount;
     int deviceSocket = mGroup->mDeviceSocket;
 
     // Find out the frame count for AudioTrack and AudioRecord.
@@ -799,7 +799,7 @@
         ALOGE("cannot compute frame count");
         return false;
     }
-    ALOGD("reported frame count: output %d, input %d", output, input);
+    ALOGD("reported frame count: output %zu, input %zu", output, input);
 
     if (output < sampleCount * 2) {
         output = sampleCount * 2;
@@ -807,7 +807,7 @@
     if (input < sampleCount * 2) {
         input = sampleCount * 2;
     }
-    ALOGD("adjusted frame count: output %d, input %d", output, input);
+    ALOGD("adjusted frame count: output %zu, input %zu", output, input);
 
     // Initialize AudioTrack and AudioRecord.
     sp<AudioTrack> track = new AudioTrack();
@@ -815,11 +815,11 @@
     if (track->set(AUDIO_STREAM_VOICE_CALL, sampleRate, AUDIO_FORMAT_PCM_16_BIT,
                 AUDIO_CHANNEL_OUT_MONO, output, AUDIO_OUTPUT_FLAG_NONE, NULL /*callback_t*/,
                 NULL /*user*/, 0 /*notificationFrames*/, 0 /*sharedBuffer*/,
-                false /*threadCanCallJava*/, 0 /*sessionId*/,
+                false /*threadCanCallJava*/, AUDIO_SESSION_ALLOCATE,
                 AudioTrack::TRANSFER_OBTAIN) != NO_ERROR ||
             record->set(AUDIO_SOURCE_VOICE_COMMUNICATION, sampleRate, AUDIO_FORMAT_PCM_16_BIT,
                 AUDIO_CHANNEL_IN_MONO, input, NULL /*callback_t*/, NULL /*user*/,
-                0 /*notificationFrames*/, false /*threadCanCallJava*/, 0 /*sessionId*/,
+                0 /*notificationFrames*/, false /*threadCanCallJava*/, AUDIO_SESSION_ALLOCATE,
                 AudioRecord::TRANSFER_OBTAIN) != NO_ERROR) {
         ALOGE("cannot initialize audio device");
         return false;
diff --git a/src/jni/rtp/G711Codec.cpp b/src/jni/rtp/G711Codec.cpp
index ef54863..e2c25c8 100644
--- a/src/jni/rtp/G711Codec.cpp
+++ b/src/jni/rtp/G711Codec.cpp
@@ -34,7 +34,7 @@
 class UlawCodec : public AudioCodec
 {
 public:
-    int set(int sampleRate, const char *fmtp) {
+    int set(int sampleRate, const char */* fmtp */) {
         mSampleCount = sampleRate / 50;
         return mSampleCount;
     }
@@ -85,7 +85,7 @@
 class AlawCodec : public AudioCodec
 {
 public:
-    int set(int sampleRate, const char *fmtp) {
+    int set(int sampleRate, const char */* fmtp */) {
         mSampleCount = sampleRate / 50;
         return mSampleCount;
     }
diff --git a/src/jni/rtp/GsmCodec.cpp b/src/jni/rtp/GsmCodec.cpp
index 61dfdc9..4a04bfa 100644
--- a/src/jni/rtp/GsmCodec.cpp
+++ b/src/jni/rtp/GsmCodec.cpp
@@ -39,7 +39,7 @@
         }
     }
 
-    int set(int sampleRate, const char *fmtp) {
+    int set(int sampleRate, const char */* fmtp */) {
         return (sampleRate == 8000 && mEncode && mDecode) ? 160 : -1;
     }
 
diff --git a/src/jni/rtp/rtp_jni.cpp b/src/jni/rtp/rtp_jni.cpp
index 9f4bff9..a501f7d 100644
--- a/src/jni/rtp/rtp_jni.cpp
+++ b/src/jni/rtp/rtp_jni.cpp
@@ -21,7 +21,7 @@
 extern int registerRtpStream(JNIEnv *env);
 extern int registerAudioGroup(JNIEnv *env);
 
-__attribute__((visibility("default"))) jint JNI_OnLoad(JavaVM *vm, void *unused)
+__attribute__((visibility("default"))) jint JNI_OnLoad(JavaVM *vm, void *)
 {
     JNIEnv *env = NULL;
     if (vm->GetEnv((void **)&env, JNI_VERSION_1_4) != JNI_OK ||