Merge "Avoid to hold a strong reference to Context object" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4f1ceac15e
@@ -378,7 +378,7 @@ public final class ContentCaptureManager {
|
|||||||
private final Object mLock = new Object();
|
private final Object mLock = new Object();
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final Context mContext;
|
private final StrippedContext mContext;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final IContentCaptureManager mService;
|
private final IContentCaptureManager mService;
|
||||||
@@ -413,10 +413,38 @@ public final class ContentCaptureManager {
|
|||||||
ComponentName contentCaptureClientGetComponentName();
|
ComponentName contentCaptureClientGetComponentName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
static class StrippedContext {
|
||||||
|
final String mPackageName;
|
||||||
|
final String mContext;
|
||||||
|
final @UserIdInt int mUserId;
|
||||||
|
|
||||||
|
private StrippedContext(Context context) {
|
||||||
|
mPackageName = context.getPackageName();
|
||||||
|
mContext = context.toString();
|
||||||
|
mUserId = context.getUserId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return mContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPackageName() {
|
||||||
|
return mPackageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@UserIdInt
|
||||||
|
public int getUserId() {
|
||||||
|
return mUserId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public ContentCaptureManager(@NonNull Context context,
|
public ContentCaptureManager(@NonNull Context context,
|
||||||
@NonNull IContentCaptureManager service, @NonNull ContentCaptureOptions options) {
|
@NonNull IContentCaptureManager service, @NonNull ContentCaptureOptions options) {
|
||||||
mContext = Objects.requireNonNull(context, "context cannot be null");
|
Objects.requireNonNull(context, "context cannot be null");
|
||||||
|
mContext = new StrippedContext(context);
|
||||||
mService = Objects.requireNonNull(service, "service cannot be null");
|
mService = Objects.requireNonNull(service, "service cannot be null");
|
||||||
mOptions = Objects.requireNonNull(options, "options cannot be null");
|
mOptions = Objects.requireNonNull(options, "options cannot be null");
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ import android.annotation.NonNull;
|
|||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.UiThread;
|
import android.annotation.UiThread;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.pm.ParceledListSlice;
|
import android.content.pm.ParceledListSlice;
|
||||||
import android.graphics.Insets;
|
import android.graphics.Insets;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
@@ -103,7 +102,7 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
|
|||||||
private final AtomicBoolean mDisabled = new AtomicBoolean(false);
|
private final AtomicBoolean mDisabled = new AtomicBoolean(false);
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final Context mContext;
|
private final ContentCaptureManager.StrippedContext mContext;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final ContentCaptureManager mManager;
|
private final ContentCaptureManager mManager;
|
||||||
@@ -197,7 +196,7 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MainContentCaptureSession(@NonNull Context context,
|
protected MainContentCaptureSession(@NonNull ContentCaptureManager.StrippedContext context,
|
||||||
@NonNull ContentCaptureManager manager, @NonNull Handler handler,
|
@NonNull ContentCaptureManager manager, @NonNull Handler handler,
|
||||||
@NonNull IContentCaptureManager systemServerInterface) {
|
@NonNull IContentCaptureManager systemServerInterface) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
|||||||
Reference in New Issue
Block a user