Esempio n. 1
0
 /**
  * 反射属性
  *
  * @param obj obj
  * @param fieldName field
  * @return the value of the fieldName
  */
 public static Object getObj(Object obj, String fieldName) {
   Object result = null;
   try {
     Field field = obj.getClass().getDeclaredField(fieldName);
     field.setAccessible(true);
     result = field.get(obj);
   } catch (NoSuchFieldException e) {
     Log.e(e.getMessage());
   } catch (IllegalAccessException e) {
     Log.e(e.getMessage());
   }
   return result;
 }
Esempio n. 2
0
 public void makePointCloud(float innerRadius, float outerRadius) {
   if (innerRadius == 0) {
     Log.w(TAG, "Must specify an inner radius");
     return;
   }
   mOuterRadius = outerRadius;
   mPointCloud.clear();
   final float pointAreaRadius = (outerRadius - innerRadius);
   final float ds = (2.0f * PI * innerRadius / INNER_POINTS);
   final int bands = (int) Math.round(pointAreaRadius / ds);
   final float dr = pointAreaRadius / bands;
   float r = innerRadius;
   for (int b = 0; b <= bands; b++, r += dr) {
     float circumference = 2.0f * PI * r;
     final int pointsInBand = (int) (circumference / ds);
     float eta = PI / 2.0f;
     float dEta = 2.0f * PI / pointsInBand;
     for (int i = 0; i < pointsInBand; i++) {
       float x = r * FloatMath.cos(eta);
       float y = r * FloatMath.sin(eta);
       eta += dEta;
       mPointCloud.add(new Point(x, y, r));
     }
   }
 }
Esempio n. 3
0
 @Override
 public void onBeforeStartPjsip() {
   if (enableModule) {
     int status = pjsua.sipclf_mod_init();
     Log.d(THIS_FILE, "SipClfModule module added with status " + status);
   }
 }
Esempio n. 4
0
  /**
   * Retrieve all dynamic codec plugins available in the platform It will resolve for a given action
   * available sip plugins
   *
   * @param ctxt Context of the application
   * @param action Action of the plugin to be resolved
   * @return a map containing plugins infos and registrered component name as key
   */
  public static Map<String, DynCodecInfos> getDynCodecPlugins(Context ctxt, String action) {
    if (!CACHED_RESOLUTION.containsKey(action)) {
      HashMap<String, DynCodecInfos> plugins = new HashMap<String, DynCodecInfos>();

      PackageManager packageManager = ctxt.getPackageManager();
      Intent it = new Intent(action);

      List<ResolveInfo> availables = packageManager.queryBroadcastReceivers(it, 0);
      for (ResolveInfo resInfo : availables) {
        ActivityInfo actInfos = resInfo.activityInfo;
        if (packageManager.checkPermission(
                SipManager.PERMISSION_CONFIGURE_SIP, actInfos.packageName)
            == PackageManager.PERMISSION_GRANTED) {
          ComponentName cmp = new ComponentName(actInfos.packageName, actInfos.name);
          DynCodecInfos dynInfos;
          try {
            dynInfos = new DynCodecInfos(ctxt, cmp);
            plugins.put(cmp.flattenToString(), dynInfos);
          } catch (NameNotFoundException e) {
            Log.e(THIS_FILE, "Error while retrieving infos from dyn codec ", e);
          }
        }
      }
      CACHED_RESOLUTION.put(action, plugins);
    }

    return CACHED_RESOLUTION.get(action);
  }
Esempio n. 5
0
 /**
  * 设置私有字段的值
  *
  * @param obj boject
  * @param key fieldName
  * @param value the value to be set
  */
 public static void setFieldValue(Object obj, String key, Object value) {
   Field field = null;
   try {
     field = obj.getClass().getDeclaredField(key);
     field.setAccessible(true);
     field.set(obj, value);
   } catch (NoSuchFieldException e) {
     Log.e(e.getMessage());
   } catch (IllegalArgumentException e) {
     //            e.printStackTrace();
     if (field != null)
       Log.e(
           "IllegalArgumentException--"
               + "field:"
               + field.getName()
               + "-value:"
               + field.getType());
   } catch (IllegalAccessException e) {
     Log.e(e.getMessage());
   }
 }
  @Override
  public void onDetach() {
    super.onDetach();

    try {
      Field childFragmentManager = Fragment.class.getDeclaredField("mChildFragmentManager");
      childFragmentManager.setAccessible(true);
      childFragmentManager.set(this, null);
    } catch (Exception e) {
      Log.e(TAG, "onDetach(), " + e.toString());
    }
  }