├── .gitignore
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── licenses
│ │ ├── afilechooser.txt
│ │ ├── kotlin.txt
│ │ ├── libsuperuser.txt
│ │ └── usbmountr.txt
│ ├── java
│ └── streetwalrus
│ │ └── usbmountr
│ │ ├── ActivityResultDispatcher.kt
│ │ ├── FilePickerPreference.kt
│ │ ├── HostPreferenceFragment.kt
│ │ ├── ImageChooserActivity.kt
│ │ ├── ImageFilesAdapter.kt
│ │ ├── LicenseActivity.kt
│ │ ├── MainActivity.kt
│ │ ├── RequestCodes.kt
│ │ └── UsbMountrApplication.kt
│ └── res
│ ├── layout
│ ├── activity_image_chooser.xml
│ ├── activity_licenses.xml
│ ├── activity_main.xml
│ ├── dialog_license.xml
│ └── image_chooser_row.xml
│ ├── menu
│ ├── menu_image_chooser.xml
│ └── menu_main.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-de
│ └── strings.xml
│ ├── values-fr
│ └── strings.xml
│ ├── values-it
│ └── strings.xml
│ ├── values-lt
│ └── strings.xml
│ ├── values-w820dp
│ └── dimens.xml
│ ├── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
│ └── xml
│ ├── host_preferences.xml
│ └── licenses.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── screenshot.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.apk
2 | *.iml
3 | .gradle
4 | /local.properties
5 | /.idea/
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2017 Streetwalrus
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Notice
2 | This is a fork of streetwalrus' USB Mountr application.
3 | I am planning to call it PhoneStick, but this project is still in its infancy.
4 | Below is the original README of USB Mountr.
5 |
6 | # USB Mountr
7 | A helper application to set the Mass Storage Device gadget up in Android kernels
8 | [
](https://f-droid.org/app/streetwalrus.usbmountr)
11 | 
12 |
13 | ## How it works
14 | Android kernels still include a USB MSD component in their device gadget nowadays, though it is mostly unused since
15 | Android started using MTP. Some OEM ROMs still use it to provide a drivers installation "disc", but it is otherwise
16 | useless.
17 | This application leverages the module in order to let you use your device as a standard USB thumbdrive for the purpose
18 | of, e.g., booting a distro ISO.
19 |
20 | ## Building
21 | Standard gradle build process.
22 |
23 | ## Contributions...
24 | ...are welcome, I'm looking for a better icon, and if you feel like implementing it before I do, a menu to create blank
25 | images. Feel free to translate the application to your own language as well.
26 |
27 | ## See also
28 | - @morfikov has written up [a tutorial](https://gist.github.com/morfikov/0bd574817143d0239c5a0e1259613b7d) on setting up
29 | your phone as a boot device for a LUKS setup
30 |
31 | ## Donations
32 | I've been asked for donation info, so here it is.
33 | [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SHUNWU2HDU7EY)
34 | BTC: 199wYd9jB9yfBdXsfCXXESjzDHLHoKpBdd
35 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | def getVersionName = { ->
6 | def stdout = new ByteArrayOutputStream()
7 | exec {
8 | commandLine 'git', 'describe', '--tags'
9 | standardOutput = stdout
10 | }
11 | return stdout.toString().trim()
12 | }
13 |
14 | android {
15 | compileSdkVersion 28
16 | buildToolsVersion "28.0.3"
17 | defaultConfig {
18 | applicationId "streetwalrus.usbmountr"
19 | minSdkVersion 19
20 | targetSdkVersion 28
21 | versionCode 8
22 | versionName getVersionName()
23 | }
24 | buildTypes {
25 | release {
26 | minifyEnabled false
27 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
28 | }
29 | }
30 | sourceSets {
31 | main.java.srcDirs += 'src/main/kotlin'
32 | }
33 | lintOptions {
34 | checkReleaseBuilds false
35 | }
36 | }
37 |
38 | dependencies {
39 | implementation fileTree(include: ['*.jar'], dir: 'libs')
40 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
41 | implementation 'eu.chainfire:libsuperuser:1.0.0.+'
42 | implementation 'androidx.recyclerview:recyclerview:1.0.0'
43 | }
44 | repositories {
45 | mavenCentral()
46 | }
47 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/streetwalrus/android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/assets/licenses/afilechooser.txt:
--------------------------------------------------------------------------------
1 | Copyright (C) 2007-2008 OpenIntents.org
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/app/src/main/assets/licenses/kotlin.txt:
--------------------------------------------------------------------------------
1 | Copyright 2010-2016 JetBrains s.r.o.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/app/src/main/assets/licenses/libsuperuser.txt:
--------------------------------------------------------------------------------
1 | Copyright (C) 2012-2015 Jorrit "Chainfire" Jongma
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/app/src/main/assets/licenses/usbmountr.txt:
--------------------------------------------------------------------------------
1 | ../../../../../LICENSE
--------------------------------------------------------------------------------
/app/src/main/java/streetwalrus/usbmountr/ActivityResultDispatcher.kt:
--------------------------------------------------------------------------------
1 | package streetwalrus.usbmountr
2 |
3 | import android.content.Intent
4 | import android.util.Log
5 |
6 | class ActivityResultDispatcher {
7 | private val TAG = "ActivityResDispatcher"
8 |
9 | private val mHandlers: MutableMap = mutableMapOf()
10 | private var mCurId = 0
11 |
12 | interface ActivityResultHandler {
13 | fun onActivityResult(resultCode: Int, resultData: Intent?)
14 | }
15 |
16 | fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
17 | if (mHandlers.containsKey(requestCode)) {
18 | mHandlers[requestCode]?.onActivityResult(resultCode, resultData)
19 | } else {
20 | Log.w(TAG, "No handler for request ID $requestCode!")
21 | }
22 | }
23 |
24 | fun registerHandler(handler: ActivityResultHandler): Int {
25 | mHandlers[mCurId] = handler
26 | return mCurId++
27 | }
28 |
29 | fun removeHandler(id: Int) {
30 | mHandlers.remove(id)
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/streetwalrus/usbmountr/FilePickerPreference.kt:
--------------------------------------------------------------------------------
1 | package streetwalrus.usbmountr
2 |
3 | import android.app.Activity
4 | import android.content.Context
5 | import android.content.Intent
6 | import android.preference.Preference
7 | import android.util.AttributeSet
8 | import android.util.Log
9 | import android.view.View
10 | import android.view.ViewGroup
11 | import android.widget.Toast
12 | import java.io.File
13 |
14 | class FilePickerPreference : Preference, ActivityResultDispatcher.ActivityResultHandler {
15 | val TAG = "FilePickerPreference"
16 |
17 | constructor(context: Context) : super(context)
18 | constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
19 | constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int)
20 | : super(context, attrs, defStyleAttr)
21 |
22 | val appContext = context.applicationContext as UsbMountrApplication
23 | private val mActivityResultId = appContext.mActivityResultDispatcher.registerHandler(this)
24 |
25 | override fun onCreateView(parent: ViewGroup?): View {
26 | updateSummary()
27 | return super.onCreateView(parent)
28 | }
29 | override fun onPrepareForRemoval() {
30 | super.onPrepareForRemoval()
31 |
32 | val appContext = context.applicationContext as UsbMountrApplication
33 | appContext.mActivityResultDispatcher.removeHandler(mActivityResultId)
34 | }
35 |
36 | override fun onClick() {
37 | val intent = Intent(context.applicationContext, ImageChooserActivity::class.java)
38 |
39 | val activity = context as Activity
40 | activity.startActivityForResult(intent, mActivityResultId)
41 | }
42 |
43 | override fun onActivityResult(resultCode: Int, resultData: Intent?) {
44 | if (resultCode == Activity.RESULT_OK && resultData != null) {
45 | val path = resultData.getStringExtra("path")!!
46 | Log.d(TAG, "Picked file $path")
47 | persistString(path)
48 | updateSummary()
49 | }
50 | }
51 |
52 | private fun updateSummary() {
53 | val value = getPersistedString("")
54 | if (value.equals("")) {
55 | summary = context.getString(R.string.file_picker_nofile)
56 | } else {
57 | summary = File(value).name
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/app/src/main/java/streetwalrus/usbmountr/HostPreferenceFragment.kt:
--------------------------------------------------------------------------------
1 | package streetwalrus.usbmountr
2 |
3 | import android.os.Bundle
4 | import android.preference.PreferenceFragment
5 |
6 | class HostPreferenceFragment : PreferenceFragment() {
7 | private val TAG = "HostPreferenceFragment"
8 |
9 | val SOURCE_KEY = "host_source_file"
10 | val RO_KEY = "host_ro"
11 |
12 | override fun onCreate(savedInstanceState: Bundle?) {
13 | super.onCreate(savedInstanceState)
14 | addPreferencesFromResource(R.xml.host_preferences)
15 | }
16 | }
--------------------------------------------------------------------------------
/app/src/main/java/streetwalrus/usbmountr/ImageChooserActivity.kt:
--------------------------------------------------------------------------------
1 | package streetwalrus.usbmountr
2 |
3 | import android.os.Bundle
4 | import android.app.Activity
5 | import android.app.ProgressDialog
6 | import android.content.Context
7 | import android.content.Intent
8 | import android.net.Uri
9 | import android.os.AsyncTask
10 | import android.provider.OpenableColumns
11 | import android.util.Log
12 | import android.view.Menu
13 | import android.view.MenuItem
14 | import androidx.recyclerview.widget.DefaultItemAnimator
15 | import androidx.recyclerview.widget.DividerItemDecoration
16 | import androidx.recyclerview.widget.LinearLayoutManager
17 | import androidx.recyclerview.widget.RecyclerView
18 | import java.io.File
19 | import java.io.FileInputStream
20 |
21 | class ImageChooserActivity : Activity() {
22 | @Suppress("unused")
23 | private val TAG = "ImageChooserActivity"
24 |
25 | private var directory = File("/")
26 | override fun onCreate(savedInstanceState: Bundle?) {
27 | super.onCreate(savedInstanceState)
28 | directory = filesDir
29 | setContentView(R.layout.activity_image_chooser)
30 | actionBar?.setDisplayHomeAsUpEnabled(true)
31 |
32 | val recyclerView = findViewById(R.id.recycler_view)
33 | recyclerView.layoutManager = LinearLayoutManager(applicationContext)
34 | recyclerView.itemAnimator = DefaultItemAnimator()
35 | recyclerView.addItemDecoration(DividerItemDecoration(this, LinearLayoutManager.VERTICAL))
36 |
37 | val adapter = ImageFilesAdapter(directory, this)
38 | recyclerView.adapter = adapter
39 | }
40 |
41 | override fun onCreateOptionsMenu(menu: Menu?): Boolean {
42 | menuInflater.inflate(R.menu.menu_image_chooser, menu)
43 | return super.onCreateOptionsMenu(menu)
44 | }
45 |
46 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
47 | when(item.itemId) {
48 | R.id.image_chooser_add -> {
49 | val intent = Intent(Intent.ACTION_GET_CONTENT)
50 | intent.addCategory(Intent.CATEGORY_OPENABLE)
51 | intent.type = "*/*"
52 | intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true)
53 |
54 | startActivityForResult(intent, -1)
55 |
56 | return true
57 | }
58 | else -> {
59 | return super.onOptionsItemSelected(item)
60 | }
61 | }
62 | }
63 |
64 | override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
65 | if(resultCode == RESULT_CANCELED) return
66 | if(data.data == null) return
67 | CopyInTask(this, directory).execute(data.data)
68 | Log.d(TAG, "onActivityResult")
69 | }
70 |
71 | private class CopyInTask(context: Context, private val directory: File): AsyncTask, Unit>() {
72 | var totalSize = 0L
73 | private val progressDialog = ProgressDialog(context)
74 | private val contentResolver = context.contentResolver
75 | val TAG = "CopyInTask"
76 | override fun doInBackground(vararg params: Uri) {
77 | val fds = params.map { Pair(it, contentResolver.openFileDescriptor(it, "r")!!) }
78 | fds.last {(_, fileDescriptor) ->
79 | val statSize = fileDescriptor.statSize
80 | if(statSize == -1L) {
81 | totalSize = -1L
82 | false
83 | } else {
84 | totalSize += statSize
85 | true
86 | }
87 | }
88 | var transfered = 0L
89 | var counter = 0
90 | fds.forEach {(uri, fileDescriptor) ->
91 | var filename: String =
92 | contentResolver.query(uri, arrayOf(OpenableColumns.DISPLAY_NAME), null, null, null)!!.use {
93 | it.moveToFirst()
94 | it.getString(it.getColumnIndex(OpenableColumns.DISPLAY_NAME))
95 | }
96 | filename = filename.replace('/', '_')
97 | if(File(directory, filename).exists()) {
98 | var i = 1
99 | val index = filename.findLastAnyOf(arrayListOf("."))?.first ?: filename.length
100 | val basename = filename.substring(0 until index)
101 | val extension = filename.substring(index until filename.length)
102 | do {
103 | filename = "%s.%d%s".format(basename, i, extension)
104 | i++
105 | } while (File(directory, filename).exists())
106 | }
107 |
108 | FileInputStream(fileDescriptor.fileDescriptor).use { fileInputStream ->
109 | File(directory, filename).outputStream().use { fileOutputStream ->
110 | val buffer = ByteArray(1 shl 14)
111 | while (true){
112 | if(isCancelled) return@forEach
113 | val readBytes = fileInputStream.read(buffer)
114 | if(readBytes <= 0) break
115 | fileOutputStream.write(buffer, 0, readBytes)
116 | transfered += readBytes
117 | counter++
118 | if (counter % 10 == 0) publishProgress(Pair((transfered shr 10).toInt(), (totalSize shr 10).toInt()))
119 | }
120 | }
121 | }
122 |
123 | }
124 | }
125 |
126 | override fun onPreExecute() {
127 | //progressDialog.isIndeterminate = false
128 | progressDialog.setTitle(R.string.image_chooser_copying_dialog)
129 | progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL)
130 | progressDialog.show()
131 | }
132 |
133 | override fun onProgressUpdate(vararg values: Pair) {
134 | val (progress, max) = values[0]
135 | progressDialog.progress = progress
136 | progressDialog.max = max
137 | progressDialog.isIndeterminate = max == -1
138 | }
139 |
140 | override fun onPostExecute(result: Unit?) {
141 | progressDialog.dismiss()
142 | }
143 |
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/app/src/main/java/streetwalrus/usbmountr/ImageFilesAdapter.kt:
--------------------------------------------------------------------------------
1 | package streetwalrus.usbmountr
2 |
3 | import android.app.Activity
4 | import android.content.Intent
5 | import android.net.Uri
6 | import android.view.LayoutInflater
7 | import androidx.recyclerview.widget.RecyclerView
8 | import android.view.View
9 | import android.view.ViewGroup
10 | import android.widget.TextView
11 | import android.widget.Toast
12 | import java.io.File
13 |
14 | class ImageFilesAdapter(directory: File, val activity: Activity) : RecyclerView.Adapter() {
15 | private var fileList = directory.listFiles()!!
16 |
17 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ImageFilesViewHolder {
18 | val view = LayoutInflater.from(parent.context).inflate(R.layout.image_chooser_row, parent, false)
19 | return ImageFilesViewHolder(view)
20 | }
21 |
22 | override fun getItemCount(): Int {
23 | return fileList.size
24 | }
25 |
26 | override fun onBindViewHolder(holder: ImageFilesViewHolder, position: Int) {
27 | val file = fileList[position]
28 | val size = if(file.isDirectory)
29 | 0.0
30 | else
31 | file.length().toDouble() / (1 shl 20)
32 | holder.filename.text = file.name
33 | holder.fileSize.text = holder.fileSize.context.getString(R.string.image_chooser_filesize_mib, size)
34 | if(file.isFile) {
35 | holder.view.setOnClickListener {
36 | val result = Intent()
37 | result.putExtra("path", file.path)
38 | activity.setResult(Activity.RESULT_OK, result)
39 | activity.finish()
40 | }
41 | }
42 | }
43 |
44 | class ImageFilesViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
45 | val filename = view.findViewById(R.id.filename)!!
46 | val fileSize = view.findViewById(R.id.file_size)!!
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/app/src/main/java/streetwalrus/usbmountr/LicenseActivity.kt:
--------------------------------------------------------------------------------
1 | package streetwalrus.usbmountr
2 |
3 | import android.app.AlertDialog
4 | import android.app.ListActivity
5 | import android.content.Intent
6 | import android.content.res.XmlResourceParser
7 | import android.net.Uri
8 | import android.os.Bundle
9 | import android.preference.Preference
10 | import android.text.method.ScrollingMovementMethod
11 | import android.view.View
12 | import android.view.ViewGroup
13 | import android.widget.ArrayAdapter
14 | import android.widget.ImageView
15 | import android.widget.ListView
16 | import android.widget.TextView
17 | import java.io.InputStreamReader
18 |
19 | class LicenseActivity : ListActivity() {
20 | private val TAG = "LicenseActivity"
21 |
22 | private var prefLayout = -1
23 |
24 | private var mList: ListView? = null
25 |
26 | override fun onCreate(savedInstanceState: Bundle?) {
27 | super.onCreate(savedInstanceState)
28 | setContentView(R.layout.activity_licenses)
29 |
30 | // HAX
31 | prefLayout = Preference(this).layoutResource
32 |
33 | val licenseList: MutableList = mutableListOf()
34 | val xrp = resources.getXml(R.xml.licenses)
35 | while (xrp.eventType != XmlResourceParser.END_DOCUMENT) {
36 | xrp.next()
37 | if (xrp.eventType == XmlResourceParser.START_TAG && xrp.name == "license") {
38 | licenseList.add(License(xrp))
39 | }
40 | }
41 |
42 | mList = findViewById(android.R.id.list)
43 | val licensesAdapter = LicenseArrayAdapter(licenseList)
44 | mList!!.adapter = licensesAdapter
45 | }
46 |
47 | override fun onListItemClick(l: ListView, v: View, position: Int, id: Long) {
48 | val licenseTextLayout = layoutInflater.inflate(R.layout.dialog_license, null, false)
49 | val licenseTextView = licenseTextLayout.findViewById(R.id.textView)
50 | val lic = (l.adapter as LicenseArrayAdapter).getItem(position)
51 | licenseTextView.text = InputStreamReader(assets.open("licenses/${lic.file}")).readText()
52 | licenseTextView.movementMethod = ScrollingMovementMethod()
53 | AlertDialog.Builder(this@LicenseActivity)
54 | .setTitle(lic.name)
55 | .setView(licenseTextLayout)
56 | .setPositiveButton(R.string.licenses_upstream, { dialog, which ->
57 | val intent = Intent(Intent.ACTION_VIEW, Uri.parse(lic.url))
58 | startActivity(intent)
59 | })
60 | .show()
61 | }
62 |
63 | private inner class License(xrp: XmlResourceParser) {
64 | val name: String = xrp.getAttributeValue(null, "name")
65 | val type: String? = xrp.getAttributeValue(null, "type")
66 | val file: String? = xrp.getAttributeValue(null, "file")
67 | val url: String? = xrp.getAttributeValue(null, "url")
68 |
69 | var view: View? = null
70 | fun getView(parent: ViewGroup): View? {
71 | if (view == null) {
72 | // MOAR HAX
73 | // Abuse the Preference layout whose ID was retrieved earlier to create our View
74 | view = layoutInflater.inflate(prefLayout, parent, false)
75 | if (android.os.Build.VERSION.SDK_INT >= 24)
76 | (view!!.findViewById(android.R.id.icon_frame)).visibility = View.GONE
77 | (view!!.findViewById(android.R.id.icon)).visibility = View.GONE
78 | (view!!.findViewById(android.R.id.title)).text = name
79 | val summary = view!!.findViewById(android.R.id.summary)
80 | if (type != null)
81 | summary.text = type
82 | else
83 | summary.visibility = View.GONE
84 | (view!!.findViewById(android.R.id.widget_frame)).visibility = View.GONE
85 | }
86 | return view
87 | }
88 | }
89 |
90 | private inner class LicenseArrayAdapter(licenses: List)
91 | : ArrayAdapter(this, 0, licenses) {
92 | override fun getView(position: Int, convertView: View?, parent: ViewGroup): View? {
93 | return getItem(position).getView(parent)
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/app/src/main/java/streetwalrus/usbmountr/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package streetwalrus.usbmountr
2 |
3 | import android.app.Activity
4 | import android.content.Intent
5 | import android.os.AsyncTask
6 | import android.os.Bundle
7 | import android.util.Log
8 | import android.view.Menu
9 | import android.view.MenuItem
10 | import android.view.View
11 | import android.widget.Toast
12 | import eu.chainfire.libsuperuser.Shell
13 |
14 | class MainActivity : Activity() {
15 | private val TAG = "MainActivity"
16 |
17 | private var mPrefs: HostPreferenceFragment? = null
18 |
19 | override fun onCreate(savedInstanceState: Bundle?) {
20 | super.onCreate(savedInstanceState)
21 | setContentView(R.layout.activity_main)
22 |
23 | mPrefs = fragmentManager.findFragmentById(R.id.prefs) as HostPreferenceFragment
24 | }
25 |
26 | override fun onCreateOptionsMenu(menu: Menu): Boolean {
27 | menuInflater.inflate(R.menu.menu_main, menu)
28 | return super.onCreateOptionsMenu(menu)
29 | }
30 |
31 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
32 | when (item.itemId) {
33 | R.id.menu_licenses -> {
34 | val intent = Intent(this, LicenseActivity::class.java)
35 | startActivity(intent)
36 | }
37 | else -> return super.onOptionsItemSelected(item)
38 | }
39 |
40 | return true
41 | }
42 |
43 | override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
44 | val appContext = applicationContext as UsbMountrApplication
45 | appContext.onActivityResult(requestCode, resultCode, resultData)
46 | }
47 |
48 | @Suppress("unused")
49 | fun onServeClicked(@Suppress("UNUSED_PARAMETER") v: View) {
50 | // Escape the file name to avoid bugs in the shell
51 | // Could use some finer filters but who cares
52 | val file = "(.)".toRegex().replace(
53 | mPrefs!!.preferenceManager.sharedPreferences
54 | .getString(mPrefs!!.SOURCE_KEY, ""),
55 | "\\\\$1")
56 |
57 | val ro = if (mPrefs!!.preferenceManager.sharedPreferences
58 | .getBoolean(mPrefs!!.RO_KEY, true)) "1" else "0"
59 |
60 | UsbScript().execute(file, ro, "1")
61 | }
62 |
63 | @Suppress("unused")
64 | fun onDisableClicked(@Suppress("UNUSED_PARAMETER") v: View) {
65 | UsbScript().execute("", "1", "0")
66 | }
67 |
68 | inner class UsbScript : AsyncTask() {
69 | override fun doInBackground(vararg params: String): Int {
70 | val usb = "/sys/class/android_usb/android0"
71 | val file = params[0]
72 | val ro = params[1]
73 | val enable = params[2]
74 |
75 | if (!(Shell.SU.run(arrayOf(
76 | "echo 0 > $usb/enable",
77 | // Try to append if the function is not already enabled (by ourselves most likely)
78 | "grep mass_storage $usb/functions > /dev/null || sed -e 's/$/,mass_storage/' $usb/functions | cat > $usb/functions",
79 | // If empty, set ourselves as the only function
80 | "[[ -z $(cat $usb/functions) ]] && echo mass_storage > $usb/functions",
81 | // Disable the feature if told to
82 | "[[ 0 == $enable ]] && sed -e 's/mass_storage//' $usb/functions | cat > $usb/functions",
83 | "echo disk > $usb/f_mass_storage/luns",
84 | "echo USBMountr > $usb/f_mass_storage/inquiry_string",
85 | "echo 1 > $usb/enable",
86 | "[[ -f $usb/f_mass_storage/luns ]] && echo > $usb/f_mass_storage/lun0/file",
87 | "[[ -f $usb/f_mass_storage/luns ]] && echo $ro > $usb/f_mass_storage/lun0/ro",
88 | "[[ -f $usb/f_mass_storage/luns ]] && echo $file > $usb/f_mass_storage/lun0/file",
89 | // Older kernels only support a single lun, cope with it
90 | "[[ ! -f $usb/f_mass_storage/luns ]] && echo > $usb/f_mass_storage/lun/file",
91 | "[[ ! -f $usb/f_mass_storage/luns ]] && echo $ro > $usb/f_mass_storage/lun/ro",
92 | "[[ ! -f $usb/f_mass_storage/luns ]] && echo $file > $usb/f_mass_storage/lun/file",
93 | "echo success"
94 | ))?.isEmpty() ?: true)) {
95 | if (enable != "0") {
96 | return R.string.host_success
97 | } else {
98 | return R.string.host_disable_success
99 | }
100 | } else {
101 | return R.string.host_noroot
102 | }
103 | }
104 |
105 | override fun onPostExecute(result: Int) {
106 | Toast.makeText(applicationContext, getString(result), Toast.LENGTH_SHORT).show()
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/app/src/main/java/streetwalrus/usbmountr/RequestCodes.kt:
--------------------------------------------------------------------------------
1 | package streetwalrus.usbmountr
2 |
3 | const val REQUEST_CODE_OPEN_FILE = 1
4 | const val REQUEST_CODE_IMPORT_FILE = 2
5 |
--------------------------------------------------------------------------------
/app/src/main/java/streetwalrus/usbmountr/UsbMountrApplication.kt:
--------------------------------------------------------------------------------
1 | package streetwalrus.usbmountr
2 |
3 | import android.app.Application
4 | import android.content.Intent
5 |
6 | class UsbMountrApplication : Application() {
7 | val mActivityResultDispatcher: ActivityResultDispatcher = ActivityResultDispatcher()
8 |
9 | fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
10 | mActivityResultDispatcher.onActivityResult(requestCode, resultCode, resultData)
11 | }
12 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_image_chooser.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_licenses.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
22 |
23 |
27 |
28 |
36 |
37 |
45 |
46 |
47 |
50 |
51 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_license.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/image_chooser_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
17 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_image_chooser.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dratini0/phonestick/5d8c76862834e69587fce338f65d9c7a128aa4cf/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dratini0/phonestick/5d8c76862834e69587fce338f65d9c7a128aa4cf/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dratini0/phonestick/5d8c76862834e69587fce338f65d9c7a128aa4cf/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dratini0/phonestick/5d8c76862834e69587fce338f65d9c7a128aa4cf/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dratini0/phonestick/5d8c76862834e69587fce338f65d9c7a128aa4cf/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-de/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | USB Mountr
3 |
4 | Lizenzen
5 | Originalquellen
6 |
7 | Keine Datei ausgewählt
8 |
9 |
10 | Imagedatei
11 | Schreibschutz
12 | Verhindert dass der PC auf das Image schreiben beziehungsweise Dateien verändern kann
13 | Mounten
14 | Unmounten
15 | Diese Applikation versucht mit dem Android USB-Subsystem zu koexistieren, aber Android kann die von der App vorgenommmenen Änderungen am System jederzeit zurücksetzen.
16 |
17 |
18 |
19 |
20 | Das Laufwerk sollte nun auf Ihrem PC angezeigt werden
21 | Das Laufwerk sollte nun nicht mehr auf Ihrem PC angezeigt werden
22 | Root-Zugriff verweigert
23 | Bitte geben Sie der App die Berechtigung für den Zugriff auf den Speicher um auf diese Datei zugreifen zu können
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/values-fr/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | USB Mountr
3 | Licences
4 | Source
5 | Aucun
6 |
7 |
8 | Fichier image
9 | Lecture seule
10 | Empèche l\'ordinateur d\'écrire dans l\'image
11 | Monter
12 | Démonter
13 | Cette application va essayer de coexister avec les services USB Android,
14 | mais le système peut les désactiver à tout momment.
15 |
16 |
17 |
18 |
19 | Le disque devrait apparaître sur votre ordinateur
20 | Le disque devrait disparaître de votre ordinateur
21 | Impossible d\'obtenir les droits de super-utilisateur
22 | Merci de donner accès au stockage pour accéder aux fichiers
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/values-it/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | USB Mountr
3 |
4 | Licenze
5 | Sorgente upstream
6 |
7 | Nessuno
8 |
9 |
10 | File immagine
11 | Sola lettura
12 | Impedisci al PC di scrivere sull\'immagine
13 | Monta
14 | Smonta
15 | L\'applicazione proverà a coesistere con i servizi USB di Android, ma è molto probabile che il sistema sovrascriva questi effetti in qualsiasi momento.
16 |
17 |
18 |
19 |
20 | Il dispositivo dovrebbe ora apparire sul tuo PC
21 | Il dispositivo dovrebbe ora scomparire dal tuo PC
22 | Impossibile ottenere permessi di root
23 | Consentire l\'accesso alla memoria per selezionare questo file
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/values-lt/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | USB prijungėjas
3 | Leidimai
4 | Pirminis kodas
5 | Nieko
6 |
7 |
8 | Atvaizdo byla
9 | Tikskaityti
10 | Neleistikompiuteriuiįrašinėtiįatvaizdą
11 | Prijungti
12 | Nuimti
13 | Šiprogramėlė bando veiktigreta Android USB paslaugų, bet
14 | sistema bet kuriuo metugaliapeitiprogramėlės funkcijas
15 |
16 |
17 |
18 |
19 | Įrenginys dabarturėtųpasirodytiJ ūsųkompiuteryje
20 | Įrenginys dabarturėtųpradingtiiš J ūsų
21 | kompiuterio
22 | Negaligautišakninės prieigos
23 | Prašome suteikti prieigą prie saugyklos, kad pasiektumėte šį failą
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 8dp
6 | 16dp
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | USB Mountr
3 |
4 | Licenses
5 | Upstream source
6 |
7 | None
8 |
9 |
10 | Image file
11 | Read-only
12 | Prevent the PC from writing to the image
13 | Mount
14 | Unmount
15 | This application will try to coexist with Android\'s USB services,
16 | but the system is very likely to override its effects at any moment.
17 |
18 |
19 |
20 | Image files
21 | %1$.1f MiB
22 | Add new image
23 | Copying image file
24 |
25 |
26 | The device should now show up on your PC
27 | The device should now disappear from your PC
28 | Couldn\'t get root access
29 | Please grant access to storage to access this file
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/host_preferences.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/licenses.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
14 |
15 |
20 |
21 |
26 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.3.0'
5 | repositories {
6 | jcenter()
7 | google()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.1.0'
11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | jcenter()
21 | google()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dratini0/phonestick/5d8c76862834e69587fce338f65d9c7a128aa4cf/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Apr 26 19:17:45 BST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dratini0/phonestick/5d8c76862834e69587fce338f65d9c7a128aa4cf/screenshot.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------