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

Commit d1f4639c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Merge SQ1A.220205.002"

parents 0b6e3a95 f55c524f
Loading
Loading
Loading
Loading
+29 −11
Original line number Diff line number Diff line
@@ -1452,18 +1452,27 @@ public class WallpaperManager {
                    mContext.getUserId());
            if (fd != null) {
                FileOutputStream fos = null;
                boolean ok = false;
                final Bitmap tmp = BitmapFactory.decodeStream(resources.openRawResource(resid));
                try {
                    // If the stream can't be decoded, treat it as an invalid input.
                    if (tmp != null) {
                        fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
                    copyStreamToWallpaperFile(resources.openRawResource(resid), fos);
                        tmp.compress(Bitmap.CompressFormat.PNG, 100, fos);
                        // The 'close()' is the trigger for any server-side image manipulation,
                        // so we must do that before waiting for completion.
                        fos.close();
                        completion.waitForCompletion();
                    } else {
                        throw new IllegalArgumentException(
                                "Resource 0x" + Integer.toHexString(resid) + " is invalid");
                    }
                } finally {
                    // Might be redundant but completion shouldn't wait unless the write
                    // succeeded; this is a fallback if it threw past the close+wait.
                    IoUtils.closeQuietly(fos);
                    if (tmp != null) {
                        tmp.recycle();
                    }
                }
            }
        } catch (RemoteException e) {
@@ -1705,13 +1714,22 @@ public class WallpaperManager {
                    result, which, completion, mContext.getUserId());
            if (fd != null) {
                FileOutputStream fos = null;
                final Bitmap tmp = BitmapFactory.decodeStream(bitmapData);
                try {
                    // If the stream can't be decoded, treat it as an invalid input.
                    if (tmp != null) {
                        fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
                    copyStreamToWallpaperFile(bitmapData, fos);
                        tmp.compress(Bitmap.CompressFormat.PNG, 100, fos);
                        fos.close();
                        completion.waitForCompletion();
                    } else {
                        throw new IllegalArgumentException("InputStream is invalid");
                    }
                } finally {
                    IoUtils.closeQuietly(fos);
                    if (tmp != null) {
                        tmp.recycle();
                    }
                }
            }
        } catch (RemoteException e) {
+6 −0
Original line number Diff line number Diff line
@@ -686,6 +686,12 @@ std::unique_ptr<const LoadedPackage> LoadedPackage::Load(const Chunk& chunk,
        std::unordered_set<uint32_t> finalized_ids;
        const auto lib_alias = child_chunk.header<ResTable_staged_alias_header>();
        if (!lib_alias) {
          LOG(ERROR) << "RES_TABLE_STAGED_ALIAS_TYPE is too small.";
          return {};
        }
        if ((child_chunk.data_size() / sizeof(ResTable_staged_alias_entry))
            < dtohl(lib_alias->count)) {
          LOG(ERROR) << "RES_TABLE_STAGED_ALIAS_TYPE is too small to hold entries.";
          return {};
        }
        const auto entry_begin = child_chunk.data_ptr().convert<ResTable_staged_alias_entry>();
+6 −5
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.controls.ui

import android.annotation.MainThread
import android.app.Dialog
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
@@ -88,7 +89,7 @@ class ControlActionCoordinatorImpl @Inject constructor(
        bouncerOrRun(createAction(cvh.cws.ci.controlId, {
            cvh.layout.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK)
            if (cvh.usePanel()) {
                showDetail(cvh, control.getAppIntent().getIntent())
                showDetail(cvh, control.getAppIntent())
            } else {
                cvh.action(CommandAction(templateId))
            }
@@ -116,7 +117,7 @@ class ControlActionCoordinatorImpl @Inject constructor(
            // Long press snould only be called when there is valid control state, otherwise ignore
            cvh.cws.control?.let {
                cvh.layout.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
                showDetail(cvh, it.getAppIntent().getIntent())
                showDetail(cvh, it.getAppIntent())
            }
        }, false /* blockable */))
    }
@@ -167,10 +168,10 @@ class ControlActionCoordinatorImpl @Inject constructor(
        bgExecutor.execute { vibrator.vibrate(effect) }
    }

    private fun showDetail(cvh: ControlViewHolder, intent: Intent) {
    private fun showDetail(cvh: ControlViewHolder, pendingIntent: PendingIntent) {
        bgExecutor.execute {
            val activities: List<ResolveInfo> = context.packageManager.queryIntentActivities(
                intent,
                pendingIntent.getIntent(),
                PackageManager.MATCH_DEFAULT_ONLY
            )

@@ -178,7 +179,7 @@ class ControlActionCoordinatorImpl @Inject constructor(
                // make sure the intent is valid before attempting to open the dialog
                if (activities.isNotEmpty() && taskViewFactory.isPresent) {
                    taskViewFactory.get().create(context, uiExecutor, {
                        dialog = DetailDialog(activityContext, it, intent, cvh).also {
                        dialog = DetailDialog(activityContext, it, pendingIntent, cvh).also {
                            it.setOnDismissListener { _ -> dialog = null }
                            it.show()
                        }
+16 −12
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ import com.android.wm.shell.TaskView
class DetailDialog(
    val activityContext: Context?,
    val taskView: TaskView,
    val intent: Intent,
    val pendingIntent: PendingIntent,
    val cvh: ControlViewHolder
) : Dialog(
    activityContext ?: cvh.context,
@@ -59,6 +59,14 @@ class DetailDialog(

    var detailTaskId = INVALID_TASK_ID

    private val fillInIntent = Intent().apply {
        putExtra(EXTRA_USE_PANEL, true)

        // Apply flags to make behaviour match documentLaunchMode=always.
        addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT)
        addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
    }

    fun removeDetailTask() {
        if (detailTaskId == INVALID_TASK_ID) return
        ActivityTaskManager.getInstance().removeTask(detailTaskId)
@@ -67,13 +75,6 @@ class DetailDialog(

    val stateCallback = object : TaskView.Listener {
        override fun onInitialized() {
            val launchIntent = Intent(intent)
            launchIntent.putExtra(EXTRA_USE_PANEL, true)

            // Apply flags to make behaviour match documentLaunchMode=always.
            launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT)
            launchIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK)

            val options = activityContext?.let {
                ActivityOptions.makeCustomAnimation(
                    it,
@@ -82,9 +83,8 @@ class DetailDialog(
                )
            } ?: ActivityOptions.makeBasic()
            taskView.startActivity(
                PendingIntent.getActivity(context, 0, launchIntent,
                        PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE),
                null /* fillInIntent */,
                pendingIntent,
                fillInIntent,
                options,
                getTaskViewBounds()
            )
@@ -97,6 +97,9 @@ class DetailDialog(

        override fun onTaskCreated(taskId: Int, name: ComponentName?) {
            detailTaskId = taskId
            requireViewById<ViewGroup>(R.id.controls_activity_view).apply {
                setAlpha(1f)
            }
        }

        override fun onReleased() {
@@ -121,6 +124,7 @@ class DetailDialog(

        requireViewById<ViewGroup>(R.id.controls_activity_view).apply {
            addView(taskView)
            setAlpha(0f)
        }

        requireViewById<ImageView>(R.id.control_detail_close).apply {
@@ -134,7 +138,7 @@ class DetailDialog(
                removeDetailTask()
                dismiss()
                context.sendBroadcast(Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS))
                v.context.startActivity(intent)
                pendingIntent.send()
            }
        }

+4 −1
Original line number Diff line number Diff line
@@ -15,7 +15,8 @@ import com.android.systemui.statusbar.phone.SystemUIDialog
class SensorUseDialog(
    context: Context,
    val sensor: Int,
    val clickListener: DialogInterface.OnClickListener
    val clickListener: DialogInterface.OnClickListener,
    val dismissListener: DialogInterface.OnDismissListener
) : SystemUIDialog(context) {

    // TODO move to onCreate (b/200815309)
@@ -69,6 +70,8 @@ class SensorUseDialog(
                context.getString(com.android.internal.R.string
                        .cancel), clickListener)

        setOnDismissListener(dismissListener)

        setCancelable(false)
    }
}
Loading