Merge "Merge "Properly handle HSUM no-user in the ContextHubService" into udc-qpr-dev am: 66224219ba" into udc-qpr-dev-plus-aosp
This commit is contained in:
committed by
Android (Google) Code Review
commit
1dc42da01a
@@ -52,6 +52,7 @@ import android.os.ResultReceiver;
|
|||||||
import android.os.ShellCallback;
|
import android.os.ShellCallback;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.os.UserManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
@@ -169,6 +170,8 @@ public class ContextHubService extends IContextHubService.Stub {
|
|||||||
|
|
||||||
private SensorPrivacyManagerInternal mSensorPrivacyManagerInternal;
|
private SensorPrivacyManagerInternal mSensorPrivacyManagerInternal;
|
||||||
|
|
||||||
|
private UserManager mUserManager = null;
|
||||||
|
|
||||||
private final Map<Integer, AtomicLong> mLastRestartTimestampMap = new HashMap<>();
|
private final Map<Integer, AtomicLong> mLastRestartTimestampMap = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -491,6 +494,14 @@ public class ContextHubService extends IContextHubService.Stub {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mUserManager == null) {
|
||||||
|
mUserManager = mContext.getSystemService(UserManager.class);
|
||||||
|
if (mUserManager == null) {
|
||||||
|
Log.e(TAG, "Unable to get the UserManager service");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sendMicrophoneDisableSettingUpdateForCurrentUser();
|
sendMicrophoneDisableSettingUpdateForCurrentUser();
|
||||||
if (mSensorPrivacyManagerInternal == null) {
|
if (mSensorPrivacyManagerInternal == null) {
|
||||||
Log.e(TAG, "Unable to add a sensor privacy listener for all users");
|
Log.e(TAG, "Unable to add a sensor privacy listener for all users");
|
||||||
@@ -499,8 +510,9 @@ public class ContextHubService extends IContextHubService.Stub {
|
|||||||
|
|
||||||
mSensorPrivacyManagerInternal.addSensorPrivacyListenerForAllUsers(
|
mSensorPrivacyManagerInternal.addSensorPrivacyListenerForAllUsers(
|
||||||
SensorPrivacyManager.Sensors.MICROPHONE, (userId, enabled) -> {
|
SensorPrivacyManager.Sensors.MICROPHONE, (userId, enabled) -> {
|
||||||
if (userId == getCurrentUserId()) {
|
// If we are in HSUM mode, any user can change the microphone setting
|
||||||
Log.d(TAG, "User: " + userId + "mic privacy: " + enabled);
|
if (mUserManager.isHeadlessSystemUserMode() || userId == getCurrentUserId()) {
|
||||||
|
Log.d(TAG, "User: " + userId + " mic privacy: " + enabled);
|
||||||
sendMicrophoneDisableSettingUpdate(enabled);
|
sendMicrophoneDisableSettingUpdate(enabled);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user