Merge "Remove injection from BubbleOverflowActivity"

This commit is contained in:
Mady Mellor
2020-10-09 03:06:43 +00:00
committed by Android (Google) Code Review
4 changed files with 64 additions and 13 deletions

View File

@@ -30,6 +30,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
import static com.android.systemui.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_EXPANDED_VIEW;
import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_BUBBLES;
import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.systemui.bubbles.BubbleOverflowActivity.EXTRA_BUBBLE_CONTROLLER;
import android.annotation.NonNull;
import android.annotation.SuppressLint;
@@ -51,6 +52,7 @@ import android.graphics.Rect;
import android.graphics.drawable.ShapeDrawable;
import android.hardware.display.VirtualDisplay;
import android.os.Binder;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.AttributeSet;
import android.util.Log;
@@ -576,6 +578,9 @@ public class BubbleExpandedView extends LinearLayout {
mIsOverflow = overflow;
Intent target = new Intent(mContext, BubbleOverflowActivity.class);
Bundle extras = new Bundle();
extras.putBinder(EXTRA_BUBBLE_CONTROLLER, ObjectWrapper.wrap(mBubbles));
target.putExtras(extras);
mPendingIntent = PendingIntent.getActivity(mContext, /* requestCode */ 0,
target, PendingIntent.FLAG_UPDATE_CURRENT);
mSettingsIcon.setVisibility(GONE);

View File

@@ -22,11 +22,13 @@ import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.os.Bundle;
import android.os.IBinder;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
@@ -47,13 +49,14 @@ import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import javax.inject.Inject;
/**
* Activity for showing aged out bubbles.
* Must be public to be accessible to androidx...AppComponentFactory
*/
public class BubbleOverflowActivity extends Activity {
static final String EXTRA_BUBBLE_CONTROLLER = "bubble_controller";
private static final String TAG = TAG_WITH_CLASS_NAME ? "BubbleOverflowActivity" : TAG_BUBBLES;
private LinearLayout mEmptyState;
@@ -93,11 +96,6 @@ public class BubbleOverflowActivity extends Activity {
}
}
@Inject
public BubbleOverflowActivity(Bubbles bubbles) {
mBubbles = bubbles;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -109,6 +107,15 @@ public class BubbleOverflowActivity extends Activity {
mEmptyStateSubtitle = findViewById(R.id.bubble_overflow_empty_subtitle);
mEmptyStateImage = findViewById(R.id.bubble_overflow_empty_state_image);
Intent intent = getIntent();
if (intent != null && intent.getExtras() != null) {
IBinder binder = intent.getExtras().getBinder(EXTRA_BUBBLE_CONTROLLER);
if (binder instanceof ObjectWrapper) {
mBubbles = ((ObjectWrapper<Bubbles>) binder).get();
}
} else {
Log.w(TAG, "Bubble overflow activity created without bubble controller!");
}
updateOverflow();
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.bubbles;
import android.os.Binder;
import android.os.IBinder;
// Copied from Launcher3
/**
* Utility class to pass non-parcealable objects within same process using parcealable payload.
*
* It wraps the object in a binder as binders are singleton within a process
*/
public class ObjectWrapper<T> extends Binder {
private T mObject;
public ObjectWrapper(T object) {
mObject = object;
}
public T get() {
return mObject;
}
public void clear() {
mObject = null;
}
public static IBinder wrap(Object obj) {
return new ObjectWrapper<>(obj);
}
}

View File

@@ -19,7 +19,6 @@ package com.android.systemui.dagger;
import android.app.Activity;
import com.android.systemui.ForegroundServicesDialog;
import com.android.systemui.bubbles.BubbleOverflowActivity;
import com.android.systemui.keyguard.WorkLockActivity;
import com.android.systemui.screenrecord.ScreenRecordDialog;
import com.android.systemui.settings.BrightnessDialog;
@@ -68,12 +67,6 @@ public abstract class DefaultActivityBinder {
@ClassKey(ScreenRecordDialog.class)
public abstract Activity bindScreenRecordDialog(ScreenRecordDialog activity);
/** Inject into BubbleOverflowActivity. */
@Binds
@IntoMap
@ClassKey(BubbleOverflowActivity.class)
public abstract Activity bindBubbleOverflowActivity(BubbleOverflowActivity activity);
/** Inject into UsbDebuggingActivity. */
@Binds
@IntoMap