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.

Long Smith
  • 1,339
  • 3
  • 21
  • 40

1 Answers1

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.

simekadam
  • 7,334
  • 11
  • 56
  • 79
  • 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 – Minami May 06 '22 at 12:33
  • @Minami would it be possible to still install an app with that permission using adb or root? – binarynoise Jun 29 '22 at 13:04