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

Commit d5b3cb2a authored by YoonKyung Kim's avatar YoonKyung Kim
Browse files

Revert "Read "showClockAndComplications" metadata."

This reverts commit 30711f85.

Reason for revert: b/217651561

Change-Id: I1647577ae5a7415ac336a5814fb0a73902c56aa7
parent 30711f85
Loading
Loading
Loading
Loading
+4 −40
Original line number Diff line number Diff line
@@ -65,7 +65,6 @@ import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.view.accessibility.AccessibilityEvent;

import com.android.internal.R;
import com.android.internal.util.DumpUtils;

import org.xmlpull.v1.XmlPullParser;
@@ -258,16 +257,13 @@ public class DreamService extends Service implements Window.Callback {
            mRequests = new ArrayDeque<>();
        }

        public void bind(Context context, @Nullable ComponentName overlayService,
                ComponentName dreamService) {
        public void bind(Context context, @Nullable ComponentName overlayService) {
            if (overlayService == null) {
                return;
            }

            final Intent overlayIntent = new Intent();
            overlayIntent.setComponent(overlayService);
            overlayIntent.putExtra(EXTRA_SHOW_COMPLICATIONS,
                    fetchShouldShowComplications(context, dreamService));

            context.bindService(overlayIntent,
                    this, Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE);
@@ -989,8 +985,7 @@ public class DreamService extends Service implements Window.Callback {

        // Connect to the overlay service if present.
        if (!mWindowless) {
            mOverlayConnection.bind(this, intent.getParcelableExtra(EXTRA_DREAM_OVERLAY_COMPONENT),
                    new ComponentName(this, getClass()));
            mOverlayConnection.bind(this, intent.getParcelableExtra(EXTRA_DREAM_OVERLAY_COMPONENT));
        }

        return mDreamServiceWrapper;
@@ -1122,9 +1117,7 @@ public class DreamService extends Service implements Window.Callback {
                convertToComponentName(rawMetadata.getString(
                        com.android.internal.R.styleable.Dream_settingsActivity), serviceInfo),
                rawMetadata.getDrawable(
                        com.android.internal.R.styleable.Dream_previewImage),
                rawMetadata.getBoolean(R.styleable.Dream_showClockAndComplications,
                        DEFAULT_SHOW_COMPLICATIONS));
                        com.android.internal.R.styleable.Dream_previewImage));
        rawMetadata.recycle();
        return metadata;
    }
@@ -1343,30 +1336,6 @@ public class DreamService extends Service implements Window.Callback {
        return (oldFlags&~mask) | (flags&mask);
    }

    /**
     * Fetches metadata of the dream indicated by the ${@link ComponentName}, and returns whether
     * the dream should show complications on the overlay. If not defined, returns
     * ${@link DreamService#DEFAULT_SHOW_COMPLICATIONS}.
     */
    private static boolean fetchShouldShowComplications(Context context,
            ComponentName componentName) {
        final PackageManager pm = context.getPackageManager();

        try {
            final ServiceInfo si = pm.getServiceInfo(componentName,
                    PackageManager.ComponentInfoFlags.of(PackageManager.GET_META_DATA));
            final DreamMetadata metadata = getDreamMetadata(context, si);

            if (metadata != null) {
                return metadata.showComplications;
            }
        } catch (PackageManager.NameNotFoundException e) {
            if (DEBUG) Log.w(TAG, "cannot find component " + componentName.flattenToShortString());
        }

        return DEFAULT_SHOW_COMPLICATIONS;
    }

    @Override
    protected void dump(final FileDescriptor fd, PrintWriter pw, final String[] args) {
        DumpUtils.dumpAsync(mHandler, (pw1, prefix) -> dumpOnHandler(fd, pw1, args), pw, "", 1000);
@@ -1440,14 +1409,9 @@ public class DreamService extends Service implements Window.Callback {
        @Nullable
        public final Drawable previewImage;

        @Nullable
        public final boolean showComplications;

        DreamMetadata(ComponentName settingsActivity, Drawable previewImage,
                boolean showComplications) {
        DreamMetadata(ComponentName settingsActivity, Drawable previewImage) {
            this.settingsActivity = settingsActivity;
            this.previewImage = previewImage;
            this.showComplications = showComplications;
        }
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -15,5 +15,4 @@
  -->

<dream xmlns:android="http://schemas.android.com/apk/res/android"
       android:settingsActivity="com.android.server.dreams/.TestDreamSettingsActivity"
       android:showClockAndComplications="false" />
       android:settingsActivity="com.android.server.dreams/.TestDreamSettingsActivity" />
+0 −2
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.server.dreams;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import android.content.ComponentName;
import android.content.Context;
@@ -50,7 +49,6 @@ public class DreamServiceTest {

            assertEquals(0, metadata.settingsActivity.compareTo(
                    ComponentName.unflattenFromString(testSettingsActivity)));
            assertFalse(metadata.showComplications);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }