From: kfl_614 Date: Tue, 8 Dec 2020 01:39:30 +0000 (+0800) Subject: first commit. X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=48d1ac774ab3b393a77540bc8c480ff7626e5138;p=IcTemperature.git first commit. --- 48d1ac774ab3b393a77540bc8c480ff7626e5138 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..81b4fd1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,88 @@ +# Built application files +*.apk +*.aar +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +# Uncomment the following line in case you need and you don't have the release build type files in your app +# release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild +.cxx/ + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ + +# Android Profiling +*.hprof \ No newline at end of file diff --git a/.idea/$PROJECT_FILE$ b/.idea/$PROJECT_FILE$ new file mode 100644 index 0000000..58b7e3e --- /dev/null +++ b/.idea/$PROJECT_FILE$ @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..7cd0af1 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +Temperature \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..3c7772a --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,139 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..a5f05cd --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..9f83622 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/qaplug_profiles.xml b/.idea/qaplug_profiles.xml new file mode 100644 index 0000000..3dfd21f --- /dev/null +++ b/.idea/qaplug_profiles.xml @@ -0,0 +1,465 @@ + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..dc45aca --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,51 @@ +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'kotlin-kapt' +} + +android { + compileSdkVersion 29 + + defaultConfig { + applicationId "com.ic.temperature" + minSdkVersion 19 + targetSdkVersion 29 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } + dataBinding { + enabled = true + } +} + +dependencies { + + def lifecycle_version = "2.2.0" + + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'com.google.android.material:material:1.2.1' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + implementation 'com.github.silvestrpredko:dot-progress-bar:1.1' + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/com/ic/temperature/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/ic/temperature/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..bba05c2 --- /dev/null +++ b/app/src/androidTest/java/com/ic/temperature/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.ic.temperature + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.ic.temperature", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..808da0d --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/aidl/com/ic/aidl/temp/ITempAidlInterface.aidl b/app/src/main/aidl/com/ic/aidl/temp/ITempAidlInterface.aidl new file mode 100644 index 0000000..433313c --- /dev/null +++ b/app/src/main/aidl/com/ic/aidl/temp/ITempAidlInterface.aidl @@ -0,0 +1,11 @@ +// ITempAidlInterface.aidl +package com.ic.aidl.temp; + +interface ITempAidlInterface { + /** + * Demonstrates some basic types that you can use as parameters + * and return values in AIDL. + */ + void updateCurrTempValue(double value,double animal,double tempOut); + void updateResultTempValue(double value,double animal,double tempOut); +} diff --git a/app/src/main/aidl/com/ic/aidl/temp/ITempRemoteService.aidl b/app/src/main/aidl/com/ic/aidl/temp/ITempRemoteService.aidl new file mode 100644 index 0000000..bad691f --- /dev/null +++ b/app/src/main/aidl/com/ic/aidl/temp/ITempRemoteService.aidl @@ -0,0 +1,18 @@ +// ITempRemoteService.aidl +package com.ic.aidl.temp; + +// Declare any non-default types here with import statements + +import com.ic.aidl.temp.ITempAidlInterface; + +interface ITempRemoteService { + /** + * Demonstrates some basic types that you can use as parameters + * and return values in AIDL. + */ + void registerCallback(ITempAidlInterface cb); + void unregisterCallback(ITempAidlInterface cb); + + void onStartQueryTemp(); + void onStopQueryTemp(); +} diff --git a/app/src/main/java/com/ic/temperature/App.kt b/app/src/main/java/com/ic/temperature/App.kt new file mode 100644 index 0000000..3c1f144 --- /dev/null +++ b/app/src/main/java/com/ic/temperature/App.kt @@ -0,0 +1,19 @@ +package com.ic.temperature + +import android.app.Application +import android.content.Context + +class App : Application() { + + init { + instance = this + } + + companion object { + private var instance: App? = null + + fun applicationContext(): Context { + return instance!!.applicationContext + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/ic/temperature/MainActivity.kt b/app/src/main/java/com/ic/temperature/MainActivity.kt new file mode 100644 index 0000000..5279193 --- /dev/null +++ b/app/src/main/java/com/ic/temperature/MainActivity.kt @@ -0,0 +1,84 @@ +package com.ic.temperature + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import androidx.lifecycle.ViewModelProvider +import com.ic.temperature.databinding.ActivityMainBinding +import com.ic.temperature.utils.ICViewModelFactory +import com.ic.temperature.viewmodel.TemperatureViewModel + +/** + * 这个是健康的界面,如果没有佩戴的话,不做检查。 + *

