拷贝APP_Bck20250119项目源码,移除libjc/jcc/libs/android-29.jar文件。
This commit is contained in:
45
jcndk/AndroidManifest.xml
Normal file
45
jcndk/AndroidManifest.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="cc.winboll.studio.jcndk"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0"
|
||||
android:sharedUserId="com.termux">
|
||||
|
||||
<!-- 拥有完全的网络访问权限 -->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<!-- MANAGE_EXTERNAL_STORAGE -->
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
|
||||
|
||||
<!-- 读取您共享存储空间中的内容 -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
|
||||
<!-- 修改或删除您共享存储空间中的内容 -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
|
||||
<uses-sdk android:minSdkVersion="4"/>
|
||||
|
||||
<application
|
||||
android:label="@string/app_name"
|
||||
android:debuggable="true">
|
||||
|
||||
<activity
|
||||
android:name=".HelloJni"
|
||||
android:label="@string/app_name">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<service android:name=".services.JCMainService"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
BIN
jcndk/META-INF/ANDROID.RSA
Normal file
BIN
jcndk/META-INF/ANDROID.RSA
Normal file
Binary file not shown.
26
jcndk/META-INF/ANDROID.SF
Normal file
26
jcndk/META-INF/ANDROID.SF
Normal file
@@ -0,0 +1,26 @@
|
||||
Signature-Version: 1.0
|
||||
Created-By: 1.0 (Android)
|
||||
SHA1-Digest-Manifest: bu8k0On7Dhh5SmMHhFIiFNy8VsE=
|
||||
X-Android-APK-Signed: 2,3
|
||||
|
||||
Name: AndroidManifest.xml
|
||||
SHA1-Digest: 650KiNkJz8zR0YjtU60p9JLk6DM=
|
||||
|
||||
Name: jni/Android.mk
|
||||
SHA1-Digest: GCbLdrenTX+es3yN2Kxr5JFTmqI=
|
||||
|
||||
Name: jni/Application.mk
|
||||
SHA1-Digest: Ej81608yiBv2xXvZNNdOqAX6inY=
|
||||
|
||||
Name: jni/hello-jni.cpp
|
||||
SHA1-Digest: JnFzQ87JOmgl03YXyU4KXOoIEVw=
|
||||
|
||||
Name: project.properties
|
||||
SHA1-Digest: J4uuFC9e5midbRb0CLjwmCe9yzI=
|
||||
|
||||
Name: res/values/strings.xml
|
||||
SHA1-Digest: b0ttc6FsJASe2A/iHmjJc46Roe4=
|
||||
|
||||
Name: src/$package_name$/HelloJni.java
|
||||
SHA1-Digest: bCqE6Coyb2Z88XANCeKu6L+lflw=
|
||||
|
25
jcndk/META-INF/MANIFEST.MF
Normal file
25
jcndk/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,25 @@
|
||||
Manifest-Version: 1.0
|
||||
Built-By: Generated-by-ADT
|
||||
Created-By: Android Gradle 3.5.0
|
||||
|
||||
Name: AndroidManifest.xml
|
||||
SHA1-Digest: U36A0NWthb49+Rxs33tkIuNYFCI=
|
||||
|
||||
Name: jni/Android.mk
|
||||
SHA1-Digest: ZpGSlRJPL0g9OejiWbQorqj40/Y=
|
||||
|
||||
Name: jni/Application.mk
|
||||
SHA1-Digest: TKh2CbRLeKfvgL4cPfmoxcVz+vc=
|
||||
|
||||
Name: jni/hello-jni.cpp
|
||||
SHA1-Digest: 1btXO19SqB6rDvPo5ynG0brDqTk=
|
||||
|
||||
Name: project.properties
|
||||
SHA1-Digest: 0ekOiGTFMVJOWqAFzNFj/1vxPL8=
|
||||
|
||||
Name: res/values/strings.xml
|
||||
SHA1-Digest: FgRO/zbNaC1wuZKVT7h6NSYBmpY=
|
||||
|
||||
Name: src/$package_name$/HelloJni.java
|
||||
SHA1-Digest: p0e9DNKocjRnsOhetb9bnp9s9J4=
|
||||
|
3
jcndk/README.md
Normal file
3
jcndk/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
## JCNDK
|
||||
### Java console NDK APP
|
||||
### It use libjc with JC project together.
|
7
jcndk/assets/switch2bash.sh
Normal file
7
jcndk/assets/switch2bash.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
## JC Shell switch to Termux Bash Shell
|
||||
export HOME=/data/data/com.termux/files/home
|
||||
export PATH="/data/data/com.termux/files/usr/bin:$PATH"
|
||||
cd ${HOME}
|
||||
echo "Home dir is : "$(pwd)
|
||||
echo "PATH is $PATH"
|
||||
bash
|
27
jcndk/jni/Android.mk
Normal file
27
jcndk/jni/Android.mk
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright (C) 2009 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.
|
||||
#
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_CPP_EXTENSION := .cpp .cc
|
||||
LOCAL_MODULE := hello-jni
|
||||
LOCAL_SRC_FILES := hello-jni.cpp
|
||||
|
||||
ifeq ($(TARGET_ARCH_ABI),x86)
|
||||
LOCAL_CFLAGS += -ffast-math -mtune=atom -mssse3 -mfpmath=sse
|
||||
endif
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
3
jcndk/jni/Application.mk
Normal file
3
jcndk/jni/Application.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
NDK_TOOLCHAIN_VERSION := clang
|
||||
APP_STL := c++_static
|
||||
APP_ABI := armeabi-v7a x86
|
32
jcndk/jni/hello-jni.cpp
Normal file
32
jcndk/jni/hello-jni.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2009 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.
|
||||
*
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <jni.h>
|
||||
|
||||
/* This is a trivial JNI example where we use a native method
|
||||
* to return a new VM String. See the corresponding Java source
|
||||
* file located at:
|
||||
*
|
||||
* apps/samples/hello-jni/project/src/com/example/hellojni/HelloJni.java
|
||||
*/
|
||||
extern "C"
|
||||
{
|
||||
JNIEXPORT jstring JNICALL Java_cc_winboll_studio_jcndk_HelloJni_stringFromJNI(JNIEnv* env, jobject thiz)
|
||||
{
|
||||
return env->NewStringUTF("Hello from JNI !");
|
||||
}
|
||||
}
|
BIN
jcndk/libs/armeabi-v7a/libhello-jni.so
Normal file
BIN
jcndk/libs/armeabi-v7a/libhello-jni.so
Normal file
Binary file not shown.
BIN
jcndk/libs/x86/libhello-jni.so
Normal file
BIN
jcndk/libs/x86/libhello-jni.so
Normal file
Binary file not shown.
BIN
jcndk/obj/local/armeabi-v7a/libhello-jni.so
Normal file
BIN
jcndk/obj/local/armeabi-v7a/libhello-jni.so
Normal file
Binary file not shown.
BIN
jcndk/obj/local/armeabi-v7a/objs/hello-jni/hello-jni.o
Normal file
BIN
jcndk/obj/local/armeabi-v7a/objs/hello-jni/hello-jni.o
Normal file
Binary file not shown.
7
jcndk/obj/local/armeabi-v7a/objs/hello-jni/hello-jni.o.d
Normal file
7
jcndk/obj/local/armeabi-v7a/objs/hello-jni/hello-jni.o.d
Normal file
@@ -0,0 +1,7 @@
|
||||
./obj/local/armeabi-v7a/objs/hello-jni/hello-jni.o: jni/hello-jni.cpp \
|
||||
/data/data/aidepro.top/no_backup/ndksupport-1710240003/android-ndk-aide/sources/cxx-stl/llvm-libc++/include/string.h \
|
||||
/data/data/aidepro.top/no_backup/ndksupport-1710240003/android-ndk-aide/sources/cxx-stl/llvm-libc++/include/__config
|
||||
|
||||
/data/data/aidepro.top/no_backup/ndksupport-1710240003/android-ndk-aide/sources/cxx-stl/llvm-libc++/include/string.h:
|
||||
|
||||
/data/data/aidepro.top/no_backup/ndksupport-1710240003/android-ndk-aide/sources/cxx-stl/llvm-libc++/include/__config:
|
BIN
jcndk/obj/local/x86/libhello-jni.so
Normal file
BIN
jcndk/obj/local/x86/libhello-jni.so
Normal file
Binary file not shown.
BIN
jcndk/obj/local/x86/objs/hello-jni/hello-jni.o
Normal file
BIN
jcndk/obj/local/x86/objs/hello-jni/hello-jni.o
Normal file
Binary file not shown.
7
jcndk/obj/local/x86/objs/hello-jni/hello-jni.o.d
Normal file
7
jcndk/obj/local/x86/objs/hello-jni/hello-jni.o.d
Normal file
@@ -0,0 +1,7 @@
|
||||
./obj/local/x86/objs/hello-jni/hello-jni.o: jni/hello-jni.cpp \
|
||||
/data/data/aidepro.top/no_backup/ndksupport-1710240003/android-ndk-aide/sources/cxx-stl/llvm-libc++/include/string.h \
|
||||
/data/data/aidepro.top/no_backup/ndksupport-1710240003/android-ndk-aide/sources/cxx-stl/llvm-libc++/include/__config
|
||||
|
||||
/data/data/aidepro.top/no_backup/ndksupport-1710240003/android-ndk-aide/sources/cxx-stl/llvm-libc++/include/string.h:
|
||||
|
||||
/data/data/aidepro.top/no_backup/ndksupport-1710240003/android-ndk-aide/sources/cxx-stl/llvm-libc++/include/__config:
|
13
jcndk/project.properties
Normal file
13
jcndk/project.properties
Normal file
@@ -0,0 +1,13 @@
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system use,
|
||||
# "build.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
|
||||
# Project target.
|
||||
target=android-29
|
||||
|
||||
android.library.reference.1=../libjc
|
47
jcndk/res/layout/view_main.xml
Normal file
47
jcndk/res/layout/view_main.xml
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/viewmainLinearLayout1">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:id="@+id/viewmainScrollView1"
|
||||
android:layout_weight="1.0"
|
||||
android:layout_margin="10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/viewmainTextView1"
|
||||
android:textIsSelectable="true"/>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<EditText
|
||||
android:layout_width="0dp"
|
||||
android:ems="10"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0"
|
||||
android:id="@+id/viewmainEditText1"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Enter"
|
||||
android:id="@+id/viewmainButton1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
4
jcndk/res/values/strings.xml
Normal file
4
jcndk/res/values/strings.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">JCNDK</string>
|
||||
</resources>
|
56
jcndk/src/cc/winboll/studio/jcndk/FileUtils.java
Normal file
56
jcndk/src/cc/winboll/studio/jcndk/FileUtils.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package cc.winboll.studio.jcndk;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2025/01/08 16:31:28
|
||||
* @Describe 文件工具类
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import cc.winboll.studio.libjc.Log;
|
||||
|
||||
public class FileUtils {
|
||||
|
||||
public static final String TAG = "FileUtils";
|
||||
|
||||
public static void copyAssetsToSD(Context context, String szSrcAssets, String szDstSD) {
|
||||
Log.d(TAG, "copyAssetsToSD [" + szSrcAssets + "] to [" + szDstSD + "]");
|
||||
AssetManager assetManager = context.getAssets();
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
try {
|
||||
inputStream = assetManager.open(szSrcAssets);
|
||||
File outputFile = new File(szDstSD);
|
||||
outputStream = new FileOutputStream(outputFile);
|
||||
byte[] buffer = new byte[1024];
|
||||
int length = 0;
|
||||
while ((length = inputStream.read(buffer)) > 0) {
|
||||
outputStream.write(buffer, 0, length);
|
||||
}
|
||||
outputStream.flush();
|
||||
Log.d(TAG, "copyAssetsToSD done.");
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, e, Thread.currentThread().getStackTrace());
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
265
jcndk/src/cc/winboll/studio/jcndk/HelloJni.java
Normal file
265
jcndk/src/cc/winboll/studio/jcndk/HelloJni.java
Normal file
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* Copyright (C) 2009 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 cc.winboll.studio.jcndk;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import cc.winboll.studio.jcndk.R;
|
||||
import cc.winboll.studio.libjc.JAR_RUNNING_MODE;
|
||||
import cc.winboll.studio.libjc.JCMainThread;
|
||||
import cc.winboll.studio.libjc.Log;
|
||||
import cc.winboll.studio.libjc.net.JCSocketServer;
|
||||
import java.io.File;
|
||||
|
||||
|
||||
public class HelloJni extends Activity implements JCMainThread.OnMessageListener {
|
||||
|
||||
public static String TAG = "HelloJni";
|
||||
final public static int MSG_APPEN = 0;
|
||||
|
||||
MessageHandler mMessageHandler;
|
||||
static JCMainThread _JCMainThread;
|
||||
StringBuilder mStringBuilder;
|
||||
Context mContext;
|
||||
ScrollView mScrollView;
|
||||
LinearLayout mRootLayout;
|
||||
TextView mTextView;
|
||||
EditText mEditText;
|
||||
Button mButton;
|
||||
JCSocketServer mJCSocketServer;
|
||||
JCMainServerThread mJCMainServerThread;
|
||||
|
||||
// @Override
|
||||
// public void log(String message) {
|
||||
// Message msg = mMessageHandler.obtainMessage(MSG_APPEN, message);
|
||||
// mMessageHandler.sendMessage(msg);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void outPrint(String message) {
|
||||
Message msg = mMessageHandler.obtainMessage(MSG_APPEN, message);
|
||||
mMessageHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void errPrint(String message) {
|
||||
Message msg = mMessageHandler.obtainMessage(MSG_APPEN, message);
|
||||
mMessageHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// 初始化日志类
|
||||
Log.init(getPackageName());
|
||||
Log.d(TAG, "onCreate");
|
||||
// 初始化视图元素
|
||||
mContext = this;
|
||||
mMessageHandler = new MessageHandler();
|
||||
//initView();
|
||||
initView2();
|
||||
// 测试添加消息 方式 1
|
||||
appendMessage("appendMessage(...) test.\n");
|
||||
// 测试添加消息 方式 2
|
||||
int szwhat = MSG_APPEN;
|
||||
String szobj = "mMessageHandler.sendMessage(...) test.\n";
|
||||
Message msg = mMessageHandler.obtainMessage(szwhat, szobj);
|
||||
mMessageHandler.sendMessage(msg);
|
||||
|
||||
// 启动主线程
|
||||
_JCMainThread = JCMainThread.getInstance(getPackageName());
|
||||
_JCMainThread.setOnLogListener(this);
|
||||
_JCMainThread.setRunningMode(JAR_RUNNING_MODE.JCNDK);
|
||||
_JCMainThread.start();
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
Log.e(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
appendMessage("Switch To Termux Bash Shell ...");
|
||||
File dirHome = new File(getFilesDir(), "home");
|
||||
if (!dirHome.exists()) {
|
||||
dirHome.mkdirs();
|
||||
}
|
||||
String szBashSwitchFileName = "switch2bash.sh";
|
||||
File fDstBashSwitch = new File(dirHome, szBashSwitchFileName);
|
||||
FileUtils.copyAssetsToSD(this, szBashSwitchFileName, fDstBashSwitch.toPath().toString());
|
||||
_JCMainThread.exeInit("cd " + dirHome.toPath().toString());
|
||||
_JCMainThread.exeInit("ash " + szBashSwitchFileName);
|
||||
|
||||
//Intent intent = new Intent(this, JCMainService.class);
|
||||
//startService(intent);
|
||||
mJCMainServerThread = new JCMainServerThread();
|
||||
mJCMainServerThread.start();
|
||||
}
|
||||
|
||||
void initView2() {
|
||||
View mainView = getLayoutInflater().inflate(R.layout.view_main, null);
|
||||
mRootLayout = mainView.findViewById(R.id.viewmainLinearLayout1);
|
||||
mScrollView = mainView.findViewById(R.id.viewmainScrollView1);
|
||||
mTextView = mainView.findViewById(R.id.viewmainTextView1);
|
||||
mButton = mainView.findViewById(R.id.viewmainButton1);
|
||||
mEditText = mainView.findViewById(R.id.viewmainEditText1);
|
||||
setContentView(mRootLayout);
|
||||
|
||||
mButton.setOnClickListener(new View.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mJCSocketServer.sendMessage(mEditText.getText().toString());
|
||||
|
||||
//System.out.println("onClick");
|
||||
//_JCMainThread.exeBashCommand(mEditText.getText().toString());
|
||||
mEditText.setText("");
|
||||
}
|
||||
});
|
||||
}
|
||||
//
|
||||
// //
|
||||
// // 函数式初始化视图元素
|
||||
// //
|
||||
// void initView() {
|
||||
// // 创建一个线性布局作为根布局
|
||||
// mRootLayout = new LinearLayout(mContext);
|
||||
// mRootLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
// mRootLayout.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
// ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
// ViewGroup.LayoutParams.MATCH_PARENT
|
||||
// ));
|
||||
//
|
||||
// // 创建ScrollView
|
||||
// mScrollView = new ScrollView(mContext);
|
||||
// mScrollView.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
// ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
// ViewGroup.LayoutParams.MATCH_PARENT
|
||||
// ));
|
||||
//
|
||||
// // 创建TextView
|
||||
// mTextView = new TextView(mContext);
|
||||
// mTextView.setTextColor(Color.BLACK);
|
||||
// mTextView.setTextSize(16);
|
||||
// mTextView.setGravity(Gravity.LEFT);
|
||||
// mTextView.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
// ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
// ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
// ));
|
||||
//
|
||||
// // 模拟添加文本内容
|
||||
// /*String longText = "";
|
||||
// for (int i = 0; i < 100; i++) {
|
||||
// longText += "这是一些示例文本内容,用于测试滚动效果。\n";
|
||||
// }
|
||||
// textView.setText(longText);*/
|
||||
//
|
||||
// // 将TextView添加到ScrollView中
|
||||
// mScrollView.addView(mTextView);
|
||||
//
|
||||
// // 将ScrollView添加到根布局中
|
||||
// mRootLayout.addView(mScrollView);
|
||||
//
|
||||
// // 设置Activity的内容视图为根布局
|
||||
// setContentView(mRootLayout);
|
||||
//
|
||||
// }
|
||||
|
||||
//
|
||||
// 添加输出消息
|
||||
//
|
||||
void appendMessage(String szMessage) {
|
||||
mTextView.append(szMessage);
|
||||
|
||||
// 让ScrollView滚动到底部
|
||||
mScrollView.post(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
mScrollView.fullScroll(ScrollView.FOCUS_DOWN);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/* A native method that is implemented by the
|
||||
* 'hello-jni' native library, which is packaged
|
||||
* with this application.
|
||||
*/
|
||||
public native String stringFromJNI();
|
||||
|
||||
/* This is another native method declaration that is *not*
|
||||
* implemented by 'hello-jni'. This is simply to show that
|
||||
* you can declare as many native methods in your Java code
|
||||
* as you want, their implementation is searched in the
|
||||
* currently loaded native libraries only the first time
|
||||
* you call them.
|
||||
*
|
||||
* Trying to call this function will result in a
|
||||
* java.lang.UnsatisfiedLinkError exception !
|
||||
*/
|
||||
public native String unimplementedStringFromJNI();
|
||||
|
||||
/* this is used to load the 'hello-jni' library on application
|
||||
* startup. The library has already been unpacked into
|
||||
* /data/data/com.example.hellojni/lib/libhello-jni.so at
|
||||
* installation time by the package manager.
|
||||
*/
|
||||
static {
|
||||
System.loadLibrary("hello-jni");
|
||||
}
|
||||
|
||||
class MessageHandler extends Handler {
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_APPEN : {
|
||||
appendMessage(String.format("%s", msg.obj));
|
||||
}
|
||||
}
|
||||
super.handleMessage(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class JCMainServerThread extends Thread {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
System.err.println(String.format("%s Exception : %s", TAG, e.getMessage()));
|
||||
Log.e(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
System.out.println("JCMainServerThread run()");
|
||||
mJCSocketServer = JCSocketServer.getInstance();
|
||||
mJCSocketServer.main(null);
|
||||
System.out.println("JCMainServerThread exit.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package cc.winboll.studio.jcndk.services;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2025/01/09 11:19:28
|
||||
* @Describe JC 主服务类
|
||||
*/
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import cc.winboll.studio.libjc.Main;
|
||||
import cc.winboll.studio.libjc.net.JCSocketServer;
|
||||
|
||||
public class JCMainService extends Service {
|
||||
|
||||
public static final String TAG = "JCService";
|
||||
|
||||
JCMainServiceThread mJCMainServiceThread;
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
System.out.println("onStartCommand");
|
||||
mJCMainServiceThread = new JCMainServiceThread();
|
||||
mJCMainServiceThread.start();
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
class JCMainServiceThread extends Thread {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
System.out.println("JCMainServiceThread run()");
|
||||
JCSocketServer.main(null);
|
||||
System.out.println("JCMainServiceThread exit.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user