mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Merge pull request #13289 from gcalero/workaround_buffer_corruption_rc68
Workaround buffer corruption rc68
This commit is contained in:
commit
0d999533b4
1 changed files with 43 additions and 0 deletions
|
@ -14,12 +14,16 @@ package io.highfidelity.hifiinterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.view.HapticFeedbackConstants;
|
import android.view.HapticFeedbackConstants;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.qtproject.qt5.android.QtLayout;
|
||||||
|
import org.qtproject.qt5.android.QtSurface;
|
||||||
import org.qtproject.qt5.android.bindings.QtActivity;
|
import org.qtproject.qt5.android.bindings.QtActivity;
|
||||||
|
|
||||||
/*import com.google.vr.cardboard.DisplaySynchronizer;
|
/*import com.google.vr.cardboard.DisplaySynchronizer;
|
||||||
|
@ -31,6 +35,9 @@ import android.content.pm.ActivityInfo;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class InterfaceActivity extends QtActivity {
|
public class InterfaceActivity extends QtActivity {
|
||||||
|
|
||||||
|
@ -134,6 +141,7 @@ public class InterfaceActivity extends QtActivity {
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
nativeEnterForeground();
|
nativeEnterForeground();
|
||||||
|
surfacesWorkaround();
|
||||||
//gvrApi.resumeTracking();
|
//gvrApi.resumeTracking();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,6 +166,41 @@ public class InterfaceActivity extends QtActivity {
|
||||||
Log.w("[VR]", "Portrait detected but not in VR mode. Should not happen");
|
Log.w("[VR]", "Portrait detected but not in VR mode. Should not happen");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
surfacesWorkaround();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void surfacesWorkaround() {
|
||||||
|
FrameLayout fl = findViewById(android.R.id.content);
|
||||||
|
if (fl.getChildCount() > 0) {
|
||||||
|
QtLayout qtLayout = (QtLayout) fl.getChildAt(0);
|
||||||
|
if (qtLayout.getChildCount() > 1) {
|
||||||
|
QtSurface s1 = (QtSurface) qtLayout.getChildAt(0);
|
||||||
|
QtSurface s2 = (QtSurface) qtLayout.getChildAt(1);
|
||||||
|
Integer subLayer1 = 0;
|
||||||
|
Integer subLayer2 = 0;
|
||||||
|
try {
|
||||||
|
String field;
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
field = "mSubLayer";
|
||||||
|
} else {
|
||||||
|
field = "mWindowType";
|
||||||
|
}
|
||||||
|
Field f = s1.getClass().getSuperclass().getDeclaredField(field);
|
||||||
|
f.setAccessible(true);
|
||||||
|
subLayer1 = (Integer) f.get(s1);
|
||||||
|
subLayer2 = (Integer) f.get(s2);
|
||||||
|
if (subLayer1 < subLayer2) {
|
||||||
|
s1.setVisibility(View.VISIBLE);
|
||||||
|
s2.setVisibility(View.INVISIBLE);
|
||||||
|
} else {
|
||||||
|
s1.setVisibility(View.INVISIBLE);
|
||||||
|
s2.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
} catch (ReflectiveOperationException e) {
|
||||||
|
Log.e(TAG, "Workaround failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openUrlInAndroidWebView(String urlString) {
|
public void openUrlInAndroidWebView(String urlString) {
|
||||||
|
|
Loading…
Reference in a new issue