应用程序在尝试授权健康工具包时卡住了

App stuck while trying to authorize health kit

我正在尝试为我的应用程序获取授权,以便能够读取和写入华为智能手环的心率。但是,每次我启动应用程序时,一旦授权请求开始,它就会卡在登录屏幕上...... 该应用程序未被重定向到任何地方以提供授权,它只是卡住了,我无法从我的应用程序获得任何类型的响应,甚至登录屏幕上的按钮也没有响应。

这是我请求授权的登录代码。


import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Button
import com.huawei.hms.hihealth.HuaweiHiHealth
import com.huawei.hms.hihealth.SettingController
import com.huawei.hms.hihealth.data.Scopes

class login : AppCompatActivity() {
    private var mSettingController: SettingController?  = null
    private val REQUEST_AUTH = 1002
    private val TAG = "HealthKitAuthActivity"
    private var mContext: Context? = null


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //Inicia el pedido de autorizacion por parte del usuario, una sola vez por instalacion
        initService()
        //Proceso de autorizacion
        requestAuth()
        setContentView(R.layout.activity_login)

        val irMain: Button = findViewById(R.id.login)
        irMain.setOnClickListener {
            val intent = Intent(this, Menu::class.java)
            startActivity(intent)
        }

    }

    private fun initService(){
        mContext = this
        Log.i(TAG, "HiHealthKitClient connect to service")
        mSettingController = HuaweiHiHealth.getSettingController(mContext!!)
    }
    private fun requestAuth(){
        val scopes = arrayOf(
            //VER Y GUARDAR EL RITMO CARDIACO DEL USUARIO
            Scopes.HEALTHKIT_HEARTRATE_READ, Scopes.HEALTHKIT_OXYGEN_SATURATION_READ,
            //VER Y GUARDAR LA SATURACION DE OXIGENO DEL USUARIO
            Scopes.HEALTHKIT_HEARTRATE_WRITE, Scopes.HEALTHKIT_OXYGEN_SATURATION_WRITE)
        val intent = mSettingController!!.requestAuthorizationIntent(scopes, true)
        Log.i(TAG, "start authorization activity")
        startActivityForResult(intent, REQUEST_AUTH)
    }
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)

        // Handle only the authorized responses
        if (requestCode == REQUEST_AUTH) {
            // Obtain the authorization response from the intent.
            val result = mSettingController!!.parseHealthKitAuthResultFromIntent(data)
            if (result == null) {
                Log.w(TAG, "authorization fail")
                return
            }
            // Check whether the authorization result is successful.
            if (result.isSuccess) {
                Log.i(TAG, "authorization success")
            } else {
                Log.w(TAG, "authorization fail, errorCode:" + result.errorCode)
            }
        }
    }

}

我也授权失败,错误代码 28 和 W/HmsHealth_kit HealthKitAuthHub:HMS SignInResult 结果在 Android Studio 的 运行 选项卡上失败。

目前正在关注 https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/add-permissions-0000001050069726

上的文档

更新: 这是 logcat

