Commit 97040202 authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Implement MIDlet.checkPermission().

parent 0a54ca55
......@@ -12,6 +12,7 @@ package cc.squirreljme.runtime.cldc.asm;
import cc.squirreljme.runtime.javase.lcdui.ColorInfo;
import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import cc.squirreljme.runtime.lcdui.ExtendedCapabilities;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
......@@ -162,7 +163,8 @@ public final class NativeDisplayAccess
return Display.SUPPORTS_INPUT_EVENTS |
Display.SUPPORTS_TITLE |
Display.SUPPORTS_ORIENTATION_PORTRAIT |
Display.SUPPORTS_ORIENTATION_LANDSCAPE;
Display.SUPPORTS_ORIENTATION_LANDSCAPE |
ExtendedCapabilities.SUPPORTS_POINTER_EVENTS;
}
/**
......
......@@ -65,6 +65,7 @@ More detailed changes:
to launched tasks.
* `midp-lcdui`
* Added a 12 strike font.
* Added capability flag for pointer events.
* Added support for getting the number of display colors which depends on
the pixel format of the display.
* Added support to get the number of alpha levels.
......
......@@ -47,11 +47,45 @@ public abstract class MIDlet
protected abstract void startApp()
throws MIDletStateChangeException;
/**
* Checks if the given permission is valid.
*
* Do not use this to check permissions.
*
* @param __p The permission to check.
* @return {@code 0} if permission is denied, {@code 1} if permitted,
* and {@code -1} if unknown.
* @throws IllegalStateException If this is a MIDP 3.0 application.
* @since 2019/05/05
*/
@Deprecated
public final int checkPermission(String __p)
throws IllegalStateException
{
throw new todo.TODO();
// Not permitted on MIDP 3 or MEEP
String profile = this.getAppProperty("microedition-profile");
if (profile != null)
{
// Makes it easier to use
profile = profile.toLowerCase();
// {@squirreljme.error AD03 Cannot use check permission on
// MIDP 3.0 or MEEP suite profiles.}
if (profile.contains("midp-3") || profile.contains("meep"))
throw new IllegalStateException("AD03");
}
// Do security check
try
{
System.getSecurityManager().checkPermission(
new RuntimePermission(__p));
return 1;
}
catch (SecurityException e)
{
return 0;
}
}
/**
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.runtime.lcdui;
/**
* Represents extended capabilities of the display.
*
* @since 2019/05/05
*/
public interface ExtendedCapabilities
{
/** Does this support pointer events? */
public static final int SUPPORTS_POINTER_EVENTS =
0x4000_0000;
}
......@@ -17,6 +17,7 @@ import cc.squirreljme.runtime.lcdui.common.CommonMetrics;
import cc.squirreljme.runtime.lcdui.DisplayOrientation;
import cc.squirreljme.runtime.lcdui.DisplayState;
import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import cc.squirreljme.runtime.lcdui.ExtendedCapabilities;
import cc.squirreljme.runtime.lcdui.SerializedEvent;
import cc.squirreljme.runtime.lcdui.ui.UIDisplayState;
import cc.squirreljme.runtime.lcdui.ui.UIFramebuffer;
......@@ -565,7 +566,8 @@ public class Display
if (this._nid != 0)
return false;
throw new todo.TODO();
return 0 != (this.getCapabilities() &
ExtendedCapabilities.SUPPORTS_POINTER_EVENTS);
}
/**
......@@ -580,7 +582,8 @@ public class Display
if (this._nid != 0)
return false;
throw new todo.TODO();
return 0 != (this.getCapabilities() &
ExtendedCapabilities.SUPPORTS_POINTER_EVENTS);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment