Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 358ad7d0 authored by Lucas Silva's avatar Lucas Silva Committed by Android (Google) Code Review
Browse files

Merge "Add Callback to wake up from Dream when DreamActivity is destroyed." into tm-qpr-dev

parents acb9fe85 feb3aa71
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ import android.text.TextUtils;
public class DreamActivity extends Activity {
    static final String EXTRA_CALLBACK = "binder";
    static final String EXTRA_DREAM_TITLE = "title";
    @Nullable
    private DreamService.DreamActivityCallbacks mCallback;

    public DreamActivity() {}

@@ -57,11 +59,19 @@ public class DreamActivity extends Activity {
        }

        final Bundle extras = getIntent().getExtras();
        final DreamService.DreamActivityCallback callback =
                (DreamService.DreamActivityCallback) extras.getBinder(EXTRA_CALLBACK);
        mCallback = (DreamService.DreamActivityCallbacks) extras.getBinder(EXTRA_CALLBACK);

        if (callback != null) {
            callback.onActivityCreated(this);
        if (mCallback != null) {
            mCallback.onActivityCreated(this);
        }
    }

    @Override
    public void onDestroy() {
        if (mCallback != null) {
            mCallback.onActivityDestroyed();
        }

        super.onDestroy();
    }
}
+9 −3
Original line number Diff line number Diff line
@@ -1295,7 +1295,7 @@ public class DreamService extends Service implements Window.Callback {
            Intent i = new Intent(this, DreamActivity.class);
            i.setPackage(getApplicationContext().getPackageName());
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            i.putExtra(DreamActivity.EXTRA_CALLBACK, new DreamActivityCallback(mDreamToken));
            i.putExtra(DreamActivity.EXTRA_CALLBACK, new DreamActivityCallbacks(mDreamToken));
            final ServiceInfo serviceInfo = fetchServiceInfo(this,
                    new ComponentName(this, getClass()));
            i.putExtra(DreamActivity.EXTRA_DREAM_TITLE, fetchDreamLabel(this, serviceInfo));
@@ -1488,10 +1488,10 @@ public class DreamService extends Service implements Window.Callback {
    }

    /** @hide */
    final class DreamActivityCallback extends Binder {
    final class DreamActivityCallbacks extends Binder {
        private final IBinder mActivityDreamToken;

        DreamActivityCallback(IBinder token) {
        DreamActivityCallbacks(IBinder token) {
            mActivityDreamToken = token;
        }

@@ -1516,6 +1516,12 @@ public class DreamService extends Service implements Window.Callback {
            mActivity = activity;
            onWindowCreated(activity.getWindow());
        }

        // If DreamActivity is destroyed, wake up from Dream.
        void onActivityDestroyed() {
            mActivity = null;
            onDestroy();
        }
    }

    /**