Subversion Repositories Projects

Rev

Rev 316 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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