PrivacyBreacher/app/src/main/java/io/nandandesai/privacybreacher/PhysicalMonitorActivity.java

77 lines
3.0 KiB
Java

package io.nandandesai.privacybreacher;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.ConfigurationInfo;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
public class PhysicalMonitorActivity extends AppCompatActivity {
/**
* Hold a reference to our GLSurfaceView
*/
private GLSurfaceView mGLSurfaceView;
private SensorFusion mSensorFusion;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this, R.style.AlertDialogCustom);
alertDialog.setTitle("Physical activity monitoring");
alertDialog.setMessage("Apps installed on your phone can monitor the angle at which you are holding your phone, the direction in which you are holding your phone, speed at which you are moving your phone etc. using Gyroscope, Accelerometer and Magnetometer sensors without your permission." +
"This can give them a 3D visualization of your hand & body movements. This is a huge privacy loophole.\n\nGo ahead and see how this app visualizes your movements without any permissions. Start moving your phone!");
alertDialog.setCancelable(false);
alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
alertDialog.show();
mSensorFusion = new SensorFusion(this);
mGLSurfaceView = new GLSurfaceView(this);
// Check if the system supports OpenGL ES 2.0.
final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
if (supportsEs2) {
// Request an OpenGL ES 2.0 compatible context.
mGLSurfaceView.setEGLContextClientVersion(2);
// Set the renderer to our demo renderer, defined below.
mGLSurfaceView.setRenderer(new Renderer(mSensorFusion));
//mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
} else {
// This is where you could create an OpenGL ES 1.x compatible
// renderer if you wanted to support both ES 1 and ES 2.
return;
}
setContentView(mGLSurfaceView);
}
@Override
protected void onResume() {
// The activity must call the GL surface view's onResume() on activity onResume().
super.onResume();
mGLSurfaceView.onResume();
}
@Override
protected void onPause() {
// The activity must call the GL surface view's onPause() on activity onPause().
super.onPause();
mGLSurfaceView.onPause();
}
}