summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2021-05-18 22:42:28 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-05-18 22:42:28 +0000
commit49f6ccf69eb3bc4c027b242e62855b4e8fc0de25 (patch)
treeaed783945889c332abb2e27bd6a80e2deb2945e1
parentc5b3080f8254d2eadfe32a78831363902ea2b25b (diff)
parent11b564feb1554e7562a2589e277bd4147e2af6db (diff)
Merge "Show sensor usage dialog for assistant" into sc-dev
-rw-r--r--core/java/android/service/voice/VoiceInteractionManagerInternal.java5
-rw-r--r--services/core/java/com/android/server/SensorPrivacyService.java11
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java17
3 files changed, 33 insertions, 0 deletions
diff --git a/core/java/android/service/voice/VoiceInteractionManagerInternal.java b/core/java/android/service/voice/VoiceInteractionManagerInternal.java
index b38067b9975a..f5c959137d9b 100644
--- a/core/java/android/service/voice/VoiceInteractionManagerInternal.java
+++ b/core/java/android/service/voice/VoiceInteractionManagerInternal.java
@@ -41,4 +41,9 @@ public abstract class VoiceInteractionManagerInternal {
public abstract boolean supportsLocalVoiceInteraction();
public abstract void stopLocalVoiceInteraction(IBinder callingActivity);
+
+ /**
+ * Returns whether the given package is currently in an active session
+ */
+ public abstract boolean hasActiveSession(String packageName);
} \ No newline at end of file
diff --git a/services/core/java/com/android/server/SensorPrivacyService.java b/services/core/java/com/android/server/SensorPrivacyService.java
index baec5449d896..9314ed74f9c8 100644
--- a/services/core/java/com/android/server/SensorPrivacyService.java
+++ b/services/core/java/com/android/server/SensorPrivacyService.java
@@ -76,6 +76,7 @@ import android.provider.Settings;
import android.service.SensorPrivacyIndividualEnabledSensorProto;
import android.service.SensorPrivacyServiceDumpProto;
import android.service.SensorPrivacyUserProto;
+import android.service.voice.VoiceInteractionManagerInternal;
import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;
import android.telephony.emergency.EmergencyNumber;
@@ -172,6 +173,7 @@ public final class SensorPrivacyService extends SystemService {
mActivityManager = context.getSystemService(ActivityManager.class);
mActivityTaskManager = context.getSystemService(ActivityTaskManager.class);
mTelephonyManager = context.getSystemService(TelephonyManager.class);
+
mSensorPrivacyServiceImpl = new SensorPrivacyServiceImpl();
}
@@ -402,6 +404,15 @@ public final class SensorPrivacyService extends SystemService {
}
}
+ VoiceInteractionManagerInternal voiceInteractionManagerInternal =
+ LocalServices.getService(VoiceInteractionManagerInternal.class);
+
+ if (sensor == MICROPHONE && voiceInteractionManagerInternal != null
+ && voiceInteractionManagerInternal.hasActiveSession(packageName)) {
+ enqueueSensorUseReminderDialogAsync(-1, user, packageName, sensor);
+ return;
+ }
+
Log.i(TAG, packageName + "/" + uid + " started using sensor " + sensor
+ " but no activity or foreground service was running. The user will not be"
+ " informed. System components should check if sensor privacy is enabled for"
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
index 92cfe4980388..f3d80b13f290 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
@@ -234,6 +234,23 @@ public class VoiceInteractionManagerService extends SystemService {
VoiceInteractionManagerService.this.mServiceStub.stopLocalVoiceInteraction(
callingActivity);
}
+
+ @Override
+ public boolean hasActiveSession(String packageName) {
+ VoiceInteractionManagerServiceImpl impl =
+ VoiceInteractionManagerService.this.mServiceStub.mImpl;
+ if (impl == null) {
+ return false;
+ }
+
+ VoiceInteractionSessionConnection session =
+ impl.mActiveSession;
+ if (session == null) {
+ return false;
+ }
+
+ return TextUtils.equals(packageName, session.mSessionComponentName.getPackageName());
+ }
}
// implementation entry point and binder service