-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from aditydcp/9-reduce-power-consumption-and-heat
reduce power consumption and heat
- Loading branch information
Showing
67 changed files
with
328 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
mobile/src/main/java/com/example/samplewearmobileapp/MobileService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.example.samplewearmobileapp | ||
|
||
import android.app.NotificationChannel | ||
import android.app.NotificationManager | ||
import android.app.PendingIntent | ||
import android.app.Service | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.graphics.Color | ||
import android.os.IBinder | ||
import androidx.core.app.NotificationCompat | ||
import androidx.core.content.ContextCompat | ||
|
||
class MobileService : Service() { | ||
private val CHANNEL_ID = "MobileService" | ||
private var isServiceRunning = false | ||
|
||
companion object { | ||
fun startService(context: Context, message: String) { | ||
val intent = Intent(context, MobileService::class.java) | ||
intent.putExtra("message", message) | ||
ContextCompat.startForegroundService(context, intent) | ||
|
||
val service = ContextCompat.getSystemService(context, MobileService::class.java) | ||
service?.isServiceRunning = true | ||
} | ||
|
||
fun stopService(context: Context) { | ||
val service = ContextCompat.getSystemService(context, MobileService::class.java) | ||
service?.isServiceRunning = false | ||
|
||
val intent = Intent(context, MobileService::class.java) | ||
context.stopService(intent) | ||
} | ||
|
||
fun isServiceRunning(context: Context) : Boolean { | ||
val service = ContextCompat.getSystemService(context, MobileService::class.java) | ||
return service?.isServiceRunning() ?: false | ||
} | ||
} | ||
|
||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { | ||
val message = intent?.getStringExtra("message") | ||
createNotificationChannel() | ||
|
||
val pendingIntent: PendingIntent = | ||
Intent(this, MainActivity::class.java).let { notificationIntent -> | ||
PendingIntent.getActivity(this, 0, notificationIntent, | ||
PendingIntent.FLAG_IMMUTABLE) | ||
} | ||
|
||
val notification = NotificationCompat.Builder(this, CHANNEL_ID) | ||
.setSmallIcon(R.drawable.ic_notification) | ||
.setContentTitle("Main Foreground Service Sample App") | ||
.setContentText("Recording...") | ||
.setContentIntent(pendingIntent) | ||
.setOngoing(true) | ||
.build() | ||
|
||
startForeground(1, notification) | ||
isServiceRunning = true | ||
return START_STICKY | ||
} | ||
|
||
override fun onBind(intent: Intent?): IBinder? { | ||
return null | ||
} | ||
|
||
private fun createNotificationChannel() { | ||
val serviceChannel = NotificationChannel( | ||
CHANNEL_ID, "Mobile Foreground Service Channel", | ||
NotificationManager.IMPORTANCE_HIGH | ||
) | ||
serviceChannel.description = "Description" | ||
serviceChannel.enableLights(true) | ||
serviceChannel.lightColor = Color.BLUE | ||
|
||
val manager = getSystemService(NotificationManager::class.java) | ||
manager?.createNotificationChannel(serviceChannel) | ||
} | ||
|
||
private fun isServiceRunning() : Boolean { | ||
return isServiceRunning | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="212" | ||
android:viewportHeight="161.64844" | ||
android:tint="#FFFFFF"> | ||
<group android:scaleX="0.92" | ||
android:scaleY="0.7014932" | ||
android:translateX="8.48" | ||
android:translateY="24.126577"> | ||
<group android:translateY="132.82031"> | ||
<path android:pathData="M51.6875,-7.8125Q51.6875,-4.359375,49.53125,-2.171875Q47.390625,-0,43.953125,-0L16.25,-0Q12.796875,-0,10.578125,-2.171875Q8.375,-4.359375,8.375,-7.8125L8.375,-35.71875L18.140625,-35.71875L18.140625,-8.65625L41.90625,-8.65625L41.90625,-34.875L11.53125,-71.578125Q8.375,-75.375,8.375,-79.953125L8.375,-102.234375Q8.375,-105.6875,10.578125,-107.859375Q12.796875,-110.046875,16.25,-110.046875L43.953125,-110.046875Q47.390625,-110.046875,49.53125,-107.859375Q51.6875,-105.6875,51.6875,-102.234375L51.6875,-76.640625L41.90625,-76.640625L41.90625,-101.390625L18.140625,-101.390625L18.140625,-78.1875L48.65625,-41.484375Q51.6875,-37.828125,51.6875,-33.265625L51.6875,-7.8125Z" | ||
android:fillColor="#000000"/> | ||
<path android:pathData="M124.21875,0L115,0L115,-69.6875Q115,-71.15625,115.984375,-78.328125L97.984375,-10.34375L96.015625,-10.34375L78.015625,-78.328125Q79,-71.09375,79,-69.6875L79,0L69.796875,0L69.796875,-110.046875L78.859375,-110.046875L96.71875,-38.46875Q96.859375,-37.90625,97,-35.296875Q97,-36.359375,97.28125,-38.46875L115.140625,-110.046875L124.21875,-110.046875L124.21875,0Z" | ||
android:fillColor="#000000"/> | ||
<path android:pathData="M208.60938,-110.046875L193.625,0.28125L185.6875,0.28125L173.73438,-82.6875Q173.65625,-84.875,173.45312,-89.15625Q173.45312,-86.90625,173.17188,-82.6875L161.21875,0.28125L153.26562,0.28125L138.29688,-110.046875L148,-110.046875L157.34375,-30.65625Q157.42188,-27.984375,157.625,-22.78125Q157.5625,-25.453125,157.90625,-30.65625L169.29688,-110.046875L177.67188,-110.046875L188.98438,-30.65625Q189.125,-27.984375,189.26562,-22.78125Q189.26562,-25.453125,189.625,-30.65625L198.96875,-110.046875L208.60938,-110.046875Z" | ||
android:fillColor="#000000"/> | ||
</group> | ||
</group> | ||
</vector> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 0 additions & 30 deletions
30
mobile/src/main/res/drawable-v24/ic_launcher_foreground.xml
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="108dp" | ||
android:height="108dp" | ||
android:viewportWidth="212" | ||
android:viewportHeight="161.64844"> | ||
<group android:scaleX="0.46" | ||
android:scaleY="0.3507466" | ||
android:translateX="57.24" | ||
android:translateY="52.4754"> | ||
<group android:translateY="132.82031"> | ||
<path android:pathData="M51.6875,-7.8125Q51.6875,-4.359375,49.53125,-2.171875Q47.390625,-0,43.953125,-0L16.25,-0Q12.796875,-0,10.578125,-2.171875Q8.375,-4.359375,8.375,-7.8125L8.375,-35.71875L18.140625,-35.71875L18.140625,-8.65625L41.90625,-8.65625L41.90625,-34.875L11.53125,-71.578125Q8.375,-75.375,8.375,-79.953125L8.375,-102.234375Q8.375,-105.6875,10.578125,-107.859375Q12.796875,-110.046875,16.25,-110.046875L43.953125,-110.046875Q47.390625,-110.046875,49.53125,-107.859375Q51.6875,-105.6875,51.6875,-102.234375L51.6875,-76.640625L41.90625,-76.640625L41.90625,-101.390625L18.140625,-101.390625L18.140625,-78.1875L48.65625,-41.484375Q51.6875,-37.828125,51.6875,-33.265625L51.6875,-7.8125Z" | ||
android:fillColor="#FFFFFF"/> | ||
<path android:pathData="M124.21875,0L115,0L115,-69.6875Q115,-71.15625,115.984375,-78.328125L97.984375,-10.34375L96.015625,-10.34375L78.015625,-78.328125Q79,-71.09375,79,-69.6875L79,0L69.796875,0L69.796875,-110.046875L78.859375,-110.046875L96.71875,-38.46875Q96.859375,-37.90625,97,-35.296875Q97,-36.359375,97.28125,-38.46875L115.140625,-110.046875L124.21875,-110.046875L124.21875,0Z" | ||
android:fillColor="#FFFFFF"/> | ||
<path android:pathData="M208.60938,-110.046875L193.625,0.28125L185.6875,0.28125L173.73438,-82.6875Q173.65625,-84.875,173.45312,-89.15625Q173.45312,-86.90625,173.17188,-82.6875L161.21875,0.28125L153.26562,0.28125L138.29688,-110.046875L148,-110.046875L157.34375,-30.65625Q157.42188,-27.984375,157.625,-22.78125Q157.5625,-25.453125,157.90625,-30.65625L169.29688,-110.046875L177.67188,-110.046875L188.98438,-30.65625Q189.125,-27.984375,189.26562,-22.78125Q189.26562,-25.453125,189.625,-30.65625L198.96875,-110.046875L208.60938,-110.046875Z" | ||
android:fillColor="#FFFFFF"/> | ||
</group> | ||
</group> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<background android:drawable="@drawable/ic_launcher_background" /> | ||
<foreground android:drawable="@drawable/ic_launcher_foreground" /> | ||
<background android:drawable="@color/ic_launcher_background"/> | ||
<foreground android:drawable="@drawable/ic_launcher_foreground"/> | ||
</adaptive-icon> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<background android:drawable="@drawable/ic_launcher_background" /> | ||
<foreground android:drawable="@drawable/ic_launcher_foreground" /> | ||
<background android:drawable="@color/ic_launcher_background"/> | ||
<foreground android:drawable="@drawable/ic_launcher_foreground"/> | ||
</adaptive-icon> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="ic_launcher_background">#5B0992</color> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.