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

Commit 6d13ba1d authored by Lucas Silva's avatar Lucas Silva Committed by Automerger Merge Worker
Browse files

Merge "Add special label to denote dream in preview mode" into tm-qpr-dev am: c2127139

parents d4c4240a c2127139
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -1306,7 +1306,8 @@ public class DreamService extends Service implements Window.Callback {
     * @param dreamToken Token for this dream service.
     * @param started    A callback that will be invoked once onDreamingStarted has completed.
     */
    private void attach(IBinder dreamToken, boolean canDoze, IRemoteCallback started) {
    private void attach(IBinder dreamToken, boolean canDoze, boolean isPreviewMode,
            IRemoteCallback started) {
        if (mDreamToken != null) {
            Slog.e(mTag, "attach() called when dream with token=" + mDreamToken
                    + " already attached");
@@ -1354,7 +1355,8 @@ public class DreamService extends Service implements Window.Callback {
            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));
            i.putExtra(DreamActivity.EXTRA_DREAM_TITLE,
                    fetchDreamLabel(this, serviceInfo, isPreviewMode));

            try {
                if (!ActivityTaskManager.getService().startDreamActivity(i)) {
@@ -1470,10 +1472,18 @@ public class DreamService extends Service implements Window.Callback {

    @Nullable
    private static CharSequence fetchDreamLabel(Context context,
            @Nullable ServiceInfo serviceInfo) {
        if (serviceInfo == null) return null;
            @Nullable ServiceInfo serviceInfo,
            boolean isPreviewMode) {
        if (serviceInfo == null) {
            return null;
        }
        final PackageManager pm = context.getPackageManager();
        return serviceInfo.loadLabel(pm);
        final CharSequence dreamLabel = serviceInfo.loadLabel(pm);
        if (!isPreviewMode || dreamLabel == null) {
            return dreamLabel;
        }
        // When in preview mode, return a special label indicating the dream is in preview.
        return context.getResources().getString(R.string.dream_preview_title, dreamLabel);
    }

    @Nullable
@@ -1529,8 +1539,9 @@ public class DreamService extends Service implements Window.Callback {
    final class DreamServiceWrapper extends IDreamService.Stub {
        @Override
        public void attach(final IBinder dreamToken, final boolean canDoze,
                IRemoteCallback started) {
            mHandler.post(() -> DreamService.this.attach(dreamToken, canDoze, started));
                final boolean isPreviewMode, IRemoteCallback started) {
            mHandler.post(
                    () -> DreamService.this.attach(dreamToken, canDoze, isPreviewMode, started));
        }

        @Override
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import android.os.IRemoteCallback;
 * @hide
 */
oneway interface IDreamService {
    void attach(IBinder windowToken, boolean canDoze, IRemoteCallback started);
    void attach(IBinder windowToken, boolean canDoze, boolean isPreviewMode, IRemoteCallback started);
    void detach();
    void wakeUp();
}
+5 −0
Original line number Diff line number Diff line
@@ -963,6 +963,11 @@
    <!-- Description for the capability of an accessibility service to take screenshot. [CHAR LIMIT=NONE] -->
    <string name="capability_desc_canTakeScreenshot">Can take a screenshot of the display.</string>

    <!-- Dream -->

    <!-- The title to use when a dream is opened in preview mode. [CHAR LIMIT=NONE] -->
    <string name="dream_preview_title">Preview, <xliff:g id="dream_name" example="Clock">%1$s</xliff:g></string>

    <!--  Permissions -->

    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+2 −0
Original line number Diff line number Diff line
@@ -4276,6 +4276,8 @@
  <java-symbol type="string" name="capability_desc_canTakeScreenshot" />
  <java-symbol type="string" name="capability_title_canTakeScreenshot" />

  <java-symbol type="string" name="dream_preview_title" />

  <java-symbol type="string" name="config_servicesExtensionPackage" />

  <!-- For app process exit info tracking -->
+1 −1
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ final class DreamController {
        try {
            service.asBinder().linkToDeath(mCurrentDream, 0);
            service.attach(mCurrentDream.mToken, mCurrentDream.mCanDoze,
                    mCurrentDream.mDreamingStartedCallback);
                    mCurrentDream.mIsPreviewMode, mCurrentDream.mDreamingStartedCallback);
        } catch (RemoteException ex) {
            Slog.e(TAG, "The dream service died unexpectedly.", ex);
            stopDream(true /*immediate*/, "attach failed");
Loading