diff options
-rw-r--r-- | src/com/android/camera/CameraSettings.java | 39 | ||||
-rw-r--r-- | src/com/android/camera/Util.java | 32 |
2 files changed, 59 insertions, 12 deletions
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index c4426fe..0a8863a 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -152,18 +152,7 @@ public class CameraSettings { // Since the screen could be loaded from different resources, we need // to check if the preference is available here if (videoQuality != null) { - // Modify video duration settings. - // The first entry is for MMS video duration, and we need to fill - // in the device-dependent value (in seconds). - CharSequence[] entries = videoQuality.getEntries(); - CharSequence[] values = videoQuality.getEntryValues(); - for (int i = 0; i < entries.length; ++i) { - if (VIDEO_QUALITY_MMS.equals(values[i])) { - entries[i] = entries[i].toString().replace( - "30", Integer.toString(MMS_VIDEO_DURATION)); - break; - } - } + initVideoQuality(videoQuality); } // Filter out unsupported settings / options @@ -426,4 +415,30 @@ public class CameraSettings { initialCameraPictureSize(context, parameters); writePreferredCameraId(preferences, currentCameraId); } + + private void initVideoQuality(ListPreference videoQuality) { + CharSequence[] entries = videoQuality.getEntries(); + CharSequence[] values = videoQuality.getEntryValues(); + if (Util.isMmsCapable(mContext)) { + // We need to fill in the device-dependent value (in seconds). + for (int i = 0; i < entries.length; ++i) { + if (VIDEO_QUALITY_MMS.equals(values[i])) { + entries[i] = entries[i].toString().replace( + "30", Integer.toString(MMS_VIDEO_DURATION)); + break; + } + } + } else { + // The device does not support mms. Remove it. Using + // filterUnsupported is not efficient but adding a new method + // for remove is not worth it. + ArrayList<String> supported = new ArrayList<String>(); + for (int i = 0; i < entries.length; ++i) { + if (!VIDEO_QUALITY_MMS.equals(values[i])) { + supported.add(values[i].toString()); + } + } + videoQuality.filterUnsupported(supported); + } + } } diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java index 4f58dfa..3e5dd77 100644 --- a/src/com/android/camera/Util.java +++ b/src/com/android/camera/Util.java @@ -20,6 +20,7 @@ import com.android.camera.gallery.IImage; import android.app.Activity; import android.app.AlertDialog; +import android.content.Context; import android.content.DialogInterface; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -27,6 +28,7 @@ import android.graphics.Matrix; import android.hardware.Camera; import android.hardware.Camera.Parameters; import android.hardware.Camera.Size; +import android.telephony.TelephonyManager; import android.util.Log; import android.view.Display; import android.view.Surface; @@ -35,6 +37,7 @@ import android.view.animation.Animation; import android.view.animation.TranslateAnimation; import java.io.Closeable; +import java.lang.reflect.Method; import java.util.List; import java.util.StringTokenizer; @@ -386,4 +389,33 @@ public class Util { Log.d(TAG, tokenizer.nextToken()); } } + + /** + * Returns whether the device is voice-capable (meaning, it can do MMS). + */ + public static boolean isMmsCapable(Context context) { + TelephonyManager telephonyManager = (TelephonyManager) + context.getSystemService(Context.TELEPHONY_SERVICE); + if (telephonyManager == null) { + return false; + } + + try { + Class partypes[] = new Class[0]; + Method sIsVoiceCapable = TelephonyManager.class.getMethod( + "isVoiceCapable", partypes); + + Object arglist[] = new Object[0]; + Object retobj = sIsVoiceCapable.invoke(telephonyManager, arglist); + return (Boolean) retobj; + } catch (java.lang.reflect.InvocationTargetException ite) { + // Failure, must be another device. + // Assume that it is voice capable. + } catch (java.lang.IllegalAccessException iae) { + // Failure, must be an other device. + // Assume that it is voice capable. + } catch (NoSuchMethodException nsme) { + } + return true; + } } |