Subversion Repositories Projects

Rev

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

/***************************************************************
 *
 * Canvas  of DUBwise Installer
 *                                                          
 * Author:        Marcus -LiGi- Bueschleb
 * Mailto:        LiGi @at@ LiGi DOTT de                    
 *
 *
 * this class detects some propertys of the Phone
 *
 ***************************************************************/


import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.rms.*;

public class DUBwiseInstallerCanvas
    extends Canvas
    implements Runnable
{

    // values to detect
    int canvas_width=-1;
    int canvas_height=-1;

    int canvas_full_width=-1;
    int canvas_full_height=-1;
    boolean fullscreen=false;
    boolean locationprovider;
    boolean devicecontrol;
    boolean bluetooth;
    boolean cldc11;
    boolean fileapi;

    boolean sensorapi;


    String comports;
    String props;
    // end  values to detect

    DUBwiseInstaller root;
    private boolean fs_check=true; // fullscreen check




    public String description_str()
    {

        int rms_avail=0;
        try {
            RecordStore recStore = RecordStore.openRecordStore("test", true );
            rms_avail=recStore.getSizeAvailable();
            }
        catch ( Exception e) {}
        System.gc();  // to have better results measuring the Mem
        return
           
            "Screenwidth:" + canvas_width + "\n"
            +"Screenheight:" + canvas_height + "\n"
            +"Screenwidth FS:" + canvas_full_width + "\n"
            +"Screenheight FS:" + canvas_full_height + "\n"
            +"CLDC1.1:" + cldc11 + "\n"
            +"JSR-82:" + bluetooth + "\n"
            +"JSR-179:" + locationprovider + "\n"
            +"FileConn:" + fileapi + "\n"
            +"SensorAPI:" + sensorapi + "\n"
            +"DeviceControl:" + devicecontrol + "\n"
            +"comports:" + comports + "\n"

            +"freeMemory:" + Runtime.getRuntime().freeMemory()+ "\n"
            +"totalMemory:" + Runtime.getRuntime().totalMemory()+ "\n"
            +"RMSAvail:" +  rms_avail+ "\n"
            +props;

    }


    public boolean try_class(String class_name)
    {
        try
            {
                Class.forName(class_name);
            }

        catch (Exception e)
            {
                return false;
            }
        return true;
    }
    public DUBwiseInstallerCanvas(DUBwiseInstaller _root)

    {
        root=_root;
        new Thread(this).start();
    }


    public void run()
    {

        repaint();
        serviceRepaints();
       
        try
            {
                Thread.sleep(500);
            }
        catch (Exception e)
            {}

        locationprovider=try_class("javax.microedition.location.LocationProvider");;
        devicecontrol=try_class("com.nokia.mid.ui.DeviceControl");
        bluetooth=try_class("javax.bluetooth.DiscoveryAgent");
        cldc11=try_class("java.lang.Math");
        fileapi=try_class("javax.microedition.io.file.FileConnection");
        comports=System.getProperty("microedition.commports")+"\n";
        sensorapi=try_class("javax.microedition.sensor.SensorManager");
       
        props="enc: " +System.getProperty("microedition.encoding")+"\n";
        props+="platform: " +System.getProperty("microedition.platform")+"\n";
        props+="locale: " +System.getProperty("microedition.locale")+"\n";
        props+="config:" + System.getProperty("microedition.configuration")+"\n";
        props+="profiles: " +System.getProperty("microedition.profiles")+"\n";
        props+="hostname: " +System.getProperty("microedition.hostname")+"\n";
        props+="loc-version: " +System.getProperty("microedition.location.version")+"\n";

        props+="sensor-api-version: " +System.getProperty("microedition.sensor.version")+"\n";


        // test for symbian src: http://discussion.forum.nokia.com/forum/showthread.php?t=96615
        try {
            Class.forName("com.symbian.gcf.NativeInputStream");
            props+="symbian: true\n";
        }
        catch (ClassNotFoundException e) {
            props+="symbian: false\n";
        }
        root.canvas_hw_detect_finish();

    }


    public void paint(Graphics g)
    {

        if (fs_check) try
            {

                setFullScreenMode(false);
                canvas_width=this.getWidth();
                canvas_height=this.getHeight();

                setFullScreenMode(true);
                canvas_full_width=this.getWidth();
                canvas_full_height=this.getHeight();

                fullscreen=((canvas_full_width!=canvas_width)||(canvas_full_height!=canvas_height));
            }
        catch (Exception e)
            {
                canvas_width=this.getWidth();
                canvas_height=this.getHeight();
                canvas_full_width=this.getWidth();
                canvas_full_height=this.getHeight();

            }

        fs_check=false;
        g.setColor(0);
        g.fillRect(0,0,canvas_full_width,canvas_full_height);
        g.setColor(0x00BB00);
        g.drawString("Detecting Hardware",0,0,Graphics.LEFT  | Graphics.TOP);

    }
}