From fa414929e1a618325a2c4ad3389eae3706564efd Mon Sep 17 00:00:00 2001 From: Joanne Chung Date: Wed, 25 May 2022 15:27:49 +0000 Subject: Revert "Rebind ContentCaptureService when the binderDied." This reverts commit 4fc5c86bb9945be49cd77140facf62ba70b5b7e4. We introduce a rebind mechanism to rebind died ContentCaptureService because the apps tht has dependency with ContentCaptureService. But it looks like the rate is raised for app to get the null content capture manager. Because the underlying issue is fixed, we don't need this workaround now. We can also monitor if the null content capture sympton is resolved. Bug: 227353916 Test: manual. Add dependency and update the app, the ContentCapture can be rebind without the this fix. Reason for revert: To monitor if the null content capture issue caused by this change. Change-Id: Ibe5d6e2b5f1434243b655289fdc60174ff33a5c0 --- .../ContentCaptureManagerService.java | 2 +- .../ContentCapturePerUserService.java | 61 +++------------------- 2 files changed, 7 insertions(+), 56 deletions(-) (limited to 'services/contentcapture/java') diff --git a/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java b/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java index ad6e7dbebae9..ff1a495edcbb 100644 --- a/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java +++ b/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java @@ -223,7 +223,7 @@ public final class ContentCaptureManagerService extends @Override // from AbstractMasterSystemService protected ContentCapturePerUserService newServiceLocked(@UserIdInt int resolvedUserId, boolean disabled) { - return new ContentCapturePerUserService(this, mLock, disabled, resolvedUserId, mHandler); + return new ContentCapturePerUserService(this, mLock, disabled, resolvedUserId); } @Override // from SystemService diff --git a/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java b/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java index 9bc1cee2aa05..41a759254909 100644 --- a/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java +++ b/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java @@ -46,7 +46,6 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ServiceInfo; import android.os.Binder; import android.os.Bundle; -import android.os.Handler; import android.os.IBinder; import android.os.UserHandle; import android.provider.Settings; @@ -76,7 +75,6 @@ import com.android.server.contentcapture.RemoteContentCaptureService.ContentCapt import com.android.server.infra.AbstractPerUserSystemService; import java.io.PrintWriter; -import java.time.Instant; import java.util.ArrayList; import java.util.List; @@ -90,10 +88,6 @@ final class ContentCapturePerUserService private static final String TAG = ContentCapturePerUserService.class.getSimpleName(); - private static final int MAX_REBIND_COUNTS = 5; - // 5 minutes - private static final long REBIND_DURATION_MS = 5 * 60 * 1_000; - @GuardedBy("mLock") private final SparseArray mSessions = new SparseArray<>(); @@ -127,18 +121,11 @@ final class ContentCapturePerUserService @GuardedBy("mLock") private ContentCaptureServiceInfo mInfo; - private Instant mLastRebindTime; - private int mRebindCount; - private final Handler mHandler; - - private final Runnable mReBindServiceRunnable = new RebindServiceRunnable(); - // TODO(b/111276913): add mechanism to prune stale sessions, similar to Autofill's ContentCapturePerUserService(@NonNull ContentCaptureManagerService master, - @NonNull Object lock, boolean disabled, @UserIdInt int userId, Handler handler) { + @NonNull Object lock, boolean disabled, @UserIdInt int userId) { super(master, lock, userId); - mHandler = handler; updateRemoteServiceLocked(disabled); } @@ -203,43 +190,9 @@ final class ContentCapturePerUserService Slog.w(TAG, "remote service died: " + service); synchronized (mLock) { mZombie = true; - // Reset rebindCount if over 12 hours mLastRebindTime - if (mLastRebindTime != null && Instant.now().isAfter( - mLastRebindTime.plusMillis(12 * 60 * 60 * 1000))) { - if (mMaster.debug) { - Slog.i(TAG, "The current rebind count " + mRebindCount + " is reset."); - } - mRebindCount = 0; - } - if (mRebindCount >= MAX_REBIND_COUNTS) { - writeServiceEvent( - FrameworkStatsLog.CONTENT_CAPTURE_SERVICE_EVENTS__EVENT__ON_REMOTE_SERVICE_DIED, - getServiceComponentName()); - } - if (mRebindCount < MAX_REBIND_COUNTS) { - mHandler.removeCallbacks(mReBindServiceRunnable); - mHandler.postDelayed(mReBindServiceRunnable, REBIND_DURATION_MS); - } - } - } - - private void updateRemoteServiceAndResurrectSessionsLocked() { - boolean disabled = !isEnabledLocked(); - updateRemoteServiceLocked(disabled); - resurrectSessionsLocked(); - } - - private final class RebindServiceRunnable implements Runnable{ - - @Override - public void run() { - synchronized (mLock) { - if (mZombie) { - mLastRebindTime = Instant.now(); - mRebindCount++; - updateRemoteServiceAndResurrectSessionsLocked(); - } - } + writeServiceEvent( + FrameworkStatsLog.CONTENT_CAPTURE_SERVICE_EVENTS__EVENT__ON_REMOTE_SERVICE_DIED, + getServiceComponentName()); } } @@ -287,8 +240,8 @@ final class ContentCapturePerUserService } void onPackageUpdatedLocked() { - mRebindCount = 0; - updateRemoteServiceAndResurrectSessionsLocked(); + updateRemoteServiceLocked(!isEnabledLocked()); + resurrectSessionsLocked(); } @GuardedBy("mLock") @@ -602,8 +555,6 @@ final class ContentCapturePerUserService mInfo.dump(prefix2, pw); } pw.print(prefix); pw.print("Zombie: "); pw.println(mZombie); - pw.print(prefix); pw.print("Rebind count: "); pw.println(mRebindCount); - pw.print(prefix); pw.print("Last rebind: "); pw.println(mLastRebindTime); if (mRemoteService != null) { pw.print(prefix); pw.println("remote service:"); -- cgit v1.2.3-59-g8ed1b