2021-09-26 20:41:05.399 17342-17342/? I/.example.catre: Late-enabling -Xcheck:jni
2021-09-26 20:41:05.399 17342-17342/? I/.example.catre: Late-enabling -Xcheck:jni
2021-09-26 20:41:05.399 17342-17342/? I/.example.catre: Late-enabling -Xcheck:jni
2021-09-26 20:41:05.443 17342-17342/? E/.example.catre: Unknown bits set in runtime_flags: 0x8000
2021-09-26 20:41:05.443 17342-17342/? E/.example.catre: Unknown bits set in runtime_flags: 0x8000
2021-09-26 20:41:05.443 17342-17342/? E/.example.catre: Unknown bits set in runtime_flags: 0x8000
2021-09-26 20:41:05.538 17342-17342/com.example.catrep I/.example.catre: The ClassLoaderContext is a special shared library.
2021-09-26 20:41:05.584 17342-17342/com.example.catrep I/Perf: Connecting to perf service.
2021-09-26 20:41:05.607 17342-17342/com.example.catrep I/AGConnectProvider: AGConnectInitializeProvider#onCreate
2021-09-26 20:41:05.607 17342-17342/com.example.catrep I/AGConnectInstance: AGConnectInstance#initialize
2021-09-26 20:41:05.608 17342-17342/com.example.catrep I/ServiceRegistrarParser: getServices
2021-09-26 20:41:05.609 17342-17342/com.example.catrep I/ServiceRegistrarParser: services:0
2021-09-26 20:41:05.618 17342-17374/com.example.catrep I/HMSSDK_HMSPackageManager: enter checkHmsIsSpoof
2021-09-26 20:41:05.620 17342-17375/com.example.catrep E/Perf: Fail to get file list com.example.catrep
2021-09-26 20:41:05.621 17342-17375/com.example.catrep E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
2021-09-26 20:41:05.622 17342-17375/com.example.catrep E/Perf: Fail to get file list com.example.catrep
2021-09-26 20:41:05.622 17342-17375/com.example.catrep E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
2021-09-26 20:41:05.623 17342-17375/com.example.catrep E/Perf: Fail to get file list oat
2021-09-26 20:41:05.623 17342-17375/com.example.catrep E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
2021-09-26 20:41:05.658 17342-17374/com.example.catrep I/HMSSDK_ReadApkFileUtil: verifyMDMSignatureV2 verify successful!
2021-09-26 20:41:05.671 17342-17342/com.example.catrep I/HealthKitAuthActivity: HiHealthKitClient connect to service
2021-09-26 20:41:05.676 17342-17342/com.example.catrep I/HealthKitAuthActivity: start authorization activity
2021-09-26 20:41:05.731 17342-17342/com.example.catrep W/.example.catre: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2021-09-26 20:41:05.732 17342-17342/com.example.catrep W/.example.catre: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2021-09-26 20:41:05.818 17342-17374/com.example.catrep I/HMSSDK_HMSPackageManager: check hms state: 2
2021-09-26 20:41:05.822 17342-17374/com.example.catrep I/HMSSDK_HMSPackageManager: Succeed to find HMS apk: com.huawei.hwid version: 30003300
2021-09-26 20:41:05.830 17342-17342/com.example.catrep V/Activity: mLastPackageName-com.example.catrep.login
2021-09-26 20:41:05.902 17342-17376/com.example.catrep I/AdrenoGLES: QUALCOMM build                   : b7efb54, I285e059637
    Build Date                       : 10/31/19
    OpenGL ES Shader Compiler Version: EV031.27.05.02
    Local Branch                     : 
    Remote Branch                    : 
    Remote Branch                    : 
    Reconstruct Branch               : 
