Loading core/java/android/view/contentcapture/ContentCaptureManager.java +12 −7 Original line number Diff line number Diff line Loading @@ -67,9 +67,6 @@ public final class ContentCaptureManager { private final Object mLock = new Object(); @GuardedBy("mLock") private boolean mDisabled; @NonNull private final Context mContext; Loading Loading @@ -115,8 +112,7 @@ public final class ContentCaptureManager { public MainContentCaptureSession getMainContentCaptureSession() { synchronized (mLock) { if (mMainSession == null) { mMainSession = new MainContentCaptureSession(mContext, mHandler, mService, mDisabled); mMainSession = new MainContentCaptureSession(mContext, this, mHandler, mService); if (VERBOSE) Log.v(TAG, "getMainContentCaptureSession(): created " + mMainSession); } return mMainSession; Loading Loading @@ -180,9 +176,17 @@ public final class ContentCaptureManager { * </ul> */ public boolean isContentCaptureEnabled() { if (mService == null) return false; final MainContentCaptureSession mainSession; synchronized (mLock) { return mService != null && !mDisabled; mainSession = mMainSession; } // The main session is only set when the activity starts, so we need to return true until // then. if (mainSession != null && mainSession.isDisabled()) return false; return true; } /** Loading Loading @@ -287,7 +291,8 @@ public final class ContentCaptureManager { public void dump(String prefix, PrintWriter pw) { synchronized (mLock) { pw.print(prefix); pw.println("ContentCaptureManager"); pw.print(prefix); pw.print("Disabled: "); pw.println(mDisabled); pw.print(prefix); pw.print("isContentCaptureEnabled(): "); pw.println(isContentCaptureEnabled()); pw.print(prefix); pw.print("Context: "); pw.println(mContext); pw.print(prefix); pw.print("User: "); pw.println(mContext.getUserId()); if (mService != null) { Loading core/java/android/view/contentcapture/MainContentCaptureSession.java +17 −11 Original line number Diff line number Diff line Loading @@ -89,13 +89,15 @@ public final class MainContentCaptureSession extends ContentCaptureSession { */ public static final String EXTRA_BINDER = "binder"; // TODO(b/111276913): make sure disabled state is in sync with manager's disabled @NonNull private final AtomicBoolean mDisabled; private final AtomicBoolean mDisabled = new AtomicBoolean(false); @NonNull private final Context mContext; @NonNull private final ContentCaptureManager mManager; @NonNull private final Handler mHandler; Loading @@ -103,7 +105,7 @@ public final class MainContentCaptureSession extends ContentCaptureSession { * Interface to the system_server binder object - it's only used to start the session (and * notify when the session is finished). */ @Nullable @Nullable // TODO(b/122959591): shoul never be null, we should make main session null instead private final IContentCaptureManager mSystemServerInterface; /** Loading Loading @@ -136,13 +138,13 @@ public final class MainContentCaptureSession extends ContentCaptureSession { private final LocalLog mFlushHistory = new LocalLog(10); /** @hide */ protected MainContentCaptureSession(@NonNull Context context, @NonNull Handler handler, @Nullable IContentCaptureManager systemServerInterface, @NonNull boolean disabled) { protected MainContentCaptureSession(@NonNull Context context, @NonNull ContentCaptureManager manager, @NonNull Handler handler, @Nullable IContentCaptureManager systemServerInterface) { mContext = context; mManager = manager; mHandler = handler; mSystemServerInterface = systemServerInterface; mDisabled = new AtomicBoolean(disabled); } @Override Loading Loading @@ -235,8 +237,8 @@ public final class MainContentCaptureSession extends ContentCaptureSession { /** * Callback from {@code system_server} after call to * {@link IContentCaptureManager#startSession(int, IBinder, ComponentName, String, * int, IResultReceiver)}. * {@link IContentCaptureManager#startSession(IBinder, ComponentName, String, int, * IResultReceiver)} * * @param resultCode session state * @param binder handle to {@code IContentCaptureDirectManager} Loading Loading @@ -517,8 +519,12 @@ public final class MainContentCaptureSession extends ContentCaptureSession { @Override boolean isContentCaptureEnabled() { return super.isContentCaptureEnabled() && mSystemServerInterface != null && !mDisabled.get(); return super.isContentCaptureEnabled() && mManager.isContentCaptureEnabled(); } // Called by ContentCaptureManager.isContentCaptureEnabled boolean isDisabled() { return mDisabled.get(); } // TODO(b/122454205): refactor "notifyXXXX" methods below to a common "Buffer" object that is Loading Loading
core/java/android/view/contentcapture/ContentCaptureManager.java +12 −7 Original line number Diff line number Diff line Loading @@ -67,9 +67,6 @@ public final class ContentCaptureManager { private final Object mLock = new Object(); @GuardedBy("mLock") private boolean mDisabled; @NonNull private final Context mContext; Loading Loading @@ -115,8 +112,7 @@ public final class ContentCaptureManager { public MainContentCaptureSession getMainContentCaptureSession() { synchronized (mLock) { if (mMainSession == null) { mMainSession = new MainContentCaptureSession(mContext, mHandler, mService, mDisabled); mMainSession = new MainContentCaptureSession(mContext, this, mHandler, mService); if (VERBOSE) Log.v(TAG, "getMainContentCaptureSession(): created " + mMainSession); } return mMainSession; Loading Loading @@ -180,9 +176,17 @@ public final class ContentCaptureManager { * </ul> */ public boolean isContentCaptureEnabled() { if (mService == null) return false; final MainContentCaptureSession mainSession; synchronized (mLock) { return mService != null && !mDisabled; mainSession = mMainSession; } // The main session is only set when the activity starts, so we need to return true until // then. if (mainSession != null && mainSession.isDisabled()) return false; return true; } /** Loading Loading @@ -287,7 +291,8 @@ public final class ContentCaptureManager { public void dump(String prefix, PrintWriter pw) { synchronized (mLock) { pw.print(prefix); pw.println("ContentCaptureManager"); pw.print(prefix); pw.print("Disabled: "); pw.println(mDisabled); pw.print(prefix); pw.print("isContentCaptureEnabled(): "); pw.println(isContentCaptureEnabled()); pw.print(prefix); pw.print("Context: "); pw.println(mContext); pw.print(prefix); pw.print("User: "); pw.println(mContext.getUserId()); if (mService != null) { Loading
core/java/android/view/contentcapture/MainContentCaptureSession.java +17 −11 Original line number Diff line number Diff line Loading @@ -89,13 +89,15 @@ public final class MainContentCaptureSession extends ContentCaptureSession { */ public static final String EXTRA_BINDER = "binder"; // TODO(b/111276913): make sure disabled state is in sync with manager's disabled @NonNull private final AtomicBoolean mDisabled; private final AtomicBoolean mDisabled = new AtomicBoolean(false); @NonNull private final Context mContext; @NonNull private final ContentCaptureManager mManager; @NonNull private final Handler mHandler; Loading @@ -103,7 +105,7 @@ public final class MainContentCaptureSession extends ContentCaptureSession { * Interface to the system_server binder object - it's only used to start the session (and * notify when the session is finished). */ @Nullable @Nullable // TODO(b/122959591): shoul never be null, we should make main session null instead private final IContentCaptureManager mSystemServerInterface; /** Loading Loading @@ -136,13 +138,13 @@ public final class MainContentCaptureSession extends ContentCaptureSession { private final LocalLog mFlushHistory = new LocalLog(10); /** @hide */ protected MainContentCaptureSession(@NonNull Context context, @NonNull Handler handler, @Nullable IContentCaptureManager systemServerInterface, @NonNull boolean disabled) { protected MainContentCaptureSession(@NonNull Context context, @NonNull ContentCaptureManager manager, @NonNull Handler handler, @Nullable IContentCaptureManager systemServerInterface) { mContext = context; mManager = manager; mHandler = handler; mSystemServerInterface = systemServerInterface; mDisabled = new AtomicBoolean(disabled); } @Override Loading Loading @@ -235,8 +237,8 @@ public final class MainContentCaptureSession extends ContentCaptureSession { /** * Callback from {@code system_server} after call to * {@link IContentCaptureManager#startSession(int, IBinder, ComponentName, String, * int, IResultReceiver)}. * {@link IContentCaptureManager#startSession(IBinder, ComponentName, String, int, * IResultReceiver)} * * @param resultCode session state * @param binder handle to {@code IContentCaptureDirectManager} Loading Loading @@ -517,8 +519,12 @@ public final class MainContentCaptureSession extends ContentCaptureSession { @Override boolean isContentCaptureEnabled() { return super.isContentCaptureEnabled() && mSystemServerInterface != null && !mDisabled.get(); return super.isContentCaptureEnabled() && mManager.isContentCaptureEnabled(); } // Called by ContentCaptureManager.isContentCaptureEnabled boolean isDisabled() { return mDisabled.get(); } // TODO(b/122454205): refactor "notifyXXXX" methods below to a common "Buffer" object that is Loading