做系统定制的同学可能会遇到第三方的软件比如Google Play store套件或者Youtube报错的问题,常常我们知道报错是因为什么但是就是没法改,有一种种很极端的方法就是像我这样直接把报错的地方屏蔽掉,这里记得屏蔽以后把应用干掉,不然会使系统卡死。
}if (mShowDialogs && !mSleeping && !mShuttingDown) {
android.util.Log.d("song","applicationLabel="+mContext.getPackageManager().getApplicationLabel(proc.info));
//holatek patch add by szh for youtube error begin 20190507
if(mContext.getPackageManager().getApplicationLabel(proc.info).equals("YouTube")){
android.util.Log.d("song","block the youtube error dialog !!!");
forceStopPackage("com.google.android.youtube.tv",UserHandle.USER_ALL);
}else if(mContext.getPackageManager().getApplicationLabel(proc.info).equals("com.android.vending")){
forceStopPackage("com.android.vending",UserHandle.USER_ALL);
}else if(mContext.getPackageManager().getApplicationLabel(proc.info).equals("com.google.android.gms")){
forceStopPackage("com.google.android.gms",UserHandle.USER_ALL);
}else if(mContext.getPackageManager().getApplicationLabel(proc.info).equals("com.google.android.gsf")){
forceStopPackage("com.google.android.gsf",UserHandle.USER_ALL);
}else if(mContext.getPackageManager().getApplicationLabel(proc.info).equals("com.google.android.gsf.login")){
forceStopPackage("com.google.android.gsf.login",UserHandle.USER_ALL);
}else{
Dialog d = new AppErrorDialog(mContext,ActivityManagerService.this, res, proc);
d.show();
proc.crashDialog = d;
}
//holatek patch add by szh for youtube error end 20190507
}
--------------AMS中杀死应用的方法
killApplicationWithAppId(pkgName,1,"kill youtube"); -----会自动start应用造成死机
forceStopPackage(,UserHandle.USER_ALL);-----可以停止应用的进程