2021-09-26 20:41:05.903 17342-17376/com.example.catrep I/AdrenoGLES: Build Config                     : S L 8.0.12 AArch64
2021-09-26 20:41:05.907 17342-17376/com.example.catrep I/AdrenoGLES: PFP: 0x005ff112, ME: 0x005ff066
2021-09-26 20:41:05.909 17342-17376/com.example.catrep W/AdrenoUtils: <ReadGpuID_from_sysfs:194>: Failed to open /sys/class/kgsl/kgsl-3d0/gpu_model
2021-09-26 20:41:05.909 17342-17376/com.example.catrep W/AdrenoUtils: <ReadGpuID:218>: Failed to read chip ID from gpu_model. Fallback to use the GSL path
2021-09-26 20:41:05.899 17342-17342/com.example.catrep W/RenderThread: type=1400 audit(0.0:9683): avc: denied { search } for name="kgsl-3d0" dev="sysfs" ino=30286 scontext=u:r:untrusted_app:s0:c215,c256,c512,c768 tcontext=u:object_r:sysfs_kgsl:s0 tclass=dir permissive=0
2021-09-26 20:41:05.934 17342-17376/com.example.catrep W/Gralloc3: mapper 3.x is not supported
2021-09-26 20:41:06.108 17342-17342/com.example.catrep W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@3282745
2021-09-26 20:41:06.119 17342-17342/com.example.catrep I/HmsHealth_kit HealthKitAuthHub: HealthKitAuthHubActivity onCreate
2021-09-26 20:41:06.119 17342-17342/com.example.catrep I/HmsHealth_kit HealthKitAuthHub: init params success, to enable auth is true
2021-09-26 20:41:06.119 17342-17342/com.example.catrep I/HmsHealth_kit HealthKitAuthHub: HiHealthKitClient connect to service
2021-09-26 20:41:06.119 17342-17342/com.example.catrep I/HmsHealth_kit HealthKitAuthHub: on signInHwId click
2021-09-26 20:41:06.133 17342-17342/com.example.catrep I/HMSSDK_HianalyticsExist: In isHianalyticsExist, Failed to find class HiAnalyticsConfig.
2021-09-26 20:41:06.133 17342-17342/com.example.catrep I/HMSSDK_HianalyticsExist: hianalytics exist: false
2021-09-26 20:41:06.135 17342-17342/com.example.catrep I/HMSSDK_HMSBIInitializer: Builder->biInitFlag :false
2021-09-26 20:41:06.137 17342-17342/com.example.catrep I/NetworkKit_CountryCodeBean: main|null|com.huawei.hms.framework.network.grs.local.model.CountryCodeBean|getVendorCountryCode|39|countryCode by ro.hw.country is: UNKNOWN
2021-09-26 20:41:06.139 17342-17342/com.example.catrep I/NetworkKit_CountryCodeBean: main|null|com.huawei.hms.framework.network.grs.local.model.CountryCodeBean|getSimCountryCode|74|countryCode by SimCountryIso is: co
2021-09-26 20:41:06.139 17342-17342/com.example.catrep I/NetworkKit_CountryCodeBean: main|null|com.huawei.hms.framework.network.grs.local.model.CountryCodeBean|init|32|get issue_country code from SIM_COUNTRY
2021-09-26 20:41:06.140 17342-17342/com.example.catrep I/HMSSDK_AnalyticsSwitchHolder: not ChinaROM
2021-09-26 20:41:06.143 17342-17342/com.example.catrep I/HMSSDK_AnalyticsSwitchHolder: Get OOBE failed
2021-09-26 20:41:06.143 17342-17342/com.example.catrep I/HMSSDK_[ACCOUNT]AccountAuthServiceImpl: silentSignIn
2021-09-26 20:41:06.164 17342-17389/com.example.catrep I/HMSSDK_HuaweiApi: inner hms is empty,hms pkg name is com.huawei.hwid
2021-09-26 20:41:06.166 17342-17389/com.example.catrep I/HMSSDK_HuaweiApiManager: sendRequest
2021-09-26 20:41:06.167 17342-17389/com.example.catrep I/HMSSDK_BaseHmsClient: ====== HMSSDK version: 50300301 ======
2021-09-26 20:41:06.168 17342-17389/com.example.catrep I/HMSSDK_BaseHmsClient: Enter connect, Connection Status: 1
2021-09-26 20:41:06.169 17342-17389/com.example.catrep I/HMSSDK_BaseHmsClient: connect minVersion:40004000 packageName:com.huawei.hwid
2021-09-26 20:41:06.172 17342-17342/com.example.catrep V/Activity: mLastPackageName-com.huawei.hms.hihealth.activity.HealthKitAuthHubActivity
2021-09-26 20:41:06.172 17342-17389/com.example.catrep I/HMSSDK_Util: available exist: true
2021-09-26 20:41:06.175 17342-17389/com.example.catrep I/HMSSDK_Util: available exist: true
2021-09-26 20:41:06.179 17342-17389/com.example.catrep I/HMSSDK_HMSPackageManager: current versionCode:30003300, minimum version requirements: 40004000
2021-09-26 20:41:06.181 17342-17389/com.example.catrep I/HMSSDK_AvailableAdapter: The current version does not meet the minimum version requirements
2021-09-26 20:41:06.182 17342-17389/com.example.catrep I/HMSSDK_BaseHmsClient: check available result: 2
2021-09-26 20:41:06.183 17342-17389/com.example.catrep I/HMSSDK_BaseHmsClient: bindCoreService3.0 fail, start resolution now.
2021-09-26 20:41:06.184 17342-17389/com.example.catrep I/HMSSDK_BaseHmsClient: enter HmsCore resolution
2021-09-26 20:41:06.187 17342-17389/com.example.catrep I/HMSSDK_UIUtil: appProcess.importance is 100
2021-09-26 20:41:06.189 17342-17389/com.example.catrep I/HMSSDK_UIUtil: isForground is true***  isLockedState is false
2021-09-26 20:41:06.192 17342-17389/com.example.catrep I/HMSSDK_UIUtil: appProcess.importance is 100
2021-09-26 20:41:06.193 17342-17389/com.example.catrep I/HMSSDK_UIUtil: isForground is true***  isLockedState is false
2021-09-26 20:41:06.194 17342-17389/com.example.catrep I/HMSSDK_AvailableAdapter: startResolution
2021-09-26 20:41:06.235 17342-17342/com.example.catrep W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@c22503e
2021-09-26 20:41:06.247 17342-17342/com.example.catrep E/HMSSDK_BridgeActivity: An exception occurred while reading: setDisplaySideModecom.huawei.android.view.WindowManagerEx$LayoutParamsEx
2021-09-26 20:41:06.248 17342-17342/com.example.catrep I/HMSSDK_UpdateAdapterMgr: onActivityCreate
2021-09-26 20:41:06.250 17342-17342/com.example.catrep I/HMSSDK_UpdateAdapter: target HMS Core packageName is com.huawei.hwid
2021-09-26 20:41:06.251 17342-17342/com.example.catrep I/HMSSDK_UpdateAdapter: old framework HMSCore upgrade process
2021-09-26 20:41:06.253 17342-17342/com.example.catrep E/HMSSDK_SystemUtils: isSystemApp Exception: android.content.pm.PackageManager$NameNotFoundException: com.huawei.appmarket
2021-09-26 20:41:06.254 17342-17342/com.example.catrep I/HMSSDK_UpdateManager: app is: com.huawei.appmarket;status is:NOT_INSTALLED
2021-09-26 20:41:06.256 17342-17342/com.example.catrep I/HMSSDK_UpdateManager: In getAndroidMarketSetting, configuration not found for android channel market setting.
2021-09-26 20:41:06.257 17342-17342/com.example.catrep I/HMSSDK_UpdateManager: typeList is empty, no upgrade solution
2021-09-26 20:41:06.275 17342-17342/com.example.catrep V/Activity: mLastPackageName-com.huawei.hms.activity.BridgeActivity
2021-09-26 20:41:06.287 17342-17342/com.example.catrep E/HMSSDK_BridgeActivity: An exception occurred while reading: onApplyWindowInsetscom.huawei.android.view.WindowManagerEx$LayoutParamsEx
2021-09-26 20:41:06.319 17342-17342/com.example.catrep W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@4a144ee
2021-09-26 20:41:06.331 17342-17342/com.example.catrep E/HMSSDK_BridgeActivity: An exception occurred while reading: setDisplaySideModecom.huawei.android.view.WindowManagerEx$LayoutParamsEx
2021-09-26 20:41:06.333 17342-17342/com.example.catrep E/HMSSDK_BridgeActivity: In initialize, Failed to create 'IUpdateWizard' instance.Invalid name: 
2021-09-26 20:41:06.334 17342-17342/com.example.catrep I/HMSSDK_BridgeActivity: Enter finish.
2021-09-26 20:41:06.358 17342-17342/com.example.catrep I/HMSSDK_UpdateAdapter: onBridgeActivityResult
2021-09-26 20:41:06.359 17342-17342/com.example.catrep I/HMSSDK_BaseHmsClient: notifyFailed result: 28
2021-09-26 20:41:06.360 17342-17342/com.example.catrep I/HMSSDK_HuaweiApiManager: onConnectionFailed
2021-09-26 20:41:06.362 17342-17342/com.example.catrep I/HMSSDK_BridgeActivity: Enter finish.
2021-09-26 20:41:06.363 17342-17389/com.example.catrep I/HMSSDK_Util: available exist: true
2021-09-26 20:41:06.365 17342-17389/com.example.catrep I/HMSSDK_[AccountSDK]AccountSignInTaskApiCall: ResponseErrorCode.status:907135003
2021-09-26 20:41:06.367 17342-17389/com.example.catrep I/HMSSDK_[AccountSDK]AccountSignInTaskApiCall: signIn complete, response is null, failed
2021-09-26 20:41:06.370 17342-17389/com.example.catrep I/HMSSDK_[AccountSDK]AccountAuthMemCache: saveDefaultAccountSignInAccount start.
2021-09-26 20:41:06.371 17342-17389/com.example.catrep I/HMSSDK_[AccountSDK]AccountAuthMemCache: saveDefaultAccountSignInAccount start.
2021-09-26 20:41:06.376 17342-17389/com.example.catrep I/HMSSDK_BaseHmsClient: Enter disconnect, Connection Status: 5
2021-09-26 20:41:06.386 17342-17342/com.example.catrep I/HmsHealth_kit HealthKitAuthHub: silentSignIn failure on exception
2021-09-26 20:41:06.387 17342-17342/com.example.catrep I/HMSSDK_[ACCOUNT]AccountAuthServiceImpl: getSignInIntent
2021-09-26 20:41:06.388 17342-17342/com.example.catrep I/HMSSDK_[AccountSDK]AccountAuthUtil: getSignInIntent
2021-09-26 20:41:06.401 17342-17342/com.example.catrep V/Activity: mLastPackageName-com.huawei.hms.hihealth.activity.HealthKitAuthHubActivity
2021-09-26 20:41:06.428 17342-17342/com.example.catrep W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@9bf0d8f
2021-09-26 20:41:06.433 17342-17342/com.example.catrep I/HMSSDK_[ACCOUNTSDK]AccountSignInHubActivity: onCreate
2021-09-26 20:41:06.439 17342-17342/com.example.catrep I/HMSSDK_[ACCOUNTSDK]AccountSignInHubActivity: checkMinVersion start.
2021-09-26 20:41:06.441 17342-17342/com.example.catrep I/HMSSDK_HmsAccountKitVersionCheckUtil: ====== HMSSDK version: 50300301 ======
2021-09-26 20:41:06.441 17342-17342/com.example.catrep I/HMSSDK_HmsAccountKitVersionCheckUtil: check minVersion:40004000
2021-09-26 20:41:06.445 17342-17342/com.example.catrep I/HMSSDK_HMSPackageManager: current versionCode:30003300, minimum version requirements: 40004000
2021-09-26 20:41:06.447 17342-17342/com.example.catrep I/HMSSDK_AvailableAdapter: The current version does not meet the minimum version requirements
2021-09-26 20:41:06.449 17342-17342/com.example.catrep I/HMSSDK_UIUtil: appProcess.importance is 100
2021-09-26 20:41:06.450 17342-17342/com.example.catrep I/HMSSDK_UIUtil: isForground is true***  isLockedState is false
2021-09-26 20:41:06.451 17342-17342/com.example.catrep I/HMSSDK_AvailableAdapter: startResolution
2021-09-26 20:41:06.472 17342-17342/com.example.catrep V/Activity: mLastPackageName-com.huawei.hms.account.internal.ui.activity.AccountSignInHubActivity
2021-09-26 20:41:06.506 17342-17342/com.example.catrep W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@7f00a08
2021-09-26 20:41:06.520 17342-17342/com.example.catrep E/HMSSDK_BridgeActivity: An exception occurred while reading: setDisplaySideModecom.huawei.android.view.WindowManagerEx$LayoutParamsEx
2021-09-26 20:41:06.522 17342-17342/com.example.catrep I/HMSSDK_UpdateAdapterMgr: onActivityCreate
2021-09-26 20:41:06.523 17342-17342/com.example.catrep I/HMSSDK_BridgeActivity: Enter finish.
2021-09-26 20:41:06.528 17342-17342/com.example.catrep I/HMSSDK_UpdateAdapterMgr: finish one
2021-09-26 20:41:06.544 17342-17342/com.example.catrep V/Activity: mLastPackageName-com.huawei.hms.account.internal.ui.activity.AccountSignInHubActivity
2021-09-26 20:41:06.555 17342-17342/com.example.catrep I/HMSSDK_UpdateAdapter: onBridgeActivityDestroy
2021-09-26 20:41:06.556 17342-17342/com.example.catrep I/HMSSDK_UpdateAdapterMgr: onActivityDestroy
2021-09-26 20:41:06.565 17342-17342/com.example.catrep V/Activity: onStop mLastPackageResume = false com.huawei.hms.activity.BridgeActivity@e5c5269
2021-09-26 20:41:06.576 17342-17342/com.example.catrep I/HMSSDK_UpdateAdapter: onBridgeActivityDestroy
2021-09-26 20:41:06.577 17342-17342/com.example.catrep I/HMSSDK_UpdateAdapterMgr: onActivityDestroy
2021-09-26 20:41:06.578 17342-17342/com.example.catrep I/HMSSDK_UpdateAdapterMgr: reset

在下面的日志中

com.huawei.appmarket;status is:NOT_INSTALLED

升级失败可能是因为没有安装华为应用市场。 因此,请检查测试设备是否为华为设备,是否安装了华为应用市场。

登录失败的可能原因是健康包依赖华为应用市场登录。如果测试设备中没有华为应用市场,则会报错。