用户 10200 和当前进程都没有 com.huawei.permission.SECURITY_DIAGNOSE
Neither user 10200 nor current process has com.huawei.permission.SECURITY_DIAGNOSE
在尝试实施 SafetyNet 时,我添加了这个 dependency:
implementation 'com.huawei.hms:safetydetect:6.3.0.301'
并且还添加了AndroidManifest.xml
的权限:
<uses-permission android:name="com.huawei.permission.SECURITY_DIAGNOSE"/>
但这在某种程度上没有按预期工作:
E/RootDetect: `isRoot` exception : Must have `com.huawei.permission.SECURITY_DIAGNOSE` permission.
Neither user `10200` nor current process has `com.huawei.permission.SECURITY_DIAGNOSE`.
也在 Apps & services
> Permissions
> View all permissions
下方,它没有列出 - 所有其他的正在合并。合并时是否有任何进一步的条件或许可可能被剥夺? AGP 版本为 7.1.2.
奇怪的是,在注释掉依赖项时,我仍然收到错误消息。
Must have com.huawei.permission.SECURITY_DIAGNOSE
permission.
此自定义权限不需要添加到 SafeDetect 套件中。另外,自定义的权限在权限管理页面是不显示的。一般在权限管理页面显示system-level权限。
华为安全检测套件不需要以下权限“SECURITYDIAGNOSE”,而只需要“INTERNET”和“ACCESSWIFI_STATE”。请参考下面 URL 示例代码示例和指南。
uses-permission android:name="com.huawei.permission.SECURITY_DIAGNOSE
<uses-permission android:name="android.permission.INTERNET" />
<!-- Access WiFi State -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
String alg
未定义;这是示例的工作版本 source:
SafetyDetectClient mClient = SafetyDetect.getClient(this);
// TODO: Change the nonce generation to include your own,
// used once value, ideally from your remote server.
byte[] nonce = ("Sample" + System.currentTimeMillis()).getBytes();
SysIntegrityRequest sysintegrityrequest = new SysIntegrityRequest();
sysintegrityrequest.setAppId("3*******"); // TODO: set your appId.
sysintegrityrequest.setNonce(nonce);
sysintegrityrequest.setAlg("RS256"); // or "PS256"
Task<SysIntegrityResp> task = mClient.sysIntegrity(sysintegrityrequest);
task.addOnSuccessListener(response -> {
// Indicates that communication with the service was successful.
String jwsStr = response.getResult();
Log.d(LOG_TAG, "SysIntegrityResp: " + jwsStr);
}).addOnFailureListener(e -> {
// An error occurred during communication with the service.
if (e instanceof ApiException) {
// An error with the HMS API contains some additional details.
ApiException apiException = (ApiException) e;
// You can retrieve the status code using the apiException.getStatusCode() method.
Log.e(LOG_TAG, "Error: " + SafetyDetectStatusCodes.getStatusCodeString(
apiException.getStatusCode()) + ": " + apiException.getMessage()
);
} else {
// A different, unknown type of error occurred.
Log.e(LOG_TAG, "ERROR: " + e.getMessage());
}
});
现在我不知道如何获取或验证 nonce
或如何处理 jwsStr
,但我得到一个 SysIntegrityResp
- 但这是另一个问题。文档中建议添加权限的部分似乎有点误导 - 日志中的错误消息也是如此。刚找到这个 Java 服务器示例 source,这对理解很有帮助。过滤 hmssafetydetect
的日志时,可以看到发生了什么。
在尝试实施 SafetyNet 时,我添加了这个 dependency:
implementation 'com.huawei.hms:safetydetect:6.3.0.301'
并且还添加了AndroidManifest.xml
的权限:
<uses-permission android:name="com.huawei.permission.SECURITY_DIAGNOSE"/>
但这在某种程度上没有按预期工作:
E/RootDetect: `isRoot` exception : Must have `com.huawei.permission.SECURITY_DIAGNOSE` permission.
Neither user `10200` nor current process has `com.huawei.permission.SECURITY_DIAGNOSE`.
也在 Apps & services
> Permissions
> View all permissions
下方,它没有列出 - 所有其他的正在合并。合并时是否有任何进一步的条件或许可可能被剥夺? AGP 版本为 7.1.2.
奇怪的是,在注释掉依赖项时,我仍然收到错误消息。
Must have
com.huawei.permission.SECURITY_DIAGNOSE
permission.
此自定义权限不需要添加到 SafeDetect 套件中。另外,自定义的权限在权限管理页面是不显示的。一般在权限管理页面显示system-level权限。
华为安全检测套件不需要以下权限“SECURITYDIAGNOSE”,而只需要“INTERNET”和“ACCESSWIFI_STATE”。请参考下面 URL 示例代码示例和指南。
uses-permission android:name="com.huawei.permission.SECURITY_DIAGNOSE
<uses-permission android:name="android.permission.INTERNET" />
<!-- Access WiFi State -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
String alg
未定义;这是示例的工作版本 source:
SafetyDetectClient mClient = SafetyDetect.getClient(this);
// TODO: Change the nonce generation to include your own,
// used once value, ideally from your remote server.
byte[] nonce = ("Sample" + System.currentTimeMillis()).getBytes();
SysIntegrityRequest sysintegrityrequest = new SysIntegrityRequest();
sysintegrityrequest.setAppId("3*******"); // TODO: set your appId.
sysintegrityrequest.setNonce(nonce);
sysintegrityrequest.setAlg("RS256"); // or "PS256"
Task<SysIntegrityResp> task = mClient.sysIntegrity(sysintegrityrequest);
task.addOnSuccessListener(response -> {
// Indicates that communication with the service was successful.
String jwsStr = response.getResult();
Log.d(LOG_TAG, "SysIntegrityResp: " + jwsStr);
}).addOnFailureListener(e -> {
// An error occurred during communication with the service.
if (e instanceof ApiException) {
// An error with the HMS API contains some additional details.
ApiException apiException = (ApiException) e;
// You can retrieve the status code using the apiException.getStatusCode() method.
Log.e(LOG_TAG, "Error: " + SafetyDetectStatusCodes.getStatusCodeString(
apiException.getStatusCode()) + ": " + apiException.getMessage()
);
} else {
// A different, unknown type of error occurred.
Log.e(LOG_TAG, "ERROR: " + e.getMessage());
}
});
现在我不知道如何获取或验证 nonce
或如何处理 jwsStr
,但我得到一个 SysIntegrityResp
- 但这是另一个问题。文档中建议添加权限的部分似乎有点误导 - 日志中的错误消息也是如此。刚找到这个 Java 服务器示例 source,这对理解很有帮助。过滤 hmssafetydetect
的日志时,可以看到发生了什么。