From ef946f3ae80556ab221265c0bf1c560683ea27f6 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Tue, 19 Feb 2013 17:29:18 -0800 Subject: Initial code for Terminal app, with JNI glue. Change-Id: I4b2ecb2eef9bef7a8236391d19a3708751a7c71d --- src/com/android/terminal/Terminal.java | 36 ++++++++++++++++++++++++++ src/com/android/terminal/TerminalActivity.java | 33 +++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 src/com/android/terminal/Terminal.java create mode 100644 src/com/android/terminal/TerminalActivity.java (limited to 'src') diff --git a/src/com/android/terminal/Terminal.java b/src/com/android/terminal/Terminal.java new file mode 100644 index 0000000..8b1809c --- /dev/null +++ b/src/com/android/terminal/Terminal.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.terminal; + +public class Terminal { + static { + System.loadLibrary("jni_terminal"); + } + + private final int mNativePtr; + + public Terminal() { + mNativePtr = nativeInit(25, 80); + } + + public int getRows() { + return nativeGetRows(mNativePtr); + } + + private static native int nativeInit(int rows, int cols); + private static native int nativeGetRows(int ptr); +} diff --git a/src/com/android/terminal/TerminalActivity.java b/src/com/android/terminal/TerminalActivity.java new file mode 100644 index 0000000..0bb73ff --- /dev/null +++ b/src/com/android/terminal/TerminalActivity.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.terminal; + +import android.app.Activity; +import android.os.Bundle; +import android.util.Log; + +public class TerminalActivity extends Activity { + private static final String TAG = "Terminal"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Terminal t = new Terminal(); + Log.d(TAG, "Rows: " + t.getRows()); + } +} -- cgit v1.2.3