Ejemplo n.º 1
0
 private boolean bindRemoteSSOService(Context context, String s)
 {
     boolean flag = true;
     if (TextUtils.isEmpty(s) || s.trim().equals(""))
     {
         s = "com.sina.weibo";
     }
     Intent intent = new Intent("com.sina.weibo.remotessoservice");
     intent.setPackage(s);
     if (!context.bindService(intent, mConnection, flag))
     {
         flag = context.bindService(new Intent("com.sina.weibo.remotessoservice"), mConnection, flag);
     }
     return flag;
 }
  /**
   * push设置初始化
   *
   * @param context
   */
  public static void init(Context context, final ConnectPushCallback callback) {
    mContext = context;
    mPushConnection =
        new ServiceConnection() {
          public void onServiceDisconnected(ComponentName name) {
            mDrPalmPushService = null;
          }

          public void onServiceConnected(ComponentName name, IBinder service) {

            mDrPalmPushService = IDrPalmPush.Stub.asInterface(service);
            Log.d("RequestOperation:onServiceConnected", "bind DrPalmPushService Success");
            if (callback != null) {
              callback.onSuccess();
            }
          }
        };

    Intent intentPushService = new Intent(mContext, DrPalmPushService.class);
    mContext.startService(intentPushService);
    boolean ret =
        mContext.bindService(intentPushService, mPushConnection, Context.BIND_AUTO_CREATE);
    Log.d("RequestOperation:bindPushService:", String.valueOf(ret));

    Intent intentGuideService = new Intent(mContext, DrPalmGuideService.class);
    mContext.startService(intentGuideService);
    Log.d("RequestOperation:startGuideService:", "");
  }
Ejemplo n.º 3
0
 public static List a(Context context, int i1, String s)
     throws GoogleAuthException, IOException
 {
     g g1;
     am.a(s, "accountName must be provided");
     am.c("Calling this from your main thread can lead to deadlock");
     context = context.getApplicationContext();
     a(context);
     g1 = new g();
     if (!context.bindService(m, g1, 1))
     {
         break MISSING_BLOCK_LABEL_119;
     }
     s = com.google.android.gms.internal.dr.a.a(g1.a()).a((new AccountChangeEventsRequest()).a(s).a(i1)).a();
     context.unbindService(g1);
     return s;
     s;
     Log.i("GoogleAuthUtil", "GMS remote exception ", s);
     throw new IOException("remote exception");
     s;
     context.unbindService(g1);
     throw s;
     s;
     throw new GoogleAuthException("Interrupted");
     throw new IOException("Could not bind to service with the given context.");
 }
Ejemplo n.º 4
0
  public MusicPlayCtrl(Context context) {

    this.context = context;
    context.startService(new Intent(context, MusicPlayService.class));
    context.bindService(
        new Intent(context, MusicPlayService.class), mConnection, Context.BIND_AUTO_CREATE);
  }
Ejemplo n.º 5
0
  private void initDiscoveryService() {
    // create the service connection
    if (mArdiscoveryServiceConnection == null) {
      mArdiscoveryServiceConnection =
          new ServiceConnection() {
            @Override
            public void onServiceConnected(ComponentName name, IBinder service) {
              mArdiscoveryService = ((ARDiscoveryService.LocalBinder) service).getService();

              startDiscovering();
            }

            @Override
            public void onServiceDisconnected(ComponentName name) {
              mArdiscoveryService = null;
            }
          };
    }

    if (mArdiscoveryService == null) {
      // if the discovery service doesn't exists, bind to it
      Intent i = new Intent(mCtx, ARDiscoveryService.class);
      mCtx.bindService(i, mArdiscoveryServiceConnection, Context.BIND_AUTO_CREATE);
    } else {
      // if the discovery service already exists, start discovery
      startDiscovering();
    }
  }
Ejemplo n.º 6
0
 public void startChallengeJump() {
   Intent intent = new Intent(context, AccelerometerListerner.class);
   context.bindService(intent, connection, Context.BIND_AUTO_CREATE);
   updateThread = new Thread(new updateJumps());
   totalJumps = 0;
   updateThread.start();
 }
 /** Create a BluetoothPbap proxy object. */
 public BluetoothPbap(Context context, ServiceListener l) {
   mContext = context;
   mServiceListener = l;
   if (!context.bindService(new Intent(IBluetoothPbap.class.getName()), mConnection, 0)) {
     Log.e(TAG, "Could not bind to Bluetooth Pbap Service");
   }
 }
 /** Create the service connection. */
 public void bind() {
   if (serviceObject != null) {
     return;
   }
   final Context context = contextRef.get();
   if (context == null) {
     return;
   }
   final Intent intent = new Intent(context, configuration.getApplicationServiceClass());
   intent.setAction(getInterfaceClass().getName());
   if (DEBUG_CALLS) {
     Log.v(TAG, "Attempt to bind to service " + this + "/" + context, new RuntimeException());
   }
   // start manually, so that it will be stopped manually
   context.startService(intent);
   final boolean bindResult = context.bindService(intent, this, 0);
   if (DEBUG) {
     Log.v(
         TAG,
         "Binded to service: "
             + bindResult
             + ", "
             + context
             + ", interface: "
             + getInterfaceClass());
   }
 }
 @Override
 protected void onPreExecute() {
   if (null == mSampleServiceIf) {
     Intent intent = new Intent(IIpcSampleServerService.class.getName());
     mContext.bindService(intent, mServiceConnection, BIND_AUTO_CREATE);
   }
 }
