导出服务不需要权限:它是什么意思?

时间:2021-08-14 23:19:20

I created a service that is bound by other applications through AIDL, and I add it to the manifest as follows:

我创建了一个由其他应用程序通过AIDL绑定的服务,并将其添加到清单中如下:

<service android:name=".MyService">
    <intent-filter>
        <action android:name="org.example.android.myservicedemo.IService" />
    </intent-filter>
</service>

where IService is the AIDL interface.

其中IService是AIDL接口。

In this way, Eclipse show me the warning Exported service does not require permission. If I remove the intent-filter, the warning disappear, but obviously the applications are unable to bind to the service.

通过这种方式,Eclipse向我展示了导出的警告服务不需要权限。如果我删除了意图过滤器,则警告将消失,但显然应用程序无法绑定到服务。

What does this warning mean?

这个警告是什么意思?

3 个解决方案

#1


104  

I had the same issue when I updated SDK to version 20. I removed it adding android:exported property android:exported="false" like so:

当我将SDK更新到版本20时也遇到了同样的问题。我删除了它添加了android:export属性android:export ="false"

<service android:name=".MyService"
    android:exported="false">
    <intent-filter>
        <action android:name="org.example.android.myservicedemo.IService" />
    </intent-filter>
</service>

See this doc

看到这个文档

#2


47  

If you want to restrict you activity usage to your own application, then you should add exported=false to your activity's manifest statement.

如果您想将活动使用限制在您自己的应用程序中,那么您应该将export =false添加到您的活动的manifest语句中。

If you want to allow other applications to use it (explicitly through its class name or, better, by using an intent with a data type or action) then you have two choices :

如果您希望允许其他应用程序使用它(通过它的类名显式地使用它,或者更好地说,通过使用带有数据类型或操作的意图使用它),那么您有两个选择:

  • restrict those applications by using a permission
  • 通过使用权限来限制这些应用程序
  • allow all applications to use it, then you can add tools:ignore="ExportedActivity" to your activity's manifest statement.
  • 允许所有应用程序使用它,然后您可以添加工具:ignore="ExportedActivity"到活动的manifest语句。

--

- - -

Same reasonning applies to a service, with tools:ignore="ExportedService" and content providers with tools:ignore="ExportedContentProvider".

同样的道理也适用于服务,使用工具:ignore=“ExportedService”,使用工具提供内容:ignore=“ExportedContentProvider”。

#3


4  

As Jens said, "It means that other (arbitrary) applications the user has on his phone can bind to your Service and call whatever method they please that is exposed through your AIDL interface."

正如Jens所说,“这意味着用户在他手机上的其他(任意的)应用程序可以绑定到您的服务,并调用通过AIDL接口公开的任何方法。”

#1


104  

I had the same issue when I updated SDK to version 20. I removed it adding android:exported property android:exported="false" like so:

当我将SDK更新到版本20时也遇到了同样的问题。我删除了它添加了android:export属性android:export ="false"

<service android:name=".MyService"
    android:exported="false">
    <intent-filter>
        <action android:name="org.example.android.myservicedemo.IService" />
    </intent-filter>
</service>

See this doc

看到这个文档

#2


47  

If you want to restrict you activity usage to your own application, then you should add exported=false to your activity's manifest statement.

如果您想将活动使用限制在您自己的应用程序中,那么您应该将export =false添加到您的活动的manifest语句中。

If you want to allow other applications to use it (explicitly through its class name or, better, by using an intent with a data type or action) then you have two choices :

如果您希望允许其他应用程序使用它(通过它的类名显式地使用它,或者更好地说,通过使用带有数据类型或操作的意图使用它),那么您有两个选择:

  • restrict those applications by using a permission
  • 通过使用权限来限制这些应用程序
  • allow all applications to use it, then you can add tools:ignore="ExportedActivity" to your activity's manifest statement.
  • 允许所有应用程序使用它,然后您可以添加工具:ignore="ExportedActivity"到活动的manifest语句。

--

- - -

Same reasonning applies to a service, with tools:ignore="ExportedService" and content providers with tools:ignore="ExportedContentProvider".

同样的道理也适用于服务,使用工具:ignore=“ExportedService”,使用工具提供内容:ignore=“ExportedContentProvider”。

#3


4  

As Jens said, "It means that other (arbitrary) applications the user has on his phone can bind to your Service and call whatever method they please that is exposed through your AIDL interface."

正如Jens所说,“这意味着用户在他手机上的其他(任意的)应用程序可以绑定到您的服务,并调用通过AIDL接口公开的任何方法。”