~ubuntu-branches/ubuntu/raring/glmark2/raring

« back to all changes in this revision

Viewing changes to android/src/org/linaro/glmark2/Glmark2Activity.java

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo
  • Date: 2012-08-21 15:38:09 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120821153809-bwux72bat8qp2n5v
Tags: 2012.08-0ubuntu1
* New upstream release 2012.08 (LP: #1039736)
  - Avoid crashing if gl used is not >= 2.0 (LP: #842279)
* Bumping dh compatibility level to v9
* debian/control:
  - Update Standards-Version to 3.9.3.
  - Add libjpeg-dev build dependency.
  - Use libegl1-x11-dev as an build-dep alternative instead of libegl1-dev.
  - Update description of glmark2-data binary package.
* debian/copyright:
  - Refresh copyright based on the current upstrem version
* debian/rules:
  - Clean compiled python code from unpacked waflib/ directory, as
    described in http://wiki.debian.org/UnpackWaf

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
import android.app.Activity;
4
4
import android.os.Bundle;
5
5
import android.opengl.GLSurfaceView;
 
6
import android.app.Dialog;
 
7
import android.app.AlertDialog;
 
8
import android.content.DialogInterface;
 
9
import android.content.Context;
 
10
import android.os.PowerManager;
 
11
import android.os.PowerManager.WakeLock;
6
12
 
7
13
public class Glmark2Activity extends Activity {
 
14
    public static final int DIALOG_EGLCONFIG_FAIL_ID = 0;
 
15
    public static final String TAG = "GLMark2";
 
16
    private WakeLock mWakeLock;
 
17
 
 
18
    @Override
 
19
    protected void onDestroy() {
 
20
        super.onDestroy();
 
21
        mWakeLock.release();
 
22
    }
 
23
 
8
24
    @Override
9
25
    protected void onCreate(Bundle savedInstanceState) {
10
26
        super.onCreate(savedInstanceState);
 
27
 
 
28
        PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
 
29
        mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, TAG);
 
30
        mWakeLock.acquire();
 
31
 
11
32
        mGLView = new Glmark2SurfaceView(this);
12
33
        setContentView(mGLView);
13
34
    }
16
37
    protected void onPause() {
17
38
        super.onPause();
18
39
        mGLView.onPause();
 
40
        Glmark2Activity.this.finish();
 
41
        android.os.Process.killProcess(android.os.Process.myPid());
19
42
    }
20
43
 
21
44
    @Override
24
47
        mGLView.onResume();
25
48
    }
26
49
 
 
50
    @Override
 
51
    protected Dialog onCreateDialog(int id) {
 
52
        Dialog dialog;
 
53
        switch (id) {
 
54
            case DIALOG_EGLCONFIG_FAIL_ID:
 
55
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
 
56
                builder.setMessage("Glmark2 cannot run because it couldn't find a suitable EGLConfig for GLES2.0. Please check that proper GLES2.0 drivers are installed.");
 
57
                builder.setCancelable(false);
 
58
                builder.setPositiveButton("Quit",
 
59
                    new DialogInterface.OnClickListener() {
 
60
                        public void onClick(DialogInterface dialog, int id) {
 
61
                            Glmark2Activity.this.finish();
 
62
                            /*
 
63
                             * Force process shutdown. There is no safer way to
 
64
                             * do this, as we have open threads we can't close
 
65
                             * when we fail to get an EGLConfig
 
66
                             */
 
67
                            android.os.Process.killProcess(android.os.Process.myPid());
 
68
                        }
 
69
                    });
 
70
 
 
71
                dialog = builder.create();
 
72
                break;
 
73
            default:
 
74
                dialog = null;
 
75
                break;
 
76
        }
 
77
 
 
78
        return dialog;
 
79
    }
 
80
 
 
81
 
27
82
    private GLSurfaceView mGLView;
28
83
 
29
84
    static {