Ejemplo n.º 10
0
  /*
   * Start the oldest service
   */
  private void startService() {
    if (mMatchingIntents.size() > 0) { // There are some Intents untested
      if (LOG)
        Log.d(
            TAG,
            "Trying service " + mMatchingIntents.get(0).loadLabel(mContext.getPackageManager()));

      final ServiceInfo servInfo = mMatchingIntents.get(0).serviceInfo;
      final Intent i = new Intent();
      i.setComponent(new ComponentName(servInfo.applicationInfo.packageName, servInfo.name));
      mMatchingIntents.remove(0);
      try { // try added by Lionscribe
        mContext.bindService(i, this, Context.BIND_AUTO_CREATE);
      } catch (SecurityException e) {
        startService(); // ignore this one, and start next one
      }
    } else { // No more service to test

      getMostFrequentOpenUDID(); // Choose the most frequent

      if (OpenUDID == null) // No OpenUDID was chosen, generate one		
      generateOpenUDID();
      if (LOG) Log.d(TAG, "OpenUDID: " + OpenUDID);

      storeOpenUDID(); // Store it locally
    }
  }
Ejemplo n.º 11
0
  /**
   * Binds to the Face Unlock service. Face Unlock will be started when the bind completes. The Face
   * Unlock view is displayed to hide the backup lock while the service is starting up. Called on
   * the UI thread.
   */
  public boolean start() {
    if (DEBUG) Log.d(TAG, "start()");
    if (mHandler.getLooper() != Looper.myLooper()) {
      Log.e(TAG, "start() called off of the UI thread");
    }

    if (mIsRunning) {
      Log.w(TAG, "start() called when already running");
    }

    // Show Face Unlock view, but only for a little bit so lockpattern will become visible if
    // Face Unlock fails to start or crashes
    // This must show before bind to guarantee that Face Unlock has a place to display
    show(SERVICE_STARTUP_VIEW_TIMEOUT);
    if (!mBoundToService) {
      Log.d(TAG, "Binding to Face Unlock service");
      mContext.bindService(
          new Intent(IFaceLockInterface.class.getName()),
          mConnection,
          Context.BIND_AUTO_CREATE,
          mLockPatternUtils.getCurrentUser());
      mBoundToService = true;
    } else {
      Log.w(TAG, "Attempt to bind to Face Unlock when already bound");
    }

    mIsRunning = true;
    return true;
  }
 /**
  * Initializes the UI automation provider instance.
  *
  * <p>The constructor will attempt to bind the UI automation service
  *
  * @param context
  * @throws IOException if the provider failed to bind the service
  */
 public AutomationProvider(Context context) throws IOException {
   mServiceLock = new Object();
   if (!context.bindService(
       new Intent(SERVICE_NAME), mServiceConnection, Context.BIND_AUTO_CREATE)) {
     throw new IOException("Failed to connect to Provider service");
   }
   synchronized (mServiceLock) {
     if (mService == null) {
       try {
         // wait 3s for the service to finish connecting, should take less than that
         mServiceLock.wait(SERVICE_BIND_TIMEOUT);
       } catch (InterruptedException ie) {
       }
     }
   }
   if (mService == null) {
     throw new IOException("Failed to connect to Provider service");
   }
   try {
     if (!mService.checkUiVerificationEnabled()) {
       throw new IOException("dependent services are not running");
     }
   } catch (RemoteException re) {
     throw new IOException("error checking dependent services", re);
   }
 }
Ejemplo n.º 13
0
 public void startService(final ServiceConnection connection) {
   Intent intent = new Intent(context, NotificationService.class);
   context.startService(intent);
   if (connection != null) {
     context.bindService(intent, connection, Context.BIND_AUTO_CREATE);
   }
 }
