How to warm up an Android device to 40 degrees through Unity?
I want to create an Android application that will act as a “manual heater”. I use GPS calls, vibration, flashlight, and I also use multiple threads to run the code in a loop. Battery consumption is high, but not enough.
When I use this application, it takes about 10 minutes to transition from 25 degrees to 33. My goal is to reach 40 degrees in the shortest possible time.
So, how can I read the temperature of the device through C # code and how to reach 40 degrees heat and stay there?
You do not need a flashlight or vibrator to do this, since the application will annoy most people, as these two will be turned on, even if they are not needed.
Use methods that should not physically affect the user, but are capable of generating heat.
how can i read device temperature via c # code
First you need to check if the device has a temperature sensor before you read the sensor. As for the Android reading sensor with C #, you need to write this using Java code and then call this function from C #.
You can use the already created Unity-Android-Sensor-Plugin plugin .
private AndroidJavaObject plugin; void Start () { #if UNITY_ANDROID plugin = new AndroidJavaClass("jp.kshoji.unity.sensor.UnitySensorPlugin").CallStatic<AndroidJavaObject>("getInstance"); //Init the ambienttemperature sensor if (plugin != null) { plugin.Call("startSensorListening", "ambienttemperature"); } #endif }
To read the ambient temperature sensors again in the update function:
float[] sensorValue = plugin.Call<float[]>("getSensorValues", "ambienttemperature");
Battery consumption is high, but not enough.
These are the methods used to heat your mobile device.
Brightness:
1 . Change the brightness to the highest value. Now turn off auto dimming so that the screen always glows.
Networking:
2 . Create several (4-5) TCP-servers, each of which works in its own flows, as well as with different ports on the device.
Now create the same amount of TCP client and connect to the server with ports and IPAddress.Loopback
as the IP address.
In the while loop, about 13 thousand floating point numbers are randomly generated, converted to a byte array, and then sent to each client and server continuously. When you get it, convert that byte array back to float, and then get nothing with the result. Repeat and rinse.
Audio:
3 . Download 5 or 6 audio files to the audio file, set it in a loop, and set the volume to 0
. Play all the audio.
Video:
4 . Download 5 or 6 animations, set it in a loop, then play it. It may not appear on the screen, but while it plays, it does everything possible.
Video:
5 . Download 3 videos from Unity new VidepPlayer , mute audio, connect video to RawImage. Set the alpha of the other RawImage to 0
so that it is not visible. Play video and enable decoding.
Senors:
6 . Built-in accelerometer and gyroscope sensors check each frame in the update function.
7. .Enable GPS and read the survey of each frame in the update function.
8. .Enable Bluetooth and continuously search for other devices every second.
9 . Replace the front and rear cameras, remove the textures from them, but do nothing with it.
how to reach 40 degrees heat and stay there?
Combination :
Put everything described above in a function or its own class.
1 . Create a simple class with an int
variable called a level. This level variable should be used to determine what actions described above should be performed.
2 . When the application starts, change the level to 9
, then enable / run each method described above. If the temperature reaches about 38, lower the level to about 5. When the level is reduced, you will stop working under anything, so in this case you should stop polling the accelerometer, gyroscope, GPS, Bluetooth and camera, and then turn them off.
3 . If the temperature is above 40, lower the level. If it is below 40, increase the level. So you maintain a temperature of about ~40
degrees.
4 . Even better, you may have to create your own PID controller that uses these methods above for this. It will take some time to fix this, but it may be the best way to do it.
Tip
For each material you make, check the frame rate. If the frame rate is below 6, stop. If you do not, Android can kill the application so that it does not respond.
Note
Write a simple function that detects some specific devices mentioned in the comment section. Make sure that this application does not run in this application, or your “hand warmer” application may become a “manual and amp; amputator application”.