赞
踩
一、环境
高通865 Android10
二、情景
从framework层禁止应用商场下载的应用安装,adb 、pm 可以正常安装
三、代码实现
- @@ -35,6 +35,7 @@ import android.os.Build;
- import android.os.Bundle;
- import android.os.RemoteException;
- import android.util.Log;
- +import android.provider.Settings;
-
- /**
- * Select which activity is the first visible activity of the installation and forward the intent to
- @@ -46,10 +47,23 @@ public class InstallStart extends Activity {
- private static final String DOWNLOADS_AUTHORITY = "downloads";
- private IPackageManager mIPackageManager;
- private boolean mAbortInstall = false;
- + int installState = 0;
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- + installState = Settings.Global.getInt(getContentResolver(), "installState", 0);
- + if(installState == 0){
- + finish();
- + return;
- + }
- +
- + Settings.Global.putInt(getContentResolver(), "installState", 0);
- +
- +
- +
- mIPackageManager = AppGlobals.getPackageManager();
- Intent intent = getIntent();
- String callingPackage = getCallingPackage();
- @@ -246,15 +246,6 @@ public class PackageInstallerActivity extends AlertActivity {
- }
-
- private void initiateInstall() {
- - Log.d(TAG," initiateInstall uid : " + Process.myUid()/100000 );
- - if((Process.myUid()/100000) != Process.ROOT_UID
- - && (Process.myUid()/100000) != Process.SHELL_UID){
- - return;
- - }
- -
- -
- String pkgName = mPkgInfo.packageName;
- // Check if there is already a package on the device with this name
- // but it has been renamed to something else.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。