1
master
wangsiyuan 2023-08-08 22:27:21 +08:00
commit 075eb56102
66 changed files with 3034 additions and 0 deletions

15
.gitignore vendored Normal file
View File

@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties

3
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

6
.idea/compiler.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>

20
.idea/gradle.xml Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="Embedded JDK" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

10
.idea/misc.xml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

1
app/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

41
app/build.gradle Normal file
View File

@ -0,0 +1,41 @@
plugins {
id 'com.android.application'
}
android {
namespace 'iku.os.ikuterminal'
compileSdk 33
defaultConfig {
applicationId "iku.os.ikuterminal"
minSdk 29
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_9
targetCompatibility JavaVersion.VERSION_1_9
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.squareup.okhttp3:okhttp:3.14.9'
implementation 'org.java-websocket:Java-WebSocket:1.5.3'
}

21
app/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

BIN
app/release/app-release.apk Normal file

Binary file not shown.

View File

@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "iku.os.ikuterminal",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}

View File

@ -0,0 +1,26 @@
package iku.os.ikuterminal;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("iku.os.ikuterminal", appContext.getPackageName());
}
}

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<application
android:usesCleartextTraffic="true"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.IkuTerminal"
tools:targetApi="31">
<activity
android:name=".DownloadActivity"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="iku.os.net.IkuService" />
<receiver
android:name="iku.os.net.NetworkStateReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@ -0,0 +1,419 @@
package iku.os.FileUtils;
import android.util.Log;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
/**
* @author litianxiang
* @description:
* @date :2021/9/28 15:44
*/
public class FileUtils {
private static final String TAG = "IkuClient FileUtils:";
private static final int BUFFER_SIZE = 1024 * 1024;//1M Byte
//创建文件夹
public static boolean createDir(String destDirName) {
File dir = new File(destDirName);
if (dir.exists()) {
System.out.println("创建目录" + destDirName + "失败,目标目录已经存在");
return false;
}
if (!destDirName.endsWith(File.separator)) {
destDirName = destDirName + File.separator;
}
//创建目录
if (dir.mkdirs()) {
Log.e("createDir","创建目录" + destDirName + "成功!");
return true;
} else {
Log.e("createDir","创建目录" + destDirName + "失败!");
return false;
}
}
/**
*
*
* @param filePath
* @param fileName
* @return
*/
public static boolean createFile(String filePath, String fileName) {
String strFilePath = filePath + fileName;
File file = new File(filePath);
if (!file.exists()) {
/** 注意这里是 mkdirs()方法 可以创建多个文件夹 */
file.mkdirs();
}
File subfile = new File(strFilePath);
if (!subfile.exists()) {
try {
boolean b = subfile.createNewFile();
return b;
} catch (IOException e) {
e.printStackTrace();
}
} else {
return true;
}
return false;
}
/**
*
*
* @param file
*/
public static List<File> getFile(File file) {
List<File> list = new ArrayList<>();
File[] fileArray = file.listFiles();
if (fileArray == null) {
return null;
} else {
for (File f : fileArray) {
if (f.isFile()) {
list.add(0, f);
} else {
getFile(f);
}
}
}
return list;
}
/**
*
*
* @param filePath
* @return
*/
public static boolean deleteFiles(String filePath) {
List<File> files = getFile(new File(filePath));
if (files.size() != 0) {
for (int i = 0; i < files.size(); i++) {
File file = files.get(i);
/** 如果是文件则删除 如果都删除可不必判断 */
if (file.isFile()) {
file.delete();
}
}
}
return true;
}
//删除文件夹和文件夹里面的文件
public static void deleteDirWihtFile(File dir) {
if (dir == null || !dir.exists() || !dir.isDirectory())
return;
for (File file : dir.listFiles()) {
if (file.isFile())
file.delete(); // 删除所有文件
else if (file.isDirectory())
deleteDirWihtFile(file); // 递规的方式删除文件夹
}
dir.delete();// 删除目录本身
}
/**
*
*
* @param strcontent
* @param filePath
* @param fileName
*/
public static void writeToFile(String strcontent, String filePath, String fileName) {
//生成文件夹之后,再生成文件,不然会出错
String strFilePath = filePath + fileName;
// 每次写入时,都换行写
File subfile = new File(strFilePath);
RandomAccessFile raf = null;
try {
/** 构造函数 第二个是读写方式 */
raf = new RandomAccessFile(subfile, "rw");
/** 将记录指针移动到该文件的最后 */
raf.seek(subfile.length());
/** 向文件末尾追加内容 */
raf.write(strcontent.getBytes());
raf.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
*
*
* @param path
* @param content
* @param append (true=)(false=)
*/
public static void modifyFile(String path, String content, boolean append) {
try {
FileWriter fileWriter = new FileWriter(path, append);
BufferedWriter writer = new BufferedWriter(fileWriter);
writer.append(content);
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
*
*
* @param filePath
* @param filename
* @return
*/
public static String getString(String filePath, String filename) {
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(new File(filePath + filename));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
InputStreamReader inputStreamReader = null;
try {
inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
BufferedReader reader = new BufferedReader(inputStreamReader);
StringBuffer sb = new StringBuffer("");
String line;
try {
while ((line = reader.readLine()) != null) {
sb.append(line);
sb.append("\n");
}
} catch (IOException e) {
e.printStackTrace();
}
return sb.toString();
}
/**
*
*
* @param oldPath
* @param newPath
*/
public static void renameFile(String oldPath, String newPath) {
File oleFile = new File(oldPath);
File newFile = new File(newPath);
//执行重命名
oleFile.renameTo(newFile);
}
/**
*
*
* @param fromFile
* @param toFile
* @return
*/
public static boolean copy(String fromFile, String toFile) {
//要复制的文件目录
File[] currentFiles;
File root = new File(fromFile);
//如同判断SD卡是否存在或者文件是否存在
//如果不存在则 return出去
if (!root.exists()) {
return false;
}
//如果存在则获取当前目录下的全部文件 填充数组
currentFiles = root.listFiles();
//目标目录
File targetDir = new File(toFile);
//创建目录
if (!targetDir.exists()) {
targetDir.mkdirs();
}
//遍历要复制该目录下的全部文件
for (int i = 0; i < currentFiles.length; i++) {
if (currentFiles[i].isDirectory())//如果当前项为子目录 进行递归
{
copy(currentFiles[i].getPath() + "/", toFile + currentFiles[i].getName() + "/");
} else//如果当前项为文件则进行文件拷贝
{
CopySdcardFile(currentFiles[i].getPath(), toFile + currentFiles[i].getName());
}
}
return true;
}
//文件拷贝
//要复制的目录下的所有非子目录(文件夹)文件拷贝
public static boolean CopySdcardFile(String fromFile, String toFile) {
try {
InputStream fosfrom = new FileInputStream(fromFile);
OutputStream fosto = new FileOutputStream(toFile);
byte bt[] = new byte[1024];
int c;
while ((c = fosfrom.read(bt)) > 0) {
fosto.write(bt, 0, c);
}
fosfrom.close();
fosto.close();
return true;
} catch (Exception ex) {
return false;
}
}
/**
*
* @param path
* @return
*/
public static List<String> getFilesAllName(String path) {
File file=new File(path);
File[] files=file.listFiles();
if (files == null){
Log.e("error","空目录");
return null;
}
List<String> s = new ArrayList<>();
for(int i =0;i<files.length;i++){
s.add(files[i].getAbsolutePath());
}
return s;
}
/**
*
*
* @param zipFile
* @param folderPath
* @return
* @throws IOException
*/
public static ArrayList<File> upZipFile(File zipFile, String folderPath) throws IOException {
ArrayList<File> fileList = new ArrayList<File>();
File desDir = new File(folderPath);
if (!desDir.exists()) {
desDir.mkdirs();
}
ZipFile zf = new ZipFile(zipFile);
for (Enumeration<?> entries = zf.entries(); entries.hasMoreElements(); ) {
ZipEntry entry = (ZipEntry) entries.nextElement();
if (entry.isDirectory()) {
continue;
}
InputStream is = zf.getInputStream(entry);
String str = folderPath + File.separator + entry.getName();
str = new String(str.getBytes("8859_1"), "UTF-8");
File desFile = new File(str);
if (!desFile.exists()) {
File fileParentDir = desFile.getParentFile();
if (!fileParentDir.exists()) {
fileParentDir.mkdirs();
}
desFile.createNewFile();
}
OutputStream os = new FileOutputStream(desFile);
byte buffer[] = new byte[BUFFER_SIZE];
int length;
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
os.flush();
os.close();
is.close();
fileList.add(desFile);
}
return fileList;
}
//复制文件
public static void copyFile(File sourceFile,File targetFile) throws IOException{
// 新建文件输入流并对它进行缓冲
FileInputStream input = new FileInputStream(sourceFile);
BufferedInputStream inBuff = new BufferedInputStream(input);
// 新建文件输出流并对它进行缓冲
FileOutputStream output = new FileOutputStream(targetFile);
BufferedOutputStream outBuff = new BufferedOutputStream(output);
// 缓冲数组
byte[] b = new byte[1024 * 5];
int len;
while ((len =inBuff.read(b)) != -1) {
outBuff.write(b, 0, len);
}
// 刷新此缓冲的输出流
outBuff.flush();
//关闭流
inBuff.close();
outBuff.close();
output.close();
input.close();
}
public static void writeToSD(String content)
{
FileWriter fileWriter;
try
{
fileWriter = new FileWriter("/data/data/com.affsystem.androidhooker/device.txt", false);
fileWriter.write(content);
fileWriter.flush();
fileWriter.close();
}
catch (IOException e)
{
Log.d(TAG, "writeToSD:失败!!!");
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,214 @@
package iku.os.ShellUtils;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
public class ShellUtils {
public static final String COMMAND_SU = "";
public static final String COMMAND_SH = "sh";
public static final String COMMAND_EXIT = "exit\n";
public static final String COMMAND_LINE_END = "\n";
private ShellUtils() {
throw new AssertionError();
}
/**
* check whether has root permission
*
* @return
*/
public static boolean checkRootPermission() {
return execCommand("echo root", true, false).result == 0;
}
/**
* execute shell command, default return result msg
*
* @param command command
* @param isRoot whether need to run with root
* @return
* @see ShellUtils#execCommand(String[], boolean, boolean)
*/
public static CommandResult execCommand(String command, boolean isRoot) {
return execCommand(new String[] {command}, isRoot, true);
}
/**
* execute shell commands, default return result msg
*
* @param commands command list
* @param isRoot whether need to run with root
* @return
* @see ShellUtils#execCommand(String[], boolean, boolean)
*/
public static CommandResult execCommand(List<String> commands, boolean isRoot) {
return execCommand(commands == null ? null : commands.toArray(new String[] {}), isRoot, true);
}
/**
* execute shell commands, default return result msg
*
* @param commands command array
* @param isRoot whether need to run with root
* @return
* @see ShellUtils#execCommand(String[], boolean, boolean)
*/
public static CommandResult execCommand(String[] commands, boolean isRoot) {
return execCommand(commands, isRoot, true);
}
/**
* execute shell command
*
* @param command command
* @param isRoot whether need to run with root
* @param isNeedResultMsg whether need result msg
* @return
* @see ShellUtils#execCommand(String[], boolean, boolean)
*/
public static CommandResult execCommand(String command, boolean isRoot, boolean isNeedResultMsg) {
return execCommand(new String[] {command}, isRoot, isNeedResultMsg);
}
/**
* execute shell commands
*
* @param commands command list
* @param isRoot whether need to run with root
* @param isNeedResultMsg whether need result msg
* @return
* @see ShellUtils#execCommand(String[], boolean, boolean)
*/
public static CommandResult execCommand(List<String> commands, boolean isRoot, boolean isNeedResultMsg) {
return execCommand(commands == null ? null : commands.toArray(new String[] {}), isRoot, isNeedResultMsg);
}
/**
* execute shell commands
*
* @param commands command array
* @param isRoot whether need to run with root
* @param isNeedResultMsg whether need result msg
* @return <ul>
* <li>if isNeedResultMsg is false, {@link CommandResult#successMsg} is null and
* {@link CommandResult#errorMsg} is null.</li>
* <li>if {@link CommandResult#result} is -1, there maybe some excepiton.</li>
* </ul>
*/
public static CommandResult execCommand(String[] commands, boolean isRoot, boolean isNeedResultMsg) {
int result = -1;
if (commands == null || commands.length == 0) {
return new CommandResult(result, null, null);
}
Process process = null;
BufferedReader successResult = null;
BufferedReader errorResult = null;
StringBuilder successMsg = null;
StringBuilder errorMsg = null;
DataOutputStream os = null;
try {
process = Runtime.getRuntime().exec(isRoot ? COMMAND_SU : COMMAND_SH);
os = new DataOutputStream(process.getOutputStream());
for (String command : commands) {
if (command == null) {
continue;
}
// donnot use os.writeBytes(commmand), avoid chinese charset error
os.write(command.getBytes());
os.writeBytes(COMMAND_LINE_END);
os.flush();
}
os.writeBytes(COMMAND_EXIT);
os.flush();
result = process.waitFor();
// get command result
if (isNeedResultMsg) {
successMsg = new StringBuilder();
errorMsg = new StringBuilder();
successResult = new BufferedReader(new InputStreamReader(process.getInputStream()));
errorResult = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String s;
while ((s = successResult.readLine()) != null) {
successMsg.append(s);
}
while ((s = errorResult.readLine()) != null) {
errorMsg.append(s);
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (os != null) {
os.close();
}
if (successResult != null) {
successResult.close();
}
if (errorResult != null) {
errorResult.close();
}
} catch (IOException e) {
e.printStackTrace();
}
if (process != null) {
process.destroy();
}
}
return new CommandResult(result, successMsg == null ? null : successMsg.toString(), errorMsg == null ? null
: errorMsg.toString());
}
/**
* result of command
* <ul>
* <li>{@link CommandResult#result} means result of command, 0 means normal, else means error, same to excute in
* linux shell</li>
* <li>{@link CommandResult#successMsg} means success message of command result</li>
* <li>{@link CommandResult#errorMsg} means error message of command result</li>
* </ul>
*
* @author <a href="http://www.trinea.cn" target="_blank">Trinea</a> 2013-5-16
*/
public static class CommandResult {
/** result of command **/
public int result;
/** success message of command result **/
public String successMsg;
/** error message of command result **/
public String errorMsg;
public CommandResult(int result) {
this.result = result;
}
public CommandResult(int result, String successMsg, String errorMsg) {
this.result = result;
this.successMsg = successMsg;
this.errorMsg = errorMsg;
}
}
}

View File

@ -0,0 +1,120 @@
package iku.os.apkManager;
import static java.lang.Thread.sleep;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.util.Log;
import java.io.File;
import java.io.IOException;
import iku.os.FileUtils.FileUtils;
import iku.os.ShellUtils.ShellUtils;
public class apk {
private static final String TAG = "IkuClient apkManager";
private static String apk_path = "/sdcard/apks";
private static String appName;
private static String oldpath = apk_path + appName;
private static String name,baoming, zip_name, newpath;
public static boolean clientInstall(File apkFile) {
Log.i(TAG, "clientInstall : " + apkFile);
try {
String chmodCmd = "chmod 777 " + apkFile;
ShellUtils.execCommand(chmodCmd,true);
String installCmd = "pm install -r" + apkFile;
ShellUtils.execCommand(installCmd,true);
return true;
} catch (Exception e) {
Log.e(TAG, "clientInstall eror:",e);
e.printStackTrace();
}
return false;
}
public static boolean clientUninstall(String packageName) {
Log.i(TAG, "start to clientuninstall : " + packageName);
try {
String cmd = "pm uninstall " + packageName;
ShellUtils.execCommand(cmd,true);
return true;
} catch (Exception e) {
Log.e(TAG, "clientUninstall eror: ",e);
e.printStackTrace();
}
return false;
}
public static boolean checkAppInstalled(Context context, String pkgName) {
if (pkgName == null || pkgName.isEmpty()) {
return false;
}
PackageInfo packageInfo;
try {
packageInfo = context.getPackageManager().getPackageInfo(pkgName, 0);
} catch (PackageManager.NameNotFoundException e) {
packageInfo = null;
// e.printStackTrace();
}
boolean exists = false;
if (packageInfo == null) {
exists = false;
} else {
exists = true;//true为安装了false为未安装
}
Log.i(TAG, "checkAppInstalled(" + pkgName + ") : " + exists);
return exists;
}
private static void changeZip() {
String[] split = appName.split(".xapk");
//分割后选择保留那段
zip_name = split[0];
Log.e("压缩包名", zip_name);
oldpath = apk_path + "/" + name;
Log.i("oldpath", oldpath);
newpath = apk_path + "/" + zip_name + ".zip";
Log.i("newpath", newpath);
//将xapk换成zip格式
FileUtils.renameFile(oldpath, newpath);
//进行解压
new Thread(new Runnable() {
@Override
public void run() {
try {
sleep(3000);
try {
FileUtils.upZipFile(new File(newpath), apk_path + "/" + zip_name);
} catch (IOException e) {
e.printStackTrace();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
Log.e("zip", "文件解压成功");
}
}).start();
FileUtils.renameFile(newpath, oldpath);
}
}

View File

@ -0,0 +1,6 @@
package iku.os.apkManager;
public class apks {
}

View File

@ -0,0 +1,244 @@
//package iku.os.apkManager;
//
//import static iku.os.apkManager.apk.clientInstall;
//
//import android.content.Context;
//import android.content.pm.ApplicationInfo;
//import android.content.pm.PackageInfo;
//import android.content.pm.PackageManager;
//import android.util.Log;
//
//import java.io.File;
//import java.io.IOException;
//import java.util.ArrayList;
//import java.util.List;
//
//import iku.os.FileUtils.FileUtils;
//import iku.os.ikuterminal.MainActivity;
//
//public class xapk {
//
// private static final String TAG = "apkManager xapk";
// private String name;
// private String apk_path;
// private String zip_name;
// private String baoming;
// private String appName;
//
// private void installxapk() {
// new Thread(new Runnable() {
// @Override
// public void run() {
//
// try {
// getName(apk_path,".xapk");
// Thread.sleep(3000);
// changeZip();
// Thread.sleep(120000);
// getZipApk();
// Thread.sleep(120000);
// obb_name();
// Thread.sleep(120000);
// installApk();
// } catch (IOException | InterruptedException e) {
// e.printStackTrace();
// }
//
// }
// }).start();
//
// }
//
//
// private static void changeZip() {
// String[] split = appName.split(".xapk");
// //分割后选择保留那段
// zip_name = split[0];
// Log.e("压缩包名", zip_name);
//
//
// oldpath = apk_path + "/" + name;
// Log.i("oldpath", oldpath);
// newpath = apk_path + "/" + zip_name + ".zip";
// Log.i("newpath", newpath);
//
// //将xapk换成zip格式
// FileUtils.renameFile(oldpath, newpath);
//
// //进行解压
// new Thread(new Runnable() {
// @Override
// public void run() {
//
// try {
// sleep(3000);
//
// try {
// FileUtils.upZipFile(new File(newpath), apk_path + "/" + zip_name);
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
//
//
// Log.e("zip", "文件解压成功");
// }
// }).start();
//
// FileUtils.renameFile(newpath, oldpath);
//
// }
//
//
// private void getName(String path,String houzhui) throws IOException {
//
// //新建ArrayList
// List<String> list = new ArrayList<>();
// //获取指定路径下的所有文件
// list = FileUtils.getFilesAllName(path);
// if(list != null){
// for(String listname : list ){
// Log.e("TAG","listname :"+listname );
// //判断文件是不是想要查找后缀
// if(listname .endsWith(houzhui)){
// //获取路径下最后一个‘/’后的坐标
// int lastindex = listname .lastIndexOf("/");
// //获取具体文件名称
// name= listname .substring(lastindex+1,listname.length());
// //获取到想要的名称后,去干你想干的事
// //dosomething
// Log.e("name",name);
//
// }
// }
// }
//
// }
//
// private void getZipApk() throws IOException {
//
//
// new Thread(new Runnable() {
// @Override
// public void run() {
//
// try {
// Thread.sleep(65000);
// String apkpath = apk_path+"/"+zip_name;
//
// Log.e("sss",apkpath);
// //获取apk
// getName(apkpath,".apk");
//
// baoming = getApkPackageName(MainActivity.this,apkpath+"/"+name);
//
// Log.e("baoming",baoming+"获取成功");
// } catch (InterruptedException | IOException e) {
// e.printStackTrace();
// }
//
// }
// }).start();
// }
//
//
// public static String getApkPackageName(Context context, String apkPath) {
//
// PackageManager pm = context.getPackageManager();
// PackageInfo info = pm.getPackageArchiveInfo(apkPath, PackageManager.GET_ACTIVITIES);
// ApplicationInfo appInfo = null;
// String packageName = "";
// if (info != null) {
// appInfo = info.applicationInfo;
// packageName = appInfo.packageName; //得到apk包名
// }
// return packageName;
// }
//
// private void obb_name() throws IOException {
//
// //首先先获取obb文件所在的位置
// String obb_path = apk_path+"/"+zip_name+"/Android/obb/"+baoming;
// Log.e("Tag",obb_path);
//
// getName(obb_path,".obb");
//
// //创建文件夹
// FileUtils.createDir("/sdcard/Android/obb/"+baoming);
//
// new Thread(new Runnable() {
// @Override
// public void run() {
//
// try {
// Thread.sleep(3000);//休眠3秒
// //复制到/sdcard/Android/obb/ 文件下
// try {
//
// String sourceFile = obb_path+"/"+name;
// Log.e("sourceFile",sourceFile);
// String targetFile = "/sdcard/Android/obb"+"/"+baoming+"/"+name;
// Log.e("targetFile",targetFile);
// FileUtils.copyFile(new File(sourceFile),new File(targetFile));
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
//
//
// Log.e("obb","文件复制成功");
//
// }
// }).start();
//
//
// }
//
//
// //安装压缩包中的apk
// private void installApk() throws IOException {
//
// String apkpath = apk_path+"/"+zip_name;
//
// Log.e("sss",apkpath);
// //获取apk
// getName(apkpath,".apk");
//
// baoming = getApkPackageName(MainActivity.this,apkpath+"/"+name);
//
// Log.e("baoming",baoming);
//
//
//
// clientInstall(new File(apkpath+"/"+name));
//
// Log.e("install","apk安装成功");
//
// //65秒后删除压缩后的文件
// new Thread(new Runnable() {
// @Override
// public void run() {
//
//
// try {
// Thread.sleep(65000);
//
// FileUtils.deleteDirWihtFile(new File(apkpath));
//
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
//
// Log.e("delete","文件删除成功");
//
// }
// }).start();
//
// }
//}

View File

@ -0,0 +1,32 @@
package iku.os.ikuterminal;
import static iku.os.net.taskInfo.getTask;
import android.os.Bundle;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
public class DownloadActivity extends AppCompatActivity {
private static final String TAG = "IkuClient";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_download);
Log.i(TAG, "onCreate: ");
startDownloadThread();
}
private void startDownloadThread() {
new Thread(new Runnable() {
@Override
public void run() {
getTask();
// 执行其他下载操作
}
}).start();
}
}

View File

@ -0,0 +1,188 @@
package iku.os.ikuterminal;
import static iku.os.net.IkuService.ACTION_STATUS_DESC_CHANGED;
import static iku.os.net.IkuService.ACTION_WEBSOCKET_STATE_RECEIVED;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.google.android.material.textfield.TextInputEditText;
import java.io.File;
import dalvik.system.DexClassLoader;
import iku.os.net.IkuService;
import iku.os.net.PermissionUtil;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
protected IkuService mService;
private boolean websocketConnected = false;
private static Context context;
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(ACTION_STATUS_DESC_CHANGED))
{
String msg = intent.getStringExtra("msg");
TextView statusText = findViewById(R.id.statusText);
statusText.setText(msg);
}
else if (action.equals(ACTION_WEBSOCKET_STATE_RECEIVED))
{
boolean connected = intent.getBooleanExtra("connected", false);
notifyWebsocketState(connected);
}
}
};
private void notifyWebsocketState(boolean connected)
{
websocketConnected = connected;
Button connectBtn = findViewById(R.id.connectBtn);
TextInputEditText serverIpInput = findViewById(R.id.serverIpInput);
if (connected)
{
serverIpInput.setEnabled(false);
connectBtn.setText("断开连接");
}
else {
serverIpInput.setEnabled(true);
connectBtn.setText("连接");
}
}
private ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
Log.i(TAG, "onServiceConnected");
IkuService.WebSocketsBinder binder = (IkuService.WebSocketsBinder) service;
mService = binder.getService();
}
@Override
public void onServiceDisconnected(ComponentName name) {Log.i(TAG, "onServiceDisconnected");
unbindService(mConnection);
LocalBroadcastManager.getInstance(mService.getApplicationContext()).unregisterReceiver(mMessageReceiver);
mService = null;
}
};
private ClassLoader dexClassLoader;
private ClassLoader getDexClassLoader(Class clazz, File file) {
if (this.dexClassLoader == null)
{
this.dexClassLoader = new DexClassLoader(file.getAbsolutePath(), "", null, clazz.getClassLoader());
}
return this.dexClassLoader;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//下载测试
download();
TextInputEditText serverIpInput = findViewById(R.id.serverIpInput);
SharedPreferences sharedPreferences = getSharedPreferences("iku_net_config", MODE_PRIVATE);
String url = sharedPreferences.getString("ws_url", "");
serverIpInput.setText(url);
PermissionUtil.verifyStoragePermissions(this);
Context context = getApplicationContext();
File f1 = context.getObbDir();
File f2 = context.getNoBackupFilesDir();
String filename = System.mapLibraryName("");
Log.i("", "");
}
public void onClick(View view)
{
if (!websocketConnected)
{
TextInputEditText serverIpInput = findViewById(R.id.serverIpInput);
String url = serverIpInput.getEditableText().toString();
startWebsocket(url);
}
else {
stopWebsocket();
}
}
private void getWebsocketState()
{
Intent intent = new Intent(this, IkuService.class);
intent.setAction(IkuService.ACTION_WEBSOCKET_STATE_GET);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
private void startWebsocket(String url)
{
Intent intent = new Intent(this, IkuService.class);
intent.setAction(IkuService.ACTION_WEBSOCKET_START);
intent.putExtra("ws_url", url);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
private void stopWebsocket()
{
Intent intent = new Intent(this, IkuService.class);
intent.setAction(IkuService.ACTION_WEBSOCKET_STOP);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
@Override
protected void onStart() {
super.onStart();
if (mService == null)
{
Intent intent = new Intent(this, IkuService.class);
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter(ACTION_STATUS_DESC_CHANGED));
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter(ACTION_WEBSOCKET_STATE_RECEIVED));
}
}
@Override
protected void onStop() {
//unbindService(mConnection);
//LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
super.onStop();
}
private void download() {
Button testbutton = findViewById(R.id.testBtn);
testbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, DownloadActivity.class);
startActivity(intent);
}
});
}
}

