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

Commit 2bb5596c authored by Lucas Silva's avatar Lucas Silva Committed by Automerger Merge Worker
Browse files

Merge "Add Callback to wake up from Dream when DreamActivity is destroyed."...

Merge "Add Callback to wake up from Dream when DreamActivity is destroyed." into tm-qpr-dev am: 358ad7d0 am: 42127fba

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19734004



Change-Id: Ib6790ff54cd3a16ee4e08b1983182821758b93ed
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents ee1089dd 42127fba
Loading
Loading
Loading
Loading
+14 −4
Original line number Original line Diff line number Diff line
@@ -44,6 +44,8 @@ import android.text.TextUtils;
public class DreamActivity extends Activity {
public class DreamActivity extends Activity {
    static final String EXTRA_CALLBACK = "binder";
    static final String EXTRA_CALLBACK = "binder";
    static final String EXTRA_DREAM_TITLE = "title";
    static final String EXTRA_DREAM_TITLE = "title";
    @Nullable
    private DreamService.DreamActivityCallbacks mCallback;


    public DreamActivity() {}
    public DreamActivity() {}


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


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


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

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

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


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


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


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

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


    /**
    /**