Example #1
1
  public void logIntent(String tag, String msg, Intent intent, int logLevel, boolean logExtras) {
    StringBuilder sb = new StringBuilder();

    if (msg != null) {
      sb.append(msg);
      sb.append(intent.toString());
    } else {
      sb.append("LOG Intent: ");
      sb.append(intent.toString());
    }

    if (intent.getAction() != null) {
      sb.append(intent.getAction());
      sb.append(" ");
    }

    if (intent.getDataString() != null) {
      sb.append(intent.getDataString());
      sb.append(" ");
    }

    if (logExtras) {
      Bundle extras = intent.getExtras();
      if (extras != null) {
        for (String key : extras.keySet()) {
          String extra = String.valueOf(extras.get(key));
          sb.append(String.format("EXTRA [\"%s\"]: %s ", key, extra));
        }
      }
    }

    log(tag, sb.toString(), logLevel);
  }
  // ##date:2013/11/28 ##author:hongxing.whx
  // backup restore functionality support
  private void handleRestore() {
    if (BackupManager.getRestoreFlag(this)) {
      // set in restore flag, so that other part can use it to judge if homeshell
      // is in restore mode
      Log.d(TAG, "Set homeshell inRestore flag");
      BackupManager.getInstance().setIsInRestore(true);
      //            BackupManager.setRestoreFlag(this, false);

      /*YUNOS BEGIN*/
      // ##date:2013/12/20 ##author:hao.liuhaolh ##BugID: 75596
      // restore app isn't in folder if restore failed and reload.
      Cursor c = null;
      File restoreDBfile =
          new File(getApplicationContext().getFilesDir() + "/backup/" + RESTORE_DB_FILE);
      if (restoreDBfile.exists() == true) {
        Log.d(TAG, "handleRestore read data from restore db");
        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(restoreDBfile, null);
        c = db.query("favorites", null, null, null, null, null, null);
        // convertDBToBackupSet will close cursor, so we don't need to close it
        mBackupRecordMap = BackupUitil.convertDBToBackupSet(c);
        db.close();
      } else {
        Log.d(TAG, "handleRestore read data from homeshell db");
        final ContentResolver contentResolver = getApplicationContext().getContentResolver();
        c = contentResolver.query(Favorites.CONTENT_URI, null, null, null, null);
        // convertDBToBackupSet will close cursor, so we don't need to close it
        mBackupRecordMap = BackupUitil.convertDBToBackupSet(c);
      }
      /*YUNOS END*/

      for (Entry<String, BackupRecord> r : LauncherApplication.mBackupRecordMap.entrySet()) {
        Log.d(TAG, r.getValue().getField(Favorites._ID));
        String intentStr = r.getValue().getField(Favorites.INTENT);
        if (TextUtils.isEmpty(intentStr)) {
          continue;
        }
        try {
          Intent intent = Intent.parseUri(intentStr, 0);
          final ComponentName name = intent.getComponent();
          if (name == null) {
            Log.e(TAG, "ComponentName == Null");
            Log.i(TAG, "intent = " + intent.toString());
            continue;
          }
          Log.d(
              TAG,
              "onCreate() mBackupRecordMap getPackageName()="
                  + intent.getComponent().getPackageName());
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
  }
        @Override
        public void onReceive(Context context, Intent intent) {
          if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(intent.getAction())) {
            long reference = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
            Log.d(
                TAG,
                "refrence:"
                    + reference
                    + "#my reference:"
                    + mDownloadReference
                    + ", intent:"
                    + intent.toString());
            if (mDownloadReference == reference) {
              DownloadManager downloadManager;
              mContext.unregisterReceiver(mReceiver);
              downloadManager =
                  (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);
              Uri apkUri = downloadManager.getUriForDownloadedFile(reference);

              if (apkUri != null) {
                Intent installIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
                installIntent.setData(apkUri);
                mContext.startActivity(installIntent);
              }
            }
          }
        }
Example #4
0
  @Override
  public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    Log.i(TAG, intent.toString());

    String action = intent.getAction();
    Uri uri = intent.getData();
    Log.i(TAG, "MediaMountReceiver" + uri);
    if (Intent.ACTION_MEDIA_MOUNTED.equals(action)) {
      if (Util.hasExternalUpdateFile(uri) && Util.checkAllFileMD5(context)) {
        Log.d(
            TAG,
            "Name : UdiskUpgrade, Version : 1.0.0, Date : 2015-1-27, Publisher : Michael.Zhang, Revision : ");
        //				Intent intent1 = new Intent(context, UpgradeActivity.class);
        //				intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        //				context.startActivity(intent1);
        Intent intent1 = new Intent("com.intent.action.UPGRADESERVICE");
        context.startService(intent1);
      }

      /*
       * Bundle args = new Bundle(); args.putString("path", path);
       * args.putStringArray("files", files); context.startService(new
       * Intent(context, UdiskUpgradeService.class).putExtras(args));
       */
    }
  }
Example #5
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    try {
      if (requestCode == Result_load_img && resultCode == RESULT_OK && data != null) {
        Log.d("Mainaaaa", data.toString());
        //    Uri selectedImg = data.getData();
        //      String[] filepathcolumn = {MediaStore.Images.Media.DATA};
        //                Cursor cursor = getContentResolver().query(selectedImg, filepathcolumn,
        // null, null, null);

        //  cursor.moveToFirst();

        // int columnIndex = cursor.getColumnIndex(filepathcolumn[0]);

        // imgDecodableString = cursor.getString(columnIndex);

        // cursor.close();
        ImageView imageView = (ImageView) findViewById(R.id.imgView);
        //  imageView.setImageBitmap(BitmapFactory.decodeFile(imgDecodableString));

        Uri uri = data.getData();
        imageView.setImageURI(uri);

      } else {
        Toast.makeText(this, "You haven't picked any image", Toast.LENGTH_LONG).show();
      }
    } catch (Exception e) {
      Toast.makeText(this, "Something went wrong", Toast.LENGTH_LONG).show();
    }
  }