Ejemplo n.º 14
0
  /**
   * Starts the setup process. This will start up the setup process asynchronously. You will be
   * notified through the listener when the setup process is complete. This method is safe to call
   * from a UI thread.
   *
   * @param listener The listener to notify when the setup process is complete.
   */
  public void startSetup(final OnIabSetupFinishedListener listener) {
    // If already set up, can't do it again.
    if (mSetupDone) throw new IllegalStateException("IAB helper is already set up.");

    // Connection to IAB service
    logDebug("Starting in-app billing setup.");
    mServiceConn =
        new ServiceConnection() {
          @Override
          public void onServiceDisconnected(ComponentName name) {
            logDebug("Billing service disconnected.");
            mService = null;
          }

          @Override
          public void onServiceConnected(ComponentName name, IBinder service) {
            logDebug("Billing service connected.");
            mService = IInAppBillingService.Stub.asInterface(service);
            String packageName = mContext.getPackageName();
            try {
              logDebug("Checking for in-app billing 3 support.");
              mCheckSupportedResponse =
                  mService.isBillingSupported(BILLING_API_VERSION, packageName, ITEM_TYPE_INAPP);
              if (mCheckSupportedResponse != BILLING_RESPONSE_RESULT_OK) {
                if (listener != null)
                  listener.onIabSetupFinished(
                      new IabResult(
                          mCheckSupportedResponse,
                          "Error checking for billing v3 support.",
                          Purchase.PURCHASE_HANDLE_UNKNOWN));
                return;
              }
              logDebug("In-app billing version 3 supported for " + packageName);
              mSetupDone = true;
            } catch (RemoteException e) {
              if (listener != null) {
                listener.onIabSetupFinished(
                    new IabResult(
                        IABHELPER_REMOTE_EXCEPTION,
                        "RemoteException while setting up in-app billing.",
                        Purchase.PURCHASE_HANDLE_UNKNOWN));
              }
              e.printStackTrace();
            }

            if (listener != null) {
              listener.onIabSetupFinished(
                  new IabResult(
                      BILLING_RESPONSE_RESULT_OK,
                      "Setup successful.",
                      Purchase.PURCHASE_HANDLE_UNKNOWN));
            }
          }
        };
    mContext.bindService(
        new Intent("com.android.vending.billing.InAppBillingService.BIND"),
        mServiceConn,
        Context.BIND_AUTO_CREATE);
  }
Ejemplo n.º 15
0
  public FavoritesApi(Context context) {
    mContext = context;
    mPackageManager = mContext.getPackageManager();

    String actionFavorites = mContext.getPackageName() + ".favorites";

    mContext.bindService(new Intent(actionFavorites), serviceConnection, Context.BIND_AUTO_CREATE);
  }
Ejemplo n.º 16
0
 public void bindService(Context ctx, Handler h) {
   handler = h;
   Log.d(TAG, "binding");
   Intent i = new Intent(ctx, PlayerService.class);
   bound = true;
   ctx.startService(i);
   ctx.bindService(i, this, Context.BIND_AUTO_CREATE);
 }
Ejemplo n.º 17
0
 private void doBindService() {
   Context context = libriDroidPlayerService.getApplicationContext();
   Intent intent = new Intent(context, DownloadService.class);
   mIsBound = context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
   if (!mIsBound) {
     throw new RuntimeException("Could not connect to download service...");
   }
 }
 public void checkUSBConnection() {
   // final String servicename = "de.uniulm.bagception.service.USBConnectionServiceRemote";
   final String servicename = ServiceNames.RFID_SERVICE;
   if (!context.bindService(
       new Intent(servicename), usbConnectionService, Context.BIND_AUTO_CREATE)) {
     callback.onUSBConnectionError(new Exception("error binding to connection service"));
   }
 }
Ejemplo n.º 19
0
 /** Create a BluetoothHeadset proxy object. */
 /*package*/ BluetoothHeadset(Context context, ServiceListener l) {
   mContext = context;
   mServiceListener = l;
   mAdapter = BluetoothAdapter.getDefaultAdapter();
   if (!context.bindService(new Intent(IBluetoothHeadset.class.getName()), mConnection, 0)) {
     Log.e(TAG, "Could not bind to Bluetooth Headset Service");
   }
 }
Ejemplo n.º 20
0
    /** bind WapPushManager */
    public void bindWapPushManager() {
      if (mWapPushMan != null) return;

      final ServiceConnection wapPushConnection = this;

      mOwner.bindService(
          new Intent(IWapPushManager.class.getName()), wapPushConnection, Context.BIND_AUTO_CREATE);
    }
Ejemplo n.º 21
0
 public void init() {
   Intent service = new Intent("com.voice.common.util.IDogControlService");
   if (!context.bindService(service, mConnection, context.BIND_AUTO_CREATE)) {
     if (mOnGetDevAdd != null) {
       mOnGetDevAdd.onDisConnect();
     }
   }
 }
  public void test_bindService_succeeds() throws RemoteException {
    Mockito.when(
            context.bindService(Mockito.any(Intent.class), Mockito.same(wrapper), Mockito.eq(0)))
        .thenReturn(true);

    boolean success = wrapper.bindService();

    assertTrue(success);
  }
