Subversion Repositories Projects

Rev

Rev 316 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
280 ligi 1
/***************************************************************
2
 *
3
 * Canvas  of DUBwise Installer
4
 *                                                          
5
 * Author:        Marcus -LiGi- Bueschleb
6
 * Mailto:        LiGi @at@ LiGi DOTT de                    
7
 *
531 ligi 8
 *
9
 * this class detects some propertys of the Phone
10
 *
280 ligi 11
 ***************************************************************/
12
 
13
import javax.microedition.lcdui.*;
14
import java.io.*;
15
import javax.microedition.io.*;
531 ligi 16
import javax.microedition.rms.*;
280 ligi 17
 
18
public class DUBwiseInstallerCanvas
19
    extends Canvas
20
    implements Runnable
21
{
22
 
23
    // values to detect
24
    int canvas_width=-1;
25
    int canvas_height=-1;
26
 
27
    int canvas_full_width=-1;
28
    int canvas_full_height=-1;
29
    boolean fullscreen=false;
30
    boolean locationprovider;
31
    boolean devicecontrol;
32
    boolean bluetooth;
33
    boolean cldc11;
34
    boolean fileapi;
35
 
316 ligi 36
    boolean sensorapi;
37
 
38
 
280 ligi 39
    String comports;
40
    String props;
41
    // end  values to detect
42
 
43
    DUBwiseInstaller root;
531 ligi 44
    private boolean fs_check=true; // fullscreen check 
280 ligi 45
 
531 ligi 46
 
47
 
48
 
49
    public String description_str()
50
    {
51
 
52
        int rms_avail=0;
53
        try {
54
            RecordStore recStore = RecordStore.openRecordStore("test", true );
55
            rms_avail=recStore.getSizeAvailable();
56
            }
57
        catch ( Exception e) {}
58
        System.gc();  // to have better results measuring the Mem
59
        return
60
 
61
            "Screenwidth:" + canvas_width + "\n"
62
            +"Screenheight:" + canvas_height + "\n"
63
            +"Screenwidth FS:" + canvas_full_width + "\n"
64
            +"Screenheight FS:" + canvas_full_height + "\n"
65
            +"CLDC1.1:" + cldc11 + "\n"
66
            +"JSR-82:" + bluetooth + "\n"
67
            +"JSR-179:" + locationprovider + "\n"
68
            +"FileConn:" + fileapi + "\n"
69
            +"SensorAPI:" + sensorapi + "\n"
70
            +"DeviceControl:" + devicecontrol + "\n"
71
            +"comports:" + comports + "\n"
72
 
73
            +"freeMemory:" + Runtime.getRuntime().freeMemory()+ "\n"
74
            +"totalMemory:" + Runtime.getRuntime().totalMemory()+ "\n"
75
            +"RMSAvail:" +  rms_avail+ "\n"
76
            +props;
77
 
78
    }
79
 
80
 
280 ligi 81
    public boolean try_class(String class_name)
82
    {
83
        try
84
            {
85
                Class.forName(class_name);
86
            }
87
 
88
        catch (Exception e)
89
            {
90
                return false;
91
            }
92
        return true;
93
    }
94
    public DUBwiseInstallerCanvas(DUBwiseInstaller _root)
95
 
96
    {
97
        root=_root;
98
        new Thread(this).start();
99
    }
100
 
101
 
102
    public void run()
103
    {
104
 
105
        repaint();
106
        serviceRepaints();
107
 
108
        try
109
            {
110
                Thread.sleep(500);
111
            }
112
        catch (Exception e)
113
            {}
114
 
115
        locationprovider=try_class("javax.microedition.location.LocationProvider");;
116
        devicecontrol=try_class("com.nokia.mid.ui.DeviceControl");
117
        bluetooth=try_class("javax.bluetooth.DiscoveryAgent");
118
        cldc11=try_class("java.lang.Math");
119
        fileapi=try_class("javax.microedition.io.file.FileConnection");
120
        comports=System.getProperty("microedition.commports")+"\n";
316 ligi 121
        sensorapi=try_class("javax.microedition.sensor.SensorManager");
122
 
280 ligi 123
        props="enc: " +System.getProperty("microedition.encoding")+"\n";
124
        props+="platform: " +System.getProperty("microedition.platform")+"\n";
125
        props+="locale: " +System.getProperty("microedition.locale")+"\n";
126
        props+="config:" + System.getProperty("microedition.configuration")+"\n";
127
        props+="profiles: " +System.getProperty("microedition.profiles")+"\n";
128
        props+="hostname: " +System.getProperty("microedition.hostname")+"\n";
316 ligi 129
        props+="loc-version: " +System.getProperty("microedition.location.version")+"\n";
280 ligi 130
 
316 ligi 131
        props+="sensor-api-version: " +System.getProperty("microedition.sensor.version")+"\n";
280 ligi 132
 
316 ligi 133
 
134
        // test for symbian src: http://discussion.forum.nokia.com/forum/showthread.php?t=96615
135
        try {
136
            Class.forName("com.symbian.gcf.NativeInputStream");
137
            props+="symbian: true\n";
138
        }
139
        catch (ClassNotFoundException e) {
140
            props+="symbian: false\n";
141
        }
531 ligi 142
        root.canvas_hw_detect_finish();
280 ligi 143
 
144
    }
145
 
146
 
147
    public void paint(Graphics g)
148
    {
149
 
150
        if (fs_check) try
151
            {
152
 
153
                setFullScreenMode(false);
154
                canvas_width=this.getWidth();
155
                canvas_height=this.getHeight();
156
 
157
                setFullScreenMode(true);
158
                canvas_full_width=this.getWidth();
159
                canvas_full_height=this.getHeight();
160
 
161
                fullscreen=((canvas_full_width!=canvas_width)||(canvas_full_height!=canvas_height));
162
            }
163
        catch (Exception e)
164
            {
165
                canvas_width=this.getWidth();
166
                canvas_height=this.getHeight();
167
                canvas_full_width=this.getWidth();
168
                canvas_full_height=this.getHeight();
169
 
170
            }
171
 
172
        fs_check=false;
173
        g.setColor(0);
174
        g.fillRect(0,0,canvas_full_width,canvas_full_height);
175
        g.setColor(0x00BB00);
176
        g.drawString("Detecting Hardware",0,0,Graphics.LEFT  | Graphics.TOP);
177
 
178
    }
179
}