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

Commit eaa66095 authored by Roshan Pius's avatar Roshan Pius Committed by Automerger Merge Worker
Browse files

Merge "Revert "svc(nfc): Use NfcAdapter API to enable/disable"" into main am:...

Merge "Revert "svc(nfc): Use NfcAdapter API to enable/disable"" into main am: 47be3bb6 am: 8b0f9025 am: 714286d1

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



Change-Id: I337d51bc8410046f2f84d834539825963c45e723
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 1a14e406 714286d1
Loading
Loading
Loading
Loading
+18 −15
Original line number Diff line number Diff line
@@ -16,10 +16,10 @@

package com.android.commands.svc;

import android.app.ActivityThread;
import android.content.Context;
import android.nfc.NfcAdapter;
import android.nfc.NfcManager;
import android.nfc.INfcAdapter;
import android.os.RemoteException;
import android.os.ServiceManager;

public class NfcCommand extends Svc.Command {

@@ -42,17 +42,15 @@ public class NfcCommand extends Svc.Command {

    @Override
    public void run(String[] args) {
        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();
        INfcAdapter adapter = INfcAdapter.Stub.asInterface(
                ServiceManager.getService(Context.NFC_SERVICE));

        if (adapter == null) {
            System.err.println("Got a null NfcAdapter, is the system running?");
            return;
        }

        try {
            if (args.length == 2 && "enable".equals(args[1])) {
                adapter.enable();
                return;
@@ -60,6 +58,11 @@ public class NfcCommand extends Svc.Command {
                adapter.disable(true);
                return;
            }
        } catch (RemoteException e) {
            System.err.println("NFC operation failed: " + e);
            return;
        }

        System.err.println(longHelp());
    }