Android數(shù)據(jù)庫(kù)安全permission
android是基于linux的操作系統(tǒng),linux本身就提供了強(qiáng)大的安全機(jī)制。
1. 應(yīng)用程序沙箱,將你的代碼、數(shù)據(jù)與其他app隔離
2. 應(yīng)用框架層提供了“魯棒”的加密、權(quán)限以及安全的進(jìn)程間通信機(jī)制
3. ASLR, NX, ProPolice, safe_iop, OpenBSD dlmalloc, OpenBSD calloc, and Linux mmap_min_addr 來處理共享內(nèi)存的風(fēng)險(xiǎn)
這片文章主要講的是大家不要亂用這個(gè)權(quán)限相關(guān)的東西
使用權(quán)限:
如果你的應(yīng)用程序可以不使用任何權(quán)限當(dāng)然是最好的,曾經(jīng)安裝一個(gè)單機(jī)游戲,看到不需要任何權(quán)限的的時(shí)候就感覺很舒服。
舉例:做應(yīng)用過程中需要建立一個(gè)唯一標(biāo)識(shí)。有很多種方法,主要是通過訪問設(shè)備信息,有獲得imei的 有獲得wifi的mac地址的等等,這就需要程序中獲得電話操作(imei)或者是wifi操作的權(quán)限。比如寫了一個(gè)應(yīng)用,當(dāng)用戶看到你需要訪問電話的權(quán)限的時(shí)候就會(huì)感覺很奇怪了,我安裝一個(gè)游戲?yàn)樯缎璋央娫挼臋?quán)限啊?其實(shí)只是為了獲得一個(gè)唯一標(biāo)識(shí)。
定義權(quán)限:
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. // 載入從網(wǎng)絡(luò)上下載的類的全類名 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 閱讀(264) 評(píng)論(0) 編輯 收藏 所屬分類: linux 、android