summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2012-01-30 18:41:36 (GMT)
committer Jaromil <jaromil@dyne.org>2012-01-30 18:42:23 (GMT)
commit6b63a1a4fd5fc898c62ff70dfed99080ce61b364 (patch)
treef009025676ce4370ef873c3bc0a429ea202f7d7c
parent366b38581944da382352ed90a125493e87907e69 (diff)
apk now uses lzma system compression, more cleanupsv0.4
-rw-r--r--termapk/AndroidManifest.xml120
-rw-r--r--termapk/build.xml152
-rw-r--r--termapk/res/layout/main.xml162
-rw-r--r--termapk/src/org/dyne/zshaolin/Start.java2
-rw-r--r--termapk/src/org/dyne/zshaolin/startup/TerminalIDEPrefs.java34
-rw-r--r--termapk/src/org/dyne/zshaolin/startup/installer.java288
-rw-r--r--termapk/src/org/dyne/zshaolin/startup/introscreen.java154
-rw-r--r--termapk/src/org/dyne/zshaolin/startup/setup/assetextract.java129
-rw-r--r--termapk/src/org/dyne/zshaolin/startup/setup/filemanager.java172
9 files changed, 1002 insertions, 211 deletions
diff --git a/termapk/AndroidManifest.xml b/termapk/AndroidManifest.xml
index b61e9e4..ee492cc 100644
--- a/termapk/AndroidManifest.xml
+++ b/termapk/AndroidManifest.xml
@@ -1,62 +1,58 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.dyne.zshaolin"
- android:versionName="1.1"
- android:versionCode="3">
-
-<!--android:installLocation="preferExternal" -->
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.WAKE_LOCK" />
-
- <application android:icon="@drawable/yingyang" android:label="@string/application_terminal">
-
- <activity android:name=".Start"
- android:theme="@style/Theme"
- android:launchMode="singleTask">
-
- <!-- android:configChanges="keyboard|keyboardHidden|orientation"
- android:windowSoftInputMode="adjustResize|stateVisible" -->
-
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
-
- </activity>
-
- <activity android:name="com.spartacusrex.spartacuside.Term"
- android:theme="@style/Theme"
- android:configChanges="keyboard|keyboardHidden|orientation"
- android:windowSoftInputMode="adjustResize|stateVisible"/>
-
- <activity android:name="com.spartacusrex.spartacuside.TermPreferences"/>
- <activity android:name="com.spartacusrex.spartacuside.WindowList"/>
-
- <activity android:name="com.spartacusrex.spartacuside.startup.tutorial.tutlist"/>
- <activity android:name="com.spartacusrex.spartacuside.startup.tutorial.vimlist"/>
- <activity android:name="com.spartacusrex.spartacuside.startup.tutorial.tutview"/>
-
- <activity android:name="com.spartacusrex.spartacuside.startup.introscreen"/>
-
- <activity android:name="com.spartacusrex.spartacuside.startup.installer"
- android:configChanges="keyboardHidden|orientation"/>
-
- <activity android:name="com.spartacusrex.spartacuside.startup.TerminalIDEPrefs"/>
-
- <activity android:name="com.spartacusrex.spartacuside.keyboard.KeyboardPrefs"/>
-
- <service android:name="com.spartacusrex.spartacuside.TermService" />
-
- <service android:name="com.spartacusrex.spartacuside.keyboard.TerminalKeyboard" android:permission="android.permission.BIND_INPUT_METHOD">
- <intent-filter>
- <action android:name="android.view.InputMethod" />
- </intent-filter>
- <meta-data android:name="android.view.im" android:resource="@xml/method" />
- </service>
-
- </application>
-
- <uses-sdk android:minSdkVersion="8"/>
-<!-- <uses-feature android:name="android.hardware.touchscreen" android:required="false" />-->
-
-</manifest>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.dyne.zshaolin"
+ android:versionName="1.1"
+ android:versionCode="3">
+
+<!--android:installLocation="preferExternal" -->
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
+
+ <application android:icon="@drawable/yingyang" android:label="@string/application_terminal">
+
+ <activity android:name=".Start"
+ android:theme="@style/Theme"
+ android:launchMode="singleTask">
+
+ <!-- android:configChanges="keyboard|keyboardHidden|orientation"
+ android:windowSoftInputMode="adjustResize|stateVisible" -->
+
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+
+ </activity>
+
+ <activity android:name="com.spartacusrex.spartacuside.Term"
+ android:theme="@style/Theme"
+ android:configChanges="keyboard|keyboardHidden|orientation"
+ android:windowSoftInputMode="adjustResize|stateVisible"/>
+
+ <activity android:name="com.spartacusrex.spartacuside.TermPreferences"/>
+ <activity android:name="com.spartacusrex.spartacuside.WindowList"/>
+
+ <activity android:name="org.dyne.zshaolin.introscreen"/>
+
+ <activity android:name="org.dyne.zshaolin.startup.installer"
+ android:configChanges="keyboardHidden|orientation"/>
+
+ <activity android:name="org.dyne.zshaolin.startup.TerminalIDEPrefs"/>
+
+ <activity android:name="com.spartacusrex.spartacuside.keyboard.KeyboardPrefs"/>
+
+ <service android:name="com.spartacusrex.spartacuside.TermService" />
+
+ <service android:name="com.spartacusrex.spartacuside.keyboard.TerminalKeyboard" android:permission="android.permission.BIND_INPUT_METHOD">
+ <intent-filter>
+ <action android:name="android.view.InputMethod" />
+ </intent-filter>
+ <meta-data android:name="android.view.im" android:resource="@xml/method" />
+ </service>
+
+ </application>
+
+ <uses-sdk android:minSdkVersion="8"/>
+<!-- <uses-feature android:name="android.hardware.touchscreen" android:required="false" />-->
+
+</manifest>
diff --git a/termapk/build.xml b/termapk/build.xml
index 292c187..cab5b7d 100644
--- a/termapk/build.xml
+++ b/termapk/build.xml
@@ -1,67 +1,85 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="terminus" default="help">
-
- <!-- The local.properties file is created and updated by the 'android' tool.
- It contains the path to the SDK. It should *NOT* be checked in in Version
- Control Systems. -->
- <property file="local.properties" />
-
- <!-- The build.properties file can be created by you and is never touched
- by the 'android' tool. This is the place to change some of the default property values
- used by the Ant rules.
- Here are some properties you may want to change/update:
-
- application.package
- the name of your application package as defined in the manifest. Used by the
- 'uninstall' rule.
- source.dir
- the name of the source directory. Default is 'src'.
- out.dir
- the name of the output directory. Default is 'bin'.
-
- Properties related to the SDK location or the project target should be updated
- using the 'android' tool with the 'update' action.
-
- This file is an integral part of the build system for your application and
- should be checked in in Version Control Systems.
-
- -->
- <property file="build.properties" />
-
- <!-- The default.properties file is created and updated by the 'android' tool, as well
- as ADT.
- This file is an integral part of the build system for your application and
- should be checked in in Version Control Systems. -->
- <property file="default.properties" />
-
- <!-- Custom Android task to deal with the project target, and import the proper rules.
- This requires ant 1.6.0 or above. -->
- <path id="android.antlibs">
- <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
- <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
- <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
- <pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
- <pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
- </path>
-
- <taskdef name="setup"
- classname="com.android.ant.SetupTask"
- classpathref="android.antlibs" />
-
- <!-- Execute the Android Setup task that will setup some properties specific to the target,
- and import the build rules files.
-
- The rules file is imported from
- <SDK>/platforms/<target_platform>/templates/android_rules.xml
-
- To customize some build steps for your project:
- - copy the content of the main node <project> from android_rules.xml
- - paste it in this build.xml below the <setup /> task.
- - disable the import by changing the setup task below to <setup import="false" />
-
- This will ensure that the properties are setup correctly but that your customized
- build steps are used.
- -->
- <setup />
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="ZShaolin" default="help">
+
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The ant.properties file can be created by you. It is only edited by the
+ 'android' tool to add properties to it.
+ This is the place to change some Ant specific build properties.
+ Here are some properties you may want to change/update:
+
+ source.dir
+ The name of the source directory. Default is 'src'.
+ out.dir
+ The name of the output directory. Default is 'bin'.
+
+ For other overridable properties, look at the beginning of the rules
+ files in the SDK, at tools/ant/build.xml
+
+ Properties related to the SDK location or the project target should
+ be updated using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems.
+
+ -->
+ <property file="ant.properties" />
+
+ <!-- The project.properties file is created and updated by the 'android'
+ tool, as well as ADT.
+
+ This contains project specific properties such as project target, and library
+ dependencies. Lower level build properties are stored in ant.properties
+ (or in .classpath for Eclipse projects).
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems. -->
+ <loadproperties srcFile="project.properties" />
+
+ <!-- quick check on sdk.dir -->
+ <fail
+ message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
+ unless="sdk.dir"
+ />
+
+
+<!-- extension targets. Uncomment the ones where you want to do custom work
+ in between standard targets -->
+<!--
+ <target name="-pre-build">
+ </target>
+ <target name="-pre-compile">
+ </target>
+
+ /* This is typically used for code obfuscation.
+ Compiled code location: ${out.classes.absolute.dir}
+ If this is not done in place, override ${out.dex.input.absolute.dir} */
+ <target name="-post-compile">
+ </target>
+-->
+
+ <!-- Import the actual build file.
+
+ To customize existing targets, there are two options:
+ - Customize only one target:
+ - copy/paste the target into this file, *before* the
+ <import> task.
+ - customize it to your needs.
+ - Customize the whole content of build.xml
+ - copy/paste the content of the rules files (minus the top node)
+ into this file, replacing the <import> task.
+ - customize to your needs.
+
+ ***********************
+ ****** IMPORTANT ******
+ ***********************
+ In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+ in order to avoid having your file be overridden by tools such as "android update project"
+ -->
+ <!-- version-tag: 1 -->
+ <import file="${sdk.dir}/tools/ant/build.xml" />
+
+</project>
diff --git a/termapk/res/layout/main.xml b/termapk/res/layout/main.xml
index 554c4f3..a826290 100644
--- a/termapk/res/layout/main.xml
+++ b/termapk/res/layout/main.xml
@@ -1,81 +1,81 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:background="#000000"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
-
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom|right"
- android:gravity="right"
- android:textColor="#ffffff"
- android:textSize="12dip"
- android:text="GNU GPL v2 - may the source be with you "/>
-
-
- <ScrollView android:layout_gravity="center"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
-
- <LinearLayout android:orientation="vertical"
- android:layout_gravity="center"
- android:gravity="center"
- android:background="#000000"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content">
-
- <Button android:id="@+id/main_start"
- android:layout_width="200dip"
- android:layout_height="wrap_content"
- android:text="Start ZShaolin"/>
-
- <Button android:id="@+id/main_install"
- android:layout_width="200dip"
- android:layout_height="wrap_content"
- android:text="Install System"/>
-
- <Button android:id="@+id/main_stop"
- android:layout_width="200dip"
- android:layout_height="wrap_content"
- android:text="Shutdown"/>
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="5dip"
- android:gravity="center"
- android:text=" "/>
-
- <Button android:id="@+id/main_keyboard"
- android:layout_width="200dip"
- android:layout_height="wrap_content"
- android:text="Keyboard"/>
-
- <Button android:id="@+id/main_options"
- android:layout_width="200dip"
- android:layout_height="wrap_content"
- android:text="Options"/>
-
- <Button android:id="@+id/main_help"
- android:layout_width="200dip"
- android:layout_height="wrap_content"
- android:text="Documentation"/>
-
- <TextView android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:textColor="#ffffff"
- android:textSize="12dip"
- android:text="ZShaolin.org ver.0.2\n
-Software by dyne.org (2012)"/>
-
- </LinearLayout>
-
-
-
- </ScrollView>
-
-
-
-</FrameLayout>
+<?xml version="1.0" encoding="UTF-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:background="#000000"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom|right"
+ android:gravity="right"
+ android:textColor="#ffffff"
+ android:textSize="12dip"
+ android:text="GNU GPL - may the source be with you "/>
+
+
+ <ScrollView android:layout_gravity="center"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <LinearLayout android:orientation="vertical"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:background="#000000"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <Button android:id="@+id/main_start"
+ android:layout_width="200dip"
+ android:layout_height="wrap_content"
+ android:text="Start ZShaolin"/>
+
+ <Button android:id="@+id/main_install"
+ android:layout_width="200dip"
+ android:layout_height="wrap_content"
+ android:text="Install System"/>
+
+ <Button android:id="@+id/main_stop"
+ android:layout_width="200dip"
+ android:layout_height="wrap_content"
+ android:text="Shutdown"/>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="5dip"
+ android:gravity="center"
+ android:text=" "/>
+
+ <Button android:id="@+id/main_keyboard"
+ android:layout_width="200dip"
+ android:layout_height="wrap_content"
+ android:text="Keyboard"/>
+
+ <Button android:id="@+id/main_options"
+ android:layout_width="200dip"
+ android:layout_height="wrap_content"
+ android:text="Options"/>
+
+ <Button android:id="@+id/main_help"
+ android:layout_width="200dip"
+ android:layout_height="wrap_content"
+ android:text="Documentation"/>
+
+ <TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:textColor="#ffffff"
+ android:textSize="12dip"
+ android:text="ZShaolin.org ver.0.4\n
+by Jaromil @ dyne.org (2012)"/>
+
+ </LinearLayout>
+
+
+
+ </ScrollView>
+
+
+
+</FrameLayout>
diff --git a/termapk/src/org/dyne/zshaolin/Start.java b/termapk/src/org/dyne/zshaolin/Start.java
index d8e3cae..f067fcf 100644
--- a/termapk/src/org/dyne/zshaolin/Start.java
+++ b/termapk/src/org/dyne/zshaolin/Start.java
@@ -5,7 +5,7 @@
package org.dyne.zshaolin;
-import com.spartacusrex.spartacuside.startup.introscreen;
+import org.dyne.zshaolin.startup.introscreen;
import org.dyne.zshaolin.R;
diff --git a/termapk/src/org/dyne/zshaolin/startup/TerminalIDEPrefs.java b/termapk/src/org/dyne/zshaolin/startup/TerminalIDEPrefs.java
new file mode 100644
index 0000000..d4fcea1
--- /dev/null
+++ b/termapk/src/org/dyne/zshaolin/startup/TerminalIDEPrefs.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2007 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 org.dyne.zshaolin.startup;
+import org.dyne.zshaolin.R;
+
+
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+
+public class TerminalIDEPrefs extends PreferenceActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Load the preferences from an XML resource
+ addPreferencesFromResource(R.xml.terminal_prefs);
+ }
+
+}
diff --git a/termapk/src/org/dyne/zshaolin/startup/installer.java b/termapk/src/org/dyne/zshaolin/startup/installer.java
new file mode 100644
index 0000000..bdf7901
--- /dev/null
+++ b/termapk/src/org/dyne/zshaolin/startup/installer.java
@@ -0,0 +1,288 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.dyne.zshaolin.startup;
+import org.dyne.zshaolin.R;
+
+import java.io.File;
+
+import android.app.Activity;
+import android.app.Dialog;
+import android.app.ProgressDialog;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.res.Configuration;
+import android.graphics.Typeface;
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.Handler;
+import android.os.Message;
+import android.preference.PreferenceManager;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.spartacusrex.spartacuside.TermService;
+import org.dyne.zshaolin.startup.setup.filemanager;
+
+/**
+ *
+ * @author Spartacus Rex
+ */
+public class installer extends Activity implements OnClickListener{
+
+ //THE MAIN INSTALL VALUE
+ public static int CURRENT_INSTALL_SYSTEM_NUM = 1;
+ public static String CURRENT_INSTALL_SYSTEM = "System v0.4";
+ public static String CURRENT_INSTALL_ASSETFILE = "system-0.4.tar.lzma.mp3";
+
+ private ProgressDialog mInstallProgress;
+
+ boolean mOverwriteAll = false;
+
+ public Handler mInstallHandler = new Handler() {
+ @Override
+ public void handleMessage(Message zMsg) {
+ Bundle msg = zMsg.getData();
+ //Is it over
+ if(msg.containsKey("close_install")){
+ //Shut it down..
+ mInstallProgress.dismiss();
+
+ //Set the Text
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(installer.this);
+ String current = prefs.getString("CURRENT_SYSTEM", "no system installed");
+ TextView tv = (TextView)findViewById(R.id.install_sys);
+ tv.setText("Current : "+current+"\n"+ "Available : "+CURRENT_INSTALL_SYSTEM);
+
+ //Start the service
+ Intent mTSIntent = new Intent(installer.this, TermService.class);
+ startService(mTSIntent);
+
+ }else if(msg.containsKey("error")){
+ String info = msg.getString("error");
+ mInstallProgress.setMessage(info);
+
+ Toast.makeText(installer.this, "ERROR : \n"+info, Toast.LENGTH_LONG).show();
+
+ }else{
+ String info = msg.getString("info");
+ mInstallProgress.setMessage(info);
+ }
+ }
+ };
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+
+ //Set the right Content
+ setContentView(R.layout.install);
+
+ //Get the current system
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ String current = prefs.getString("CURRENT_SYSTEM", "no system installed");
+ int currentnum = prefs.getInt("CURRENT_SYSTEM_NUM", 0);
+ String avail = CURRENT_INSTALL_SYSTEM;
+
+ TextView tv = (TextView)findViewById(R.id.install_sys);
+ tv.setTypeface(Typeface.MONOSPACE);
+ tv.setText("Current : "+current+"\n"+ "Available : "+avail);
+
+ Button but = (Button)findViewById(R.id.install_start);
+ but.setOnClickListener(this);
+ }
+
+ @Override
+ protected Dialog onCreateDialog(int id) {
+ mInstallProgress = new ProgressDialog(this);
+ mInstallProgress.setTitle("System installing..");
+ mInstallProgress.setMessage("Please wait..");
+ mInstallProgress.setCancelable(false);
+
+ return mInstallProgress;
+ }
+ public void onClick(View zButton) {
+ if(zButton == findViewById(R.id.install_start)){
+ //Extract all the files..
+ showDialog(0);
+
+ //Shut down the service
+ Intent mTSIntent = new Intent(this, TermService.class);
+ stopService(mTSIntent);
+
+ //Overwrite
+ CheckBox over = (CheckBox)findViewById(R.id.install_overwrite);
+ mOverwriteAll = over.isChecked();
+
+ //Start the Installer
+ Thread tt = new Thread(){
+ public void run(){
+ //Set the Message
+ Message msg = new Message();
+ msg.getData().putString("info", "Starting System install..");
+ mInstallHandler.sendMessage(msg);
+
+ //Main HOME FOlder
+ File home = installer.this.getFilesDir();
+
+ //Where to store the system number
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(installer.this);
+
+ try {
+ //Create a working Directory
+ File tmp = new File(home, "tmp");
+ if (!tmp.exists()) {
+ tmp.mkdirs();
+ }
+
+ //Working directory
+ File worker = new File(tmp,"sys_install_"+System.currentTimeMillis());
+ if(!worker.exists()){
+ worker.mkdirs();
+ }
+
+ //Extract the assets..
+ msg = new Message();
+ msg.getData().putString("info", "Preparing tar..");
+ mInstallHandler.sendMessage(msg);
+
+ File busytar = new File(worker, "busybox");
+ if(busytar.exists()){
+ busytar.delete();
+ }
+
+ //Extract BusyBox, need it just for ln and cp
+ filemanager.extractAsset(installer.this, "busybox.mp3", busytar);
+
+ //Set up a simple environment
+ String[] env = new String[2];
+ env[0] = "PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin";
+ env[1] = "LD_LIBRARY_PATH=/vendor/lib:/system/lib";
+
+ //Set executable
+ Process pp = Runtime.getRuntime().exec
+ ("chmod 770 "+busytar.getPath(),env,home);
+
+ pp.waitFor();
+
+ msg = new Message();
+ msg.getData().putString("info", "Preparing "+CURRENT_INSTALL_SYSTEM+" ..");
+ mInstallHandler.sendMessage(msg);
+
+ File systar = new File(worker, "system.tar.gz");
+ filemanager.extractAsset(installer.this, CURRENT_INSTALL_ASSETFILE, systar);
+
+ //Now start
+ msg = new Message();
+ msg.getData().putString("info", "Removing the old system..");
+ mInstallHandler.sendMessage(msg);
+
+ File system = new File(home,"system");
+ filemanager.deleteFolder(system);
+
+ msg = new Message();
+ msg.getData().putString("info", "Extracting the new system..");
+ mInstallHandler.sendMessage(msg);
+
+
+ File bins = new File(system,"bin");
+
+ //Now run the extract command
+ pp = Runtime.getRuntime().exec
+ (busytar.getPath()+
+ " tar -C "+home.getPath()+" -xaf "+systar.getPath(),env,home);
+ pp.waitFor();
+
+ //Now copy some initial files..
+ msg = new Message();
+ msg.getData().putString("info", "Initializing the environment..");
+ mInstallHandler.sendMessage(msg);
+
+ File etc = new File(system,"etc");
+
+ // zshrc
+ File zshrc = new File(etc,"zshrc");
+ File zshrcu = new File(home,".zshrc");
+ if(!zshrcu.exists() || mOverwriteAll){
+ pp = Runtime.getRuntime().exec
+ (busytar.getPath()+
+ " cp -f "+zshrc.getPath()+" "+zshrcu.getPath(),env,home);
+ pp.waitFor();
+ }
+
+ // grml.conf
+ File grml = new File(etc,"grml.conf");
+ File grmlu = new File(home,".grml.conf");
+ if(!grmlu.exists() || mOverwriteAll){
+ pp = Runtime.getRuntime().exec
+ (busytar.getPath()+
+ " cp -f "+grml.getPath()+" "+grmlu.getPath(),env,home);
+ pp.waitFor();
+ }
+
+ //Create a link to the sdcard
+ File sdcard = Environment.getExternalStorageDirectory();
+ File lnsdcard = new File(home,"sdcard");
+ String func = busytar.getPath()+" ln -s "+sdcard.getPath()+" "+lnsdcard.getPath();
+ Log.v("ZShaolin", "SDCARD ln : "+func);
+// pp = Runtime.getRuntime().exec(func);
+ pp = Runtime.getRuntime().exec(func,env,home);
+ pp.waitFor();
+
+ //Make a few initial folders
+ //File public_html = new File(home,"public_html");
+ //if(!.exists()){public_html.mkdirs();}
+
+ msg = new Message();
+ msg.getData().putString("info", "Cleaning up..");
+ mInstallHandler.sendMessage(msg);
+ filemanager.deleteFolder(worker);
+
+ //SYSTEM INSTALLED!!
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putString("CURRENT_SYSTEM", CURRENT_INSTALL_SYSTEM);
+ editor.putInt("CURRENT_SYSTEM_NUM", CURRENT_INSTALL_SYSTEM_NUM);
+ editor.commit();
+
+ } catch (Exception iOException) {
+ Log.v("ZShaolin", "INSTALL SYSTEM EXCEPTION : "+iOException);
+
+ msg = new Message();
+ msg.getData().putString("error", iOException.toString());
+ mInstallHandler.sendMessage(msg);
+
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putString("CURRENT_SYSTEM", "ERROR : Last Install");
+ editor.putInt("CURRENT_SYSTEM_NUM", -1);
+ editor.commit();
+ }
+
+ //Its done..
+ msg = new Message();
+ msg.getData().putString("info", "System install complete!");
+ mInstallHandler.sendMessage(msg);
+
+ msg = new Message();
+ msg.getData().putString("close_install", "1");
+ mInstallHandler.sendMessage(msg);
+
+ Log.v("ZShaolin", "Finished Binary Install");
+ }
+ };
+ tt.start();
+ }
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ Log.v("ZShaolin","Installer onConfigurationChanged!!!!");
+ }
+}
diff --git a/termapk/src/org/dyne/zshaolin/startup/introscreen.java b/termapk/src/org/dyne/zshaolin/startup/introscreen.java
new file mode 100644
index 0000000..02b3de2
--- /dev/null
+++ b/termapk/src/org/dyne/zshaolin/startup/introscreen.java
@@ -0,0 +1,154 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.dyne.zshaolin.startup;
+import org.dyne.zshaolin.R;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.res.Configuration;
+import android.net.Uri;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.Button;
+
+import com.spartacusrex.spartacuside.Term;
+import com.spartacusrex.spartacuside.TermService;
+
+/**
+ *
+ * @author Spartacus Rex
+ */
+public class introscreen extends Activity implements OnClickListener{
+
+ Dialog mConfirmDialog;
+ Dialog mInstallDialog;
+ Intent mTSIntent;
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+
+ setContentView(R.layout.main);
+
+ //Start the Service..
+ mTSIntent = new Intent(this, TermService.class);
+ startService(mTSIntent);
+
+ Button but = (Button)findViewById(R.id.main_start);
+ but.setOnClickListener(this);
+ but = (Button)findViewById(R.id.main_stop);
+ but.setOnClickListener(this);
+ but = (Button)findViewById(R.id.main_keyboard);
+ but.setOnClickListener(this);
+ but = (Button)findViewById(R.id.main_install);
+ but.setOnClickListener(this);
+ but = (Button)findViewById(R.id.main_help);
+ but.setOnClickListener(this);
+ but = (Button)findViewById(R.id.main_options);
+ but.setOnClickListener(this);
+
+ AlertDialog.Builder build = new AlertDialog.Builder(this);
+ build.setTitle("Confirm");
+ build.setMessage("Shutdown all terminals ?");
+ build.setCancelable(true);
+ build.setPositiveButton("Shutdown", new android.content.DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface arg0, int arg1) {
+ stopService(mTSIntent);
+
+ finish();
+
+ mConfirmDialog.dismiss();
+ }
+ });
+ build.setNegativeButton("Cancel", new android.content.DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface arg0, int arg1) {
+ mConfirmDialog.dismiss();
+ }
+ });
+ mConfirmDialog = build.create();
+
+ build = new AlertDialog.Builder(this);
+ build.setTitle("New System");
+ build.setMessage("There is a newer system for you to install.");
+ build.setCancelable(true);
+ build.setPositiveButton("Show me", new android.content.DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface arg0, int arg1) {
+ //Install the system
+ startActivity(new Intent(introscreen.this, installer.class));
+
+ mConfirmDialog.dismiss();
+ }
+ });
+ build.setNegativeButton("Later", new android.content.DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface arg0, int arg1) {
+ //Start the Terminal
+ startActivity(new Intent(introscreen.this, Term.class));
+
+ mConfirmDialog.dismiss();
+ }
+ });
+ mInstallDialog = build.create();
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ }
+
+ public void onClick(View zButton) {
+ if(zButton == findViewById(R.id.main_start)){
+ //Check system version
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ String current = prefs.getString("CURRENT_SYSTEM", "no system installed");
+ int currentnum = prefs.getInt("CURRENT_SYSTEM_NUM", -1);
+
+ if(currentnum < installer.CURRENT_INSTALL_SYSTEM_NUM){
+ mInstallDialog.show();
+ }else{
+ //Start the Terminal
+ startActivity(new Intent(introscreen.this, Term.class));
+ }
+
+ }else if(zButton == findViewById(R.id.main_stop)){
+ mConfirmDialog.show();
+
+ }else if(zButton == findViewById(R.id.main_keyboard)){
+ //Show Keyboard Picker
+ InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.showInputMethodPicker();
+
+ }else if(zButton == findViewById(R.id.main_install)){
+ //Install the system
+ startActivity(new Intent(this, installer.class));
+
+ }else if(zButton == findViewById(R.id.main_help)){
+ //Open the Help Section
+ String url = "http://www.zshaolin.org/help";
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse(url));
+ startActivity(i);
+
+ }else if(zButton == findViewById(R.id.main_options)){
+ //Show the Options..
+ startActivity(new Intent(this, TerminalIDEPrefs.class));
+ }
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ Log.v("ZShaolin","IntroScreen onConfigurationChanged!!!!");
+ }
+}
diff --git a/termapk/src/org/dyne/zshaolin/startup/setup/assetextract.java b/termapk/src/org/dyne/zshaolin/startup/setup/assetextract.java
new file mode 100644
index 0000000..df5f991
--- /dev/null
+++ b/termapk/src/org/dyne/zshaolin/startup/setup/assetextract.java
@@ -0,0 +1,129 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.dyne.zshaolin.startup.setup;
+// import org.dyne.zshaolin.R;
+
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import android.content.res.AssetManager;
+import android.util.Log;
+
+/**
+ *
+ * @author Spartacus Rex
+ */
+public class assetextract {
+
+ AssetManager mAssets;
+
+ public assetextract(AssetManager zAssets){
+ mAssets = zAssets;
+ }
+
+ private static void log(String zLog){
+ Log.v("ZShaolin","BinaryManager : "+zLog);
+ }
+
+ private void copyFile(InputStream in, OutputStream out) throws IOException {
+ byte[] buffer = new byte[1024];
+ int read;
+ while((read = in.read(buffer)) != -1){
+ out.write(buffer, 0, read);
+ }
+ }
+
+ private void extractAsset(String zAssetFile, File zOuput) throws IOException {
+ InputStream in = mAssets.open(zAssetFile);
+ OutputStream os = new FileOutputStream(zOuput);
+ copyFile(in,os);
+ in.close();
+ os.close();
+ }
+
+ public static void deleteFolder(File zFile){
+ if(zFile.isDirectory()){
+ //Its a directory
+ File[] files = zFile.listFiles();
+ for(File ff : files){
+ deleteFolder(ff);
+ }
+ }
+
+ //Now delete
+ zFile.delete();
+ }
+
+ public boolean isAssetDirectory(String zAssetPath) throws IOException{
+ String[] files = mAssets.list(zAssetPath);
+ if(files==null || files.length==0){
+ return false;
+ }
+ return true;
+ }
+
+ private String getPathName(String zPath){
+ int index = zPath.lastIndexOf("/");
+ if(index==-1){
+ return zPath;
+ }
+ return zPath.substring(index);
+ }
+
+ public void recurseExtractAssets(String zAssetPath, File zBaseDir){
+ log("recurseExtractAssets "+zAssetPath+" "+zBaseDir);
+
+ //Check that this folder exists
+ File folder = new File(zBaseDir.getPath());
+ if(!folder.exists()){
+ folder.mkdirs();
+ }
+
+ //Get the Asset name..
+ String asset = getPathName(zAssetPath);
+
+ //Create a file handle
+ File newfile = new File(zBaseDir, asset);
+
+ //Now - what to do..
+ try {
+ //Is it a Dir
+ if(isAssetDirectory(zAssetPath)){
+ //Create a Directory..
+ newfile.mkdirs();
+
+ //List the Asset files
+ String[] files = mAssets.list(zAssetPath);
+ for(String file : files){
+ String fpath = zAssetPath+"/"+file;
+
+ //Recurse down through the tree..
+ recurseExtractAssets(fpath, newfile);
+ }
+
+ }else{
+ String name = newfile.getName();
+ if(name.endsWith(".mp3")){
+ //Big file - copy and remove .mp3 from filename
+ newfile = new File(zBaseDir, asset.substring(0, asset.length()-4));
+ }
+
+ //Now extract the file..
+ extractAsset(zAssetPath, newfile);
+ }
+
+ } catch (IOException ex) {
+ Logger.getLogger(assetextract.class.getName()).log(Level.SEVERE, null, zAssetPath+" "+ex);
+ }
+ }
+
+}
diff --git a/termapk/src/org/dyne/zshaolin/startup/setup/filemanager.java b/termapk/src/org/dyne/zshaolin/startup/setup/filemanager.java
new file mode 100644
index 0000000..3665b73
--- /dev/null
+++ b/termapk/src/org/dyne/zshaolin/startup/setup/filemanager.java
@@ -0,0 +1,172 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.dyne.zshaolin.startup.setup;
+// import org.dyne.zshaolin.R;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import android.content.Context;
+import android.util.Log;
+
+/**
+ *
+ * @author Spartacus Rex
+ */
+public class filemanager {
+
+ private static void log(String zLog){
+ Log.v("ZShaolin","BinaryManager : "+zLog);
+ }
+
+ private static void copyFile(InputStream in, OutputStream out) throws IOException {
+ byte[] buffer = new byte[1024];
+ int read;
+ while((read = in.read(buffer)) != -1){
+ out.write(buffer, 0, read);
+ }
+ }
+
+ public static void extractAsset(Context zContext, String zAssetFile, File zOuput) throws IOException {
+ InputStream in = zContext.getAssets().open(zAssetFile);
+ OutputStream os = new FileOutputStream(zOuput);
+ copyFile(in,os);
+ in.close();
+ os.close();
+ }
+
+ public static void deleteFolder(File zFile){
+ if(zFile.isDirectory()){
+ //Its a directory
+ File[] files = zFile.listFiles();
+ for(File ff : files){
+ deleteFolder(ff);
+ }
+ }
+
+ //Now delete
+ zFile.delete();
+ }
+
+ public static void extractBinaryFiles(Context zContext){
+ //Extract some stuff..
+ File home = zContext.getFilesDir();
+ log("Main Files dir : "+home.getPath());
+
+ if(true){
+ return;
+ }
+
+ File system = new File(home,"system");
+
+ File andr = new File(system,"android");
+ andr.mkdirs();
+ File andjar = new File(andr,"android.jar");
+
+ File bindir = new File(system,"bin");
+ bindir.mkdirs();
+ File busyb = new File(bindir,"busybox");
+ File bbdir = new File(bindir,"bbdir");
+ bbdir.mkdirs();
+
+ //get the assets
+ try {
+ String[] files = zContext.getAssets().list("binary");
+ boolean onefound=false;
+
+ for (int i = 0; i < files.length; i++) {
+ String name = files[i];
+
+ String pname = new String(name);
+ if(name.endsWith(".mp3")){
+ //Remove it..
+ pname = files[i].substring(0, files[i].length()-4);
+ }
+
+ //Bin file
+ File binfile = new File(bindir,pname);
+
+ //Check exists
+ if(!binfile.exists()){
+ onefound=true;
+ log("Copying file : "+files[i]);
+
+ //Asset file
+ InputStream in = zContext.getAssets().open("binary/"+files[i]);
+
+ //Output
+ OutputStream os = new FileOutputStream(binfile);
+
+ copyFile(in, os);
+
+ //CLose both streams
+ in.close();
+ os.close();
+
+ log("File copied: "+files[i]+" as "+binfile.getPath());
+
+ //Now set the mode..
+// log("RUN CHMOD : chmod 550 "+binfile.getPath());
+ Process pp = Runtime.getRuntime().exec("chmod 550 "+binfile.getPath());
+ pp.waitFor();
+ }
+ }
+
+ //Now copy over android.jar
+ if(!andjar.exists()){
+ onefound = true;
+
+ log("Install android.jar");
+ extractAsset(zContext, "androidjar/android.jar", andjar);
+ }
+
+ //Now extract home files..
+ if(onefound){
+ //reinstall busybox links
+ File binfile = new File(bindir,"busybox");
+ String command = binfile.getPath()+" --install -s "+bbdir.getPath();
+ log("BB INSTALL command "+command);
+ Runtime.getRuntime().exec(command);
+
+ log("Install home files");
+ extractAsset(zContext, "home/vimrc", new File(home, ".vimrc"));
+ extractAsset(zContext, "home/bashrc", new File(home, ".bashrc"));
+ extractAsset(zContext, "home/bash_profile", new File(home, ".bash_profile"));
+ extractAsset(zContext, "home/inputrc", new File(home, ".inputrc"));
+
+ //Now extract etc
+ File extract = new File(system,"etc.tar.gz");
+ log("Extract ETC ");
+ extractAsset(zContext, "etc/etc.tar.gz.mp3", extract);
+
+ //Now run bbox..
+ command = binfile.getPath()+" tar -xz -C "+system.getPath()+" -f "+extract.getPath();
+ log("BB command "+command);
+ Process pp = Runtime.getRuntime().exec(command);
+ log("BB command started..");
+ int result = pp.waitFor();
+ log("BB command finshed .."+result);
+
+ //And now remove it..
+ extract.delete();
+
+ //Now extract the init file
+ File init = new File(system,"init");
+ extractAsset(zContext, "sys/init", init);
+ }
+
+ } catch (IOException iOException) {
+ log("Exception extracting files : "+iOException);
+ } catch (InterruptedException iOException) {
+ log("Exception extracting files : "+iOException);
+ }
+
+ log("All done..!");
+ }
+}