permission 又一个头疼的问题 研究了一整天哦!
首先protectionLevel分为四级:
"normal"
The default value. A lower-risk permission that gives requesting applications access to isolated application-level features, with minimal risk to other applications, the system, or the user. The system automatically grants this type of permission to a requesting application at installation, without asking for the user's explicit approval (though the user always has the option to review these permissions before installing).
"dangerous"
A higher-risk permission that would give a requesting application access to private user data or control over the device that can negatively impact the user. Because this type of permission introduces potential risk, the system may not automatically grant it to the requesting application. For example, any dangerous permissions requested by an application may be displayed to the user and require confirmation before proceeding, or some other approach may be taken to avoid the user automatically allowing the use of such facilities.
"signature"
A permission that the system grants only if the requesting application is signed with the same certificate as the application that declared the permission. If the certificates match, the system automatically grants the permission without notifying the user or asking for the user's explicit approval.
"signatureOrSystem"
A permission that the system grants only to applications that are in the Android system image or that are signed with the same certificates as those in the system image. Please avoid using this option, as the signature protection level should be sufficient for most needs and works regardless of exactly where applications are installed. The "signatureOrSystem" permission is used for certain special situations where multiple vendors have applications built into a system image and need to share specific features explicitly because they are being built together.
前面几个很好理解
现在重点记忆下最后一个signatureOrSystem 顾名思义就是在拥有权限的同时还必须满足signature一致或System级别APK才拥有!
现在做了如下尝试
Test Result: |
TestCustomPermission是我自定义了一个Activity的访问权限的APK |
TestPermission 去访问TestCustomPermission的Activity |
EclipseSignature 中两个都用eclipse的签名 |
OtherSignature 中两个都用相同的另一种签名 |
DifferentSignature 中两个签名不想同 |
以下是测试结果: |
|
APP级别 |
权限设置为signatureOrSystem |
1. EclipseSignature 成功访问 ! 可以加入权限! |
2. OtherSignature 成功访问 ! 可以加入权限! |
3. DifferentSignature 访问失败! |
04-01 11:03:31.453: WARN/ActivityManager(58): Activity destroy timeout for HistoryRecord{43f38bb0 com.test.testpermission/.TestPermission}
04-01 11:03:55.285: INFO/ActivityManager(58): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.test.testpermission/.TestPermission }
04-01 11:03:55.365: INFO/ActivityManager(58): Start proc com.test.testpermission for activity com.test.testpermission/.TestPermission: pid=1273 uid=10037 gids={1015}
04-01 11:03:55.876: WARN/Resources(1273): Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f050000}
04-01 11:03:56.026: INFO/ActivityManager(58): Displayed activity com.test.testpermission/.TestPermission: 672 ms (total 672 ms)
04-01 11:03:57.305: INFO/ActivityManager(58): Starting activity: Intent { cmp=com.test.testcustompermission/.TestCustomPermission }
04-01 11:03:57.305: WARN/ActivityManager(58): Permission Denial: starting Intent { cmp=com.test.testcustompermission/.TestCustomPermission } from ProcessRecord{43f9de88 1273:com.test.testpermission/10037} (pid=1273, uid=10037) requires com.test.TESTCUSTOMPERMISSION
04-01 11:03:57.305: DEBUG/AndroidRuntime(1273): Shutting down VM
04-01 11:03:57.315: WARN/dalvikvm(1273): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): FATAL EXCEPTION: main
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.test.testcustompermission/.TestCustomPermission } from ProcessRecord{43f9de88 1273:com.test.testpermission/10037} (pid=1273, uid=10037) requires com.test.TESTCUSTOMPERMISSION
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at android.os.Parcel.readException(Parcel.java:1247)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at android.os.Parcel.readException(Parcel.java:1235)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1298)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at android.app.Activity.startActivityForResult(Activity.java:2817)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at android.app.Activity.startActivity(Activity.java:2923)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at com.test.testpermission.TestPermission.onClick(TestPermission.java:27)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at android.view.View.performClick(View.java:2408)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at android.view.View$PerformClick.run(View.java:8816)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at android.os.Handler.handleCallback(Handler.java:587)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at android.os.Handler.dispatchMessage(Handler.java:92)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at android.os.Looper.loop(Looper.java:123)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at java.lang.reflect.Method.invokeNative(Native Method)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at java.lang.reflect.Method.invoke(Method.java:521)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-01 11:03:57.325: ERROR/AndroidRuntime(1273): at dalvik.system.NativeStart.main(Native Method)
04-01 11:03:57.335: WARN/ActivityManager(58): Force finishing activity com.test.testpermission/.TestPermission
04-01 11:03:57.836: WARN/ActivityManager(58): Activity pause timeout for HistoryRecord{43fa0440 com.test.testpermission/.TestPermission}
04-01 11:03:58.856: INFO/Process(1273): Sending signal. PID: 1273 SIG: 9
04-01 11:03:58.876: INFO/ActivityManager(58): Process com.test.testpermission (pid 1273) has died.
04-01 11:03:58.876: INFO/WindowManager(58): WIN DEATH: Window{4405d010 com.test.testpermission/com.test.testpermission.TestPermission paused=false}
04-01 11:03:58.916: WARN/InputManagerService(58): Got RemoteException sending setActive(false) notification to pid 1273 uid 10037
04-01 11:04:08.169: WARN/ActivityManager(58): Activity destroy timeout for HistoryRecord{43fa0440 com.test.testpermission/.TestPermission}
权限设置为normal |
1. DifferentSignature 成功访问 ! 可以加入权限! |
System 级别 |
|
权限设置为signatureOrSystem |
1. EclipseSignature 成功访问 ! 可以加入权限! |
2. OtherSignature 成功访问 ! 可以加入权限! |
3. DifferentSignature 成功访问 ! 可以加入权限! |
|
TestCustomPermission再 system TestPermission 在APP |
1.DifferentSignature 失败 |
2.签名相同成功! |
|
最后一个实验 |
在TestCustomPermission中注册 signatureOrSystem!APP层访问 在framework API中验证! |
|
分享到:
相关推荐
1. `android.permission.ACCESS_CHECKIN_PROPERTIES`:允许应用程序读写"checkin"数据库中的"properties"表,这些信息可能用于系统更新和设备管理。 2. `android.permission.ACCESS_COARSE_LOCATION`:让应用能获取...
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission....
- **声明**:需要在`androidmanifest.xml`文件中添加`<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />`。 2. **ACCESS_FINE_LOCATION** - **定义**:用于获取精确位置信息,如GPS...
1. `android.permission.ACCESS_CHECKIN_PROPERTIES`: 这个权限允许应用读写checkin数据库中的"properties"表,checkin是Android设备向Google服务器发送设备信息的过程,主要用于更新和统计设备状态。通过此权限,...
在Android系统中,权限分为两种类型:Permission权限和Runtime Permission(运行时权限)。本文将详细介绍Permission权限机制及其在Android系统中的使用。 首先,Permission权限机制是Android系统为了防止恶意软件...
### Android.Permission大全知识点详解 #### 一、概述 在Android应用开发过程中,权限管理是非常重要的一环。合理的权限设置不仅可以保障用户的隐私安全,还可以确保应用的正常运行。本篇文章将详细介绍部分...
- **权限名称**:"android.permission.BROADCAST_PACKAGE_REMOVED" - **应用场景**:通常用于清理与已卸载应用相关的数据或资源,确保应用状态的一致性。 #### 2. CALL_PHONE - **定义**:允许应用程序直接拨打电话...
1. `android.permission.ACCESS_CHECKIN_PROPERTIES`:这个权限允许应用程序读写checkin数据库中的"properties"表,以便修改上传到服务器的数据。 2. `android.permission.ACCESS_COARSE_LOCATION`:授予应用访问...
<permission android:name="com.example.MY_PERMISSION" android:protectionLevel="signature"/> ``` 其中,`android:name`是权限的唯一标识,`android:protectionLevel`决定权限的保护级别,可以设置为`normal`...
1. android.permission.BROADCAST_PACKAGE_REMOVED:允许应用接收广播通知,当有包被移除时。通常用于安全监控等应用,以便在有包被删除时采取措施。 2. android.permission.CALL_PHONE:允许应用进行电话呼叫,...
- `android.permission.ACCESS_COARSE_LOCATION`:这个权限允许应用获取粗略的位置信息,如通过蜂窝基站或Wi-Fi热点定位,但精度较低。 - `android.permission.ACCESS_FINE_LOCATION`:应用获得此权限后,可以访问...
17. `android.permission.READ_EXTERNAL_STORAGE` 和 `android.permission.WRITE_EXTERNAL_STORAGE`:允许应用访问和修改外部存储(如SD卡)上的数据。 这些权限的设置有助于保护用户隐私,限制不必要的应用访问,...
在安卓(Android)平台上,日历和日程管理是用户常用的功能之一,涉及到系统的底层机制和API接口。本文将深入探讨安卓Android系统日历日程的操作,基于提供的"安卓Android源码——安卓Android系统日历日程操作.rar...
* `android.permission.RECEIVE_BOOT_COMPLETED`:用于接收设备启动完成事件 * `android.permission.VIBRATE`:用于控制振动 * `android.permission.CAMERA`:用于访问摄像头 * `android.permission.READ_LOGS`:...
Android SDK Permission 系统访问权限简介 Android SDK Permission 系统是一种保护 Android 设备和用户隐私的机制,它允许应用程序访问特定的系统功能和用户数据,但同时也对应用程序的权限进行限制和控制。通过在...
4. **权限组**:Android权限分组可以帮助用户理解为何应用需要某项权限。例如,`READ_CONTACTS`属于`PHONE`权限组,用户可能会更容易接受因为这些权限通常是相互关联的。 5. **权限的最佳实践**:始终只请求应用...
1. 使用Canvas绘制:Android的View类提供了丰富的绘图API,通过Canvas对象可以绘制出日历的格子、日期等元素。自定义日历视图通常需要重写onDraw()方法,根据日期范围计算每个格子的位置和大小,然后绘制相应的日期...
1. **Android多媒体API**:Android提供了MediaRecorder类,用于录制视频。通过配置MediaRecorder,可以设置视频的分辨率、编码格式、帧率等参数。例如,设置outputFormat为MPEG_4,videoEncoder为VIDEO_CODEC_H264,...
这个压缩包“安卓Android源码——androidGPS及WIFI基站定位坐标源码.zip”提供了一个实践示例,展示了如何在Android平台上实现基于GPS和WIFI的定位功能。下面将详细讲解这两个定位技术及其在源码中的应用。 1. GPS...
* android.permission.ACCESS_CHECKIN_PROPERTIES:访问登记属性,读取或写入登记check-in数据库属性表的权限。 * android.permission.ACCESS_COARSE_LOCATION:获取用户粗略的经纬度信息,定位精度大概误差在30~...