Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIMOB-6008 Add android support for the new Titanium.Platform.runtime property #750

Merged
merged 3 commits into from
Nov 22, 2011
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.KrollRuntime;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.kroll.common.TiConfig;
Expand Down Expand Up @@ -196,6 +197,12 @@ public double getBatteryLevel()
return batteryLevel;
}

@Kroll.getProperty @Kroll.method
public String getRuntime()
{
return KrollRuntime.getInstance().getRuntimeName();
}

protected void registerBatteryStateReceiver()
{
batteryStateReceiver = new BroadcastReceiver() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,6 @@ public boolean handleMessage(Message msg)
public abstract void doDispose();
public abstract void doRunModule(String source, String filename, KrollProxySupport activityProxy);
public abstract void initObject(KrollProxySupport proxy);
public abstract String getRuntimeName();
}

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
public class RhinoRuntime extends KrollRuntime implements ErrorReporter
{
private static final String TAG = "RhinoRuntime";
private static final String NAME = "rhino";

private Scriptable globalScope;
private Scriptable globalKrollObject;
Expand Down Expand Up @@ -151,6 +152,12 @@ public EvaluatorException runtimeError(String message, String sourceName, int li
return new EvaluatorException(message, sourceName, line, lineSource, lineOffset);
}

@Override
public String getRuntimeName()
{
return NAME;
}

@Override
public void warning(String message, String sourceName, int line, String lineSource, int lineOffset)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
public final class V8Runtime extends KrollRuntime implements Handler.Callback
{
private static final String TAG = "KrollV8Runtime";
private static final String NAME = "v8";
private static final String DEVICE_LIB = "kroll-v8-device";
private static final String EMULATOR_LIB = "kroll-v8-emulator";
private static final int MSG_PROCESS_DEBUG_MESSAGES = KrollRuntime.MSG_LAST_ID + 100;
Expand Down Expand Up @@ -72,6 +73,12 @@ public boolean handleMessage(Message message)
return super.handleMessage(message);
}

@Override
public String getRuntimeName()
{
return NAME;
}

protected void dispatchDebugMessages()
{
handler.sendEmptyMessage(MSG_PROCESS_DEBUG_MESSAGES);
Expand Down
4 changes: 4 additions & 0 deletions apidoc/Titanium/Platform/Platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ properties:
description: the number of processors the device reports
type: Number
permission: read-only
- name: runtime
description: a short name for the JavaScript runtime in use. On iOS this will return "javascriptcore", on Android either "v8" or "rhino", on Mobile Web any number of things depending on the browser that is being used.
type: String
permission: read-only
- name: username
description: the username of the device, if set
type: String
Expand Down
2 changes: 2 additions & 0 deletions drillbit/tests/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ describe("Ti.Platform tests", {
valueOf(Ti.Platform.ostype).shouldBeString();
valueOf(Ti.Platform.processorCount).shouldBeNumber();
valueOf(Ti.Platform.version).shouldBeString();
valueOf(Ti.Platform.runtime).shouldBeString();
valueOf(Ti.Platform.runtime.length).shouldBeGreaterThan(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wonder if there should be platform specific versions to test that it's one of the valid platform types if known?

}

});