Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 8390b2d97b07fcda97bc9ef0029d6299be93c881 0 parents
James Brechtel authored
3  .gitignore
@@ -0,0 +1,3 @@
+.idea
+target
+.idea_modules/gen
55 .idea_modules/Scala Installer.iml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="FacetManager">
+ <facet type="scala" name="Scala">
+ <configuration>
+ <option name="compilerLibraryLevel" value="Project" />
+ <option name="compilerLibraryName" value="scala-2.9.1" />
+ </configuration>
+ </facet>
+ <facet type="android" name="Android">
+ <configuration>
+ <option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/gen" />
+ <option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/gen" />
+ <option name="MANIFEST_FILE_RELATIVE_PATH" value="/../src/main/AndroidManifest.xml" />
+ <option name="RES_FOLDER_RELATIVE_PATH" value="/../src/main/res" />
+ <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/../src/main/assets" />
+ <option name="LIBS_FOLDER_RELATIVE_PATH" value="/../libs" />
+ <option name="REGENERATE_R_JAVA" value="true" />
+ <option name="REGENERATE_JAVA_BY_AIDL" value="true" />
+ <option name="USE_CUSTOM_APK_RESOURCE_FOLDER" value="false" />
+ <option name="CUSTOM_APK_RESOURCE_FOLDER" value="" />
+ <option name="USE_CUSTOM_COMPILER_MANIFEST" value="false" />
+ <option name="CUSTOM_COMPILER_MANIFEST" value="" />
+ <option name="APK_PATH" value="" />
+ <option name="LIBRARY_PROJECT" value="false" />
+ <option name="RUN_PROCESS_RESOURCES_MAVEN_TASK" value="true" />
+ <option name="GENERATE_UNSIGNED_APK" value="false" />
+ <option name="CUSTOM_DEBUG_KEYSTORE_PATH" value="" />
+ </configuration>
+ </facet>
+ </component>
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/../target/scala-2.9.1/classes" />
+ <output-test url="file://$MODULE_DIR$/../target/scala-2.9.1/test-classes" />
+ <exclude-output />
+ <content url="file://$MODULE_DIR$/..">
+ <sourceFolder url="file://$MODULE_DIR$/../src/main/scala" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/../src/main/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/../target/scala-2.9.1/src_managed/main" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/../src/main/resources" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/../src/test/scala" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/../src/test/java" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/../src/test/resources" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/../target/scala-2.9.1/cache" />
+ <excludeFolder url="file://$MODULE_DIR$/../target/streams" />
+ </content>
+ <orderEntry type="jdk" jdkName="Android 3.2 Platform" jdkType="Android SDK" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" name="org.scala-lang_scala-library_2.9.1" level="project" />
+ <orderEntry type="library" scope="TEST" name="org.scalatest_scalatest_2.9.1_1.6.1" level="project" />
+ <orderEntry type="library" name="android.jar" level="project" />
+ </component>
+</module>
+
74 .idea_modules/project.iml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/../project/target/scala_2.9.1" />
+ <output-test url="file://$MODULE_DIR$/../project/target/scala_2.9.1" />
+ <exclude-output />
+ <content url="file://$MODULE_DIR$/../project">
+ <sourceFolder url="file://$MODULE_DIR$/../project" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/../project/plugins" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/../project/boot" />
+ <excludeFolder url="file://$MODULE_DIR$/../project/plugins/project/target" />
+ <excludeFolder url="file://$MODULE_DIR$/../project/plugins/target" />
+ <excludeFolder url="file://$MODULE_DIR$/../project/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module-library">
+ <library name="sbt-and-plugins">
+ <CLASSES>
+ <root url="file://$MODULE_DIR$/../project/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1" />
+ <root url="jar://$MODULE_DIR$/../project/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/xsbti/interface-0.11.1.jar!/" />
+ <root url="file://$USER_HOME$/.sbt/plugins/target/scala-2.9.1/sbt-0.11.1/classes" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/logging_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/actions_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/commons-io/commons-io/jars/commons-io-2.0.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/task-system_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/commons-httpclient-3.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/io_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/incremental-compiler_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/jline-0.9.94.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/com.google.android.tools/ddmlib/jars/ddmlib-r10.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/cache_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/tracking_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/commons-logging-1.0.4.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/commons-codec-1.2.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/ivy_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/xsbti/interface-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/main_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/completion_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/control_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/process_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/launcher-interface_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/lib/jansi.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/lib/scala-compiler.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/sbt_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/jsch-0.1.31.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/scala_2.9.1/sbt_0.11.1/com.typesafe.sbteclipse/sbteclipse/jars/sbteclipse-1.4.0.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/collections_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/run_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/testing_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/scala_2.9.1/sbt_0.11.1/com.github.mpeltonen/sbt-idea/jars/sbt-idea-0.11.0.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/persist_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/tasks_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/test-interface-0.5.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/lib/scala-library.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/ivy-2.2.0.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/compile_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/classpath_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/lib/jline.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/sbinary_2.9.0-0.4.0.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/api_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/net.sf.proguard/proguard-base/jars/proguard-base-4.6.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.9.1/org.scala-tools.sbt/sbt/0.11.1/classfile_2.9.1-0.11.1.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scalaz/scalaz-core_2.9.1/jars/scalaz-core_2.9.1-6.0.2.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/local/org.scala-tools.sbt/sbt-android-plugin/scala_2.9.1/sbt_0.11.1/0.6.0/jars/sbt-android-plugin.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="library" name="scala-2.9.1" level="project" />
+ </component>
+</module>
+
31 .idea_modules/tests.iml
@@ -0,0 +1,31 @@
+<module version="4" type="JAVA_MODULE">
+ <component name="FacetManager">
+ <facet name="Scala" type="scala">
+ <configuration>
+ <option name="compilerLibraryLevel" value="Project"></option>
+ <option name="compilerLibraryName" value="scala-2.9.1"></option>
+ </configuration>
+ </facet>
+ </component>
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/../tests/target/scala-2.9.1/classes"></output>
+ <output-test url="file://$MODULE_DIR$/../tests/target/scala-2.9.1/test-classes"></output-test>
+ <exclude-output></exclude-output>
+ <content url="file://$MODULE_DIR$/../tests">
+ <sourceFolder url="file://$MODULE_DIR$/../tests/src/main/scala" isTestSource="false"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../tests/src/main/java" isTestSource="false"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../tests/target/scala-2.9.1/src_managed/main" isTestSource="false"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../tests/src/main/resources" isTestSource="false"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../tests/src/test/scala" isTestSource="true"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../tests/src/test/java" isTestSource="true"></sourceFolder>
+ <sourceFolder url="file://$MODULE_DIR$/../tests/src/test/resources" isTestSource="true"></sourceFolder>
+ <excludeFolder url="file://$MODULE_DIR$/../tests/target/scala-2.9.1/cache"></excludeFolder>
+ <excludeFolder url="file://$MODULE_DIR$/../tests/target/streams"></excludeFolder>
+ </content>
+ <orderEntry type="inheritedJdk"></orderEntry>
+ <orderEntry type="sourceFolder" forTests="false"></orderEntry>
+ <orderEntry level="project" name="org.scala-lang_scala-library_2.9.1" type="library"></orderEntry>
+ <orderEntry level="project" name="android.jar" type="library"></orderEntry>
+ <orderEntry type="module" module-name="Scala Installer" exported=""></orderEntry>
+ </component>
+</module>
38 project/build.scala
@@ -0,0 +1,38 @@
+import sbt._
+
+import Keys._
+import AndroidKeys._
+
+object General {
+ val settings = Defaults.defaultSettings ++ Seq (
+ name := "Scala Installer",
+ version := "0.1",
+ scalaVersion := "2.9.1",
+ platformName in Android := "android-8"
+ )
+
+ lazy val fullAndroidSettings =
+ General.settings ++
+ AndroidProject.androidSettings ++
+ TypedResources.settings ++
+ AndroidMarketPublish.settings ++ Seq (
+ keyalias in Android := "change-me",
+ libraryDependencies += "org.scalatest" %% "scalatest" % "1.6.1" % "test"
+ )
+}
+
+object AndroidBuild extends Build {
+ lazy val main = Project (
+ "Scala Installer",
+ file("."),
+ settings = General.fullAndroidSettings
+ )
+
+ lazy val tests = Project (
+ "tests",
+ file("tests"),
+ settings = General.settings ++ AndroidTest.androidSettings ++ Seq (
+ name := "Scala InstallerTests"
+ )
+ ) dependsOn main
+}
3  project/plugins.sbt
@@ -0,0 +1,3 @@
+resolvers += "nexus snapshots" at "http://nexus.scala-tools.org/content/repositories/snapshots"
+
+addSbtPlugin("org.scala-tools.sbt" % "sbt-android-plugin" % "0.6.0")
12 src/main/AndroidManifest.xml
@@ -0,0 +1,12 @@
+<manifest
+android:versionName="0.1" android:versionCode="1" package="com.mobilemagic.scalainstaller" xmlns:android="http://schemas.android.com/apk/res/android">
+ <uses-sdk android:minSdkVersion="8"></uses-sdk>
+ <application android:icon="@drawable/android:star_big_on" android:label="@string/app_name">
+ <activity android:label="@string/app_name" android:name=".MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"></action>
+ <category android:name="android.intent.category.LAUNCHER"></category>
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
25 src/main/res/layout/main_activity.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical" >
+
+ <TextView android:id="@+id/text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="15sp"
+ android:text="@string/info_text" />
+
+ <Button android:id="@+id/button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/run_button_text" />
+
+ <Button android:id="@+id/button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/uninstall_button_text" />
+
+</LinearLayout>
BIN  src/main/res/raw/scala_actors_291.jar
Binary file not shown
4 src/main/res/raw/scala_actors_291_desc.xml
@@ -0,0 +1,4 @@
+<permissions>
+ <library name="scala_actors-2.9.1"
+ file="/data/data/com.mobilemagic.scalainstaller/files/scala_actors_291.jar"/>
+</permissions>
BIN  src/main/res/raw/scala_collection_291.jar
Binary file not shown
4 src/main/res/raw/scala_collection_291_desc.xml
@@ -0,0 +1,4 @@
+<permissions>
+ <library name="scala_collection-2.9.1"
+ file="/data/data/com.mobilemagic.scalainstaller/files/scala_collection_291.jar"/>
+</permissions>
BIN  src/main/res/raw/scala_immutable_291.jar
Binary file not shown
4 src/main/res/raw/scala_immutable_291_desc.xml
@@ -0,0 +1,4 @@
+<permissions>
+ <library name="scala_immutable-2.9.1"
+ file="/data/data/com.mobilemagic.scalainstaller/files/scala_immutable_291.jar"/>
+</permissions>
BIN  src/main/res/raw/scala_library_291.jar
Binary file not shown
4 src/main/res/raw/scala_library_291_desc.xml
@@ -0,0 +1,4 @@
+<permissions>
+ <library name="scala_library-2.9.1"
+ file="/data/data/com.mobilemagic.scalainstaller/files/scala_library_291.jar"/>
+</permissions>
BIN  src/main/res/raw/scala_mutable_291.jar
Binary file not shown
4 src/main/res/raw/scala_mutable_291_desc.xml
@@ -0,0 +1,4 @@
+<permissions>
+ <library name="scala_mutable-2.9.1"
+ file="/data/data/com.mobilemagic.scalainstaller/files/scala_mutable_291.jar"/>
+</permissions>
15 src/main/res/values/strings.xml
@@ -0,0 +1,15 @@
+<resources>
+ <string name="app_name">Scala Installer</string>
+ <string name="info_text">
+ Disclaimer: Execute this at your own risk\n\n
+ This installer does the following:\n\n
+
+
+ 1. Remount /system writable\n
+ 2. Extract the libraries from this package\n
+ 3. Link the library descriptor files into /system/etc/permissions\n
+ 4. Remount /system read-only\n
+ </string>
+ <string name="run_button_text">Install Scala 2.9.1 libraries</string>
+ <string name="uninstall_button_text">Remove Scala 2.9.1 libraries</string>
+</resources>
40 src/main/scala/MainActivity.scala
@@ -0,0 +1,40 @@
+package com.mobilemagic.scalainstaller
+
+import android.app.Activity
+import android.app.ProgressDialog
+import android.os.Bundle
+import android.view.View
+import android.widget.Button
+import android.widget.TextView
+
+class MainActivity extends Activity with Runnable {
+ protected override def onCreate(savedInstanceState: Bundle): Unit = {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.main_activity)
+ button.setOnClickListener(new View.OnClickListener {
+ def onClick(view: View): Unit = {
+ progress = ProgressDialog.show(MainActivity.this, "Installing...", "")
+ val thread: Thread = new Thread(MainActivity.this)
+ thread.start
+ }
+ })
+ }
+
+ def run: Unit = {
+ val installer: RoboInstaller = new RoboInstaller(getApplicationContext)
+ installer.installScalaLibs()
+ runOnUiThread(new Runnable {
+ def run {
+ button.setEnabled(false)
+ text.setTextSize(20)
+ text.setText("Finished! Please restart your phone.")
+ progress.dismiss()
+ }
+ })
+ }
+
+ var progress: ProgressDialog = null
+ lazy val text = findViewById(R.id.text).asInstanceOf[TextView]
+ lazy val button = findViewById(R.id.button).asInstanceOf[Button]
+}
+
105 src/main/scala/RoboInstaller.scala
@@ -0,0 +1,105 @@
+package com.mobilemagic.scalainstaller
+
+import android.content.Context
+import android.util.Log
+import java.io._
+
+object RoboInstaller {
+ def makeWritable() {
+ Log.d(TAG, "Make /system writable")
+ sudo("mount -o remount,rw /system")
+ }
+
+ def makeReadOnly() {
+ Log.d(TAG, "Make /system read-only")
+ sudo("mount -o remount,ro /system")
+ }
+
+ def sudo(cmd: String) {
+ try {
+ val proc: Process = runtime.exec(Array[String]("su", "-c", cmd))
+ val res: Int = proc.waitFor
+ if (res != 0) throw new RuntimeException("Execution of cmd '"+cmd+"' failed with exit code "+res)
+ }
+ catch {
+ case e: Exception => {
+ throw new RuntimeException(e)
+ }
+ }
+ }
+
+ final val TAG: String = "RoboInstaller"
+ val resources = Array(R.raw.scala_actors_291,
+ R.raw.scala_actors_291_desc,
+ R.raw.scala_collection_291,
+ R.raw.scala_collection_291_desc,
+ R.raw.scala_immutable_291,
+ R.raw.scala_immutable_291_desc,
+ R.raw.scala_library_291,
+ R.raw.scala_library_291_desc,
+ R.raw.scala_mutable_291,
+ R.raw.scala_mutable_291_desc)
+
+ val runtime: Runtime = Runtime.getRuntime
+}
+
+class RoboInstaller(ctx: Context) {
+
+ def installScalaLibs() {
+ try {
+ RoboInstaller.makeWritable()
+ installFiles()
+ makeLinks()
+ }
+ catch {
+ case e: Exception => {
+ throw new RuntimeException(e)
+ }
+ }
+ finally {
+ RoboInstaller.makeReadOnly()
+ }
+ }
+
+ private def installFiles() {
+ for (resid <- RoboInstaller.resources) installFile(resid)
+ }
+
+ private def makeLinks() {
+ for (resid <- RoboInstaller.resources) {
+ val path: File = fileForResource(resid)
+ if (path.getName.endsWith("_desc.xml")) RoboInstaller.sudo("ln -s "+path.getAbsolutePath+" /system/etc/permissions/"+path.getName)
+ }
+ }
+
+ /**
+ * Takes the resource with the given name and installs it into the files dir
+ * @param resid
+ */
+ private def installFile(resid: Int) {
+ val targetFile: File = fileForResource(resid)
+ Log.i(RoboInstaller.TAG, "Extracting file to " + targetFile.getAbsolutePath)
+ val fos: FileOutputStream = new FileOutputStream(targetFile)
+ val is: InputStream = ctx.getResources.openRawResource(resid)
+ val buffer: Array[Byte] = new Array[Byte](65000)
+ while (is.available > 0) {
+ val read: Int = is.read(buffer)
+ fos.write(buffer, 0, read)
+ }
+ is.close()
+ fos.close()
+ RoboInstaller.sudo("chmod 666 "+targetFile.getAbsolutePath)
+ }
+
+ private def fileForResource(resid: Int): File = {
+ var namePart: String = lastPart(ctx.getResources.getResourceName(resid))
+ if (namePart.endsWith("_desc")) namePart = namePart + ".xml"
+ else namePart = namePart + ".jar"
+ return new File(ctx.getFilesDir, namePart)
+ }
+
+ private def lastPart(path: String): String = {
+ return path.substring(path.lastIndexOf("/") + 1)
+ }
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.