View File

@ -0,0 +1,194 @@
package iku.os.net;
import android.content.Context;
import android.provider.Settings;
import android.util.Log;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import org.json.JSONArray;
import org.json.JSONObject;
import java.net.URI;
public class IkuClient {
private static final String TAG = "IkuClient";
private static IkuClient instance;
public static IkuClient getInstance()
{
if (instance == null)
instance = new IkuClient();
return instance;
}
private WebSocketClient webSocketClient;
private String deviceId;
private boolean initialized = false;
private boolean connected = false;
private IkuClientListener listener;
private IkuClient()
{
}
public void sendMsg(String cmd, JSONArray data)
{
sendMsg(cmd, data.toString());
}
public void sendMsg(String cmd, JSONObject data)
{
sendMsg(cmd, data.toString());
}
public void sendMsg(String cmd, String data)
{
if (webSocketClient != null && webSocketClient.isOpen())
{
try {
JSONObject msg = new JSONObject();
msg.put("cmd", cmd);
msg.put("data", data);
webSocketClient.send(msg.toString());
}
catch (Throwable e)
{
status(e.toString());
}
}
}
public void init(Context context, IkuClientListener listener)
{
if (initialized)
return;
this.initialized = true;
this.listener = listener;
this.deviceId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
}
public String getDeviceId()
{
return deviceId;
}
private void msgReceived(JSONObject msg)
{
if (listener != null)
listener.onData(msg);
}
private void stateChanged(boolean connected)
{
if (listener != null)
listener.onStateChanged(connected);
}
private void connected()
{
if (listener != null)
listener.onConnected();
}
private void status(String msg)
{
if (listener != null)
listener.onStatusLog(msg);
}
public URI getConnectedURI()
{
return webSocketClient.getURI();
}
public void connect(String url)
{
try {
if (webSocketClient != null)
webSocketClient.close();
URI uri = new URI(url);
String scheme = uri.getScheme().toLowerCase();
String other = uri.getSchemeSpecificPart();
uri = new URI(scheme + ":" + other);
webSocketClient = new WebSocketClient(uri) {
@Override
public void onOpen(ServerHandshake handshakedata) {
Log.i(TAG, "onOpen");
connected = true;
sendMsg("handshark", "I am device, id=" + getDeviceId());
stateChanged(true);
}
@Override
public void onMessage(String message) {
Log.i(TAG, "onMessage " + message);
try {
JSONObject msg = new JSONObject(message);
String cmd = msg.getString("cmd");
String data = msg.getString("data");
if (cmd.equals("handshark"))
{
status("连接服务器成功!!!");
connected();
}
else {
msgReceived(msg);
}
}
catch (Throwable e)
{
status(e.toString());
}
}
@Override
public void onClose(int code, String reason, boolean remote) {
Log.i(TAG, "onClose " + reason);
if (!connected)
{
status("无法连接到服务器...");
}
else {
status("连接已断开...");
}
connected = false;
stateChanged(false);
}
@Override
public void onError(Exception ex) {
Log.e(TAG, "onError " + ex.toString());
status("出现错误 " + ex.toString());
}
};
webSocketClient.connect();
} catch (Throwable e) {
status(e.toString());
}
}
public void disconnect() {
webSocketClient.close();
}
public void destroy() {
if (webSocketClient != null && webSocketClient.isOpen())
webSocketClient.close();
webSocketClient = null;
listener = null;
}
public boolean isConnected() {
if (webSocketClient == null)
return false;
return webSocketClient.isOpen();
}
public interface IkuClientListener {
void onStatusLog(String msg);
void onData(JSONObject data);
void onStateChanged(boolean connected);
void onConnected();
}
}