+ * 获取当前是否佩戴的状态key为:persist.sys.ic_antioff + *

+ * 这个是主动获取的。 + *

+ * 被动通知可以通过广播的方式监听佩戴状态的变化。 + *

+ * 广播相关的内容: + *

+ * public static String ACTION_ANTI_OFF0 = "com.ic.ACTION_ANTIOFF"; + * //integer eventID =1 脱落, eventID =0 佩戴 + * public static String KEY_ANTI_EVENT="eventID"; + */ +class MainActivity : AppCompatActivity() { + private val viewModel by lazy { + ViewModelProvider(this, + ICViewModelFactory() + ).get(TemperatureViewModel::class.java) + } + + private val binding by lazy { + ActivityMainBinding.inflate(layoutInflater) + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(binding.root) + initObserver() + } + + /** + * 观察ViewModel中的数据变化,然后去设置UI + */ + private fun initObserver() { + val that = this + viewModel.apply { + mBodyTemp.observe(that) { + //体温 + binding.bodyTemp = it + } + mWristTemp.observe(that) { + //腕部温度 + binding.wristTemp = it + } + mEnvTemp.observe(that) { + //环境温度 + binding.envTemp = it + } + mCheckTips.observe(that) { + //检查状态 + binding.checkTips = it + } + mShowLoading.observe(that) { + //显示Loading + binding.showLoading = it + } + mDisableWristTemp.observe(that) { + //是否开启腕部温度 + binding.disableWristTemp = it + } + mDisableEnvTemp.observe(that) { + //是否开启环境温度 + binding.disableEnvTemp = it + } + mFinishActivity.observe(that) { + //关闭Activity + if (it) { + finish() + } + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/ic/temperature/repository/TemperatureRepository.kt b/app/src/main/java/com/ic/temperature/repository/TemperatureRepository.kt new file mode 100644 index 0000000..7b6fc29 --- /dev/null +++ b/app/src/main/java/com/ic/temperature/repository/TemperatureRepository.kt @@ -0,0 +1,5 @@ +package com.ic.temperature.repository + +class TemperatureRepository { + +} \ No newline at end of file diff --git a/app/src/main/java/com/ic/temperature/utils/Constants.kt b/app/src/main/java/com/ic/temperature/utils/Constants.kt new file mode 100644 index 0000000..28fa2c3 --- /dev/null +++ b/app/src/main/java/com/ic/temperature/utils/Constants.kt @@ -0,0 +1,13 @@ +package com.ic.temperature.utils + +object Constants { + const val ACTION_ANTI_OFF0: String = "com.ic.ACTION_ANTIOFF" + + //integer eventID =1 脱落, eventID =0 佩戴 + const val KEY_ANTI_EVENT = "eventID" + const val STATE_ANTI_ON = 0 + const val STATE_ANTI_OFF = 1 + const val STATE_ANTI_NONE = -1 + const val ACTION_REMOTE_WORK_SERVICE = "com.ic.action.WORK_SERVICE" + const val PACKAGE_REMOTE_WORK_SERVICE = "com.ic.temp" +} \ No newline at end of file diff --git a/app/src/main/java/com/ic/temperature/utils/ICViewModelFactory.kt b/app/src/main/java/com/ic/temperature/utils/ICViewModelFactory.kt new file mode 100644 index 0000000..1e99a18 --- /dev/null +++ b/app/src/main/java/com/ic/temperature/utils/ICViewModelFactory.kt @@ -0,0 +1,20 @@ +package com.ic.temperature.utils + +import android.content.Context +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider +import com.ic.temperature.App + +/** + * ViewModel的创建工厂,把context和repository给到ViewModel里头 + */ +class ICViewModelFactory : ViewModelProvider.Factory { + + override fun create(modelClass: Class): T { + println("App.applicationContext() ${App.applicationContext()}") + return modelClass.getConstructor( + Context::class.java, + ).newInstance(App.applicationContext()) + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/ic/temperature/utils/IcLog.kt b/app/src/main/java/com/ic/temperature/utils/IcLog.kt new file mode 100644 index 0000000..1281dd6 --- /dev/null +++ b/app/src/main/java/com/ic/temperature/utils/IcLog.kt @@ -0,0 +1,53 @@ +package com.ic.temperature.utils + +import android.util.Log + +import com.ic.temperature.BuildConfig; + +object IcLog { + private val DOT = "." + private var isDebug: Boolean = BuildConfig.DEBUG + private var tagHead = "" + + fun v(tag: String, msg: String?) { + if (isDebug) { + Log.v(mergeHeadTag(tag), msg) + } + } + + fun d(tag: String, msg: String?) { + if (isDebug) { + Log.d(mergeHeadTag(tag), msg) + } + } + + fun i(tag: String, msg: String?) { + if (isDebug) { + Log.i(mergeHeadTag(tag), msg) + } + } + + fun w(tag: String, msg: String?) { + if (isDebug) { + Log.w(mergeHeadTag(tag), msg) + } + } + + fun e(tag: String, msg: String?, e: Throwable?) { + if (isDebug) { + Log.e(mergeHeadTag(tag), msg, e) + } + } + + fun setDebug(debug: Boolean) { + isDebug = debug + } + + fun setLogHead(head: String) { + tagHead = head + DOT + } + + private fun mergeHeadTag(tag: String): String? { + return tagHead + tag + } +} \ No newline at end of file diff --git a/app/src/main/java/com/ic/temperature/utils/ServiceUtil.kt b/app/src/main/java/com/ic/temperature/utils/ServiceUtil.kt new file mode 100644 index 0000000..a4a6c4e --- /dev/null +++ b/app/src/main/java/com/ic/temperature/utils/ServiceUtil.kt @@ -0,0 +1,45 @@ +package com.ic.temperature.utils + +import android.content.ComponentName +import android.content.Context +import android.content.Intent +import android.content.ServiceConnection + +object ServiceUtil { + + fun startServiceUtil(context: Context, serviceAction: String?, packageName: String?) { + val intent = getExplicitIntent(context, Intent(serviceAction)) + if (intent != null) { + intent.setPackage(packageName) + context.startService(intent) + } + } + + fun bindServiceUtil( + context: Context, + action: String?, + connection: ServiceConnection?, + pck: String? + ) { + val targetIntent = getExplicitIntent(context, Intent(action)) + if (targetIntent != null) { + targetIntent.setPackage(pck) + context.bindService(targetIntent, connection!!, Context.BIND_AUTO_CREATE) + } + } + + fun unBindServiceUtil(context: Context, connection: ServiceConnection?) { + if (connection != null) { + context.unbindService(connection) + } + } + + private fun getExplicitIntent(context: Context, impl: Intent): Intent? { + val resolveInfo = context.packageManager.queryIntentServices(impl, 0) + if (resolveInfo.size != 1) return null + val intent = Intent(impl) + val info = resolveInfo[0].serviceInfo ?: return null + intent.component = ComponentName(info.packageName, info.name) + return intent + } +} \ No newline at end of file diff --git a/app/src/main/java/com/ic/temperature/utils/StringUtils.kt b/app/src/main/java/com/ic/temperature/utils/StringUtils.kt new file mode 100644 index 0000000..6f68049 --- /dev/null +++ b/app/src/main/java/com/ic/temperature/utils/StringUtils.kt @@ -0,0 +1,22 @@ +package com.ic.temperature.utils + +import java.text.DecimalFormat + +object StringUtils { + + private val sDf = DecimalFormat("#.0") + + private const val MAX_TEM = 99.9 + + fun formatTem(temp: Double): String? { + var temp = temp + if (temp > MAX_TEM) { + temp = MAX_TEM + } + var format = sDf.format(temp) + if (".0" == format) { + format = "0.0" + } + return format + } +} \ No newline at end of file diff --git a/app/src/main/java/com/ic/temperature/utils/SystemUtils.kt b/app/src/main/java/com/ic/temperature/utils/SystemUtils.kt new file mode 100644 index 0000000..f5a1d94 --- /dev/null +++ b/app/src/main/java/com/ic/temperature/utils/SystemUtils.kt @@ -0,0 +1,124 @@ +package com.ic.temperature.utils + +import java.io.FileInputStream + +object SystemUtils { + fun GetCidFromSystem(): String? { + val cid_file = getSystemProperties("ro.product.partitionpath") + "miscdata" + val resCid = ByteArray(16) + try { + val buf = ByteArray(50) + val inputStream = FileInputStream(cid_file) + val len = inputStream.read(buf) + if (len < 50) return null + for (i in 0..15) { + resCid[i] = buf[i + 28] + } + for (i in 0..15) { + if (resCid[i] >= 0x30 && resCid[i] <= 0x39 || resCid[i] >= 0x61 && resCid[i] <= 0x7A || resCid[i] >= 0x41 && resCid[i] <= 0x5A) { + // valid + } else { + // invalid + for (j in 28 until 28 + 16) { + resCid[j] = 0x30 + } + break + } + } + } catch (e: Exception) { + e.printStackTrace() + } + return String(resCid) + } + + fun showOutTemp(): Boolean { + var show = true + show = !getSystemPropertiesBoolean("persyst.sys.disableTempOut", false) + return show + } + + fun isL02(): Boolean { + val launcher = getLauncherName() + return launcher == "l02" + } + + fun isDC001(): Boolean { + val launcher = getLauncherName() + return launcher == "dc001" + } + + fun h88tinyMode(): Boolean { + val launcher = getLauncherName() + return launcher == "h88tiny" + } + + fun isH88(): Boolean { + val launcher = getLauncherName() + return launcher == "h88" + } + + fun isS123(): Boolean { + val launcher = getLauncherName() + return launcher == "s123" + } + + fun isq3fyt(): Boolean { + val launcher = getLauncherName() + return launcher == "q3fyt" + } + + fun getLauncherName(): String { + return getSystemPropertiesString("persist.sys.launcherName", "l02") + } + + fun isYT(): Boolean { + val launcher = getLauncherName() + return launcher == "q3fyt" + } + + + fun getSystemPropertiesString(prop: String?, defaultvlaue: String): String { + var ret = defaultvlaue + val temp = getSystemProperties(prop) + if (temp.trim { it <= ' ' }.isNotEmpty()) { + ret = temp + } + return ret + } + + fun getSystemPropertiesBoolean(prop: String?, defaultvlaue: Boolean): Boolean { + var ret = defaultvlaue + val temp = getSystemProperties(prop) + if (temp.trim { it <= ' ' }.isNotEmpty()) { + if (temp.trim { it <= ' ' } == "true") { + ret = true + } else if (temp.trim { it <= ' ' } == "false") { + ret = false + } + } + return ret + } + + fun getSystemProperties(prop: String?): String { + var str = "" + var clazz: Class<*>? = null + try { + clazz = Class.forName("android.os.SystemProperties") + str = clazz.getMethod("get", *arrayOf>(String::class.java)) + .invoke(clazz, *arrayOf(prop)) as String + } catch (e: Exception) { + e.printStackTrace() + } + return str + } + + fun setSystemProperties(key: String?, defaultValue: String) { + try { + val c = Class.forName("android.os.SystemProperties") + val get = c.getMethod("set", String::class.java, String::class.java) + get.invoke(c, key, defaultValue) + } catch (e: Exception) { + e.printStackTrace() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/ic/temperature/viewmodel/TemperatureViewModel.kt b/app/src/main/java/com/ic/temperature/viewmodel/TemperatureViewModel.kt new file mode 100644 index 0000000..ce98f65 --- /dev/null +++ b/app/src/main/java/com/ic/temperature/viewmodel/TemperatureViewModel.kt @@ -0,0 +1,300 @@ +package com.ic.temperature.viewmodel + +import android.content.* +import android.os.IBinder +import android.os.RemoteException +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.ic.aidl.temp.ITempAidlInterface +import com.ic.aidl.temp.ITempRemoteService +import com.ic.temperature.R +import com.ic.temperature.utils.* +import com.ic.temperature.utils.Constants.ACTION_REMOTE_WORK_SERVICE +import com.ic.temperature.utils.Constants.KEY_ANTI_EVENT +import com.ic.temperature.utils.Constants.PACKAGE_REMOTE_WORK_SERVICE +import com.ic.temperature.utils.Constants.STATE_ANTI_NONE +import com.ic.temperature.utils.Constants.STATE_ANTI_OFF +import com.ic.temperature.utils.Constants.STATE_ANTI_ON +import kotlinx.coroutines.launch + +class TemperatureViewModel() : ViewModel() { + + + lateinit var mContext: Context + + constructor(context: Context) : this() { + println("context == > $context") + this.mContext = context + //注册广播,监听佩戴状态的变化 + registerBroadcast() + checkWristWear() + } + + + /** + * 是否支持腕温检测 + */ + private val isDisableWristTemp by lazy { + SystemUtils.getSystemPropertiesBoolean( + "persyst.sys.disableWristTemp", + false + ) + } + + /** + * 是否支持环境温度检测 + */ + private val isDisableEnvTemp by lazy { + SystemUtils.getSystemPropertiesBoolean( + "persyst.sys.disableTempOut", + true + ) + } + + /** + * true(off)表示没有佩戴,false表示已经佩戴了 + */ + private val isWristWear by lazy { + SystemUtils.getSystemPropertiesBoolean( + "persist.sys.ic_antioff", + false + ); + } + + /** + * 一进来就检查一下是否有佩戴,如果已经佩戴了,那么就绑定远程服务 + * 如果没有戴表,那么就不绑定服务,接收到佩戴的广播以后再绑定。 + */ + private fun checkWristWear() { + if (!isWristWear && mService == null) { + bindWorkService(mContext) + } else { + //给出提示:未正确佩戴设备 + mCheckTips.value = mContext.getString(R.string.no_wearing_device_tips_text) + } + } + + private var mHasWear = false + + companion object { + const val TAG = "TemperatureViewModel" + } + + private val mIntentReceiver by lazy { + println("init receiver") + DialogDismissReceiver() + } + + private val mAntiStateReceiver by lazy { + WristWearStateReceiver() + } + private val mRemoteConnection by lazy { + RemoteServiceConnection() + } + + private val remoteDataCallback by lazy { + Callback4Remote() + } + + private var mService: ITempRemoteService? = null + + //关心的数据 + val mBodyTemp = MutableLiveData() + val mWristTemp = MutableLiveData() + val mEnvTemp = MutableLiveData() + val mCheckTips = MutableLiveData() + val mShowLoading = MutableLiveData() + val mFinishActivity = MutableLiveData() + val mDisableWristTemp by lazy { + val mutableLiveData = MutableLiveData() + mutableLiveData.value = isDisableWristTemp + mutableLiveData + } + val mDisableEnvTemp by lazy { + val mutableLiveData = MutableLiveData() + mutableLiveData.value = isDisableEnvTemp + mutableLiveData + } + + /** + * 注册广播接收者,主要是监听佩戴和一个Dialog的退出 + * 这个Dialog的退出广播是祖传代码,具体case目前不明确 + */ + private fun registerBroadcast() { + val filter = IntentFilter() + filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS) + mContext.registerReceiver(mIntentReceiver, filter) + //注册监听是否有佩戴的广播 + val antiStateFilter = IntentFilter() + antiStateFilter.addAction(Constants.ACTION_ANTI_OFF0) + mContext.registerReceiver(mAntiStateReceiver, antiStateFilter) + } + + override fun onCleared() { + super.onCleared() + //取消广播注册 + mContext.unregisterReceiver(mIntentReceiver) + mContext.unregisterReceiver(mAntiStateReceiver) + ServiceUtil.unBindServiceUtil(mContext, mRemoteConnection) + } + + /** + * 绑定远程服务 + * + * @param context + */ + private fun bindWorkService(context: Context) { + IcLog.i(TAG, "bind remote service..") + ServiceUtil.bindServiceUtil( + context, + ACTION_REMOTE_WORK_SERVICE, + mRemoteConnection, + PACKAGE_REMOTE_WORK_SERVICE + ) + } + + /** + * 远程服务的回调 + */ + inner class RemoteServiceConnection : ServiceConnection { + override fun onServiceConnected(name: ComponentName?, service: IBinder?) { + mService = ITempRemoteService.Stub.asInterface(service) + //把回调接口设置给对方 + mService?.registerCallback(remoteDataCallback) + getRemoteData() + } + + override fun onServiceDisconnected(name: ComponentName?) { + mService = null + } + } + + private fun getRemoteData() { + //展示Loading,也 就是进度条那个 + mShowLoading.postValue(true) + //设置UI正在检测中 + mCheckTips.postValue(mContext.getString(R.string.activity_temp_tips_check)) + IcLog.d(TAG, "getRemoteData...") + try { + viewModelScope.launch { + //调用开始查询温度 + mService?.onStartQueryTemp() + } + } catch (e: Exception) { + e.printStackTrace() + } + } + + inner class WristWearStateReceiver : BroadcastReceiver() { + override fun onReceive(context: Context?, intent: Intent?) { + //如果来了佩戴的广播,判断到没有绑定远程服务的话,那么就绑定吧 + val state = intent!!.getIntExtra(KEY_ANTI_EVENT, STATE_ANTI_NONE) + IcLog.i(TAG, "on AntiStateChange....$state") + if (state == STATE_ANTI_NONE) { + IcLog.i(TAG, "state error === > $state") + return + } + + if (state == STATE_ANTI_OFF) { + mCheckTips.value = context!!.getString(R.string.no_wearing_device_tips_text) + //脱落了,给出提示 + //停止Loading + mShowLoading.value = false + } else if (state == STATE_ANTI_ON && mService == null) { + bindWorkService(context!!) + } + + mHasWear = state == STATE_ANTI_ON + if (mHasWear) { + //判断状态,如果已经检测完了,就显示检测完成 + // 按客户需求,马上进来显示检测完成,看起来不爽 + //那就再次检测吧,底层做了处理,多次调用测试也没关系,如果判断到繁忙的话会不处理的。 + //heatBinding.setCheckTips(getString(R.string.activity_temp_tips_end)); + getRemoteData() + } + } + } + + inner class Callback4Remote : ITempAidlInterface.Stub() { + @Throws(RemoteException::class) + /** + * bodyOrWristTemp:体温或者腕温(当不支持腕温的时候,就是体温) + * maybeBodyTemp:可能是体温(如果支持腕温的时候) + * envTemp:环境温度 + */ + override fun updateCurrTempValue( + bodyOrWristTemp: Double, + maybeBodyTemp: Double, + envTemp: Double + ) { + IcLog.d( + TAG, + "updateCurrTempValue... " + + bodyOrWristTemp + + " maybeBodyTemp --> " + + maybeBodyTemp + + " envTemp + > " + + envTemp + ) + updateUiData(bodyOrWristTemp, maybeBodyTemp, envTemp) + } + + /** + * bodyOrWristTemp:体温或者腕温(当不支持腕温的时候,就是体温) + * maybeBodyTemp:可能是体温(如果支持腕温的时候) + * envTemp:环境温度 + */ + @Throws(RemoteException::class) + override fun updateResultTempValue( + bodyOrWristTemp: Double, + maybeBodyTemp: Double, + envTemp: Double + ) { + IcLog.d( + TAG, + "final ... " + + bodyOrWristTemp + + " maybeBodyTemp --> " + + maybeBodyTemp + + " envTemp + > " + + envTemp + ) + //最后的结果 + updateUiData(bodyOrWristTemp, maybeBodyTemp, envTemp) + //结束一些loading和文字提示 + mShowLoading.postValue(false) + mCheckTips.postValue(mContext.getString(R.string.activity_temp_tips_end)) + } + } + + private fun updateUiData( + bodyOrWristTemp: Double, + maybeBodyTemp: Double, + envTemp: Double + ) { + mDisableWristTemp.value = isDisableWristTemp + //数据更新 + if (isDisableWristTemp) { + mBodyTemp.value = StringUtils.formatTem(bodyOrWristTemp) + } else { + mBodyTemp.value = StringUtils.formatTem(maybeBodyTemp) + mWristTemp.value = StringUtils.formatTem(bodyOrWristTemp) + } + mEnvTemp.value = StringUtils.formatTem(envTemp) + } + + inner class DialogDismissReceiver : BroadcastReceiver() { + override fun onReceive(context: Context?, intent: Intent?) { + if (intent != null && + Intent.ACTION_CLOSE_SYSTEM_DIALOGS == intent.action + ) { + val reason = intent.getStringExtra("reason") + if ("homekey" == reason) { + // 按下HOME健 + mFinishActivity.value = true + } + } + } + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_temp_human.xml b/app/src/main/res/drawable/ic_temp_human.xml new file mode 100644 index 0000000..5e9b037 --- /dev/null +++ b/app/src/main/res/drawable/ic_temp_human.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_temp_wrist.xml b/app/src/main/res/drawable/ic_temp_wrist.xml new file mode 100644 index 0000000..f26ff82 --- /dev/null +++ b/app/src/main/res/drawable/ic_temp_wrist.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..238b22a --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,268 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/outtemp.png b/app/src/main/res/mipmap-mdpi/outtemp.png new file mode 100644 index 0000000..ea16ca8 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/outtemp.png differ diff --git a/app/src/main/res/mipmap-mdpi/qs_background.png b/app/src/main/res/mipmap-mdpi/qs_background.png new file mode 100644 index 0000000..1bc9fbd Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/qs_background.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..4a1bd24 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,9 @@ + + + #008577 + #00574B + #D81B60 + + #000000 + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..406f9eb --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,10 @@ + + Temperature + ℃ + 腕温 + 体温 + 环境 + 未配戴设备 + 正在测量 + 测量完成 + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..7553077 --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/app/src/test/java/com/ic/temperature/ExampleUnitTest.kt b/app/src/test/java/com/ic/temperature/ExampleUnitTest.kt new file mode 100644 index 0000000..104e29e --- /dev/null +++ b/app/src/test/java/com/ic/temperature/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.ic.temperature + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..55e96ce --- /dev/null +++ b/build.gradle @@ -0,0 +1,26 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlin_version = "1.4.20" + repositories { + google() + jcenter() + } + dependencies { + classpath "com.android.tools.build:gradle:4.1.0" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..98bed16 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app"s APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..7bd1923 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Dec 02 15:32:17 CST 2020 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# 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 new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem 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= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..733002b --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +include ':app' +rootProject.name = "Temperature" \ No newline at end of file