Loading cmds/svc/src/com/android/commands/svc/NfcCommand.java +18 −18 Original line number Diff line number Diff line Loading @@ -16,10 +16,11 @@ package com.android.commands.svc; import android.app.ActivityThread; import android.content.Context; import android.nfc.INfcAdapter; import android.os.RemoteException; import android.os.ServiceManager; import android.nfc.NfcAdapter; import android.nfc.NfcManager; import android.os.Looper; public class NfcCommand extends Svc.Command { Loading @@ -42,15 +43,19 @@ public class NfcCommand extends Svc.Command { @Override public void run(String[] args) { INfcAdapter adapter = INfcAdapter.Stub.asInterface( ServiceManager.getService(Context.NFC_SERVICE)); 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; } try { if (args.length == 2 && "enable".equals(args[1])) { adapter.enable(); return; Loading @@ -58,11 +63,6 @@ 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()); } Loading Loading
cmds/svc/src/com/android/commands/svc/NfcCommand.java +18 −18 Original line number Diff line number Diff line Loading @@ -16,10 +16,11 @@ package com.android.commands.svc; import android.app.ActivityThread; import android.content.Context; import android.nfc.INfcAdapter; import android.os.RemoteException; import android.os.ServiceManager; import android.nfc.NfcAdapter; import android.nfc.NfcManager; import android.os.Looper; public class NfcCommand extends Svc.Command { Loading @@ -42,15 +43,19 @@ public class NfcCommand extends Svc.Command { @Override public void run(String[] args) { INfcAdapter adapter = INfcAdapter.Stub.asInterface( ServiceManager.getService(Context.NFC_SERVICE)); 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; } try { if (args.length == 2 && "enable".equals(args[1])) { adapter.enable(); return; Loading @@ -58,11 +63,6 @@ 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()); } Loading