Merge "Notify CHRE of host endpoint [dis]connections"
This commit is contained in:
committed by
Android (Google) Code Review
commit
8560519713
@@ -30,6 +30,7 @@ import android.compat.annotation.ChangeId;
|
||||
import android.compat.annotation.EnabledAfter;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.hardware.contexthub.HostEndpointInfo;
|
||||
import android.hardware.location.ContextHubInfo;
|
||||
import android.hardware.location.ContextHubManager;
|
||||
import android.hardware.location.ContextHubTransaction;
|
||||
@@ -42,6 +43,7 @@ import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.Process;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
@@ -329,6 +331,15 @@ public class ContextHubClientBroker extends IContextHubClient.Stub
|
||||
mAppOpsManager = context.getSystemService(AppOpsManager.class);
|
||||
|
||||
startMonitoringOpChanges();
|
||||
|
||||
HostEndpointInfo info = new HostEndpointInfo();
|
||||
info.hostEndpointId = (char) mHostEndPointId;
|
||||
info.packageName = mPackage;
|
||||
info.attributionTag = mAttributionTag;
|
||||
info.type = (mUid == Process.SYSTEM_UID)
|
||||
? HostEndpointInfo.Type.TYPE_FRAMEWORK
|
||||
: HostEndpointInfo.Type.TYPE_APP;
|
||||
mContextHubProxy.onHostEndpointConnected(info);
|
||||
}
|
||||
|
||||
/* package */ ContextHubClientBroker(
|
||||
@@ -862,6 +873,8 @@ public class ContextHubClientBroker extends IContextHubClient.Stub
|
||||
mRegistered = false;
|
||||
}
|
||||
mAppOpsManager.stopWatchingMode(this);
|
||||
|
||||
mContextHubProxy.onHostEndpointDisconnected(mHostEndPointId);
|
||||
}
|
||||
|
||||
private String authStateToString(@ContextHubManager.AuthorizationState int state) {
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.android.server.location.contexthub;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.hardware.contexthub.HostEndpointInfo;
|
||||
import android.hardware.contexthub.V1_0.ContextHub;
|
||||
import android.hardware.contexthub.V1_0.ContextHubMsg;
|
||||
import android.hardware.contexthub.V1_0.TransactionResult;
|
||||
@@ -238,6 +239,20 @@ public abstract class IContextHubWrapper {
|
||||
*/
|
||||
public abstract void onMicrophoneSettingChanged(boolean enabled);
|
||||
|
||||
/**
|
||||
* Invoked whenever a host client connects with the framework.
|
||||
*
|
||||
* @param info The host endpoint info.
|
||||
*/
|
||||
public void onHostEndpointConnected(HostEndpointInfo info) {}
|
||||
|
||||
/**
|
||||
* Invoked whenever a host client disconnects from the framework.
|
||||
*
|
||||
* @param hostEndpointId The ID of the host endpoint that disconnected.
|
||||
*/
|
||||
public void onHostEndpointDisconnected(short hostEndpointId) {}
|
||||
|
||||
/**
|
||||
* Sends a message to the Context Hub.
|
||||
*
|
||||
@@ -407,6 +422,24 @@ public abstract class IContextHubWrapper {
|
||||
onSettingChanged(android.hardware.contexthub.Setting.WIFI_SCANNING, enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHostEndpointConnected(HostEndpointInfo info) {
|
||||
try {
|
||||
mHub.onHostEndpointConnected(info);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException in onHostEndpointConnected");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHostEndpointDisconnected(short hostEndpointId) {
|
||||
try {
|
||||
mHub.onHostEndpointDisconnected((char) hostEndpointId);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException in onHostEndpointDisconnected");
|
||||
}
|
||||
}
|
||||
|
||||
@ContextHubTransaction.Result
|
||||
public int sendMessageToContextHub(
|
||||
short hostEndpointId, int contextHubId, NanoAppMessage message)
|
||||
|
||||
Reference in New Issue
Block a user