| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.view.contentcapture; |
| 17 |
|
| 18 |
import android.annotation.NonNull; |
| 19 |
import android.annotation.Nullable; |
| 20 |
import android.graphics.Insets; |
| 21 |
import android.view.autofill.AutofillId; |
| 22 |
import android.view.contentcapture.ViewNode.ViewStructureImpl; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
final class ChildContentCaptureSession extends ContentCaptureSession { |
| 31 |
|
| 32 |
@NonNull |
| 33 |
private final ContentCaptureSession mParent; |
| 34 |
|
| 35 |
|
| 36 |
protected ChildContentCaptureSession(@NonNull ContentCaptureSession parent, |
| 37 |
@NonNull ContentCaptureContext clientContext) { |
| 38 |
super(clientContext); |
| 39 |
mParent = parent; |
| 40 |
} |
| 41 |
|
| 42 |
@Override |
| 43 |
MainContentCaptureSession getMainCaptureSession() { |
| 44 |
if (mParent instanceof MainContentCaptureSession) { |
| 45 |
return (MainContentCaptureSession) mParent; |
| 46 |
} |
| 47 |
return mParent.getMainCaptureSession(); |
| 48 |
} |
| 49 |
|
| 50 |
@Override |
| 51 |
ContentCaptureSession newChild(@NonNull ContentCaptureContext clientContext) { |
| 52 |
final ContentCaptureSession child = new ChildContentCaptureSession(this, clientContext); |
| 53 |
getMainCaptureSession().notifyChildSessionStarted(mId, child.mId, clientContext); |
| 54 |
return child; |
| 55 |
} |
| 56 |
|
| 57 |
@Override |
| 58 |
void flush(@FlushReason int reason) { |
| 59 |
mParent.flush(reason); |
| 60 |
} |
| 61 |
|
| 62 |
@Override |
| 63 |
public void updateContentCaptureContext(@Nullable ContentCaptureContext context) { |
| 64 |
getMainCaptureSession().notifyContextUpdated(mId, context); |
| 65 |
} |
| 66 |
|
| 67 |
@Override |
| 68 |
void onDestroy() { |
| 69 |
getMainCaptureSession().notifyChildSessionFinished(mParent.mId, mId); |
| 70 |
} |
| 71 |
|
| 72 |
@Override |
| 73 |
void internalNotifyViewAppeared(@NonNull ViewStructureImpl node) { |
| 74 |
getMainCaptureSession().notifyViewAppeared(mId, node); |
| 75 |
} |
| 76 |
|
| 77 |
@Override |
| 78 |
void internalNotifyViewDisappeared(@NonNull AutofillId id) { |
| 79 |
getMainCaptureSession().notifyViewDisappeared(mId, id); |
| 80 |
} |
| 81 |
|
| 82 |
@Override |
| 83 |
void internalNotifyViewTextChanged(@NonNull AutofillId id, @Nullable CharSequence text) { |
| 84 |
getMainCaptureSession().notifyViewTextChanged(mId, id, text); |
| 85 |
} |
| 86 |
|
| 87 |
@Override |
| 88 |
void internalNotifyViewInsetsChanged(@NonNull Insets viewInsets) { |
| 89 |
getMainCaptureSession().notifyViewInsetsChanged(mId, viewInsets); |
| 90 |
} |
| 91 |
|
| 92 |
@Override |
| 93 |
public void internalNotifyViewTreeEvent(boolean started) { |
| 94 |
getMainCaptureSession().notifyViewTreeEvent(mId, started); |
| 95 |
} |
| 96 |
|
| 97 |
@Override |
| 98 |
void internalNotifySessionResumed() { |
| 99 |
getMainCaptureSession().notifySessionResumed(); |
| 100 |
} |
| 101 |
|
| 102 |
@Override |
| 103 |
void internalNotifySessionPaused() { |
| 104 |
getMainCaptureSession().notifySessionPaused(); |
| 105 |
} |
| 106 |
|
| 107 |
@Override |
| 108 |
boolean isContentCaptureEnabled() { |
| 109 |
return getMainCaptureSession().isContentCaptureEnabled(); |
| 110 |
} |
| 111 |
} |