Ejemplo n.º 23
0
  private void startService(Context context) {

    //  context.startService(new
    // Intent(TimerService.class.getName()).setPackage("com.winhands.settime"));
    Intent intent = new Intent("aw.untas.com.timerappwidget.TimerService");

    context.bindService(intent, connection, BIND_AUTO_CREATE);
    // context.startService(intent);
  }
Ejemplo n.º 24
0
 public void bindWeatherService() {
   if (mWeatherService == null) {
     Context context = getContext();
     Intent intent = new Intent("com.borqs.borqsweather.weatherservice");
     // for android 5.0+
     intent.setPackage(context.getPackageName());
     context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
   }
 }
 boolean doBind() {
   Intent intent = new Intent(IBluetoothInputDevice.class.getName());
   ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
   intent.setComponent(comp);
   if (comp == null || !mContext.bindService(intent, mConnection, 0)) {
     Log.e(TAG, "Could not bind to Bluetooth HID Service with " + intent);
     return false;
   }
   return true;
 }
  // Assume this is called from the Handler thread.
  private void takeScreenshot() {
    synchronized (mScreenshotLock) {
      if (mScreenshotConnection != null) {
        return;
      }

      notifyKey(ASUSDEC_SCREENSHOT, ASUSDEC_STATUS_OFF);

      ComponentName cn =
          new ComponentName(
              "com.android.systemui", "com.android.systemui.screenshot.TakeScreenshotService");
      Intent intent = new Intent();
      intent.setComponent(cn);
      ServiceConnection conn =
          new ServiceConnection() {
            @Override
            public void onServiceConnected(ComponentName name, IBinder service) {
              synchronized (mScreenshotLock) {
                if (mScreenshotConnection != this) {
                  return;
                }
                Messenger messenger = new Messenger(service);
                Message msg = Message.obtain(null, 1);
                final ServiceConnection myConn = this;
                Handler h =
                    new Handler(mHandler.getLooper()) {
                      @Override
                      public void handleMessage(Message msg) {
                        synchronized (mScreenshotLock) {
                          if (mScreenshotConnection == myConn) {
                            mContext.unbindService(mScreenshotConnection);
                            mScreenshotConnection = null;
                            mHandler.removeCallbacks(mScreenshotTimeout);
                          }
                        }
                      }
                    };
                msg.replyTo = new Messenger(h);
                msg.arg1 = msg.arg2 = 0;
                try {
                  messenger.send(msg);
                } catch (RemoteException e) {
                }
              }
            }

            @Override
            public void onServiceDisconnected(ComponentName name) {}
          };
      if (mContext.bindService(intent, conn, Context.BIND_AUTO_CREATE)) {
        mScreenshotConnection = conn;
        mHandler.postDelayed(mScreenshotTimeout, 10000);
      }
    }
  }
Ejemplo n.º 27
0
 public WapPushOverSms(Context context) {
   mContext = context;
   Intent intent = new Intent(IWapPushManager.class.getName());
   ComponentName comp = intent.resolveSystemService(context.getPackageManager(), 0);
   intent.setComponent(comp);
   if (comp == null || !context.bindService(intent, this, Context.BIND_AUTO_CREATE)) {
     Rlog.e(TAG, "bindService() for wappush manager failed");
   } else {
     if (DBG) Rlog.v(TAG, "bindService() for wappush manager succeeded");
   }
 }
Ejemplo n.º 28
0
  public void doBindService() {
    // Establish a connection with the service.  We use an explicit
    // class name because there is no reason to be able to let other
    // applications replace our component.
    // if(!mIsBound) {
    final Intent intent = new Intent(mContext, UploadingService.class);
    //        intent.setAction("org.ecomap.android.app.PHOTOS_UPLOADING");
    mContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
    // }

  }
Ejemplo n.º 29
0
 public boolean setTask(ProxyTask task) throws IllegalStateException {
   if (mDead) {
     throw new IllegalStateException();
   }
   mTask = task;
   mStartTime = System.currentTimeMillis();
   if (DEBUG_PROXY) {
     Log.v(mTag, "Bind requested for task " + mName);
   }
   return mContext.bindService(mIntent, mConnection, Context.BIND_AUTO_CREATE);
 }
Ejemplo n.º 30
0
  public synchronized void startImServiceIfNeed() {
    if (!mServiceStarted) {
      if (Log.isLoggable(LOG_TAG, Log.DEBUG)) log("start ImService");

      Intent serviceIntent = new Intent();
      serviceIntent.setComponent(ImServiceConstants.IM_SERVICE_COMPONENT);
      mApplicationContext.startService(serviceIntent);
      mApplicationContext.bindService(serviceIntent, mImServiceConn, Context.BIND_AUTO_CREATE);
      mServiceStarted = true;

      mConnectionListener = new MyConnListener(new Handler());
    }
  }