From ecb08f3cffd0b6e1737eb9c9de2d81dd1bf697f9 Mon Sep 17 00:00:00 2001 From: cyrus-rbc Date: Wed, 20 Sep 2023 11:15:59 +0800 Subject: [PATCH 01/12] disable auto kill in non temi environment --- .../robotemi/sdk/TemiSdkServiceConnection.kt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sdk/src/main/java/com/robotemi/sdk/TemiSdkServiceConnection.kt b/sdk/src/main/java/com/robotemi/sdk/TemiSdkServiceConnection.kt index 4d59de97..f6c389b1 100644 --- a/sdk/src/main/java/com/robotemi/sdk/TemiSdkServiceConnection.kt +++ b/sdk/src/main/java/com/robotemi/sdk/TemiSdkServiceConnection.kt @@ -5,6 +5,7 @@ import android.content.ComponentName import android.content.Context import android.content.Intent import android.content.ServiceConnection +import android.content.pm.PackageManager import android.os.IBinder import android.os.Process import android.util.Log @@ -27,6 +28,9 @@ internal class TemiSdkServiceConnection { } } + @Volatile + private var isLauncherExist = false + @NonNull private val serviceConnection = object : ServiceConnection { @@ -48,6 +52,8 @@ internal class TemiSdkServiceConnection { @UiThread internal fun startConnection(context: Context) { Log.d(TAG, "startConnection(Context)") + isLauncherExist = isPackageExist(context, SdkConstants.TEMI_USA) || + isPackageExist(context, SdkConstants.TEMI_CHINA) when { context.bindService( getSdkServiceIntent(SdkConstants.TEMI_USA), @@ -73,6 +79,17 @@ internal class TemiSdkServiceConnection { @SuppressLint("LongLogTag") private fun forceStop() { Log.d(TAG, "forceStop()") - Process.killProcess(Process.myPid()) + if (isLauncherExist) + Process.killProcess(Process.myPid()) + } + + private fun isPackageExist(context: Context, targetPackage: String): Boolean { + val pm: PackageManager = context.packageManager + try { + val info = pm.getPackageInfo(targetPackage, PackageManager.GET_META_DATA) + } catch (e: PackageManager.NameNotFoundException) { + return false + } + return true } } From bc4c7d86a9efd9295337e67c9222076faeb639e1 Mon Sep 17 00:00:00 2001 From: cyrus-rbc Date: Mon, 25 Sep 2023 16:34:36 +0800 Subject: [PATCH 02/12] add startPage() tour page support, getAllTours()and playTour() --- .../com/robotemi/sdk/sample/MainActivity.kt | 40 +++++++++++++ .../src/main/res/layout/group_resources.xml | 10 ++++ .../aidl/com/robotemi/sdk/ISdkService.aidl | 5 ++ .../com/robotemi/sdk/tourguide/TourModel.aidl | 4 ++ sdk/src/main/java/com/robotemi/sdk/Robot.kt | 38 ++++++++++++ .../robotemi/sdk/constants/SdkConstants.kt | 5 +- .../com/robotemi/sdk/tourguide/TourModel.kt | 58 +++++++++++++++++++ 7 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 sdk/src/main/aidl/com/robotemi/sdk/tourguide/TourModel.aidl create mode 100644 sdk/src/main/java/com/robotemi/sdk/tourguide/TourModel.kt diff --git a/sample/src/main/java/com/robotemi/sdk/sample/MainActivity.kt b/sample/src/main/java/com/robotemi/sdk/sample/MainActivity.kt index d11d1864..4f886a96 100644 --- a/sample/src/main/java/com/robotemi/sdk/sample/MainActivity.kt +++ b/sample/src/main/java/com/robotemi/sdk/sample/MainActivity.kt @@ -68,6 +68,7 @@ import com.robotemi.sdk.sequence.SequenceModel import com.robotemi.sdk.telepresence.CallState import com.robotemi.sdk.telepresence.LinkBasedMeeting import com.robotemi.sdk.telepresence.Participant +import com.robotemi.sdk.tourguide.TourModel import com.robotemi.sdk.voice.ITtsService import com.robotemi.sdk.voice.model.TtsVoice import kotlinx.android.synthetic.main.activity_main.* @@ -393,7 +394,9 @@ class MainActivity : AppCompatActivity(), NlpListener, OnRobotReadyListener, btnRequestToBeKioskApp.setOnClickListener { requestToBeKioskApp() } btnStartDetectionModeWithDistance.setOnClickListener { startDetectionWithDistance() } btnFetchSequence.setOnClickListener { getAllSequences() } + btnFetchTour.setOnClickListener { getAllTours() } btnPlayFirstSequence.setOnClickListener { playFirstSequence() } + btnPlayFirstTour.setOnClickListener { playFirstTour() } btnPlayFirstSequenceWithoutPlayer.setOnClickListener { playFirstSequenceWithoutPlayer() } btnFetchMap.setOnClickListener { getMap() } btnClearLog.setOnClickListener { clearLog() } @@ -1633,6 +1636,43 @@ class MainActivity : AppCompatActivity(), NlpListener, OnRobotReadyListener, } } + @Volatile + private var allTours: List = emptyList() + + private fun getAllTours() { + if (requestPermissionIfNeeded(Permission.SEQUENCE, REQUEST_CODE_SEQUENCE_FETCH_ALL)) { + return + } + Thread { + allTours = robot.getAllTours() + printLog("allTours: ${allTours.size}", false) + val imageKeys: MutableList = ArrayList() + for ((_, _, _, _, imageKey) in allTours) { + if (imageKey.isEmpty()) continue + imageKeys.add(imageKey) + } + val pairs = if (imageKeys.isEmpty()) emptyList() + else robot.getSignedUrlByMediaKey(imageKeys) + runOnUiThread { + for (tourGuide in allTours) { + printLog(tourGuide.toString()) + } + for (pair in pairs) { + printLog(pair.component2(), false) + } + } + }.start() + } + + private fun playFirstTour() { + if (requestPermissionIfNeeded(Permission.SEQUENCE, REQUEST_CODE_SEQUENCE_PLAY)) { + return + } + if (!allTours.isNullOrEmpty()) { + robot.playTour(allTours[0].id) + } + } + private fun getMap() { if (requestPermissionIfNeeded(Permission.MAP, REQUEST_CODE_MAP)) { return diff --git a/sample/src/main/res/layout/group_resources.xml b/sample/src/main/res/layout/group_resources.xml index ba2b6a58..a1629cad 100644 --- a/sample/src/main/res/layout/group_resources.xml +++ b/sample/src/main/res/layout/group_resources.xml @@ -42,6 +42,11 @@ style="@style/ButtonCommon" android:text="Get All Sequences" /> +