Merge "Show sensor usage dialog for assistant" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
49f6ccf69e
@@ -41,4 +41,9 @@ public abstract class VoiceInteractionManagerInternal {
|
|||||||
public abstract boolean supportsLocalVoiceInteraction();
|
public abstract boolean supportsLocalVoiceInteraction();
|
||||||
|
|
||||||
public abstract void stopLocalVoiceInteraction(IBinder callingActivity);
|
public abstract void stopLocalVoiceInteraction(IBinder callingActivity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given package is currently in an active session
|
||||||
|
*/
|
||||||
|
public abstract boolean hasActiveSession(String packageName);
|
||||||
}
|
}
|
||||||
@@ -76,6 +76,7 @@ import android.provider.Settings;
|
|||||||
import android.service.SensorPrivacyIndividualEnabledSensorProto;
|
import android.service.SensorPrivacyIndividualEnabledSensorProto;
|
||||||
import android.service.SensorPrivacyServiceDumpProto;
|
import android.service.SensorPrivacyServiceDumpProto;
|
||||||
import android.service.SensorPrivacyUserProto;
|
import android.service.SensorPrivacyUserProto;
|
||||||
|
import android.service.voice.VoiceInteractionManagerInternal;
|
||||||
import android.telephony.TelephonyCallback;
|
import android.telephony.TelephonyCallback;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.telephony.emergency.EmergencyNumber;
|
import android.telephony.emergency.EmergencyNumber;
|
||||||
@@ -172,6 +173,7 @@ public final class SensorPrivacyService extends SystemService {
|
|||||||
mActivityManager = context.getSystemService(ActivityManager.class);
|
mActivityManager = context.getSystemService(ActivityManager.class);
|
||||||
mActivityTaskManager = context.getSystemService(ActivityTaskManager.class);
|
mActivityTaskManager = context.getSystemService(ActivityTaskManager.class);
|
||||||
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
||||||
|
|
||||||
mSensorPrivacyServiceImpl = new SensorPrivacyServiceImpl();
|
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
|
Log.i(TAG, packageName + "/" + uid + " started using sensor " + sensor
|
||||||
+ " but no activity or foreground service was running. The user will not be"
|
+ " but no activity or foreground service was running. The user will not be"
|
||||||
+ " informed. System components should check if sensor privacy is enabled for"
|
+ " informed. System components should check if sensor privacy is enabled for"
|
||||||
|
|||||||
@@ -234,6 +234,23 @@ public class VoiceInteractionManagerService extends SystemService {
|
|||||||
VoiceInteractionManagerService.this.mServiceStub.stopLocalVoiceInteraction(
|
VoiceInteractionManagerService.this.mServiceStub.stopLocalVoiceInteraction(
|
||||||
callingActivity);
|
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
|
// implementation entry point and binder service
|
||||||
|
|||||||
Reference in New Issue
Block a user