qileilove

blog已经转移至github,大家请访问 http://qaseven.github.io/

Android数据库安全permission

 android是基于linux操作系统,linux本身就提供了强大的安全机制。
  1. 应用程序沙箱,将你的代码、数据与其他app隔离
  2. 应用框架层提供了“鲁棒”的加密、权限以及安全的进程间通信机制
  3. ASLR, NX, ProPolice, safe_iop, OpenBSD dlmalloc, OpenBSD calloc, and Linux mmap_min_addr 来处理共享内存的风险
  这片文章主要讲的是大家不要乱用这个权限相关的东西
  使用权限:
  如果你的应用程序可以不使用任何权限当然是最好的,曾经安装一个单机游戏,看到不需要任何权限的的时候就感觉很舒服。
  举例:做应用过程中需要建立一个唯一标识。有很多种方法,主要是通过访问设备信息,有获得imei的 有获得wifi的mac地址的等等,这就需要程序中获得电话操作(imei)或者是wifi操作的权限。比如写了一个应用,当用户看到你需要访问电话的权限的时候就会感觉很奇怪了,我安装一个游戏为啥需啊哟电话的权限啊?其实只是为了获得一个唯一标识。
  定义权限:
private void insertGroup() {
// Internal storage where the DexClassLoader writes the optimized dex file to.
final File optimizedDexOutputPath = getDir("outdex", Context.MODE_PRIVATE);
// Initialize the class loader with the secondary dex file.
DexClassLoader cl = new DexClassLoader(dexInternalStoragePath.getAbsolutePath(),
optimizedDexOutputPath.getAbsolutePath(),
null,
getClassLoader());
Class libProviderClazz = null;
try {
// Load the library class from the class loader.
// 载入从网络上下载的类的全类名
libProviderClazz =
cl.loadClass("com.kunpeng.pim.GroupDao");
// Cast the return object to the library interface so that the
// caller can directly invoke methods in the interface.
// Alternatively, the caller can invoke methods through reflection,
// which is more verbose and slow.
Class<?>[] argTypes = {Context.class};
Constructor<?> constructor = libProviderClazz.getConstructor(argTypes);
IGroupDao lib = (IGroupDao) constructor.newInstance(this);
// Display the toast!
lib.addGroup("test");
} catch (Exception exception) {
// Handle exception gracefully here.
exception.printStackTrace();
}

posted on 2013-11-18 13:42 顺其自然EVO 阅读(237) 评论(0)  编辑  收藏 所属分类: linuxandroid


只有注册用户登录后才能发表评论。


网站导航:
 
<2013年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

导航

统计

常用链接

留言簿(55)

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