Example #6
0
 private void startService() {
   Intent intent = new Intent();
   intent.setClassName(
       "org.dobots.monotonesweepmodule",
       "org.dobots.monotonesweepmodule.aim.MonotoneSweepModuleService");
   ComponentName name = startService(intent);
   Log.i(TAG, "Starting: " + intent.toString());
 }
 private static void logTransactionTooLargeOrRethrow(RuntimeException e, Intent intent) {
   // See http://crbug.com/369574.
   if (e.getCause() != null && e.getCause() instanceof TransactionTooLargeException) {
     Log.e(TAG, "Could not resolve Activity for intent " + intent.toString(), e);
   } else {
     throw e;
   }
 }
  private void runStart() {
    Intent intent = makeIntent();

    if (intent != null) {
      System.out.println("Starting: " + intent);
      try {
        intent.addFlags(intent.FLAG_ACTIVITY_NEW_TASK);
        // XXX should do something to determine the MIME type.
        int res =
            mAm.startActivity(
                null, intent, intent.getType(), null, 0, null, null, 0, false, mDebugOption);
        switch (res) {
          case IActivityManager.START_SUCCESS:
            break;
          case IActivityManager.START_CLASS_NOT_FOUND:
            System.err.println("Error type 3");
            System.err.println(
                "Error: Activity class "
                    + intent.getComponent().toShortString()
                    + " does not exist.");
            break;
          case IActivityManager.START_DELIVERED_TO_TOP:
            System.err.println(
                "Warning: Activity not started, intent has "
                    + "been delivered to currently running "
                    + "top-most instance.");
            break;
          case IActivityManager.START_FORWARD_AND_REQUEST_CONFLICT:
            System.err.println(
                "Error: Activity not started, you requested to "
                    + "both forward and receive its result");
            break;
          case IActivityManager.START_INTENT_NOT_RESOLVED:
            System.err.println(
                "Error: Activity not started, unable to " + "resolve " + intent.toString());
            break;
          case IActivityManager.START_RETURN_INTENT_TO_CALLER:
            System.err.println(
                "Warning: Activity not started because intent "
                    + "should be handled by the caller");
            break;
          case IActivityManager.START_TASK_TO_FRONT:
            System.err.println(
                "Warning: Activity not started, its current "
                    + "task has been brought to the front");
            break;
          default:
            System.err.println("Error: Activity not started, unknown error " + "code " + res);
            break;
        }
      } catch (RemoteException e) {
        System.err.println("Error type 1");
        System.err.println(
            "Error: Activity not started, unable to " + "call on to activity manager service");
      }
    }
  }
  @Override
  public void onReceive(Context context, Intent intent) {

    Log.i(TAG, "Recebendo uma transmissão: " + intent.toString());

    // iniciando o service de importação de dados
    Intent i = new Intent(context, ImportDataService.class);
    context.startService(i);
  }
Example #10
0
 private void stopService() {
   Intent intent = new Intent();
   intent.setClassName(
       "org.dobots.monotonesweepmodule",
       "org.dobots.monotonesweepmodule.aim.MonotoneSweepModuleService");
   stopService(intent);
   Log.i(TAG, "Stopping service: " + intent.toString());
   //		finish();
 }
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode != RESULT_OK) {
     return;
   }
   switch (requestCode) {
     case REQUEST_CODE_SHOW_PRODUCT:
       Trace.e(TAG, "Show Product:result data->" + (null == data ? "null" : data.toString()));
       if (data != null
           && data.hasExtra(ProductDetailActivity.KEY_PRODUCT_REC)
           && data.hasExtra(ProductDetailActivity.KEY_POST_NUMBER)
           && data.hasExtra(ProductDetailActivity.KEY_EDIT_TYPE)) {
         ProductRec productRec =
             (ProductRec) data.getSerializableExtra(ProductDetailActivity.KEY_PRODUCT_REC);
         int pos = (Integer) data.getSerializableExtra(ProductDetailActivity.KEY_POST_NUMBER);
         int editType =
             data.getIntExtra(
                 ProductDetailActivity.KEY_EDIT_TYPE, ProductDetailActivity.TYPE_EDIT_PRODUCT);
         // 移除记录满足以下条件即可:
         // (1)藏品做了移除操作;
         // (2)藏品做了下架操作;
         // (3)藏品做了重新设置了分类操作;
         boolean isNeedRemoveProduct = false;
         if (editType == ProductDetailActivity.TYPE_REMOVE_PRODUCT) {
           isNeedRemoveProduct = true;
         } else {
           //					if(null != productRec){
           ////						isNeedRemoveProduct = !productRec.isOnSale();
           ////						String catId = productRec.getCatId();
           //						String currPageCatId = null == tagRec ? null : tagRec.getId();
           //						if(!isNeedRemoveProduct && null != catId && null != currPageCatId &&
           // !catId.equalsIgnoreCase(currPageCatId)){
           //							isNeedRemoveProduct = true;
           //						}
           //					}
         }
         if (isNeedRemoveProduct) {
           try {
             productList.remove(pos);
           } catch (Exception e) {
             Log.e(TAG, "Remove ProductRec failure: pos outOfArrIndex Exception.", e);
           }
         } else {
           //					productList.get(pos).setInFav(productRec.getInFav());
           //					productList.get(pos).setFavNum(productRec.getFavNum());
         }
         productAdapter.notifyDataSetInvalidated();
       }
       break;
     case FOR_LOGIN_RESULT:
       readyToGetAllGoodsByTagID(tagRec.getId(), true);
       break;
     default:
       break;
   }
 };
Example #12
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_CANCELED) {
      // User cancelled the image capture
      showToast(getResources().getString(R.string.info_select_logimage_cancelled));
      return;
    }

    if (resultCode != RESULT_OK) {
      // Image capture failed, advise user
      showFailure();
      return;
    }

    if (data != null) {
      Uri selectedImage = data.getData();
      String[] filePathColumn = {MediaColumns.DATA};

      Cursor cursor = null;
      try {
        cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
        if (cursor == null) {
          showFailure();
          return;
        }
        cursor.moveToFirst();

        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
        String filePath = cursor.getString(columnIndex);
        if (StringUtils.isBlank(filePath)) {
          showFailure();
          return;
        }
        imageUri = Uri.parse(filePath);
      } catch (Exception e) {
        Log.e("ImageSelectActivity.onActivityResult", e);
        showFailure();
      } finally {
        if (cursor != null) {
          cursor.close();
        }
      }

      Log.d("SELECT IMAGE data = " + data.toString());
    } else {
      Log.d("SELECT IMAGE data is null");
    }

    if (requestCode == SELECT_NEW_IMAGE) {
      showToast(getResources().getString(R.string.info_stored_image) + "\n" + imageUri);
    }

    loadImagePreview();
  }
  private void startResultsLog(
      boolean wca, boolean swb, boolean hc, boolean chromaticity, boolean bayer, Intent intent) {

    Log.i(TAG, wca + " " + swb + " " + hc + " " + chromaticity + " " + bayer);
    Log.i(TAG, intent.toString());
    intent.putExtra(getString(R.string.wca_checkbox), wca);
    intent.putExtra(getString(R.string.swb_checkbox), swb);
    intent.putExtra(getString(R.string.hc_analysis_check), hc);
    intent.putExtra(getString(R.string.chromaticity_check), chromaticity);
    intent.putExtra(getString(R.string.bayer_check), bayer);
    intent.setClass(this, LensCountActivity.class);

    startActivity(intent);
  }
Example #14
0
  public static void printIntent(Intent intent) {
    EzLog.d("[Intent Info] actionName=" + intent.getAction());
    EzLog.d("  + Intent toString=" + intent.toString());

    Bundle extras = intent.getExtras();
    if (extras == null) return;

    Set keys = extras.keySet();
    int index = 0;
    for (String key : extras.keySet()) {
      EzLog.d("  + [" + index + "]" + " key=" + key + ", value=" + extras.get(key));
      index += 1;
    }
  }
Example #15
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent arg2) {
   // TODO Auto-generated method stub
   Log.e(
       "info",
       "rusultCode " + resultCode + "  arg2  " + (null != arg2 ? arg2.toString() : "kong "));
   if (resultCode != 2222) {
     return;
   }
   // if (null != arg2 && arg2.getBooleanExtra("flag", false)) {
   finish();
   // }
   super.onActivityResult(requestCode, resultCode, arg2);
 }
