Support GalaxyS SC-02B.

This commit is contained in:
Guillaume Beraudo 2011-04-06 12:26:57 +02:00
parent f9a1266bac
commit 7e5f8cc458
7 changed files with 61 additions and 16 deletions

View file

@ -714,7 +714,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
private synchronized void startRinging() { private synchronized void startRinging() {
if (Hacks.isGalaxyS()) { if (Hacks.needGalaxySAudioHack()) {
mAudioManager.setMode(MODE_RINGTONE); mAudioManager.setMode(MODE_RINGTONE);
} }
@ -749,7 +749,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
mVibrator.cancel(); mVibrator.cancel();
} }
if (Hacks.isGalaxyS()) { if (Hacks.needGalaxySAudioHack()) {
mAudioManager.setMode(MODE_IN_CALL); mAudioManager.setMode(MODE_IN_CALL);
} }
} }
@ -782,7 +782,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
} }
public void setAudioModeIncallForGalaxyS() { public void setAudioModeIncallForGalaxyS() {
if (!Hacks.isGalaxyS()) return; if (!Hacks.needGalaxySAudioHack()) return;
try { try {
stopRinging(); stopRinging();

View file

@ -34,6 +34,7 @@ import org.linphone.LinphoneManager.EcCalibrationListener;
import org.linphone.core.LinphoneCoreException; import org.linphone.core.LinphoneCoreException;
import org.linphone.core.Version; import org.linphone.core.Version;
import org.linphone.core.LinphoneCore.EcCalibratorStatus; import org.linphone.core.LinphoneCore.EcCalibratorStatus;
import org.linphone.core.video.AndroidCameraRecordManager;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
@ -104,6 +105,10 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
} }
detectVideoCodec(R.string.pref_video_codec_h264_key, "H264"); detectVideoCodec(R.string.pref_video_codec_h264_key, "H264");
if (!AndroidCameraRecordManager.getInstance().hasFrontCamera()) {
disableAndHideCheckbox(R.string.pref_video_use_front_camera_key);
}
} }
@ -186,6 +191,14 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
}); });
} }
private void disableAndHideCheckbox(int key) {
writeBoolean(key, false);
CheckBoxPreference box = (CheckBoxPreference) findPreference(key);
box.setEnabled(false);
box.setChecked(false);
box.setLayoutResource(R.layout.hidden);
}
private void disableCheckbox(int key) { private void disableCheckbox(int key) {
writeBoolean(key, false); writeBoolean(key, false);
CheckBoxPreference box = (CheckBoxPreference) findPreference(key); CheckBoxPreference box = (CheckBoxPreference) findPreference(key);

View file

@ -29,7 +29,15 @@ public final class Hacks {
private Hacks() {} private Hacks() {}
public static boolean isGalaxyS() { public static boolean isGalaxyS() {
return Build.DEVICE.startsWith("GT-I9000"); return isGT9000() || isSC02B();
}
public static boolean needGalaxySAudioHack() {
return isGalaxySOrTab();
}
public static boolean isGalaxySOrTabWithFrontCamera() {
return isGalaxySOrTab() && !isGalaxySOrTabWithoutFrontCamera();
} }
public static boolean isGalaxySOrTab() { public static boolean isGalaxySOrTab() {
@ -37,7 +45,14 @@ public final class Hacks {
} }
public static boolean isGalaxyTab() { public static boolean isGalaxyTab() {
return Build.DEVICE.startsWith("GT-P1000"); return isGTP1000();
}
private static boolean isGT9000() {return Build.DEVICE.startsWith("GT-I9000");}
private static boolean isSC02B() {return Build.DEVICE.startsWith("SC-02B");}
private static boolean isGTP1000() {return Build.DEVICE.startsWith("GT-P1000");}
private static boolean isGalaxySOrTabWithoutFrontCamera() {
return isSC02B();
} }
/* private static final boolean log(final String msg) { /* private static final boolean log(final String msg) {

View file

@ -26,7 +26,9 @@ import android.os.Build;
*/ */
public class Version { public class Version {
private static final int buildVersion = Integer.parseInt(Build.VERSION.SDK); private static final int buildVersion =
Integer.parseInt(Build.VERSION.SDK);
// 8; // 2.2
// 7; // 2.1 // 7; // 2.1
public static final boolean sdkAboveOrEqual(int value) { public static final boolean sdkAboveOrEqual(int value) {

View file

@ -33,10 +33,15 @@ interface AndroidCameraConf {
boolean isFrontCamera(int cameraId); boolean isFrontCamera(int cameraId);
/**
* Default: no front; rear=0; default=rear
* @author Guillaume Beraudo
*
*/
class AndroidCameras { class AndroidCameras {
Integer front; Integer front;
Integer rear; Integer rear = 0;
Integer defaultC; Integer defaultC = rear;
boolean hasFrontCamera() { return front != null; } boolean hasFrontCamera() { return front != null; }
boolean hasRearCamera() { return rear != null; } boolean hasRearCamera() { return rear != null; }

View file

@ -30,12 +30,17 @@ class AndroidCameraConf5 implements AndroidCameraConf {
public AndroidCameraConf5() { public AndroidCameraConf5() {
Log.i(tag, "Detecting cameras"); Log.i(tag, "Detecting cameras");
// Defaults 0/0/0 // Defaults
foundCameras = new AndroidCameras(); foundCameras = new AndroidCameras();
if (Hacks.isGalaxySOrTab()) { if (Hacks.isGalaxySOrTab()) {
Log.d(tag, "Hack Galaxy S : has 2 cameras front=2; rear=1"); Log.d(tag, "Hack Galaxy S : has one or more cameras");
foundCameras.front = 2; if (Hacks.isGalaxySOrTabWithFrontCamera()) {
Log.d(tag, "Hack Galaxy S : HAVE a front camera");
foundCameras.front = 2;
} else {
Log.d(tag, "Hack Galaxy S : NO front camera");
}
foundCameras.rear = 1; foundCameras.rear = 1;
foundCameras.defaultC = foundCameras.rear; foundCameras.defaultC = foundCameras.rear;
} }
@ -44,7 +49,7 @@ class AndroidCameraConf5 implements AndroidCameraConf {
public int getNumberOfCameras() { public int getNumberOfCameras() {
Log.i(tag, "Detecting the number of cameras"); Log.i(tag, "Detecting the number of cameras");
if (Hacks.isGalaxySOrTab()) { if (Hacks.isGalaxySOrTabWithFrontCamera()) {
Log.d(tag, "Hack Galaxy S : has 2 cameras"); Log.d(tag, "Hack Galaxy S : has 2 cameras");
return 2; return 2;
} else } else
@ -55,8 +60,8 @@ class AndroidCameraConf5 implements AndroidCameraConf {
public int getCameraOrientation(int cameraId) { public int getCameraOrientation(int cameraId) {
// Use hacks to guess orientation of the camera // Use hacks to guess orientation of the camera
if (Hacks.isGalaxySOrTab() && !isFrontCamera(cameraId)) { if (Hacks.isGalaxySOrTab() && isFrontCamera(cameraId)) {
Log.d(tag, "Hack Galaxy S : rear camera mounted landscape"); Log.d(tag, "Hack Galaxy S : front camera mounted landscape");
// mounted in landscape for a portrait phone orientation // mounted in landscape for a portrait phone orientation
// |^^^^^^^^| // |^^^^^^^^|
// | ____ | // | ____ |
@ -72,7 +77,6 @@ class AndroidCameraConf5 implements AndroidCameraConf {
public boolean isFrontCamera(int cameraId) { public boolean isFrontCamera(int cameraId) {
// Use hacks to guess facing of the camera // Use hacks to guess facing of the camera
if (cameraId == 2 && Hacks.isGalaxySOrTab()) { if (cameraId == 2 && Hacks.isGalaxySOrTab()) {

View file

@ -76,11 +76,17 @@ public class AndroidCameraRecordManager {
public boolean hasSeveralCameras() { public boolean hasSeveralCameras() {
return cc.getFoundCameras().hasSeveralCameras(); return cc.getFoundCameras().hasSeveralCameras();
} }
public boolean hasFrontCamera() {
return cc.getFoundCameras().front != null;
}
public void setUseFrontCamera(boolean value) { public void setUseFrontCamera(boolean value) {
if (!hasFrontCamera()) {
Log.e(tag, "setUseFrontCamera(true) while no front camera detected on device: using rear");
value = false;
}
if (cc.isFrontCamera(cameraId) == value) return; // already OK if (cc.isFrontCamera(cameraId) == value) return; // already OK
toggleUseFrontCamera(); toggleUseFrontCamera();
} }