View File

@ -0,0 +1,309 @@
package iku.os.net;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Binder;
import android.os.IBinder;
import android.text.TextUtils;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.List;
public class IkuService extends Service {
public static final String ACTION_MSG_RECEIVED = "msgReceived";
public static final String ACTION_STATUS_DESC_CHANGED = "statusDescChanged";
public static final String ACTION_WEBSOCKET_STATE_RECEIVED = "websocketStateReceived";
public static final String ACTION_WEBSOCKET_STATE_GET = "websocketStateGet";
public static final String ACTION_NETWORK_STATE_CHANGED = "networkStateChanged";
public static final String ACTION_WEBSOCKET_START = "websocketStart";
public static final String ACTION_WEBSOCKET_STOP = "websocketStop";
private static final String TAG = IkuService.class.getSimpleName();
private static String workDir = "/data/iku/";
private final IBinder mBinder = new WebSocketsBinder();
private IkuClient mClient;
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(ACTION_WEBSOCKET_START))
{
String url = intent.getStringExtra("ws_url");
SharedPreferences sharedPreferences = getSharedPreferences("iku_net_config", MODE_PRIVATE);
sharedPreferences.edit().putString("ws_url", url).apply();
startSocket(url);
}
else if (action.equals(ACTION_WEBSOCKET_STOP))
{
stopSocket();
}
else if (action.equals(ACTION_NETWORK_STATE_CHANGED))
{
boolean networkIsOn = intent.getBooleanExtra(ACTION_NETWORK_STATE_CHANGED, false);
if (networkIsOn) {
startSocket(getWsUrlFromLocal());
} else {
stopSocket();
}
}
else if (action.equals(ACTION_WEBSOCKET_STATE_GET))
{
boolean connected = mClient != null? mClient.isConnected():false;
sendWebsocketStateEvent(connected);
}
}
};
private String getWsUrlFromLocal()
{
SharedPreferences sharedPreferences = getSharedPreferences("iku_net_config", MODE_PRIVATE);
return sharedPreferences.getString("ws_url", "");
}
private void registerAction(String action)
{
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter(action));
}
public File getWorkDir()
{
File dir = new File(workDir);
if (!dir.exists())
dir.mkdirs();
return dir;
}
private File getEpTaskConfigFile(String packageName, String extractType)
{
return new File(getWorkDir().getAbsoluteFile() + "/ep_task-" + packageName + "-" + extractType + ".json");
}
private void writeConfigFile(String deviceId, String packageName, String extractType) {
try {
File file = getEpTaskConfigFile(packageName, extractType);
JSONObject jsonObject = new JSONObject();
URI uri = mClient.getConnectedURI();
String host = uri.getHost();
int port = uri.getPort();
jsonObject.put("ws_url", "http://" + host + ":" + port);
jsonObject.put("device_id", deviceId);
jsonObject.put("package_name", packageName);
jsonObject.put("extract_type", extractType);
jsonObject.put("extract_params_callback", "/callbacks/extract-params");
FileOutputStream fos = new FileOutputStream(file);
fos.write(jsonObject.toString().getBytes());
fos.flush();
fos.close();
file.setReadable(true, false);
} catch (JSONException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private JSONArray getPackageInfos() throws JSONException {
JSONArray result = new JSONArray();
PackageManager pm = getPackageManager();
List<PackageInfo> list = pm.getInstalledPackages(0);
for (int i = 0; i < list.size(); i++) {
PackageInfo packageInfo = list.get(i);
String name = packageInfo.packageName;
if (name.indexOf("com.android") == 0 ||
name.indexOf("com.google") == 0||
name.indexOf("android") == 0||
name.indexOf("com.qualcomm") == 0 ||
name.indexOf("iku.os") == 0)
continue;
JSONObject item = new JSONObject();
item.put("packageName", packageInfo.packageName);
result.put(item);
}
return result;
}
@Override
public void onCreate() {
super.onCreate();
mClient = IkuClient.getInstance();
mClient.init(getApplicationContext(), new IkuClient.IkuClientListener() {
@Override
public void onStatusLog(String msg) {
sendStatusChangedEvent(msg);
}
@Override
public void onData(JSONObject data) {
sendMessageReceivedEvent(data);
try {
String cmd = data.getString("cmd");
if (cmd.equals("getInstalledApps"))
{
JSONObject d = new JSONObject();
d.put("list", getPackageInfos());
d.put("deviceId", mClient.getDeviceId());
mClient.sendMsg("onGetInstalledApps", d);
}
else if (cmd.equals("startExtractParamsTask"))
{
JSONObject d = data.getJSONObject("data");
startExtractParamsTask(d.getString("packageName"), d.getString("extractType"));
}
else if (cmd.equals("stopExtractParamsTask"))
{
JSONObject d = data.getJSONObject("data");
stopExtractParamsTask(d.getString("packageName"), d.getString("extractType"));
}
}
catch (Throwable e)
{
e.printStackTrace();
}
}
@Override
public void onStateChanged(boolean connected) {
sendWebsocketStateEvent(connected);
}
@Override
public void onConnected() {
}
});
}
public static void copy(File src, File dst) throws IOException {
try (InputStream in = new FileInputStream(src)) {
try (OutputStream out = new FileOutputStream(dst)) {
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
}
}
}
private void taskStatusLog(String status) throws JSONException {
JSONObject jsonObject = new JSONObject();
jsonObject.put("status", status);
mClient.sendMsg("taskStatusLog", jsonObject);
}
private void startExtractParamsTask(String packageName, String extractType) throws IOException, JSONException {
String injectedPath = workDir + extractType + ".dex";
File injectedFile = new File(injectedPath);
if (injectedFile.exists())
{
String targetPath = workDir + packageName + "_injected.dex";
File targetFile = new File(targetPath);
if (!targetFile.exists())
{
targetFile.createNewFile();
targetFile.setReadable(true, false);
}
copy(injectedFile, targetFile);
taskStatusLog("注入Hook文件成功请打开APP并等待提参... (提参类型: " + extractType + ", 包名: " + packageName + ")");
writeConfigFile(mClient.getDeviceId(), packageName, extractType);
}
else {
taskStatusLog("未找到" + extractType + "提参Hook文件无法提参");
}
}
private void stopExtractParamsTask(String packageName, String extractType) throws IOException, JSONException {
String targetPath = workDir + packageName + "_injected.dex";
File targetFile = new File(targetPath);
if (targetFile.exists())
targetFile.delete();
File epTaskConfigFile = getEpTaskConfigFile(packageName, extractType);
if (epTaskConfigFile.exists())
epTaskConfigFile.delete();
}
@Override
public IBinder onBind(Intent intent) {
registerAction(IkuService.ACTION_NETWORK_STATE_CHANGED);
registerAction(IkuService.ACTION_WEBSOCKET_START);
registerAction(IkuService.ACTION_WEBSOCKET_STOP);
registerAction(IkuService.ACTION_WEBSOCKET_STATE_GET);
return mBinder;
}
@Override
public boolean onUnbind(Intent intent) {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
return false;
}
private void startSocket(String url) {
if (mClient != null) {
if (!TextUtils.isEmpty(url))
mClient.connect(url);
}
}
private void stopSocket() {
if (mClient != null) {
mClient.disconnect();
}
}
private void sendWebsocketStateEvent(boolean connected)
{
Intent intent = new Intent(ACTION_WEBSOCKET_STATE_RECEIVED);
intent.putExtra("connected", connected);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
private void sendMessageReceivedEvent(JSONObject msg) {
Intent intent = new Intent(ACTION_MSG_RECEIVED);
intent.putExtra("msg", msg.toString());
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
private void sendStatusChangedEvent(String msg) {
Intent intent = new Intent(ACTION_STATUS_DESC_CHANGED);
intent.putExtra("msg", msg);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
public final class WebSocketsBinder extends Binder {
public IkuService getService() {
return IkuService.this;
}
}
}

View File

@ -0,0 +1,167 @@
package iku.os.net;
import android.content.Context;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
public class MyPost {
private static final String TAG = "MyPost";
private static okhttp3.OkHttpClient oklient = new okhttp3.OkHttpClient();
public String PostData(Context context, byte[] byt, String url_) {
byte[] bytes = postDataBytes(context, byt, url_);
if (bytes != null && bytes.length > 0) {
try {
return new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return null;
}
public String PostDataCommon(Context context, byte[] byt, String url_) {
byte[] bytes = postDataBytes(context, byt, url_);
if (bytes != null && bytes.length >= 0) {
if (bytes.length == 0) {
return "";
} else {
try {
return new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
return null;
}
public String httpGet(String url) throws Exception {
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
//默认值为GET
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
System.out.println("\nSending 'GET' request to URL : " + url);
System.out.println("Response Code : " + responseCode);
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
//打印结果
System.out.println(response.toString());
return response.toString();
}
public byte[] postDataBytes(Context context, byte[] byt, String url_) {
String result = null;
HttpURLConnection httpUrlConnection = null;
InputStream inStrm = null;
ByteArrayOutputStream baos = null;
BufferedInputStream bis = null;
try {
httpUrlConnection = NetWorkUtils.getHttpURLConnection(context, url_);
httpUrlConnection.setAllowUserInteraction(true);
httpUrlConnection.setDoOutput(true);
httpUrlConnection.setDoInput(true);
httpUrlConnection.setUseCaches(false);
httpUrlConnection.setRequestProperty("Connection", "close");//add 20200428
httpUrlConnection.setRequestProperty("Content-type", "application/x-java-serialized-object");
// httpUrlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
httpUrlConnection.setRequestMethod("POST");
httpUrlConnection.setConnectTimeout(20000);
OutputStream outStrm = null;
outStrm = httpUrlConnection.getOutputStream();
outStrm.write(byt);
outStrm.flush();
outStrm.close();
inStrm = httpUrlConnection.getInputStream();
baos = new ByteArrayOutputStream();
bis = new BufferedInputStream(inStrm);
byte[] buf = new byte[1024];
int readSize = -1;
while ((readSize = bis.read(buf)) != -1) {
baos.write(buf, 0, readSize);
}
byte[] data = baos.toByteArray();
return data;
} catch (Exception e) {
e.printStackTrace();
result = null;
} finally {
if (baos != null) {
try {
baos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (bis != null) {
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (inStrm != null) {
try {
inStrm.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (httpUrlConnection != null) {
httpUrlConnection.disconnect();
httpUrlConnection = null;
}
System.gc();
}
return null;
}
}

View File

@ -0,0 +1,46 @@
package iku.os.net;
import android.content.Context;
import android.net.ConnectivityManager;
//import android.net.NetworkInfo;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
public class NetWorkUtils {
private static final String TAG = "NetWorkUtils";
public static final int APNTYPE_NONE = 0;
public static final int APNTYPE_WIFI = 1;
public static final int APNTYPE_WAP = 2;
public static final int APNTYPE_NET = 3;
/**
* wifi
*
* @param context
* @return
*/
public static HttpURLConnection getHttpURLConnection(Context context,
String _url) throws IOException {
return getHttpURLConnection(context, _url, false);
}
private static int dynamicPort0 = 20380;
private static int dynamicPort = dynamicPort0;
private static int dynamicPort1 = 30379;
public static HttpURLConnection getHttpURLConnection(Context context, String _url, boolean isProxy) throws IOException {
URL url = new URL(_url);
HttpURLConnection httpUrlConnection = null;
httpUrlConnection = (HttpURLConnection)url.openConnection();
return httpUrlConnection;
}
}

View File

@ -0,0 +1,29 @@
package iku.os.net;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
public class NetworkStateReceiver extends BroadcastReceiver {
private static final String TAG = NetworkStateReceiver.class.getSimpleName();
@Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "Network connectivity change");
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
boolean networkIsOn = activeNetworkInfo != null && activeNetworkInfo.isConnected();
Intent broadcastIntent = new Intent(IkuService.ACTION_NETWORK_STATE_CHANGED);
broadcastIntent.putExtra(IkuService.ACTION_NETWORK_STATE_CHANGED, networkIsOn);
LocalBroadcastManager.getInstance(context).sendBroadcast(broadcastIntent);
}
}

View File

@ -0,0 +1,59 @@
package iku.os.net;
import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Build;
import androidx.core.app.ActivityCompat;
import androidx.annotation.NonNull;
public class PermissionUtil {
private static final int REQUEST_EXTERNAL_STORAGE = 1;
private static final int REQUEST_CODE_INSTALL_UNKNOWN_APPS = 0;
private static String[] PERMISSIONS_STORAGE = {
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
};
public static void verifyStoragePermissions(Activity activity) {
// Check if we have write permission
int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permission != PackageManager.PERMISSION_GRANTED) {
// We don't have permission so prompt the user
ActivityCompat.requestPermissions(
activity,
PERMISSIONS_STORAGE,
REQUEST_EXTERNAL_STORAGE
);
}
}
public static void checkInstallPermission(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.REQUEST_INSTALL_PACKAGES);
if (permission != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(
activity,
new String[]{Manifest.permission.REQUEST_INSTALL_PACKAGES},
REQUEST_CODE_INSTALL_UNKNOWN_APPS
);
}
}
}
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == REQUEST_CODE_INSTALL_UNKNOWN_APPS) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// 用户授予了安装未知来源应用权限
} else {
// 用户拒绝了安装未知来源应用权限
}
}
}
}

View File

@ -0,0 +1,89 @@
package iku.os.net;
import android.util.Log;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class taskInfo {
private static final String TAG = "IkuClient";
private static boolean completed = false;
public static void getTask() {
String packageName = "";
String apkPath = "";
int code = -1;
// 检查目录是否存在
File directory = new File("/sdcard/apks/");
if (!directory.exists()) {
directory.mkdirs(); // 如果目录不存在,则创建它
}
try {
HttpURLConnection conn = (HttpURLConnection) new URL("http://123.56.44.45/tt/ddj/autoApk.do").openConnection();
conn.setConnectTimeout(5000);
conn.setRequestMethod("GET");
Log.i(TAG, "getTask ResponseCode: "+conn.getResponseCode());
if (conn.getResponseCode() == 200) {
StringBuilder sb = new StringBuilder();
try (BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
}
JSONObject json = new JSONObject(sb.toString());
code = json.getInt("code");
if (code == 1){
apkPath = json.getString("apkPath");
packageName = json.getString("packageName");
Log.i(TAG, "getTask apkPath: "+apkPath);
Log.i(TAG, "getTask packageName: "+packageName);
// 拼接URL并启动下载
String downloadUrl = "http://39.103.73.250/tt/upload/ddj/" + apkPath;
downloadFile(downloadUrl, "/sdcard/apks/" + apkPath);
}
}
} catch (Exception e) {
Log.e(TAG, "taskInfo getTask: ", e);
}
}
public static void downloadFile(String urlStr, String savePath) {
try (InputStream input = new URL(urlStr).openStream();
FileOutputStream output = new FileOutputStream(savePath)) {
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = input.read(buffer)) != -1) {
output.write(buffer, 0, bytesRead);
}
completed = true;
Log.i(TAG, "Download completed: " + savePath);
} catch (IOException e) {
Log.e(TAG, "Error downloading file: ", e);
}
}
public static boolean downloadGoBack(){
if (completed == true){
return completed;
}
return false;
}
}

View File

@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test"
android:textSize="16sp" />
<TextView
android:id="@+id/package_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp" />
<TextView
android:id="@+id/apk_path"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp" />
<TextView
android:id="@+id/error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/holo_red_dark"
android:textSize="16sp" />
</LinearLayout>

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/statusText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.071"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/connectBtn"
app:layout_constraintVertical_bias="0.045" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/serverIpInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="服务器地址" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="@+id/connectBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="连接"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textInputLayout" />
<Button
android:id="@+id/testBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="56dp"
android:onClick="onClick"
android:text="测试"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.501"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textInputLayout" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<monochrome android:drawable="@mipmap/ic_launcher_monochrome"/>
</adaptive-icon>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,7 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Base.Theme.IkuTerminal" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your dark theme here. -->
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
</style>
</resources>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>

View File

@ -0,0 +1,4 @@
<resources>
<string name="app_name">IkuTerminal</string>
<string name="apk_path">/sdcard/apks</string>
</resources>

View File

@ -0,0 +1,9 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Base.Theme.IkuTerminal" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your light theme here. -->
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
</style>
<style name="Theme.IkuTerminal" parent="Base.Theme.IkuTerminal" />
</resources>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample backup rules file; uncomment and customize as necessary.
See https://developer.android.com/guide/topics/data/autobackup
for details.
Note: This file is ignored for devices older that API 31
See https://developer.android.com/about/versions/12/backup-restore
-->
<full-backup-content>
<!--
<include domain="sharedpref" path="."/>
<exclude domain="sharedpref" path="device.xml"/>
-->
</full-backup-content>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample data extraction rules file; uncomment and customize as necessary.
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
for details.
-->
<data-extraction-rules>
<cloud-backup>
<!-- TODO: Use <include> and <exclude> to control what is backed up.
<include .../>
<exclude .../>
-->
</cloud-backup>
<!--
<device-transfer>
<include .../>
<exclude .../>
</device-transfer>
-->
</data-extraction-rules>

View File

@ -0,0 +1,17 @@
package iku.os.ikuterminal;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

5
build.gradle Normal file
View File

@ -0,0 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
}

21
gradle.properties Normal file
View File

@ -0,0 +1,21 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,6 @@
#Sat Jul 08 09:01:38 EDT 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

185
gradlew vendored Normal file
View File

@ -0,0 +1,185 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# 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
#
# https://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.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

89
gradlew.bat vendored Normal file
View File

@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

16
settings.gradle Normal file
View File

@ -0,0 +1,16 @@
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "IkuTerminal"
include ':app'