Example #16
0
  /**
   * Receive a broadcast intent.
   *
   * @param context The Context in which the receiver is running.
   * @param intent The intent received.
   */
  @Override
  public void onReceive(Context context, Intent intent) {
    int pid = intent.getIntExtra(TestStatusReporter.EXTRA_PID, 0);
    String testClass = intent.getStringExtra(TestStatusReporter.EXTRA_TEST_CLASS);
    String testMethod = intent.getStringExtra(TestStatusReporter.EXTRA_TEST_METHOD);
    String stackTrace = intent.getStringExtra(TestStatusReporter.EXTRA_STACK_TRACE);

    switch (intent.getAction()) {
      case TestStatusReporter.ACTION_TEST_STARTED:
        for (StartCallback c : mStartCallbacks) {
          c.testStarted(testClass, testMethod);
        }
        break;
      case TestStatusReporter.ACTION_TEST_PASSED:
        for (PassCallback c : mPassCallbacks) {
          c.testPassed(testClass, testMethod);
        }
        break;
      case TestStatusReporter.ACTION_TEST_FAILED:
        for (FailCallback c : mFailCallbacks) {
          c.testFailed(testClass, testMethod, stackTrace);
        }
        break;
      case TestStatusReporter.ACTION_HEARTBEAT:
        for (HeartbeatCallback c : mHeartbeatCallbacks) {
          c.heartbeat();
        }
        break;
      case TestStatusReporter.ACTION_TEST_RUN_STARTED:
        for (TestRunCallback c : mTestRunCallbacks) {
          c.testRunStarted(pid);
        }
        break;
      case TestStatusReporter.ACTION_TEST_RUN_FINISHED:
        for (TestRunCallback c : mTestRunCallbacks) {
          c.testRunFinished(pid);
        }
        break;
      case TestStatusReporter.ACTION_UNCAUGHT_EXCEPTION:
        for (TestRunCallback c : mTestRunCallbacks) {
          c.uncaughtException(pid, stackTrace);
        }
        break;
      default:
        Log.e(TAG, "Unrecognized intent received: %s", intent.toString());
        break;
    }
  }
Example #17
0
 public void doRestart() {
   try {
     String action = "org.mozilla.gecko.restart";
     Intent intent = new Intent(action);
     intent.setClassName(getPackageName(), getPackageName() + ".Restarter");
     addEnvToIntent(intent);
     intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
     Log.i(LOG_FILE_NAME, intent.toString());
     GeckoAppShell.killAnyZombies();
     startActivity(intent);
   } catch (Exception e) {
     Log.i(LOG_FILE_NAME, "error doing restart", e);
   }
   finish();
   // Give the restart process time to start before we die
   GeckoAppShell.waitForAnotherGeckoProc();
 }
 @Override
 public void onReceive(Context context, Intent intent) {
   PreyLogger.d("Boot finished. Starting Prey Boot Service");
   // just make sure we are getting the right intent (better safe than
   // sorry)
   if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
     String interval = PreyConfig.getPreyConfig(context).getIntervalReport();
     if (interval != null && !"".equals(interval)) {
       Report.run(context, Integer.parseInt(interval));
     }
     boolean keepOn = PreyConfig.getPreyConfig(context).isKeepOn();
     if (keepOn) {
       context.startService(new Intent(context, PreyKeepOnService.class));
     } else {
       context.stopService(new Intent(context, PreyKeepOnService.class));
     }
   } else PreyLogger.e("Received unexpected intent " + intent.toString(), null);
 }
Example #19
0
  @Override
  public void onReceive(Context context, Intent intent) {
    Log.i(logTag, "Received intent: " + intent.toString());
    String action = intent.getAction();

    if (action.equals(PushManager.ACTION_PUSH_RECEIVED)) {

      int id = intent.getIntExtra(PushManager.EXTRA_NOTIFICATION_ID, 0);

      Log.i(
          logTag,
          "Received push notification. Alert: "
              + intent.getStringExtra(PushManager.EXTRA_ALERT)
              + " [NotificationID="
              + id
              + "]");

      logPushExtras(intent);

    } else if (action.equals(PushManager.ACTION_NOTIFICATION_OPENED)) {

      Log.i(
          logTag,
          "User clicked notification. Message: " + intent.getStringExtra(PushManager.EXTRA_ALERT));

      logPushExtras(intent);

      Intent launch = new Intent(Intent.ACTION_MAIN);
      launch.setClass(UAirship.shared().getApplicationContext(), MainActivity.class);
      launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

      UAirship.shared().getApplicationContext().startActivity(launch);

    } else if (action.equals(PushManager.ACTION_REGISTRATION_FINISHED)) {
      Log.i(
          logTag,
          "Registration complete. APID:"
              + intent.getStringExtra(PushManager.EXTRA_APID)
              + ". Valid: "
              + intent.getBooleanExtra(PushManager.EXTRA_REGISTRATION_VALID, false));
    }
  }
  void updateResult() {
    Intent intent = new Intent();

    long id = mSpinnerAction.getSelectedItemId();
    if (id == 0) {
      intent.putExtra(ShoppingListIntents.EXTRA_ACTION, ShoppingListIntents.TASK_CLEAN_UP_LIST);
    }
    intent.putExtra(ShoppingListIntents.EXTRA_DATA, mUri.toString());

    String description = mDescriptionAction + ": " + mDescriptionShoppingList;
    intent.putExtra(AutomationIntents.EXTRA_DESCRIPTION, description);

    if (debug) {
      Log.i(TAG, "Created intent (URI)   : " + intent.toURI());
    }
    if (debug) {
      Log.i(TAG, "Created intent (String): " + intent.toString());
    }

    setResult(RESULT_OK, intent);
  }
 /**
  * Returns an explicit Intent for a service that accepts the given Intent or null if no such
  * service was found.
  *
  * @param context The application's environment.
  * @param action The Intent action to check for availability.
  * @return The explicit service Intent or null if no service was found.
  */
 public static Intent getPrestoServiceIntent(Context context, String action) {
   final PackageManager packageManager = context.getPackageManager();
   final Intent actionIntent = new Intent(action);
   List<ResolveInfo> list =
       packageManager.queryIntentServices(actionIntent, PackageManager.MATCH_DEFAULT_ONLY);
   if (list.size() > 0) {
     ResolveInfo first = list.get(0);
     if (first.serviceInfo != null) {
       Intent intent = new Intent();
       intent.setComponent(
           new ComponentName(first.serviceInfo.packageName, first.serviceInfo.name));
       Log.i(TAG, "Returning intent:" + intent.toString());
       return intent;
     } else {
       Log.e(TAG, "Found service that accepts " + action + ", but serviceInfo was null");
       return null;
     }
   } else {
     return null;
   }
 }
Example #22
0
 protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
   switch (requestCode) {
     case REQUEST_PICK_TOKEN:
       if (resultCode == RESULT_OK && intent != null) {
         Uri name = intent.getData();
         try {
           // URI vs Uri -> Java/Android fail ...
           File f = new File(new URI(name.toString()));
           Token t = Token.fromFile(f);
           SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
           SharedPreferences.Editor e = p.edit();
           e.putString("token", t.toString());
           e.commit();
           Toast.makeText(this, "Token successfully imported.", Toast.LENGTH_LONG).show();
         } catch (Exception e) {
           e.printStackTrace();
         }
       }
       break;
     default:
       Log.w(TAG, "Unknown activity " + intent.toString());
   }
 }
