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

Commit 8fb4c57a authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13453734 from 906bc5ea to 25Q3-release

Change-Id: I0ec22568311d07b231b78662a8cc686476a451b6
parents 11b10146 906bc5ea
Loading
Loading
Loading
Loading
+0 −69
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.commands.svc;

import android.app.ActivityThread;
import android.content.Context;
import android.nfc.NfcAdapter;
import android.nfc.NfcManager;
import android.os.Looper;

public class NfcCommand extends Svc.Command {

    public NfcCommand() {
        super("nfc");
    }

    @Override
    public String shortHelp() {
        return "Control NFC functions";
    }

    @Override
    public String longHelp() {
        return shortHelp() + "\n"
                + "\n"
                + "usage: svc nfc [enable|disable]\n"
                + "         Turn NFC on or off.\n\n";
    }

    @Override
    public void run(String[] args) {
        Looper.prepareMainLooper();
        ActivityThread.initializeMainlineModules();
        Context context = ActivityThread.systemMain().getSystemContext();
        NfcManager nfcManager = context.getSystemService(NfcManager.class);
        if (nfcManager == null) {
            System.err.println("Got a null NfcManager, is the system running?");
            return;
        }
        NfcAdapter adapter = nfcManager.getDefaultAdapter();
        if (adapter == null) {
            System.err.println("Got a null NfcAdapter, is the system running?");
            return;
        }
        if (args.length == 2 && "enable".equals(args[1])) {
            adapter.enable();
            return;
        } else if (args.length == 2 && "disable".equals(args[1])) {
            adapter.disable(true);
            return;
        }
        System.err.println(longHelp());
    }

}
+1 −1
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ public class Svc {
            new PowerCommand(),
            // `svc wifi` has been migrated to WifiShellCommand
            new UsbCommand(),
            new NfcCommand(),
            // `svc nfc` has been migrated to NfcShellCommand
            // `svc bluetooth` has been migrated to BluetoothShellCommand
            new SystemServerCommand(),
    };
+1 −0
Original line number Diff line number Diff line
@@ -596,6 +596,7 @@ public class ActivityOptions extends ComponentOptions {
    private boolean mIsEligibleForLegacyPermissionPrompt;
    private boolean mRemoveWithTaskOrganizer;
    private boolean mLaunchedFromBubble;
    // TODO(b/407669465): remove it once migrated to the new approach
    private boolean mLaunchNextToBubble;
    private boolean mTransientLaunch;
    private PictureInPictureParams mLaunchIntoPipParams;
+34 −29
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@ import com.android.internal.appwidget.IAppWidgetService;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
@@ -82,6 +81,7 @@ public class AppWidgetHost {
    private final Callbacks mCallbacks;
    private final SparseArray<AppWidgetHostListener> mListeners = new SparseArray<>();
    private InteractionHandler mInteractionHandler;
    private final Handler mMainHandler;

    static class Callbacks extends IAppWidgetHost.Stub {
        private final WeakReference<Handler> mWeakHandler;
@@ -214,6 +214,7 @@ public class AppWidgetHost {
        mHandler = new UpdateHandler(looper);
        mCallbacks = new Callbacks(mHandler);
        mDisplayMetrics = context.getResources().getDisplayMetrics();
        mMainHandler = new Handler(Looper.getMainLooper());
        bindService(context);
    }

@@ -673,6 +674,7 @@ public class AppWidgetHost {
        }

        List<AppWidgetEvent> eventList = new ArrayList<>();
        mMainHandler.post(() -> {
            synchronized (mListeners) {
                for (int i = 0; i < mListeners.size(); i++) {
                    AppWidgetEvent event = mListeners.valueAt(i).collectWidgetEvent();
@@ -694,6 +696,7 @@ public class AppWidgetHost {
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        });
    }

    /**
@@ -709,6 +712,7 @@ public class AppWidgetHost {
        if (listener == null) {
            return;
        }
        mMainHandler.post(() -> {
            AppWidgetEvent event = listener.collectWidgetEvent();
            if (event == null) {
                return;
@@ -720,6 +724,7 @@ public class AppWidgetHost {
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        });
    }
}

+6 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Looper;
import android.os.Parcelable;
import android.os.SystemClock;
import android.util.AttributeSet;
@@ -1043,11 +1044,16 @@ public class AppWidgetHostView extends FrameLayout implements AppWidgetHost.AppW
     * This function returns the current set of widget event data being tracked by this widget. The
     * tracked data is cleared is returned here.
     *
     * This should always be called on the main thread.
     *
     * @hide
     */
    @FlaggedApi(FLAG_ENGAGEMENT_METRICS)
    @Override
    public AppWidgetEvent collectWidgetEvent() {
        if (!Looper.getMainLooper().isCurrentThread()) {
            throw new IllegalStateException("collectWidgetEvent must be called from main thread");
        }
        return mInteractionLogger.collectWidgetEvent();
    }

Loading