Support GalaxyS SC-02B.
This commit is contained in:
parent
f9a1266bac
commit
7e5f8cc458
7 changed files with 61 additions and 16 deletions
|
|
@ -714,7 +714,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
|
||||
|
||||
private synchronized void startRinging() {
|
||||
if (Hacks.isGalaxyS()) {
|
||||
if (Hacks.needGalaxySAudioHack()) {
|
||||
mAudioManager.setMode(MODE_RINGTONE);
|
||||
}
|
||||
|
||||
|
|
@ -749,7 +749,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
mVibrator.cancel();
|
||||
}
|
||||
|
||||
if (Hacks.isGalaxyS()) {
|
||||
if (Hacks.needGalaxySAudioHack()) {
|
||||
mAudioManager.setMode(MODE_IN_CALL);
|
||||
}
|
||||
}
|
||||
|
|
@ -782,7 +782,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
}
|
||||
|
||||
public void setAudioModeIncallForGalaxyS() {
|
||||
if (!Hacks.isGalaxyS()) return;
|
||||
if (!Hacks.needGalaxySAudioHack()) return;
|
||||
|
||||
try {
|
||||
stopRinging();
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import org.linphone.LinphoneManager.EcCalibrationListener;
|
|||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.Version;
|
||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||
import org.linphone.core.video.AndroidCameraRecordManager;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
|
@ -104,6 +105,10 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
|
|||
}
|
||||
|
||||
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) {
|
||||
writeBoolean(key, false);
|
||||
CheckBoxPreference box = (CheckBoxPreference) findPreference(key);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,15 @@ public final class Hacks {
|
|||
private Hacks() {}
|
||||
|
||||
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() {
|
||||
|
|
@ -37,7 +45,14 @@ public final class Hacks {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@ import android.os.Build;
|
|||
*/
|
||||
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
|
||||
|
||||
public static final boolean sdkAboveOrEqual(int value) {
|
||||
|
|
|
|||
|
|
@ -33,10 +33,15 @@ interface AndroidCameraConf {
|
|||
|
||||
boolean isFrontCamera(int cameraId);
|
||||
|
||||
/**
|
||||
* Default: no front; rear=0; default=rear
|
||||
* @author Guillaume Beraudo
|
||||
*
|
||||
*/
|
||||
class AndroidCameras {
|
||||
Integer front;
|
||||
Integer rear;
|
||||
Integer defaultC;
|
||||
Integer rear = 0;
|
||||
Integer defaultC = rear;
|
||||
|
||||
boolean hasFrontCamera() { return front != null; }
|
||||
boolean hasRearCamera() { return rear != null; }
|
||||
|
|
|
|||
|
|
@ -30,12 +30,17 @@ class AndroidCameraConf5 implements AndroidCameraConf {
|
|||
public AndroidCameraConf5() {
|
||||
Log.i(tag, "Detecting cameras");
|
||||
|
||||
// Defaults 0/0/0
|
||||
// Defaults
|
||||
foundCameras = new AndroidCameras();
|
||||
|
||||
if (Hacks.isGalaxySOrTab()) {
|
||||
Log.d(tag, "Hack Galaxy S : has 2 cameras front=2; rear=1");
|
||||
foundCameras.front = 2;
|
||||
Log.d(tag, "Hack Galaxy S : has one or more cameras");
|
||||
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.defaultC = foundCameras.rear;
|
||||
}
|
||||
|
|
@ -44,7 +49,7 @@ class AndroidCameraConf5 implements AndroidCameraConf {
|
|||
|
||||
public int getNumberOfCameras() {
|
||||
Log.i(tag, "Detecting the number of cameras");
|
||||
if (Hacks.isGalaxySOrTab()) {
|
||||
if (Hacks.isGalaxySOrTabWithFrontCamera()) {
|
||||
Log.d(tag, "Hack Galaxy S : has 2 cameras");
|
||||
return 2;
|
||||
} else
|
||||
|
|
@ -55,8 +60,8 @@ class AndroidCameraConf5 implements AndroidCameraConf {
|
|||
|
||||
public int getCameraOrientation(int cameraId) {
|
||||
// Use hacks to guess orientation of the camera
|
||||
if (Hacks.isGalaxySOrTab() && !isFrontCamera(cameraId)) {
|
||||
Log.d(tag, "Hack Galaxy S : rear camera mounted landscape");
|
||||
if (Hacks.isGalaxySOrTab() && isFrontCamera(cameraId)) {
|
||||
Log.d(tag, "Hack Galaxy S : front camera mounted landscape");
|
||||
// mounted in landscape for a portrait phone orientation
|
||||
// |^^^^^^^^|
|
||||
// | ____ |
|
||||
|
|
@ -72,7 +77,6 @@ class AndroidCameraConf5 implements AndroidCameraConf {
|
|||
|
||||
|
||||
|
||||
|
||||
public boolean isFrontCamera(int cameraId) {
|
||||
// Use hacks to guess facing of the camera
|
||||
if (cameraId == 2 && Hacks.isGalaxySOrTab()) {
|
||||
|
|
|
|||
|
|
@ -76,11 +76,17 @@ public class AndroidCameraRecordManager {
|
|||
public boolean hasSeveralCameras() {
|
||||
return cc.getFoundCameras().hasSeveralCameras();
|
||||
}
|
||||
public boolean hasFrontCamera() {
|
||||
return cc.getFoundCameras().front != null;
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
toggleUseFrontCamera();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue