当前位置:   article > 正文

Android-Framework 不允许应用商场下载的应用安装,adb 、pm 可以正常安装

Android-Framework 不允许应用商场下载的应用安装,adb 、pm 可以正常安装

一、环境

高通865 Android10

二、情景

framework层禁止应用商场下载的应用安装,adb 、pm 可以正常安装

三、代码实现

frameworks/base/packages/PackageInstaller/src/com/android/packageinstaller/InstallStart.java
  1. @@ -35,6 +35,7 @@ import android.os.Build;
  2. import android.os.Bundle;
  3. import android.os.RemoteException;
  4. import android.util.Log;
  5. +import android.provider.Settings;
  6. /**
  7. * Select which activity is the first visible activity of the installation and forward the intent to
  8. @@ -46,10 +47,23 @@ public class InstallStart extends Activity {
  9. private static final String DOWNLOADS_AUTHORITY = "downloads";
  10. private IPackageManager mIPackageManager;
  11. private boolean mAbortInstall = false;
  12. + int installState = 0;
  13. @Override
  14. protected void onCreate(@Nullable Bundle savedInstanceState) {
  15. super.onCreate(savedInstanceState);
  16. + installState = Settings.Global.getInt(getContentResolver(), "installState", 0);
  17. + if(installState == 0){
  18. + finish();
  19. + return;
  20. + }
  21. +
  22. + Settings.Global.putInt(getContentResolver(), "installState", 0);
  23. +
  24. +
  25. +
  26. mIPackageManager = AppGlobals.getPackageManager();
  27. Intent intent = getIntent();
  28. String callingPackage = getCallingPackage();
frameworks/base/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java
  1. @@ -246,15 +246,6 @@ public class PackageInstallerActivity extends AlertActivity {
  2. }
  3. private void initiateInstall() {
  4. - Log.d(TAG," initiateInstall uid : " + Process.myUid()/100000 );
  5. - if((Process.myUid()/100000) != Process.ROOT_UID
  6. - && (Process.myUid()/100000) != Process.SHELL_UID){
  7. - return;
  8. - }
  9. -
  10. -
  11. String pkgName = mPkgInfo.packageName;
  12. // Check if there is already a package on the device with this name
  13. // but it has been renamed to something else.

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/199177
推荐阅读
相关标签
  

闽ICP备14008679号