package com.nokia.example.systemproperties; /* * Copyright © 2011 Nokia Corporation. All rights reserved. * Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation. * Oracle and Java are trademarks or registered trademarks of Oracle and/or its * affiliates. Other product and company names mentioned herein may be trademarks * or trade names of their respective owners. * See LICENSE.TXT for license information. */ import javax.microedition.lcdui.Alert; import javax.microedition.lcdui.AlertType; import javax.microedition.lcdui.List; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.midlet.MIDlet; public class SystemProperties extends MIDlet implements CommandListener { //Human readable names for the properties private static final String[] SYSPROPLISTS = { "CLDC&MIDP", "Optional packages", "MMAPI (JSR-135)", "Bluetooth API (JSR-82)", "FileConnection API (JSR-75)", "WMA (JSR-120/205)", "SATSA API (JSR-177)", "Web Services API (JSR-172)", "AMMS API (JSR-234)", "Scalable 2D Vector Graphics API (JSR-226)", "Mobile 3D Graphics API (JSR-184)", "S60 3rd Ed. FP2 system properties", "Other Nokia system properties", "Protected system properties", "S60 5th Ed. properties" }; //The following are names of details of system properties //The names of the details for the CLDC&MIDP properties private static final String[] CLDC_MIDPPROPS = { "microedition.profiles", "microedition.configuration", "microedition.locale", "microedition.platform", "microedition.encoding", "microedition.commports", "microedition.hostname", "microedition.jtwi.version", "microedition.msa.version" }; private static final String[] OPT_SYSPROPS = { "microedition.media.version", "microedition.pim.version", "microedition.m3g.version", "microedition.location.version", "bluetooth.api.version", "microedition.io.file.FileConnection.version", "microedition.global.version", "microedition.chapi.version", "microedition.sip.version", "wireless.messaging.version", "microedition.amms.version", "microedition.m2g.version", "microedition.payment.version", "microedition.contactless.version", "microedition.sensor.version", "obex.api.version", "microedition.broadcast.version", "com.nokia.mid.ui.version" }; private static final String[] MMAPI_SYSPROPS = { "supports.mixing", "supports.audio.capture", "supports.video.capture", "supports.recording", "audio.encodings", "video.encodings", "video.snapshot.encodings", "streamable.contents" }; private static final String[] BT_SYSPROPS = { "bluetooth.l2cap.receiveMTU.max", "bluetooth.connected.devices.max", "bluetooth.connected.inquiry", "bluetooth.connected.page", "bluetooth.connected.inquiry.scan", "bluetooth.connected.page.scan", "bluetooth.master.switch", "bluetooth.sd.trans.max", "bluetooth.sd.attr.retrievable.max" }; private static final String[] FILE_API_SYSPROPS = { "fileconn.dir.photos", "fileconn.dir.videos", "fileconn.dir.graphics", "fileconn.dir.tones", "fileconn.dir.music", "fileconn.dir.recordings", "fileconn.dir.memorycard", "fileconn.dir.private", "fileconn.dir.photos.name", "fileconn.dir.videos.name", "fileconn.dir.graphics.name", "fileconn.dir.tones.name", "fileconn.dir.music.name", "fileconn.dir.recordings.name", "fileconn.dir.memorycard.name", "fileconn.dir.private.name", "fileconn.dir.roots.names", "file.separator" }; private static final String[] WMA_SYSPROPS = { "wireless.messaging.sms.smsc", "wireless.messaging.mms.mmsc" }; private static final String[] SATSA_SYSPROPS = { "microedition.satsa.crypto.version", "microedition.satsa.apdu.version", "microedition.satsa.pki.version", "microedition.smartcardslots" }; private static final String[] WEB_SERVICES_SYSPROPS = { "xml.jaxp.subset.version", "xml.rpc.subset.version" }; private static final String[] AMMS_SYSPROPS = { "tuner.modulations", "audio.samplerates", "audio3d.simultaneouslocations", "camera.orientations", "camera.resolutions", "supports.mediacapabilities" }; private static final String[] M2G_SYSPROPS = { "microedition.m2g.svg.baseProfile", "microedition.m2g.svg.version" }; private static final String[] M3G_SYSPROPS = { "supportAntialiasing", "supportTrueColor", "supportDithering", "supportMipmapping", "supportPerspectiveCorrection", "supportLocalCameraLighting", "maxLights", "maxViewportWidth", "maxViewportHeight", "maxViewportDimension", "maxTextureDimension", "m3gRelease", "maxSpriteCropDimension", "numTextureUnits", "maxTransformsPerVertex" }; private static final String[] S60_3RD_FP2_SYSPROPS = { // These system properties are Nokia proprietary system properties supported // by S60 3rd Edition Feature Pack 2 (and newer S60) devices. Note, that the access to // com.nokia.mid.imsi system property (in PROTECTED_SYSPROPS) is limited with // com.nokia.mid.Mobinfo.IMSI permission. By default this permission is available only // in manufacturer and operator domain. "com.nokia.mid.networkid", "com.nokia.mid.networksignal", "com.nokia.mid.networkavailability", "com.nokia.mid.networkstatus", "com.nokia.mid.batterylevel", "com.nokia.mid.countrycode", "com.nokia.network.access", "com.nokia.mid.dateformat", "com.nokia.mid.timeformat", "com.nokia.memoryramfree", "com.nokia.mid.imsi" }; private static final String[] OTHER_NOKIA_SYSPROPS = { "com.nokia.mid.dateformat", "com.nokia.mid.timeformat", "com.nokia.network.access", "com.nokia.midp.impl.isa.network.databearer", "com.nokia.mid.impl.nativeDigitSupport", "com.nokia.midp.impl.isa.network.databearer", "com.nokia.mid.productcode", "com.nokia.mid.ui.joystick_event", "com.nokia.mid.ui.softnotification", "com.nokia.mid.ui.version", "com.nokia.keyboard.type", "com.nokia.key.scancode", "com.nokia.key.modifier" }; private static final String[] PROTECTED_SYSPROPS = { "com.nokia.mid.imei", "Cell-ID", "com.nokia.mid.imsi", "com.nokia.mid.spn", "com.nokia.mid.mnc", "com.nokia.mid.ons", "com.nokia.mid.networkID", "com.nokia.mid.cellid", "com.nokia.mid.lac", "com.nokia.mid.gid1", "com.nokia.mid.gid2", "com.nokia.mid.msisdn", "com.nokia.mid.productcode" }; protected static final String[] S60_5TH_SYSPROPS = { "com.nokia.canvas.net.indicator.location", "com.nokia.softkey1.label.location", "com.nokia.softkey2.label.location", "com.nokia.softkey3.label.location", "com.nokia.softkey1.label.anchor", "com.nokia.softkey2.label.anchor", "com.nokia.softkey3.label.anchor" }; private List list; private SysPropForm form; private Command exitCommand; private Command memCommand; protected int index; protected boolean bt = false; protected boolean m3g = false; //Constructor public SystemProperties() { list = new List("System properties", List.IMPLICIT, SYSPROPLISTS, null); form = new SysPropForm(SYSPROPLISTS[0], this, CLDC_MIDPPROPS); exitCommand = new Command("Exit", Command.EXIT, 1); memCommand = new Command("Memory status", Command.SCREEN, 1); list.addCommand(memCommand); list.addCommand(exitCommand); list.setCommandListener(this); Display.getDisplay(this).setCurrent(list); } //Required when extending MIDlet protected void startApp() { } //Required when extending MIDlet protected void pauseApp() { } //Required when extending MIDlet protected void destroyApp(boolean p1) { } //Called when a command is issued public void commandAction(Command c, Displayable d) { //If the command is a selection, call the SysPropForm //which displays the details of the property. if (c == List.SELECT_COMMAND) { index = list.getSelectedIndex(); if (index == 0) { form.update(SYSPROPLISTS[0], CLDC_MIDPPROPS); } if (index == 1) { form.update(SYSPROPLISTS[1], OPT_SYSPROPS); } if (index == 2) { form.update(SYSPROPLISTS[2], MMAPI_SYSPROPS); } if (index == 3) { bt = true; form.update(SYSPROPLISTS[3], BT_SYSPROPS); } if (index == 4) { form.update(SYSPROPLISTS[4], FILE_API_SYSPROPS); } if (index == 5) { form.update(SYSPROPLISTS[5], WMA_SYSPROPS); } if (index == 6) { form.update(SYSPROPLISTS[6], SATSA_SYSPROPS); } if (index == 7) { form.update(SYSPROPLISTS[7], WEB_SERVICES_SYSPROPS); } if (index == 8) { form.update(SYSPROPLISTS[8], AMMS_SYSPROPS); } if (index == 9) { form.update(SYSPROPLISTS[9], M2G_SYSPROPS); } if (index == 10) { m3g = true; form.update(SYSPROPLISTS[10], M3G_SYSPROPS); } if (index == 11) { form.update(SYSPROPLISTS[11], S60_3RD_FP2_SYSPROPS); } if (index == 12) { form.update(SYSPROPLISTS[12], OTHER_NOKIA_SYSPROPS); } if (index == 13) { form.update(SYSPROPLISTS[13], PROTECTED_SYSPROPS); } //A special case for S60_5TH_SYSPROPS if (index == 14) { SysPropFullCanvas canvas = new SysPropFullCanvas(this); Display.getDisplay(this).setCurrent(canvas); } if (index != 14) { Display.getDisplay(this).setCurrent(form); } } //If the command was to show the memory status. if (c == memCommand) { showMemory(); } //If the command was to exit the MIDlet if (c == exitCommand) { quitApp(); } } public void quitApp() { destroyApp(true); notifyDestroyed(); } //Display the main view (list of properties) protected void showList() { Display.getDisplay(this).setCurrent(list); } //Show the memory notification private void showMemory() { Alert alert = new Alert("Memory status"); String freemem = "" + Runtime.getRuntime().freeMemory(); String totalmem = "" + Runtime.getRuntime().totalMemory(); alert.setString("Free memory/Total memory: " + freemem + "/" + totalmem); alert.setType(AlertType.INFO); alert.setTimeout(Alert.FOREVER); Display.getDisplay(this).setCurrent(alert, list); } }