• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

frameworks/base


Commit MetaInfo

修订版6a89d1107b56327580292bad227b3aeaa65dbb8b (tree)
时间2020-04-29 03:45:07
作者Anis Assi <anisassi@goog...>
CommiterAnis Assi

Log Message

Revert "DO NOT MERGE - Kill apps outright for API contract violations"

This reverts commit c6fd63a7a80f06a89b34aa1894694922c3af9f20.

更改概述

差异

--- a/core/java/android/app/IActivityManager.aidl
+++ b/core/java/android/app/IActivityManager.aidl
@@ -266,8 +266,7 @@ interface IActivityManager {
266266 boolean isImmersive(in IBinder token);
267267 void setImmersive(in IBinder token, boolean immersive);
268268 boolean isTopActivityImmersive();
269- void crashApplication(int uid, int initialPid, in String packageName, int userId,
270- in String message, boolean force);
269+ void crashApplication(int uid, int initialPid, in String packageName, int userId, in String message);
271270 String getProviderMimeType(in Uri uri, int userId);
272271 IBinder newUriPermissionOwner(in String name);
273272 void grantUriPermissionFromOwner(in IBinder owner, int fromUid, in String targetPkg,
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -653,15 +653,6 @@ public final class ActiveServices {
653653 }
654654 }
655655
656- void killMisbehavingService(ServiceRecord r,
657- int appUid, int appPid, String localPackageName) {
658- synchronized (mAm) {
659- stopServiceLocked(r);
660- mAm.crashApplication(appUid, appPid, localPackageName, -1,
661- "Bad notification for startForeground", true /*force*/);
662- }
663- }
664-
665656 IBinder peekServiceLocked(Intent service, String resolvedType, String callingPackage) {
666657 ServiceLookupResult r = retrieveServiceLocked(service, resolvedType, callingPackage,
667658 Binder.getCallingPid(), Binder.getCallingUid(),
@@ -3400,8 +3391,7 @@ public final class ActiveServices {
34003391
34013392 void serviceForegroundCrash(ProcessRecord app) {
34023393 mAm.crashApplication(app.uid, app.pid, app.info.packageName, app.userId,
3403- "Context.startForegroundService() did not then call Service.startForeground()",
3404- false /*force*/);
3394+ "Context.startForegroundService() did not then call Service.startForeground()");
34053395 }
34063396
34073397 void scheduleServiceTimeoutLocked(ProcessRecord proc) {
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -5141,7 +5141,7 @@ public class ActivityManagerService extends IActivityManager.Stub
51415141
51425142 @Override
51435143 public void crashApplication(int uid, int initialPid, String packageName, int userId,
5144- String message, boolean force) {
5144+ String message) {
51455145 if (checkCallingPermission(android.Manifest.permission.FORCE_STOP_PACKAGES)
51465146 != PackageManager.PERMISSION_GRANTED) {
51475147 String msg = "Permission Denial: crashApplication() from pid="
@@ -5153,8 +5153,7 @@ public class ActivityManagerService extends IActivityManager.Stub
51535153 }
51545154
51555155 synchronized(this) {
5156- mAppErrors.scheduleAppCrashLocked(uid, initialPid, packageName, userId,
5157- message, force);
5156+ mAppErrors.scheduleAppCrashLocked(uid, initialPid, packageName, userId, message);
51585157 }
51595158 }
51605159
--- a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
+++ b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
@@ -921,7 +921,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
921921 } catch (NumberFormatException e) {
922922 packageName = arg;
923923 }
924- mInterface.crashApplication(-1, pid, packageName, userId, "shell-induced crash", false);
924+ mInterface.crashApplication(-1, pid, packageName, userId, "shell-induced crash");
925925 return 0;
926926 }
927927
--- a/services/core/java/com/android/server/am/AppErrors.java
+++ b/services/core/java/com/android/server/am/AppErrors.java
@@ -243,24 +243,20 @@ class AppErrors {
243243 }
244244
245245 void killAppAtUserRequestLocked(ProcessRecord app, Dialog fromDialog) {
246+ app.crashing = false;
247+ app.crashingReport = null;
248+ app.notResponding = false;
249+ app.notRespondingReport = null;
246250 if (app.anrDialog == fromDialog) {
247251 app.anrDialog = null;
248252 }
249253 if (app.waitDialog == fromDialog) {
250254 app.waitDialog = null;
251255 }
252- killAppImmediateLocked(app, "user-terminated", "user request after error");
253- }
254-
255- private void killAppImmediateLocked(ProcessRecord app, String reason, String killReason) {
256- app.crashing = false;
257- app.crashingReport = null;
258- app.notResponding = false;
259- app.notRespondingReport = null;
260256 if (app.pid > 0 && app.pid != MY_PID) {
261- handleAppCrashLocked(app, reason,
257+ handleAppCrashLocked(app, "user-terminated" /*reason*/,
262258 null /*shortMsg*/, null /*longMsg*/, null /*stackTrace*/, null /*data*/);
263- app.kill(killReason, true);
259+ app.kill("user request after error", true);
264260 }
265261 }
266262
@@ -274,7 +270,7 @@ class AppErrors {
274270 * @param message
275271 */
276272 void scheduleAppCrashLocked(int uid, int initialPid, String packageName, int userId,
277- String message, boolean force) {
273+ String message) {
278274 ProcessRecord proc = null;
279275
280276 // Figure out which process to kill. We don't trust that initialPid
@@ -307,14 +303,6 @@ class AppErrors {
307303 }
308304
309305 proc.scheduleCrash(message);
310- if (force) {
311- // If the app is responsive, the scheduled crash will happen as expected
312- // and then the delayed summary kill will be a no-op.
313- final ProcessRecord p = proc;
314- mService.mHandler.postDelayed(
315- () -> killAppImmediateLocked(p, "forced", "killed for invalid state"),
316- 5000L);
317- }
318306 }
319307
320308 /**
--- a/services/core/java/com/android/server/am/ServiceRecord.java
+++ b/services/core/java/com/android/server/am/ServiceRecord.java
@@ -453,7 +453,6 @@ final class ServiceRecord extends Binder {
453453 final String localPackageName = packageName;
454454 final int localForegroundId = foregroundId;
455455 final Notification _foregroundNoti = foregroundNoti;
456- final ServiceRecord record = this;
457456 ams.mHandler.post(new Runnable() {
458457 public void run() {
459458 NotificationManagerInternal nm = LocalServices.getService(
@@ -552,8 +551,10 @@ final class ServiceRecord extends Binder {
552551 Slog.w(TAG, "Error showing notification for service", e);
553552 // If it gave us a garbage notification, it doesn't
554553 // get to be foreground.
555- ams.mServices.killMisbehavingService(record,
556- appUid, appPid, localPackageName);
554+ ams.setServiceForeground(name, ServiceRecord.this,
555+ 0, null, 0);
556+ ams.crashApplication(appUid, appPid, localPackageName, -1,
557+ "Bad notification for startForeground: " + e);
557558 }
558559 }
559560 });
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -714,23 +714,18 @@ public class NotificationManagerService extends SystemService {
714714 @Override
715715 public void onNotificationError(int callingUid, int callingPid, String pkg, String tag, int id,
716716 int uid, int initialPid, String message, int userId) {
717- final boolean fgService;
718- synchronized (mNotificationLock) {
719- NotificationRecord r = findNotificationLocked(pkg, tag, id, userId);
720- fgService = r != null
721- && (r.getNotification().flags&Notification.FLAG_FOREGROUND_SERVICE) != 0;
722- }
717+ Slog.d(TAG, "onNotification error pkg=" + pkg + " tag=" + tag + " id=" + id
718+ + "; will crashApplication(uid=" + uid + ", pid=" + initialPid + ")");
723719 cancelNotification(callingUid, callingPid, pkg, tag, id, 0, 0, false, userId,
724720 REASON_ERROR, null);
725- if (fgService) {
726- // Still crash for foreground services, preventing the not-crash behaviour abused
727- // by apps to give us a garbage notification and silently start a fg service.
728- Binder.withCleanCallingIdentity(
729- () -> mAm.crashApplication(uid, initialPid, pkg, -1,
730- "Bad notification(tag=" + tag + ", id=" + id + ") posted from package "
731- + pkg + ", crashing app(uid=" + uid + ", pid=" + initialPid + "): "
732- + message, true /* force */));
721+ long ident = Binder.clearCallingIdentity();
722+ try {
723+ ActivityManager.getService().crashApplication(uid, initialPid, pkg, -1,
724+ "Bad notification posted from package " + pkg
725+ + ": " + message);
726+ } catch (RemoteException e) {
733727 }
728+ Binder.restoreCallingIdentity(ident);
734729 }
735730
736731 @Override