4

I'm trying to use recently added TrustAgents. Manifest made by comments in official Android sources on Git. As there is said after implementing such manifest I will be able to extend classes from TrustAgentService.

That's it:

<uses-permission android:name="android.permission.CONTROL_KEYGUARD" />
<uses-permission android:name="android.permission.PROVIDE_TRUST_AGENT" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <service android:exported="true"
             android:label="@string/app_name"
             android:name=".CustomTrustAgent"
             android:permission="android.permission.BIND_TRUST_AGENT">

        <intent-filter>
            <action android:name="android.service.trust.TrustAgentService" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

        <meta-data android:name="android.service.trust.trustagent"
                   android:value="@xml/trust_agent" />

    </service>

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

But I still can't extend from TrustAgentService. Using API 22. SDK is updated to latest version.

1 Answer 1

9

Unfortunately you can't use these APIs..and me neither..

The reason why you can't directly subclass the TrustAgentService is that it's hidden from SDK jars by the @SystemApi annotation.

Furthermore the android.permission.BIND_TRUST_AGENT requires having the signature permission.

2
  • 1
    BIND_TRUST_AGENT is a signature permission but it is used to protect your service bind by unwanted client, declaring it does not affect the installation, but android.permission.PROVIDE_TRUST_AGENT is a permission MUST obtained by this app on installation, which is also signature level, so the installation fails Commented May 6, 2022 at 12:33
  • @Minami would it be possible to still install an app with that permission using adb or root? Commented Jun 29, 2022 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.