diff --git a/app/build.gradle b/app/build.gradle index 087de43f..387f3090 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,9 +12,9 @@ android { applicationId = "info.dvkr.screenstream" minSdkVersion(21) targetSdkVersion(30) - versionCode = 30415 - versionName = "3.4.15" - resConfigs("en", "ru", "pt-rBR", "zh-rTW", "fr-rFR", "fa", "it", "pl", "hi", "de", "sk", "es", "ar", "ja", "gl","cat") + versionCode = 30500 + versionName = "3.5.0" + resConfigs("en", "ru", "pt-rBR", "zh-rTW", "fr-rFR", "fa", "it", "pl", "hi", "de", "sk", "es", "ar", "ja", "gl", "cat") vectorDrawables.useSupportLibrary = true } @@ -29,6 +29,10 @@ android { minifyEnabled = true shrinkResources = true proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + + packagingOptions { + exclude("DebugProbesKt.bin") + } } } @@ -48,15 +52,15 @@ android { } sourceSets { - main.java.srcDirs += 'src/main/kotlin' + main.java.srcDirs += "src/main/kotlin" - firebase.java.srcDirs += 'src/firebase/kotlin' - firebaseDebug.java.srcDirs += 'src/firebaseDebug/kotlin' - firebaseRelease.java.srcDirs += 'src/firebaseRelease/kotlin' + firebase.java.srcDirs += "src/firebase/kotlin" + firebaseDebug.java.srcDirs += "src/firebaseDebug/kotlin" + firebaseRelease.java.srcDirs += "src/firebaseRelease/kotlin" - firebasefree.java.srcDirs += 'src/firebasefree/kotlin' - firebasefreeDebug.java.srcDirs += 'src/firebasefreeDebug/kotlin' - firebasefreeRelease.java.srcDirs += 'src/firebasefreeRelease/kotlin' + firebasefree.java.srcDirs += "src/firebasefree/kotlin" + firebasefreeDebug.java.srcDirs += "src/firebasefreeDebug/kotlin" + firebasefreeRelease.java.srcDirs += "src/firebasefreeRelease/kotlin" } packagingOptions { @@ -67,24 +71,22 @@ android { kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8.toString() freeCompilerArgs += ["-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"] -// freeCompilerArgs += ["-Xopt-in=kotlinx.coroutines.ObsoleteCoroutinesApi"] -// freeCompilerArgs += ["-Xopt-in=kotlinx.coroutines.FlowPreview"] } } dependencies { implementation(project(":data")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.0-M1") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.0-M1") implementation("com.google.android.material:material:1.2.1") implementation("androidx.appcompat:appcompat:1.2.0") - implementation('androidx.fragment:fragment-ktx:1.2.5') + implementation("androidx.fragment:fragment-ktx:1.2.5") implementation("androidx.recyclerview:recyclerview:1.1.0") - implementation("androidx.constraintlayout:constraintlayout:2.0.1") - implementation("androidx.navigation:navigation-fragment-ktx:2.3.0") - implementation("androidx.navigation:navigation-ui-ktx:2.3.0") + implementation("androidx.constraintlayout:constraintlayout:2.0.2") + implementation("androidx.navigation:navigation-fragment-ktx:2.3.1") + implementation("androidx.navigation:navigation-ui-ktx:2.3.1") implementation("androidx.viewpager2:viewpager2:1.0.0") implementation("androidx.lifecycle:lifecycle-livedata:2.2.0") implementation("androidx.lifecycle:lifecycle-common-java8:2.2.0") @@ -101,14 +103,14 @@ dependencies { implementation("com.github.iamironz:binaryprefs:1.0.1") implementation("com.elvishew:xlog:1.6.1") - firebaseImplementation('com.google.android.play:core:1.8.0') + firebaseImplementation("com.google.android.play:core:1.8.2") firebaseImplementation("com.google.android.play:core-ktx:1.8.1") { - exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk7' + exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib-jdk7" } - firebaseReleaseImplementation('com.google.firebase:firebase-analytics:17.5.0') - firebaseReleaseImplementation('com.google.firebase:firebase-crashlytics:17.2.1') + firebaseReleaseImplementation("com.google.firebase:firebase-analytics:17.6.0") + firebaseReleaseImplementation("com.google.firebase:firebase-crashlytics:17.2.2") - debugImplementation("com.squareup.leakcanary:leakcanary-android:2.4") + debugImplementation("com.squareup.leakcanary:leakcanary-android:2.5") } android.applicationVariants.all { diff --git a/app/src/main/kotlin/info/dvkr/screenstream/ui/activity/AppActivity.kt b/app/src/main/kotlin/info/dvkr/screenstream/ui/activity/AppActivity.kt index 4e83e94f..c37c6425 100644 --- a/app/src/main/kotlin/info/dvkr/screenstream/ui/activity/AppActivity.kt +++ b/app/src/main/kotlin/info/dvkr/screenstream/ui/activity/AppActivity.kt @@ -56,14 +56,18 @@ class AppActivity : PermissionActivity(R.layout.activity_app) { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + routeIntentAction(intent) + } + + override fun onPostCreate(savedInstanceState: Bundle?) { + super.onPostCreate(savedInstanceState) + with(findNavController(R.id.fr_activity_app_nav_host_fragment)) { binding.bottomNavigationActivityApp.setupWithNavController(this) addOnDestinationChangedListener { _, destination, _ -> if (destination.id == R.id.nav_exitFragment) IntentAction.Exit.sendToAppService(this@AppActivity) } } - - routeIntentAction(intent) } override fun onNewIntent(intent: Intent?) { diff --git a/app/src/main/kotlin/info/dvkr/screenstream/ui/activity/ServiceActivity.kt b/app/src/main/kotlin/info/dvkr/screenstream/ui/activity/ServiceActivity.kt index 2119a6b4..6d083d2c 100644 --- a/app/src/main/kotlin/info/dvkr/screenstream/ui/activity/ServiceActivity.kt +++ b/app/src/main/kotlin/info/dvkr/screenstream/ui/activity/ServiceActivity.kt @@ -10,7 +10,6 @@ import androidx.annotation.LayoutRes import androidx.appcompat.app.AppCompatDelegate import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.Observer import androidx.lifecycle.coroutineScope import com.elvishew.xlog.XLog import info.dvkr.screenstream.data.other.getLog @@ -69,7 +68,7 @@ abstract class ServiceActivity(@LayoutRes contentLayoutId: Int) : AppUpdateActiv override fun onStart() { super.onStart() - serviceMessageLiveData.observe(this, Observer { message -> message?.let { onServiceMessage(it) } }) + serviceMessageLiveData.observe(this, { message -> message?.let { onServiceMessage(it) } }) bindService(AppService.getAppServiceIntent(this), serviceConnection, Context.BIND_AUTO_CREATE) settings.registerChangeListener(settingsListener) diff --git a/app/src/main/kotlin/info/dvkr/screenstream/ui/fragment/StreamFragment.kt b/app/src/main/kotlin/info/dvkr/screenstream/ui/fragment/StreamFragment.kt index 367ed6b2..d13443fa 100644 --- a/app/src/main/kotlin/info/dvkr/screenstream/ui/fragment/StreamFragment.kt +++ b/app/src/main/kotlin/info/dvkr/screenstream/ui/fragment/StreamFragment.kt @@ -14,7 +14,6 @@ import androidx.appcompat.widget.AppCompatImageView import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import androidx.lifecycle.Lifecycle -import androidx.lifecycle.Observer import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter @@ -75,7 +74,7 @@ class StreamFragment : Fragment(R.layout.fragment_stream) { XLog.d(getLog("onStart", "Invoked")) (requireActivity() as ServiceActivity).getServiceMessageLiveData() - .observe(this, Observer { serviceMessage -> + .observe(this, { serviceMessage -> when (serviceMessage) { is ServiceMessage.ServiceState -> onServiceStateMessage(serviceMessage) is ServiceMessage.Clients -> onClientsMessage(serviceMessage) diff --git a/app/src/main/kotlin/info/dvkr/screenstream/ui/view/ExpansionHeader.kt b/app/src/main/kotlin/info/dvkr/screenstream/ui/view/ExpansionHeader.kt index 65473575..8b0f0056 100644 --- a/app/src/main/kotlin/info/dvkr/screenstream/ui/view/ExpansionHeader.kt +++ b/app/src/main/kotlin/info/dvkr/screenstream/ui/view/ExpansionHeader.kt @@ -107,9 +107,9 @@ class ExpansionHeader @JvmOverloads constructor( indicatorAnimator?.cancel() indicatorAnimator = if (willExpand) { - ObjectAnimator.ofFloat(it, View.ROTATION, headerRotationExpanded.toFloat()) + ObjectAnimator.ofFloat(it, View.ROTATION, headerRotationExpanded.toFloat()) } else { - ObjectAnimator.ofFloat(it, View.ROTATION, headerRotationCollapsed.toFloat()) + ObjectAnimator.ofFloat(it, View.ROTATION, headerRotationCollapsed.toFloat()) } indicatorAnimator?.addListener(object : AnimatorListenerAdapter() { diff --git a/app/src/main/res/layout/activity_app.xml b/app/src/main/res/layout/activity_app.xml index 77258e67..5d52397a 100644 --- a/app/src/main/res/layout/activity_app.xml +++ b/app/src/main/res/layout/activity_app.xml @@ -49,7 +49,7 @@ android:background="@drawable/view_shadow_bottom" app:layout_constraintTop_toBottomOf="@id/ll_activity_app_logs" /> - (State.CREATED) + private val state = AtomicReference(State.CREATED) private var serverEventLoop: EventLoopGroup? = null private var nettyHttpServer: HttpServer? = null private var httpServerRxHandler: HttpServerRxHandler? = null diff --git a/data/src/main/kotlin/info/dvkr/screenstream/data/httpserver/ClientStatistic.kt b/data/src/main/kotlin/info/dvkr/screenstream/data/httpserver/ClientStatistic.kt index cc86a4ce..ab30c34f 100644 --- a/data/src/main/kotlin/info/dvkr/screenstream/data/httpserver/ClientStatistic.kt +++ b/data/src/main/kotlin/info/dvkr/screenstream/data/httpserver/ClientStatistic.kt @@ -53,10 +53,9 @@ class ClientStatistic( var sendBytes: Long = 0, var disconnectedTime: Long = 0 ) { - internal fun isDisconnectHoldTimePass(now: Long) = - (now - disconnectedTime) > CLIENT_DISCONNECT_HOLD_TIME_SECONDS * 1000 + fun isDisconnectHoldTimePass(now: Long) = (now - disconnectedTime) > CLIENT_DISCONNECT_HOLD_TIME_SECONDS * 1000 - internal fun toHttpClient() = HttpClient(id, clientAddressAndPort, isSlowConnection, isDisconnected) + fun toHttpClient() = HttpClient(id, clientAddressAndPort, isSlowConnection, isDisconnected) } private val statisticEventChannel = statisticScope.actor(capacity = 64) { diff --git a/data/src/main/kotlin/info/dvkr/screenstream/data/httpserver/HttpServerRxHandler.kt b/data/src/main/kotlin/info/dvkr/screenstream/data/httpserver/HttpServerRxHandler.kt index 8798dbed..8fa9f7f2 100644 --- a/data/src/main/kotlin/info/dvkr/screenstream/data/httpserver/HttpServerRxHandler.kt +++ b/data/src/main/kotlin/info/dvkr/screenstream/data/httpserver/HttpServerRxHandler.kt @@ -24,7 +24,6 @@ import kotlinx.coroutines.ensureActive import kotlinx.coroutines.launch import rx.BackpressureOverflow import rx.Observable -import rx.functions.Action0 import java.io.ByteArrayOutputStream import java.net.InetAddress import java.net.InetSocketAddress @@ -154,7 +153,7 @@ internal class HttpServerRxHandler( .observeOn(eventloopScheduler) .onBackpressureBuffer( 2, - Action0 { + { clientStatistic.sendEvent( ClientStatistic.StatisticEvent.Backpressure(clientAddress.hashCode().toLong()) ) @@ -187,6 +186,6 @@ internal class HttpServerRxHandler( addHeader(HttpHeaderNames.CONTENT_TYPE, "text/plain; charset=UTF-8") setHeader(HttpHeaderNames.CACHE_CONTROL, "no-cache,no-store,max-age=0,must-revalidate") setHeader(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE) - return Observable.empty() + return Observable.empty() } } \ No newline at end of file diff --git a/data/src/main/kotlin/info/dvkr/screenstream/data/httpserver/HttpServerThreadFactory.kt b/data/src/main/kotlin/info/dvkr/screenstream/data/httpserver/HttpServerThreadFactory.kt index 3a1083c9..5e5aac26 100644 --- a/data/src/main/kotlin/info/dvkr/screenstream/data/httpserver/HttpServerThreadFactory.kt +++ b/data/src/main/kotlin/info/dvkr/screenstream/data/httpserver/HttpServerThreadFactory.kt @@ -49,7 +49,7 @@ internal class HttpServerThreadFactory private constructor( private fun newThread(r: Runnable, name: String): Thread = FastThreadLocalThread(threadGroup, r, name) - private class DefaultRunnableDecorator internal constructor(private val r: Runnable) : Runnable { + private class DefaultRunnableDecorator constructor(private val r: Runnable) : Runnable { override fun run() { try { r.run() diff --git a/data/src/main/kotlin/info/dvkr/screenstream/data/image/BitmapCapture.kt b/data/src/main/kotlin/info/dvkr/screenstream/data/image/BitmapCapture.kt index 884f27ac..6d36b51e 100644 --- a/data/src/main/kotlin/info/dvkr/screenstream/data/image/BitmapCapture.kt +++ b/data/src/main/kotlin/info/dvkr/screenstream/data/image/BitmapCapture.kt @@ -56,8 +56,6 @@ class BitmapCapture( @Volatile private var state: State = State.INIT - private var fallback: Boolean = false - private val imageThread: HandlerThread by lazy { HandlerThread("BitmapCapture", Process.THREAD_PRIORITY_BACKGROUND) } @@ -65,19 +63,20 @@ class BitmapCapture( private var imageListener: ImageListener? = null private var imageReader: ImageReader? = null + private var lastImageMillis: Long = 0L private var virtualDisplay: VirtualDisplay? = null - private var fallbackListener: FallbackListener? = null + private var fallback: Boolean = false + private var fallbackFrameListener: FallbackFrameListener? = null private var mEglCore: EglCore? = null private var mProducerSide: Surface? = null private var mTexture: SurfaceTexture? = null private var mTextureId = 0 private var mConsumerSide: OffscreenSurface? = null - private var mShader: Texture2dProgram? = null private var mScreen: FullFrameRect? = null private var mBuf: ByteBuffer? = null - private val matrix = AtomicReference(Matrix()) + private val matrix = AtomicReference(Matrix()) private val resizeFactor = AtomicInteger(Settings.Values.RESIZE_DISABLED) private val rotation = AtomicInteger(Settings.Values.ROTATION_0) @@ -180,25 +179,26 @@ class BitmapCapture( if (fallback.not()) { imageListener = ImageListener(settingsReadOnly) imageReader = ImageReader.newInstance(screenSizeX, screenSizeY, PixelFormat.RGBA_8888, 2) - .apply { setOnImageAvailableListener(imageListener, imageThreadHandler) } + .apply { setOnImageAvailableListener(imageListener, imageThreadHandler) } } else { try { - fallbackListener = FallbackListener(settingsReadOnly, screenSizeX, screenSizeY) mEglCore = EglCore(null, EglCore.FLAG_TRY_GLES3 or EglCore.FLAG_RECORDABLE) mConsumerSide = OffscreenSurface(mEglCore, screenSizeX, screenSizeY) mConsumerSide!!.makeCurrent() - mShader = Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT) - mScreen = FullFrameRect(mShader) - mTexture = - SurfaceTexture(mScreen!!.createTextureObject().also { mTextureId = it }, false) - mTexture!!.setDefaultBufferSize(screenSizeX, screenSizeY) + + fallbackFrameListener = FallbackFrameListener(settingsReadOnly, screenSizeX, screenSizeY) + mBuf = ByteBuffer.allocate(screenSizeX * screenSizeY * 4).apply { order(ByteOrder.nativeOrder()) } + mScreen = FullFrameRect(Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT)) + mTextureId = mScreen!!.createTextureObject() + mTexture = SurfaceTexture(mTextureId, false).apply { + setDefaultBufferSize(screenSizeX, screenSizeY) + setOnFrameAvailableListener(fallbackFrameListener, imageThreadHandler) + } mProducerSide = Surface(mTexture) - mTexture!!.setOnFrameAvailableListener(fallbackListener, imageThreadHandler) - mBuf = ByteBuffer.allocate(screenSizeX * screenSizeY * 4) - mBuf!!.order(ByteOrder.nativeOrder()) + mEglCore!!.makeNothingCurrent() - } catch (ex: Exception) { - XLog.w(this@BitmapCapture.getLog("outBitmapChannel", ex.toString())) + } catch (cause: Throwable) { + XLog.w(this@BitmapCapture.getLog("startDisplayCapture", cause.toString())) state = State.ERROR onError(FatalError.BitmapFormatException) } @@ -228,12 +228,11 @@ class BitmapCapture( private fun stopDisplayCapture() { virtualDisplay?.release() imageReader?.close() - if (fallback) { - mProducerSide?.release() - mTexture?.release() - mConsumerSide?.release() - mEglCore?.release() - } + + mProducerSide?.release() + mTexture?.release() + mConsumerSide?.release() + mEglCore?.release() } @Synchronized @@ -249,37 +248,29 @@ class BitmapCapture( } /** https://stackoverflow.com/a/34741581 **/ - - private inner class FallbackListener( - private val settingsReadOnly: SettingsReadOnly, - private val width: Int, - private val height: Int + private inner class FallbackFrameListener( + private val settingsReadOnly: SettingsReadOnly, private val width: Int, private val height: Int ) : SurfaceTexture.OnFrameAvailableListener { - override fun onFrameAvailable(p0: SurfaceTexture?) { + override fun onFrameAvailable(surfaceTexture: SurfaceTexture?) { synchronized(this@BitmapCapture) { - if (state != State.STARTED || this != fallbackListener) return + if (state != State.STARTED || this != fallbackFrameListener) return mConsumerSide!!.makeCurrent() - - var mtx = FloatArray(16) - mTexture!!.updateTexImage() - mTexture!!.getTransformMatrix(mtx) val now = System.currentTimeMillis() - if ((now - lastImageMillis) < (1000 / settingsReadOnly.maxFPS)) { - return - } + ((now - lastImageMillis) >= (1000 / settingsReadOnly.maxFPS)) || return lastImageMillis = now - mConsumerSide!!.makeCurrent() + FloatArray(16).let { matrix -> + mTexture!!.getTransformMatrix(matrix) + mScreen!!.drawFrame(mTextureId, matrix) + } - mScreen!!.drawFrame(mTextureId, mtx) mConsumerSide!!.swapBuffers() mBuf!!.rewind() GLES20.glReadPixels(0, 0, width, height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, mBuf) - mBuf!!.rewind() val cleanBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) cleanBitmap.copyPixelsFromBuffer(mBuf) @@ -290,10 +281,8 @@ class BitmapCapture( if (outBitmapChannel.isClosedForSend.not()) outBitmapChannel.offer(upsizedBitmap) } } - } - // Runs on imageThread private inner class ImageListener( private val settingsReadOnly: SettingsReadOnly, ) : ImageReader.OnImageAvailableListener { @@ -319,9 +308,9 @@ class BitmapCapture( if (outBitmapChannel.isClosedForSend.not()) outBitmapChannel.offer(upsizedBitmap) } } catch (ex: UnsupportedOperationException) { - XLog.d("unsupported image format, switching to fallback image reader") - fallback = true - restart() + XLog.d("unsupported image format, switching to fallback image reader") + fallback = true + restart() } catch (throwable: Throwable) { XLog.e(this@BitmapCapture.getLog("outBitmapChannel"), throwable) state = State.ERROR @@ -352,8 +341,6 @@ class BitmapCapture( } } - private var lastImageMillis: Long = 0L - private fun getCroppedBitmap(bitmap: Bitmap): Bitmap { if (settingsReadOnly.vrMode == Settings.Default.VR_MODE_DISABLE && settingsReadOnly.imageCrop.not()) return bitmap diff --git a/gradle.properties b/gradle.properties index ebc13b5f..f8b67c2c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx4g +org.gradle.jvmargs=-Xmx2g android.useAndroidX=true android.enableJetifier=false diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index f6b961fd..f3d88b1c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3ded877c..8db0d0d9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed Mar 25 10:48:56 EET 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip diff --git a/gradlew b/gradlew index cccdd3d5..2fe81a7d 100644 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -109,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` @@ -138,19 +154,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -159,14 +175,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f9553162..9618d8d9 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome