默认关闭应用的通知
路径:
/frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java
if (res.returnCode == PackageManager.INSTALL_SUCCEEDED) {
prepareAppDataAfterInstallLIF(newPackage);
//Add By LYZK
//"eu.chainfire.supersu"需要屏幕的APK包名
if("eu.chainfire.supersu".equals(pkgName))
{
disableAppNotification(pkgName);
}
//End Add
} else {
// Remove package from internal structures, but keep around any
// data that might have already existed
deletePackageLIF(pkgName, UserHandle.ALL, false, null,
PackageManager.DELETE_KEEP_DATA, res.removedInfo, true, null);
}
} catch (PackageManagerException e) {
res.setError("Package couldn't be installed in " + pkg.codePath, e);
}
Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
}
//Add By LYZK
private void disableAppNotification(String packageName){
//NotificationManager mNotificationManager =(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
INotificationManager mNotificationManager = INotificationManager.Stub.asInterface(ServiceManager.getService(Context.NOTIFICATION_SERVICE));
try {
int uid = getPackageUid(packageName, 0, UserHandle.USER_SYSTEM);
Slog.i("yu","-----------------disableAppNotification: " + packageName + ", uid = " + uid);
mNotificationManager.setNotificationsEnabledForPackage(packageName, uid, false);
} catch (Exception e) {
Slog.e("yu", "--------------------disableAppNotification: " + e);
}
}
//End Add