Example #23
0
  @Override
  public void onReceive(Context context, Intent intent) {
    Log.v(TAG, intent.toString());

    session = Session.getInstance(context);
    String action = intent.getAction();
    Bundle data = intent.getExtras();
    final NotificationManager nm =
        (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    final NotificationCompat.Builder ncb;

    if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {

      session.registerAlarms();

    } else if (action.equals(SR.CLEAN_DB_CACHE)
        || action.equals(SR.GDRIVE_SYNCNOW)
        || action.equals(SR.CHECK_TVDB_RSS)) {

      session.registerAlarms();
      WakefulIntentService.sendWakefulWork(
          context, new Intent(context, Service.class).setAction(action));

    } else if (action.equals(SN.CONNECT_FAIL)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_error);
      ncb.setContentTitle(session.getString(R.string.notif_gac_fail));
      ncb.setContentIntent(newPI(newAI(SN.CONNECT_FAIL), false));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      nm.notify(NOTIF_CONNECT_FAIL, ncb.build());

    } else if (action.equals(Commons.SN.GENERAL_FAIL)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_error);
      ncb.setContentTitle(session.getString(R.string.notif_srv_fail));
      ncb.setContentText(data.getString("what"));
      ncb.setContentIntent(newPI(newAI(SN.GENERAL_FAIL), false));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      nm.notify(NOTIF_GENERAL_FAIL, ncb.build());

    } else if (action.equals(Commons.SN.GENERAL_INFO)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_info);
      ncb.setContentTitle(session.getString(R.string.notif_srv_info));
      ncb.setContentText(data.getString("what"));
      ncb.setContentIntent(newPI(newAI(SN.GENERAL_INFO), false));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      nm.notify(NOTIF_GENERAL_INFO, ncb.build());

    } else if (action.equals(SN.MOV_WLST)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_movie);
      ncb.setContentTitle(session.getString(R.string.notif_mov_wlst));
      ncb.setContentText(data.getString("name", session.getString(R.string.notif_gen_miss)));
      ncb.setContentIntent(
          newPI(newAI(MA.MOVIE_INFO).putExtra("imdb_id", data.getString("imdb_id")), true));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());

    } else if (action.equals(SN.MOV_COLL)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_movie);
      ncb.setContentTitle(session.getString(R.string.notif_mov_coll));
      ncb.setContentText(data.getString("name", session.getString(R.string.notif_gen_miss)));
      ncb.setContentIntent(
          newPI(newAI(MA.MOVIE_INFO).putExtra("imdb_id", data.getString("imdb_id")), true));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());

    } else if (action.equals(SN.SER_WLST)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_series);
      ncb.setContentTitle(session.getString(R.string.notif_ser_wlst));
      ncb.setContentText(data.getString("name", session.getString(R.string.notif_gen_miss)));
      ncb.setContentIntent(
          newPI(newAI(MA.SERIES_INFO).putExtra("tvdb_id", data.getString("tvdb_id")), true));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());

    } else if (action.equals(SN.SER_COLL)) {

      EID eid = new EID(data.getString("series"), data.getInt("season"), data.getInt("episode"));
      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_series);
      ncb.setContentTitle(session.getString(R.string.notif_ser_coll));
      ncb.setContentText(
          eid.readable() + " " + data.getString("name", session.getString(R.string.unknown_title)));
      ncb.setContentIntent(
          newPI(
              newAI(MA.EPISODE_INFO)
                  .putExtra("series", eid.series)
                  .putExtra("season", eid.season)
                  .putExtra("episode", eid.episode),
              true));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());

    } else if (action.equals(SN.SER_PREM)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_premiere);
      ncb.setContentTitle(session.getString(R.string.notif_ser_prem));
      ncb.setContentText(data.getString("name", session.getString(R.string.notif_gen_miss)));
      ncb.setContentIntent(
          newPI(newAI(MA.SERIES_INFO).putExtra("tvdb_id", data.getString("tvdb_id")), true));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      String plot = data.getString("plot");
      if (!TextUtils.isEmpty(plot))
        ncb.setStyle(new NotificationCompat.BigTextStyle().bigText(plot));
      String purl = data.getString("poster");
      if (TextUtils.isEmpty(purl)) nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());
      else
        session
            .picasso()
            .load(purl)
            .placeholder(R.drawable.ic_notification_premiere)
            .into(
                new Target() {
                  @Override
                  public void onPrepareLoad(Drawable arg0) {}

                  @Override
                  public void onBitmapLoaded(Bitmap bitmap, LoadedFrom source) {
                    ncb.setLargeIcon(bitmap);
                    nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());
                  }

                  @Override
                  public void onBitmapFailed(Drawable arg0) {
                    nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());
                  }
                });

    } else if (action.equals(SN.SER_CANC)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_deleted);
      ncb.setContentTitle(session.getString(R.string.notif_ser_canc));
      ncb.setContentText(data.getString("name", session.getString(R.string.notif_gen_miss)));
      ncb.setContentIntent(
          newPI(newAI(MA.SERIES_INFO).putExtra("tvdb_id", data.getString("tvdb_id")), true));
      if (session.notificationSound()) ncb.setSound(NOTIF_SOUND);
      String purl = data.getString("poster");
      if (TextUtils.isEmpty(purl)) nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());
      else
        session
            .picasso()
            .load(purl)
            .placeholder(R.drawable.ic_notification_deleted)
            .into(
                new Target() {
                  @Override
                  public void onPrepareLoad(Drawable arg0) {}

                  @Override
                  public void onBitmapLoaded(Bitmap bitmap, LoadedFrom source) {
                    ncb.setLargeIcon(bitmap);
                    nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());
                  }

                  @Override
                  public void onBitmapFailed(Drawable arg0) {
                    nm.notify(NOTIF_ID.incrementAndGet(), ncb.build());
                  }
                });

    } else if (action.equals(SN.DBG_TVDB_RSS)) {

      ncb = new NotificationCompat.Builder(session.getContext()).setAutoCancel(true);
      ncb.setSmallIcon(R.drawable.ic_notification_info);
      ncb.setContentTitle(session.getString(R.string.notif_dbg_rsst));
      ncb.setContentText(
          String.format(
              session.getString(R.string.notif_dbg_rssm),
              data.getInt("tot"),
              data.getInt("chk"),
              data.getInt("oks")));
      ncb.setContentIntent(newPI(newAI(SN.GENERAL_INFO), false));
      nm.notify(NOTIF_GENERAL_INFO, ncb.build());
    }
  }
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    if (preference.getKey().equals(KEY_FIRMWARE_VERSION)) {
      System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
      mHits[mHits.length - 1] = SystemClock.uptimeMillis();
      if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setClassName("android", com.android.internal.app.PlatLogoActivity.class.getName());
        try {
          startActivity(intent);
        } catch (Exception e) {
          Log.e(LOG_TAG, "Unable to start activity " + intent.toString());
        }
      }
    } else if (preference.getKey().equals(KEY_BUILD_NUMBER)) {
      // Don't enable developer options for secondary users.
      if (UserHandle.myUserId() != UserHandle.USER_OWNER) return true;

      if (mDevHitCountdown > 0) {
        mDevHitCountdown--;
        if (mDevHitCountdown == 0) {
          getActivity()
              .getSharedPreferences(DevelopmentSettings.PREF_FILE, Context.MODE_PRIVATE)
              .edit()
              .putBoolean(DevelopmentSettings.PREF_SHOW, true)
              .apply();
          if (mDevHitToast != null) {
            mDevHitToast.cancel();
          }
          mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_on, Toast.LENGTH_LONG);
          mDevHitToast.show();
        } else if (mDevHitCountdown > 0 && mDevHitCountdown < (TAPS_TO_BE_A_DEVELOPER - 2)) {
          if (mDevHitToast != null) {
            mDevHitToast.cancel();
          }
          mDevHitToast =
              Toast.makeText(
                  getActivity(),
                  getResources()
                      .getQuantityString(
                          R.plurals.show_dev_countdown, mDevHitCountdown, mDevHitCountdown),
                  Toast.LENGTH_SHORT);
          mDevHitToast.show();
        }
      } else if (mDevHitCountdown < 0) {
        if (mDevHitToast != null) {
          mDevHitToast.cancel();
        }
        mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_already, Toast.LENGTH_LONG);
        mDevHitToast.show();
      }
    } else if (preference.getKey().equals(KEY_MOD_VERSION)) {
      System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
      mHits[mHits.length - 1] = SystemClock.uptimeMillis();
      if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.putExtra("is_cid", true);
        intent.setClassName("android", com.android.internal.app.PlatLogoActivity.class.getName());
        try {
          startActivity(intent);
        } catch (Exception e) {
          Log.e(LOG_TAG, "Unable to start activity " + intent.toString());
        }
      }
    } else if (preference.getKey().equals(KEY_SELINUX_STATUS)) {
      System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
      mHits[mHits.length - 1] = SystemClock.uptimeMillis();
      if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
        if (SELinux.isSELinuxEnabled()) {
          if (!SELinux.isSELinuxEnforced()) {
            /* Display the warning dialog */
            AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
            alertDialog.setTitle(R.string.selinux_enable_title);
            alertDialog.setMessage(getResources().getString(R.string.selinux_enable_warning));
            alertDialog.setButton(
                DialogInterface.BUTTON_POSITIVE,
                getResources().getString(com.android.internal.R.string.ok),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    SELinux.setSELinuxEnforce(true);
                    String status = getResources().getString(R.string.selinux_status_enforcing);
                    setStringSummary(KEY_SELINUX_STATUS, status);
                  }
                });
            alertDialog.setButton(
                DialogInterface.BUTTON_NEGATIVE,
                getResources().getString(com.android.internal.R.string.cancel),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {}
                });
            alertDialog.setOnCancelListener(
                new DialogInterface.OnCancelListener() {
                  public void onCancel(DialogInterface dialog) {}
                });
            alertDialog.show();

          } else {
            SELinux.setSELinuxEnforce(false);
          }
        }

        if (!SELinux.isSELinuxEnabled()) {
          String status = getResources().getString(R.string.selinux_status_disabled);
          setStringSummary(KEY_SELINUX_STATUS, status);
        } else if (!SELinux.isSELinuxEnforced()) {
          String status = getResources().getString(R.string.selinux_status_permissive);
          setStringSummary(KEY_SELINUX_STATUS, status);
        } else if (SELinux.isSELinuxEnforced()) {
          String status = getResources().getString(R.string.selinux_status_enforcing);
          setStringSummary(KEY_SELINUX_STATUS, status);
        }
      }
    }
    return super.onPreferenceTreeClick(preferenceScreen, preference);
  }
 public boolean onUnbind(Intent intent) {
   Log.i(TAG, "Service onUnbind called for intent " + intent.toString());
   return true;
 }
 public IBinder onBind(Intent intent) {
   Log.i(TAG, "Service onBind called for intent " + intent.toString());
   return mEngineInterface;
 }
