Android需要提升許可權的操作方法_Android

來源:互聯網
上載者:User

許可權提升方法:
一種方法:
1、在AndroidManifest.xml中的manifest節點中添加 android:sharedUserId="android.uid.system"。
2、添加後程式在虛擬機器上是不可以直接用的。但可以用eclipse編譯成apk。
3、(這一步經驗證不執行即可)編譯成apk後用壓縮公用程式開啟apk,把META-INF目錄中的CERT.SF、CERT.RSA 兩個檔案刪除。
4、使用android內建的簽名工具signapk.jar 以及源碼中的platform.x509.pem,platform.pk8 對apk進行重新簽名。
執行:java -jar signapk.jar  platform.x509.pem platform.pk8 old.apk new.apk 執行後new.apk即為簽名後的檔案。
(註:執行命令時所有檔案這裡放在同一目錄下,如果不在同一目錄請修改路徑)。
檔案platform.x509.pem和platform.pk8我們可以在源碼的 build/target/product/security中找到。signapk.jar 可以編譯build/tools/signapk/ 得到。
5、簽名後就可以安裝使用了
第二種方法:
1、在AndroidManifest.xml中的manifest節點中添加 android:sharedUserId="android.uid.system"。
2、直接在源碼中編譯,Android中加入LOCAL_CERTIFICATE := platform
兩法方法簽名後可能會導致不能操作sdcard目錄下的檔案。

需要提升許可權的操作:
1、系統重啟:

複製代碼 代碼如下:

PowerManager pManager=(PowerManager) mContext.getSystemService(Context.POWER_SERVICE);  
pManager.reboot(""); 

2、向cache分區/cache中寫入檔案
3、修改系統時間

……

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.