Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
423 views
in Technique[技术] by (71.8m points)

android - Creating your own permissions

Is it possible to create your own permissions using the <uses-permission> tag?

Like this

<uses-permission android:name="com.android.myapp.INSTALL_LICENSE"></uses-permission>

Where com.android.myapp is the name of my package and INSTALL_LICENSE is the permission that users must accept

In addition I would like to budle a whole lot of existing permissions into this one permission so client would only need to declare a single permission and they would get the INTERNET, PHONE_STATE and other permissions.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

"In addition I would like to budle a whole lot of existing permissions into this one permission".

Um, no. That would be deliberately introducing a security hole, allowing other applications to bypass the actual permissions. I hope this would result in the app being pulled from Market, if it is found.

If an application is getting access to INTERNET, PHONE_STATE, or whatever else, they need to declare the real permission they are using which is directly associated with that functionality.

What is okay is to have your own permission to restrict app access to your functionality, and inside of your own .apk you implement that functionality using other permissions... but do not directly expose that to the app.

In other words, this is okay: Declare a permission for DO_SOMETHING, that allows an application to say send a broadcast do you that will have you do something and return a "true" or "false" result indicating whether it succeeded.

This is not okay: Declare a permission for DO_SOMETHING, which exposes an API that allows an application to retrieve the phone state, or send some data they provide off the device, or retrieve GPS information.

To declare a permission in your app, you use the tag as described in the docs.

However something you really need to be aware of: currently if an app is installed before your app and requests your permission, it will not be granted that permission. (Because the permission was not known at the time it was installed.) For it to be granted the permission, it needs to be re-installed or updated after your app is installed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...