Example #27
0
 private void i(Intent paramIntent)
 {
   if (paramIntent == null) {
     com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "receiveImp receiveIntent == null");
   }
   label11:
   label158:
   label421:
   label1121:
   label1128:
   label1206:
   label1212:
   do
   {
     do
     {
       do
       {
         return;
         i = WorkerProfile.lv().ah(false);
         if (ax.sO())
         {
           com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "mmcore is null, appcreate %d", new Object[] { Integer.valueOf(i) });
           return;
         }
         if (!WorkerProfile.lv().lw())
         {
           com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "WorkerProfile not has create, status %d", new Object[] { Integer.valueOf(i) });
           return;
         }
         i = paramIntent.getIntExtra("notify_option_type", 0);
         if (i == 0)
         {
           com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "receiveImp invalid opcode.");
           return;
         }
         if (ax.to())
         {
           if (ax.ts()) {
             break label158;
           }
           ax.tr();
         }
         while ((!ax.qZ()) || (ax.tu()))
         {
           com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "receiveImp hasSetuin:%b  isHold:%b  opcode:%d", new Object[] { Boolean.valueOf(ax.qZ()), Boolean.valueOf(ax.tu()), Integer.valueOf(i) });
           return;
           com.tencent.mm.sdk.platformtools.t.i("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "receiveImp uinHasDefaultButNoAcc but accInitializing true so not setup!");
         }
         if (tmbtD == null)
         {
           com.tencent.mm.sdk.platformtools.t.w("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "receiveImp  opcode:%d  getDispatcher == null", new Object[] { Integer.valueOf(i) });
           ax.tm().aH(true);
         }
         switch (i)
         {
         case 99: 
         default: 
           com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "invald opCode:" + i);
           return;
         case 1: 
           ak(aa.getContext());
           paramIntent = aa.getContext();
           com.tencent.mm.sdk.platformtools.t.i("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "dealWithLooper");
           if ((!ax.qZ()) || (ax.tu()))
           {
             com.tencent.mm.sdk.platformtools.t.w("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "receiveImp hasSetuin:" + ax.qZ() + " isHold:" + ax.tu());
             return;
           }
           if (!tmforeground)
           {
             if ((paramIntent != null) && (!al.cV(paramIntent)))
             {
               i = 1;
               if (i != 0) {
                 break label421;
               }
             }
           }
           else {
             ax.tm().d(new com.tencent.mm.ab.j(3));
           }
           for (;;)
           {
             x.Cr().run();
             v.Ca().run();
             af.zj().run();
             ay.azm().run();
             com.tencent.mm.app.plugin.voicereminder.a.e.lV().run();
             a.hXQ.g(new id());
             return;
             i = 0;
             break;
             ax.tm().d(new i());
           }
         case 2: 
           ak(aa.getContext());
           int j = paramIntent.getIntExtra("notify_respType", 0);
           localObject1 = paramIntent.getByteArrayExtra("notify_respBuf");
           localObject2 = paramIntent.getByteArrayExtra("notify_skey");
           long l = paramIntent.getLongExtra("notfiy_recv_time", -1L);
           if (localObject1 == null) {}
           for (i = -1;; i = localObject1.length)
           {
             com.tencent.mm.sdk.platformtools.t.i("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "dealWithNotify respType:%d recvTime:%d respBuf:%d sessionkey:%s ", new Object[] { Integer.valueOf(j), Long.valueOf(l), Integer.valueOf(i), bn.xZ(bn.aI((byte[])localObject2)) });
             switch (j)
             {
             default: 
               return;
             case 10: 
               com.tencent.mm.sdk.platformtools.t.d("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "on direct send notify");
               paramIntent = new l.b();
               hha = q.oI();
               localObject2 = new ae(paramIntent, 10);
               try
               {
                 if (!((ae)localObject2).a(10, (byte[])localObject1, null)) {
                   break label11;
                 }
                 ax.tm().a(0, 0, "", new com.tencent.mm.modelsimple.j(paramIntent));
                 return;
               }
               catch (RemoteException paramIntent)
               {
                 return;
               }
             }
           }
           if (bn.J((byte[])localObject2))
           {
             com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "dkpush dealWithNotify session:" + localObject2);
             return;
           }
           if ((bn.J((byte[])localObject1)) || (localObject1.length <= 8))
           {
             com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "dkpush dealWithNotify respBuf error ");
             return;
           }
           i = k.c((byte[])localObject1, 0);
           j = k.c((byte[])localObject1, 4);
           if (j != localObject1.length - 8)
           {
             com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "dkpush: respBuf length error len:" + localObject1.length);
             return;
           }
           byte[] arrayOfByte = new byte[j];
           System.arraycopy(localObject1, 8, arrayOfByte, 0, j);
           com.tencent.mm.sdk.platformtools.t.i("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "dkpush PUSHDATA flag:%d bufLen:%d respBuf:%d recvTime:%d", new Object[] { Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(localObject1.length), Long.valueOf(l) });
           paramIntent = new s.b();
           localObject1 = new PByteArray();
           PByteArray localPByteArray = new PByteArray();
           PInt localPInt = new PInt();
           try
           {
             if (!MMProtocalJni.unpack(localPByteArray, arrayOfByte, (byte[])localObject2, (PByteArray)localObject1, localPInt))
             {
               com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpJRvkgZo4JKS+ippUZtfBu8", "unpack push resp failed");
               return;
             }
           }
           catch (Exception paramIntent)
           {
             com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpJRvkgZo4JKS+ippUZtfBu8", "unpack push resp failed: %s", new Object[] { paramIntent });
             return;
           }
           if (value == -13)
           {
             hgQ = value;
             com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpJRvkgZo4JKS+ippUZtfBu8", "unpack push resp failed session timeout");
             return;
           }
           j = paramIntent.z(value);
           com.tencent.mm.sdk.platformtools.t.d("[email protected]/B4Tb64lLpJRvkgZo4JKS+ippUZtfBu8", "bufToResp using protobuf ok");
           hgQ = j;
           hgP = arrayOfByte.length;
           localObject1 = com.tencent.mm.platformtools.ad.iX(com.tencent.mm.platformtools.ad.iV((String)ax.tl().rf().get(8195, null)));
           localObject2 = w.a(hhm.hpC);
           if ((com.tencent.mm.platformtools.ad.J((byte[])localObject2)) || (!z.j((byte[])localObject1, (byte[])localObject2)))
           {
             com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpJRvkgZo4JKS+ippUZtfBu8", "compareKeybuf syncKey failed");
             return;
           }
           ax.tm().d(new com.tencent.mm.ab.j(paramIntent, i, l));
           return;
           if (localObject1 == null)
           {
             i = 7;
             if (localObject1 != null) {
               break label1206;
             }
             j = 3;
             if (localObject1 != null) {
               break label1212;
             }
           }
           for (int k = -1;; k = localObject1.length)
           {
             com.tencent.mm.sdk.platformtools.t.d("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "dkpush NOTIFY or SyncCheck selector:%d scnen:%d  respBuf:%d ", new Object[] { Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(k) });
             i = m.a(i, j, "");
             if (i <= 0) {
               break;
             }
             NotifyReceiver.by(i);
             al(aa.getContext());
             return;
             i = k.c((byte[])localObject1, 0);
             break label1121;
             j = 7;
             break label1128;
           }
           com.tencent.mm.sdk.platformtools.t.d("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "dkpush GCM Notify");
           i = m.a(7L, 15, "");
         }
       } while (i <= 0);
       NotifyReceiver.by(i);
       al(aa.getContext());
       return;
       paramIntent = new StringBuilder("oreh on newsynccheck2 notify, notify=");
       if (localObject1 != null) {}
       for (boolean bool = true;; bool = false)
       {
         com.tencent.mm.sdk.platformtools.t.d("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", bool);
         paramIntent = new w.b();
         try
         {
           paramIntent.z((byte[])localObject1);
           i = m.a(hhs, 7, paramIntent.aDt());
           if (i <= 0) {
             break;
           }
           NotifyReceiver.by(i);
           al(aa.getContext());
           return;
         }
         catch (Exception paramIntent)
         {
           return;
         }
       }
       ax.tm().d(new i());
       return;
       paramIntent = new ip();
       aFJ.aFL = true;
       a.hXQ.g(paramIntent);
       paramIntent = aFK.aFN;
       if (!bn.iW(paramIntent))
       {
         com.tencent.mm.sdk.platformtools.t.v("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "voipinvite, exit talkroom first: " + paramIntent);
         paramIntent = new ip();
         aFJ.aFM = true;
         a.hXQ.g(paramIntent);
       }
       com.tencent.mm.sdk.platformtools.t.d("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "dealWithNotify case MMFunc_VoipInvite, will launch voipUI");
       paramIntent = new jq();
       aGJ.axE = 3;
       aGJ.aGL = ((byte[])localObject1);
       a.hXQ.g(paramIntent);
       return;
       com.tencent.mm.sdk.platformtools.t.i("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "dealWithNotify MMFunc_VoipSync do VoipSync");
       paramIntent = new jq();
       aGJ.axE = 6;
       aGJ.aGL = ((byte[])localObject1);
       a.hXQ.g(paramIntent);
       return;
       paramIntent = new ck();
       axX.axY = ((byte[])localObject1);
       a.hXQ.g(paramIntent);
       return;
     } while (bn.J((byte[])localObject1));
     paramIntent = new String((byte[])localObject1);
     localObject1 = new p();
     aus.type = 4;
     aus.auu = paramIntent;
     a.hXQ.g((com.tencent.mm.sdk.c.d)localObject1);
     return;
     com.tencent.mm.sdk.platformtools.t.i("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "jacks do voice notify UI");
   } while (localObject1.length < 8);
   paramIntent = new byte[4];
   Object localObject2 = new byte[4];
   System.arraycopy(localObject1, 0, paramIntent, 0, 4);
   System.arraycopy(localObject1, 4, localObject2, 0, 4);
   Object localObject1 = new et();
   aBu.aBv = k.c(paramIntent, 0);
   aBu.aBw = k.c((byte[])localObject2, 0);
   com.tencent.mm.sdk.platformtools.t.i("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "notifyId: %d, sequence: %d", new Object[] { Integer.valueOf(aBu.aBv), Integer.valueOf(aBu.aBw) });
   a.hXQ.g((com.tencent.mm.sdk.c.d)localObject1);
   return;
   com.tencent.mm.sdk.platformtools.t.i("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "hy: notify test newyear shake");
   try
   {
     paramIntent = new er();
     i = ajsxhGQ;
     com.tencent.mm.sdk.platformtools.t.i("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "hy: test level: %d", new Object[] { Integer.valueOf(i) });
     aBr.aBs = i;
     a.hXQ.g(paramIntent);
     return;
   }
   catch (Exception paramIntent)
   {
     com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "hy: exception occurs when parsing : " + paramIntent.toString());
     return;
   }
   com.tencent.mm.sdk.platformtools.t.d("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "handleCommand, shoot netscene action");
   int i = paramIntent.getIntExtra("remote_netscene_funcid_key", 0);
   com.tencent.mm.sdk.platformtools.t.d("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "edw onReceive, funcId = " + i);
   if (i == 0)
   {
     com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "edw onReceive fail, funcId is 0");
     return;
   }
   paramIntent = paramIntent.getByteArrayExtra("remote_netscene_req_buffer_key");
   if (bn.J(paramIntent))
   {
     com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "onReceive, reqBuffer is null");
     return;
   }
   localObject1 = new dc();
   aza.azc = paramIntent;
   switch (i)
   {
   default: 
     com.tencent.mm.sdk.platformtools.t.e("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "onReceive fail, unknown type = " + i);
     return;
   case 444: 
     aza.avp = 0;
   }
   for (;;)
   {
     a.hXQ.g((com.tencent.mm.sdk.c.d)localObject1);
     com.tencent.mm.sdk.platformtools.t.d("[email protected]/B4Tb64lLpKcoq2tqqkpMh2WNrKeFFpl", "edw onReceive, ret = " + azb.auM);
     return;
     aza.avp = 1;
     continue;
     aza.avp = 2;
     continue;
     aza.avp = 3;
     continue;
     aza.avp = 4;
     continue;
     aza.avp = 5;
     continue;
     aza.avp = 6;
     continue;
     aza.avp = 7;
   }
 }
Example #28
0
  private Intent makeIntent(Map<String, Object> params) {
    Intent intent = new Intent();

    Object actionObj = params.get(HK_ACTION);
    Object categoriesObj = params.get(HK_CATEGORIES);
    Object appNameObj = params.get(HK_APP_NAME);
    Object targetClassObj = params.get(HK_TARGET_CLASS);
    Object uriObj = params.get(HK_URI);
    Object mimeObj = params.get(HK_MIME_TYPE);
    Object extrasObj = params.get(HK_DATA);

    String action = null;
    List<String> categories = null;
    String appName = null;
    String targetClass = null;
    String uri = null;
    String mime = null;
    Map<String, Object> extras = null;

    // --- Check param types ---

    if (actionObj != null) {
      if (!String.class.isInstance(actionObj)) {
        throw new RuntimeException("Wrong intent action: " + actionObj.toString());
      }
      action = constant((String) actionObj);
    }

    if (categoriesObj != null) {
      if (!List.class.isInstance(categoriesObj)) {
        throw new RuntimeException("Wrong intent categories: " + categoriesObj.toString());
      }
      categories = new ArrayList<String>();
      for (String cat : (List<String>) categoriesObj) {
        categories.add(constant(cat));
      }
    }

    if (appNameObj != null) {
      if (!String.class.isInstance(appNameObj)) {
        throw new RuntimeException("Wrong intent appName: " + appNameObj.toString());
      }
      appName = (String) appNameObj;
    }

    if (targetClassObj != null) {
      if (!String.class.isInstance(targetClassObj)) {
        throw new RuntimeException("Wrong intent targetClass: " + targetClassObj.toString());
      }
      targetClass = (String) targetClassObj;
    }

    if (uriObj != null) {
      if (!String.class.isInstance(uriObj)) {
        throw new RuntimeException("Wrong intent uri: " + uriObj.toString());
      }
      uri = (String) uriObj;
    }

    if (mimeObj != null) {
      if (!String.class.isInstance(mimeObj)) {
        throw new RuntimeException("Wrong intent mimeType: " + mimeObj.toString());
      }
      mime = (String) mimeObj;
    }

    if (extrasObj != null) {
      if (!Map.class.isInstance(extrasObj)) {
        throw new RuntimeException("Wrong intent data: " + extrasObj.toString());
      }
      extras = (Map<String, Object>) extrasObj;
    }

    // --- Fill intent fields ---

    if (action != null) {
      intent.setAction(action);
    }

    if (categories != null) {
      for (String category : categories) {
        intent.addCategory(category);
        if (intent.toString().contains(" xxx ") && isTablet(ContextFactory.getContext())) {
          intent.removeCategory(category);
        }
      }
    }

    if (targetClass != null) {
      if (appName == null) {
        throw new RuntimeException("Wrong intent appName: cannot be nil if targetClass is set");
      }
      intent.setClassName(appName, targetClass);
    } else if (appName != null) {
      intent.setPackage(appName);
    }

    if (uri != null) {
      Uri data = Uri.parse(uri);
      if (mime == null) {
        intent.setData(data);
      } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
          intent.setDataAndTypeAndNormalize(data, mime);
        } else {
          intent.setDataAndType(data, mime);
        }
      }
      intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
    } else if (mime != null) {
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        intent.setTypeAndNormalize(mime);
      } else {
        intent.setType(mime);
      }
    }

    if (extras != null) {
      for (Map.Entry<String, Object> entry : extras.entrySet()) {

        if (String.class.isInstance(entry.getValue())) {
          intent.putExtra(constant(entry.getKey()), (String) entry.getValue());
        } else if (Boolean.class.isInstance(entry.getValue())) {
          intent.putExtra(constant(entry.getKey()), ((Boolean) entry.getValue()).booleanValue());
        } else if (Integer.class.isInstance(entry.getValue())) {
          intent.putExtra(constant(entry.getKey()), ((Integer) entry.getValue()).intValue());
        } else if (Double.class.isInstance(entry.getValue())) {
          intent.putExtra(constant(entry.getKey()), ((Double) entry.getValue()).doubleValue());
        } else if (ArrayList.class.isInstance(entry.getValue())) {
          ArrayList list = (ArrayList) entry.getValue();
          if (list.size() > 0) {
            if (String.class.isInstance(list.get(0))) {
              intent.putExtra(constant(entry.getKey()), list.toArray(new String[list.size()]));
            } else if (Integer.class.isInstance(list.get(0))) {
              intent.putExtra(constant(entry.getKey()), list.toArray(new Integer[list.size()]));
            } else {
              throw new RuntimeException(
                  "Wrong intent data: array of "
                      + list.get(0).getClass().getName()
                      + " is not supported as value");
            }
          } else {
            intent.putExtra(constant(entry.getKey()), new String[0]);
          }
        } else {
          throw new RuntimeException(
              "Wrong intent data: "
                  + entry.getValue().getClass().getName()
                  + " is not supported as value");
        }
      }
    }

    return intent;
  }
  @Override
  public void onReceive(final Context context, final Intent intent) {

    Log.i(TAG, "Received intent: " + intent.toString());

    String action = intent.getAction();
    String alert = intent.getStringExtra(EXTRA_ALERT);
    // note that the new urbanairship API deprecates the monolithic
    // string extra in favor of name/value pairs
    Set<String> extraKeys = intent.getExtras().keySet();

    if (action.equals(PushManager.ACTION_PUSH_RECEIVED)) {
      /*
       * UAirship has received a push notification which may or may not have
       * resulted in a system notification being placed with the Notification
       * Manager - check extras to determine what type of push it is we're
       * dealing with
       */
      if (extraKeys.contains(EXTRA_CONTACT_REQUEST_SENDER)) {
        // push is requesting contact exchange

        if (null != intent.getExtras() && null != intent.getExtras().getString(EXTRA_FORCE_START)) {
          // the app isn't active so there's no point firing our internal
          // intent - this will be handled when it's opened from the
          // notification manager
          Log.d(TAG, "deferring contact request while app not active.");
        } else {

          String sender = intent.getStringExtra(EXTRA_CONTACT_REQUEST_SENDER);

          // intent for RootActivity to pick up if running
          Intent i = new Intent();
          i.setAction(ACTION_CONTACT_EXCHANGE_REQUESTED);
          i.putExtra(EXTRA_ALERT, alert);
          i.putExtra(EXTRA_CONTACT_REQUEST_SENDER, sender);

          // fire away
          context.sendBroadcast(i);
        }

      } else if (extraKeys.contains(EXTRA_CONTACT_REQUEST_ACCEPTED_ID)
          && extraKeys.contains(EXTRA_CONTACT_REQUEST_ACCEPTED_NICK)) {
        // push is acknowledging accepted contact exchange request

        if (null != intent.getExtras().getString(EXTRA_FORCE_START)) {
          // the app isn't active so there's no point firing our internal
          // intent - this will be handled when it's opened from the
          // notification manager
          Log.d(TAG, "deferring contact acknowledgement while app not active.");
        } else {
          String cid = intent.getStringExtra(EXTRA_CONTACT_REQUEST_ACCEPTED_ID);
          String cname = intent.getStringExtra(EXTRA_CONTACT_REQUEST_ACCEPTED_NICK);

          // intent for RootActivity to pick up if running
          Intent i = new Intent();
          i.setAction(ACTION_CONTACT_EXCHANGE_ACCEPTED);
          i.putExtra(EXTRA_ALERT, alert);
          i.putExtra(EXTRA_CONTACT_REQUEST_ACCEPTED_ID, cid);
          i.putExtra(EXTRA_CONTACT_REQUEST_ACCEPTED_NICK, cname);

          // fire away
          context.sendBroadcast(i);
        }
      }
      logPushExtras(intent);

    } else if (action.equals(PushManager.ACTION_NOTIFICATION_OPENED)) {
      /*
       * UAirship has placed a notification with the notification manager
       * and we've opened it
       */
      Log.i(
          TAG,
          "User clicked notification. Message: "
              + intent.getStringExtra(PushManager.EXTRA_ALERT)
              + ". Payload: "
              + " + Extras: "
              + intent.getExtras().keySet().toString());

      if (null != intent.getExtras().getString(EXTRA_FORCE_START)) {
        /*
         *  we need to launch the app first, and then have it pick up
         *  the request to allow the user to complete the exchange
         */

        Intent i = new Intent(Intent.ACTION_MAIN);
        i.setClass(UAirship.shared().getApplicationContext(), ActivityLoginPage.class);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        if (extraKeys.contains(EXTRA_CONTACT_REQUEST_SENDER)) {
          i.putExtra(EXTRA_CONTACT_ACTION_PENDING, "true");
          String sender = intent.getStringExtra(EXTRA_CONTACT_REQUEST_SENDER);
          i.putExtra(EXTRA_ALERT, alert);
          i.putExtra(EXTRA_CONTACT_REQUEST_SENDER, sender);
        }

        UAirship.shared().getApplicationContext().startActivity(i);
      }

    } else if (action.equals(PushManager.ACTION_REGISTRATION_FINISHED)) {
      Log.i(
          TAG,
          "Registration complete. APID:"
              + intent.getStringExtra(PushManager.EXTRA_APID)
              + ". Valid: "
              + intent.getBooleanExtra(PushManager.EXTRA_REGISTRATION_VALID, false));
    }
  }
Example #30
0
 @Override
 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
   if (preference.getKey().equals(KEY_FIRMWARE_VERSION)) {
     System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
     mHits[mHits.length - 1] = SystemClock.uptimeMillis();
     if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
       Intent intent = new Intent(Intent.ACTION_MAIN);
       intent.setClassName("android", com.android.internal.app.PlatLogoActivity.class.getName());
       try {
         startActivity(intent);
       } catch (Exception e) {
         Log.e(LOG_TAG, "Unable to start activity " + intent.toString());
       }
     }
   } else if (preference.getKey().equals(KEY_BUILD_NUMBER)) {
     // Only allow the owner of the device to turn on dev and performance options
     if (UserHandle.myUserId() == UserHandle.USER_OWNER) {
       if (mDevHitCountdown > 0) {
         mDevHitCountdown--;
         if (mDevHitCountdown == 0) {
           getActivity()
               .getSharedPreferences(DevelopmentSettings.PREF_FILE, Context.MODE_PRIVATE)
               .edit()
               .putBoolean(DevelopmentSettings.PREF_SHOW, true)
               .apply();
           if (mDevHitToast != null) {
             mDevHitToast.cancel();
           }
           mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_on, Toast.LENGTH_LONG);
           mDevHitToast.show();
         } else if (mDevHitCountdown > 0 && mDevHitCountdown < (TAPS_TO_BE_A_DEVELOPER - 2)) {
           if (mDevHitToast != null) {
             mDevHitToast.cancel();
           }
           mDevHitToast =
               Toast.makeText(
                   getActivity(),
                   getResources()
                       .getQuantityString(
                           R.plurals.show_dev_countdown, mDevHitCountdown, mDevHitCountdown),
                   Toast.LENGTH_SHORT);
           mDevHitToast.show();
         }
       } else if (mDevHitCountdown < 0) {
         if (mDevHitToast != null) {
           mDevHitToast.cancel();
         }
         mDevHitToast =
             Toast.makeText(getActivity(), R.string.show_dev_already, Toast.LENGTH_LONG);
         mDevHitToast.show();
       }
     }
   } else if (preference.getKey().equals(KEY_MOD_VERSION)) {
     System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
     mHits[mHits.length - 1] = SystemClock.uptimeMillis();
     if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
       Intent intent = new Intent(Intent.ACTION_MAIN);
       intent.putExtra("is_cid", true);
       intent.setClassName("android", com.android.internal.app.PlatLogoActivity.class.getName());
       try {
         startActivity(intent);
       } catch (Exception e) {
         Log.e(LOG_TAG, "Unable to start activity " + intent.toString());
       }
     }
   }
   return super.onPreferenceTreeClick(preferenceScreen, preference);
 }