Java Code Examples for android.os.Bundle#getByteArray()

The following examples show how to use android.os.Bundle#getByteArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AwContents.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Restore the state of this AwContents into provided Bundle.
 * @param inState Must be a bundle returned by saveState.
 * @return False if restoring state failed.
 */
public boolean restoreState(Bundle inState) {
    if (mNativeAwContents == 0 || inState == null) return false;

    byte[] state = inState.getByteArray(SAVE_RESTORE_STATE_KEY);
    if (state == null) return false;

    boolean result = nativeRestoreFromOpaqueState(mNativeAwContents, state);

    // The onUpdateTitle callback normally happens when a page is loaded,
    // but is optimized out in the restoreState case because the title is
    // already restored. See WebContentsImpl::UpdateTitleForEntry. So we
    // call the callback explicitly here.
    if (result) mContentsClient.onReceivedTitle(mContentViewCore.getTitle());

    return result;
}
 
Example 2
Source File: AwContents.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Restore the state of this AwContents into provided Bundle.
 * @param inState Must be a bundle returned by saveState.
 * @return False if restoring state failed.
 */
public boolean restoreState(Bundle inState) {
    if (mNativeAwContents == 0 || inState == null) return false;

    byte[] state = inState.getByteArray(SAVE_RESTORE_STATE_KEY);
    if (state == null) return false;

    boolean result = nativeRestoreFromOpaqueState(mNativeAwContents, state);

    // The onUpdateTitle callback normally happens when a page is loaded,
    // but is optimized out in the restoreState case because the title is
    // already restored. See WebContentsImpl::UpdateTitleForEntry. So we
    // call the callback explicitly here.
    if (result) mContentsClient.onReceivedTitle(mContentViewCore.getTitle());

    return result;
}
 
Example 3
Source File: NfcFImpl.java    From external-nfc-api with Apache License 2.0 5 votes vote down vote up
public NfcFImpl(TagImpl tag) throws RemoteException {
    this.delegate = new BasicTagTechnologyImpl(tag, TagTechnology.NFC_F);

    Bundle extras = tag.getTechExtras(TagTechnology.NFC_F);
    if (extras != null) {
        mSystemCode = extras.getByteArray(EXTRA_SC);
        mManufacturer = extras.getByteArray(EXTRA_PMM);
    }
}
 
Example 4
Source File: MmsListener.java    From OpenFit with MIT License 5 votes vote down vote up
@Override
public void onReceive(Context cntxt, Intent intent) {
    Log.d(LOG_TAG, "MMS: Intent received");
    if(intent.getAction().equals("android.provider.Telephony.WAP_PUSH_RECEIVED")) {
        Bundle bundle = intent.getExtras();
        try {
            if(bundle != null) {
                String type = intent.getType();
                if(type.trim().equalsIgnoreCase("application/vnd.wap.mms-message")) {
                    byte[] buffer = bundle.getByteArray("data");
                    String phoneNumber = new String(buffer);
                    int index = phoneNumber.indexOf("/TYPE");
                    if(index > 0 && (index - 15) > 0) {
                        int newIndx = index - 15;
                        phoneNumber = phoneNumber.substring(newIndx, index);
                        index = phoneNumber.indexOf("+");
                        if(index > 0) {
                            phoneNumber = phoneNumber.substring(index);
                            String senderNum = phoneNumber;
                            Log.d(LOG_TAG, "MMS: "+senderNum);
                            Intent msg = new Intent(OpenFitIntent.INTENT_SERVICE_MMS);
                            msg.putExtra("sender", senderNum);
                            context.sendBroadcast(msg);
                        }
                    }
                }
            }
        }
        catch(Exception e) {
            Log.e(LOG_TAG, "Error: intent.getType()", e);
        }
    }
}
 
Example 5
Source File: AutoValue_TestClassBundled.java    From auto-value-bundle with MIT License 5 votes vote down vote up
public static TestClassBundled unbundle(Bundle bundle, Gson gson) {
    return new AutoValue_TestClassBundled(
            bundle,
            bundle.getByte("some_byte"),
            bundle.getBoolean("some_boolean"),
            bundle.getShort("some_short"),
            bundle.getInt("some_int"),
            bundle.getLong("some_long"),
            bundle.getChar("some_char"),
            bundle.getFloat("some_float"),
            bundle.getDouble("some_double"),
            bundle.getString("some_string"),
            bundle.getCharSequence("some_char_sequence"),
            bundle.getParcelable("some_parcelable"),
            bundle.getParcelableArrayList("some_parcelable_array_list"),
            bundle.getSparseParcelableArray("some_parcelable_sparse_array"),
            bundle.getSerializable("some_serializable"),
            bundle.getIntegerArrayList("some_integer_array_list"),
            bundle.getStringArrayList("some_string_array_list"),
            bundle.getCharSequenceArrayList("some_char_sequence_array_list"),
            bundle.getByteArray("some_byte_array"),
            bundle.getShortArray("some_short_array"),
            bundle.getCharArray("some_char_array"),
            bundle.getFloatArray("some_float_array"),
            gson.fromJson(bundle.getString("some_unknown_object"), new com.google.common.reflect.TypeToken<UnknownObject>(){}.getType()),
            gson.fromJson(bundle.getString("some_unknown_object_list"), new com.google.common.reflect.TypeToken<ArrayList<UnknownObject>>(){}.getType()),
            gson.fromJson(bundle.getString("test_enum"), new com.google.common.reflect.TypeToken<TestEnum>(){}.getType()));
}
 
Example 6
Source File: BarCodeScannerHandler.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
@Override
public void handleMessage(Message message) {
    switch (message.what) {
        case RESTART_PREVIEW:
            restartPreviewAndDecode();       
            break;
        case DECODE_SUCCEDED:
            Log.v(TAG, "Decode SUCCEEDED");
            state = State.SUCCESS;
            Bundle bundle = message.getData();
            Bitmap barcode = null;
            float scaleFactor = 1.0f;
            if (bundle != null) {
                byte[] compressedBitmap = bundle.getByteArray(DecodeThread.BARCODE_BITMAP);
                if (compressedBitmap != null) {
                    barcode = BitmapFactory.decodeByteArray(compressedBitmap, 0, compressedBitmap.length, null);
                    // Mutable copy:
                    barcode = barcode.copy(Bitmap.Config.ARGB_8888, true);
                }
                scaleFactor = bundle.getFloat(DecodeThread.BARCODE_SCALED_FACTOR);
            }
            fragment.handleDecode((Result) message.obj, barcode, scaleFactor);
            break;
        case DECODE_FAILED:
            state = State.PREVIEW;
            cameraManager.requestPreviewFrame(decodeThread.getHandler(), DECODE);
            break;
        default:
            Log.v(TAG, "Unknown message: "+message.what);
    }
}
 
Example 7
Source File: CaptureActivityHandler.java    From CodeScaner with MIT License 5 votes vote down vote up
@Override
public void handleMessage(Message message) {
  if (message.what == R.id.restart_preview) {
    restartPreviewAndDecode();

  } else if (message.what == R.id.decode_succeeded) {
    state = State.SUCCESS;
    Bundle bundle = message.getData();
    Bitmap barcode = null;
    float scaleFactor = 1.0f;
    if (bundle != null) {
      byte[] compressedBitmap = bundle.getByteArray(DecodeThread.BARCODE_BITMAP);
      if (compressedBitmap != null) {
        barcode = BitmapFactory.decodeByteArray(compressedBitmap, 0, compressedBitmap.length, null);
        // Mutable copy:
        barcode = barcode.copy(Bitmap.Config.ARGB_8888, true);
      }
      scaleFactor = bundle.getFloat(DecodeThread.BARCODE_SCALED_FACTOR);
    }
    activity.handleDecode((Result) message.obj, barcode, scaleFactor);

  } else if (message.what == R.id.decode_failed) {// We're decoding as fast as possible, so when one decode fails, start another.
    state = State.PREVIEW;
    cameraManager.requestPreviewFrame(decodeThread.getHandler(), R.id.decode);

  } else if (message.what == R.id.return_scan_result) {
    activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
    activity.finish();

  }
}
 
Example 8
Source File: ResultActivity.java    From ZXingProject with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_result);

	Bundle extras = getIntent().getExtras();

	mResultImage = (ImageView) findViewById(R.id.result_image);
	mResultText = (TextView) findViewById(R.id.result_text);

	if (null != extras) {
		int width = extras.getInt("width");
		int height = extras.getInt("height");

		LayoutParams lps = new LayoutParams(width, height);
		lps.topMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30, getResources().getDisplayMetrics());
		lps.leftMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics());
		lps.rightMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics());
		
		mResultImage.setLayoutParams(lps);

		String result = extras.getString("result");
		mResultText.setText(result);

		Bitmap barcode = null;
		byte[] compressedBitmap = extras.getByteArray(DecodeThread.BARCODE_BITMAP);
		if (compressedBitmap != null) {
			barcode = BitmapFactory.decodeByteArray(compressedBitmap, 0, compressedBitmap.length, null);
			// Mutable copy:
			barcode = barcode.copy(Bitmap.Config.RGB_565, true);
		}

		mResultImage.setImageBitmap(barcode);
	}
}
 
Example 9
Source File: EditTriggerActivity.java    From science-journal with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_edit_trigger);
  boolean isTablet = getResources().getBoolean(R.bool.is_tablet);
  if (!isTablet) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  }

  Bundle extras = getIntent().getExtras();

  if (getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG) == null && extras != null) {
    String sensorId = extras.getString(EXTRA_SENSOR_ID, "");
    // TODO(lizlooney): figure out if extras is ever null or if EXTRA_ACCOUNT_KEY is ever not set?
    AppAccount appAccount = WhistlePunkApplication.getAccount(this, extras, EXTRA_ACCOUNT_KEY);
    String experimentId = extras.getString(EXTRA_EXPERIMENT_ID, "");
    String triggerId = extras.getString(EXTRA_TRIGGER_ID, "");
    byte[] sensorLayoutBlob = extras.getByteArray(EXTRA_SENSOR_LAYOUT_BLOB);
    int position = extras.getInt(TriggerListActivity.EXTRA_LAYOUT_POSITION);
    ArrayList<String> triggerOrder =
        extras.getStringArrayList(TriggerListActivity.EXTRA_TRIGGER_ORDER);
    EditTriggerFragment fragment =
        EditTriggerFragment.newInstance(
            appAccount,
            sensorId,
            experimentId,
            triggerId,
            sensorLayoutBlob,
            position,
            triggerOrder);
    getSupportFragmentManager()
        .beginTransaction()
        .add(R.id.container, fragment, FRAGMENT_TAG)
        .commit();
  }
}
 
Example 10
Source File: BluetoothLeDevice.java    From AndroidBleManager with Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates a new bluetooth le device.
 *
 * @param in the in
 */
@SuppressWarnings("unchecked")
protected BluetoothLeDevice(final Parcel in) {
    final Bundle b = in.readBundle(getClass().getClassLoader());

    mCurrentRssi = b.getInt(PARCEL_EXTRA_CURRENT_RSSI, 0);
    mCurrentTimestamp = b.getLong(PARCEL_EXTRA_CURRENT_TIMESTAMP, 0);
    mDevice = b.getParcelable(PARCEL_EXTRA_BLUETOOTH_DEVICE);
    mFirstRssi = b.getInt(PARCEL_EXTRA_FIRST_RSSI, 0);
    mFirstTimestamp = b.getLong(PARCEL_EXTRA_FIRST_TIMESTAMP, 0);
    mRecordStore = b.getParcelable(PARCEL_EXTRA_DEVICE_SCANRECORD_STORE);
    mRssiLog = (Map<Long, Integer>) b.getSerializable(PARCEL_EXTRA_DEVICE_RSSI_LOG);
    mScanRecord = b.getByteArray(PARCEL_EXTRA_DEVICE_SCANRECORD);
}
 
Example 11
Source File: SdlRouterService.java    From sdl_java_suite with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@SuppressWarnings("SameReturnValue")
public boolean handleIncommingClientMessage(final Bundle receivedBundle){
	int flags = receivedBundle.getInt(TransportConstants.BYTES_TO_SEND_FLAGS, TransportConstants.BYTES_TO_SEND_FLAG_NONE);
	TransportType transportType = TransportType.valueForString(receivedBundle.getString(TransportConstants.TRANSPORT_TYPE));
	if(transportType == null){
		synchronized (TRANSPORT_LOCK){
			transportType = getCompatPrimaryTransport();
		}
		receivedBundle.putString(TransportConstants.TRANSPORT_TYPE, transportType.name());
	}

	if(flags!=TransportConstants.BYTES_TO_SEND_FLAG_NONE){
		byte[] packet = receivedBundle.getByteArray(TransportConstants.BYTES_TO_SEND_EXTRA_NAME); 
		if(flags == TransportConstants.BYTES_TO_SEND_FLAG_LARGE_PACKET_START){
			this.priorityForBuffingMessage = receivedBundle.getInt(TransportConstants.PACKET_PRIORITY_COEFFICIENT,0);
		}
		handleMessage(flags, packet, transportType);
	}else{
		//Add the write task on the stack
		PacketWriteTaskBlockingQueue queue = queues.get(transportType);
		if(queue == null){	//TODO check to see if there is any better place to put this
			queue = new PacketWriteTaskBlockingQueue();
			queues.put(transportType,queue);
		}
		queue.add(new PacketWriteTask(receivedBundle));
		if(packetWriteTaskMasterMap != null) {
			PacketWriteTaskMaster packetWriteTaskMaster = packetWriteTaskMasterMap.get(transportType);
			if (packetWriteTaskMaster != null) {
				packetWriteTaskMaster.alert();
			}
		} //If this is null, it is likely the service is closing
	}
	return true;
}
 
Example 12
Source File: IsoDep.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** @hide */
public IsoDep(Tag tag)
        throws RemoteException {
    super(tag, TagTechnology.ISO_DEP);
    Bundle extras = tag.getTechExtras(TagTechnology.ISO_DEP);
    if (extras != null) {
        mHiLayerResponse = extras.getByteArray(EXTRA_HI_LAYER_RESP);
        mHistBytes = extras.getByteArray(EXTRA_HIST_BYTES);
    }
}
 
Example 13
Source File: NfcB.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** @hide */
public NfcB(Tag tag) throws RemoteException {
    super(tag, TagTechnology.NFC_B);
    Bundle extras = tag.getTechExtras(TagTechnology.NFC_B);
    mAppData = extras.getByteArray(EXTRA_APPDATA);
    mProtInfo = extras.getByteArray(EXTRA_PROTINFO);
}
 
Example 14
Source File: ServiceFactory.java    From nfcspy with GNU General Public License v3.0 4 votes vote down vote up
static byte[] extractDataFromMessage(Message msg) {
	Bundle data = msg.getData();
	return (data != null) ? data.getByteArray(KEY_BLOB) : null;
}
 
Example 15
Source File: CaptureActivityHandler.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 4 votes vote down vote up
@Override
public void handleMessage(Message message) {
  if (message.what == R.id.restart_preview) {
    restartPreviewAndDecode();

  } else if (message.what == R.id.decode_succeeded) {
    state = State.SUCCESS;
    Bundle bundle = message.getData();
    Bitmap barcode = null;
    float scaleFactor = 1.0f;
    if (bundle != null) {
      byte[] compressedBitmap = bundle.getByteArray(DecodeThread.BARCODE_BITMAP);
      if (compressedBitmap != null) {
        barcode = BitmapFactory.decodeByteArray(compressedBitmap, 0, compressedBitmap.length, null);
        // Mutable copy:
        barcode = barcode.copy(Bitmap.Config.ARGB_8888, true);
      }
      scaleFactor = bundle.getFloat(DecodeThread.BARCODE_SCALED_FACTOR);
    }
    activity.handleDecode((Result) message.obj, barcode, scaleFactor);

  } else if (message.what == R.id.decode_failed) {// We're decoding as fast as possible, so when one decode fails, start another.
    state = State.PREVIEW;
    cameraManager.requestPreviewFrame(decodeThread.getHandler(), R.id.decode);

  } else if (message.what == R.id.return_scan_result) {
    activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
    activity.finish();

  } else if (message.what == R.id.launch_product_query) {
    String url = (String) message.obj;

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    intent.setData(Uri.parse(url));

    ResolveInfo resolveInfo =
            activity.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
    String browserPackageName = null;
    if (resolveInfo != null && resolveInfo.activityInfo != null) {
      browserPackageName = resolveInfo.activityInfo.packageName;
      Log.d(TAG, "Using browser in package " + browserPackageName);
    }

    // Needed for default Android browser / Chrome only apparently
    if ("com.android.browser".equals(browserPackageName) || "com.android.chrome".equals(browserPackageName)) {
      intent.setPackage(browserPackageName);
      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      intent.putExtra(Browser.EXTRA_APPLICATION_ID, browserPackageName);
    }

    try {
      activity.startActivity(intent);
    } catch (ActivityNotFoundException ignored) {
      Log.w(TAG, "Can't find anything to handle VIEW of URI " + url);
    }

  }
}
 
Example 16
Source File: CaptureActivityHandler.java    From AndroidHttpCapture with MIT License 4 votes vote down vote up
@Override
public void handleMessage(Message message) {
    if (message.what == R.id.restart_preview) {
        restartPreviewAndDecode();
    } else if (message.what == R.id.decode_succeeded) {
        state = State.SUCCESS;
        Bundle bundle = message.getData();
        Bitmap barcode = null;
        float scaleFactor = 1.0f;
        if (bundle != null) {
            byte[] compressedBitmap = bundle.getByteArray(DecodeThread.BARCODE_BITMAP);
            if (compressedBitmap != null) {
                barcode = BitmapFactory.decodeByteArray(compressedBitmap, 0, compressedBitmap.length, null);
                // Mutable copy:
                barcode = barcode.copy(Bitmap.Config.ARGB_8888, true);
            }
            scaleFactor = bundle.getFloat(DecodeThread.BARCODE_SCALED_FACTOR);
        }
        activity.handleDecode((Result) message.obj, barcode, scaleFactor);
    } else if (message.what == R.id.decode_failed) {
        // We're decoding as fast as possible, so when one decode fails, start another.
        state = State.PREVIEW;
        cameraManager.requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
    } else if (message.what == R.id.return_scan_result) {
        activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
        activity.finish();
    } else if (message.what == R.id.launch_product_query) {
        String url = (String) message.obj;

        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        intent.setData(Uri.parse(url));

        ResolveInfo resolveInfo =
                activity.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
        String browserPackageName = null;
        if (resolveInfo != null && resolveInfo.activityInfo != null) {
            browserPackageName = resolveInfo.activityInfo.packageName;
            Log.d(TAG, "Using browser in package " + browserPackageName);
        }

        // Needed for default Android browser / Chrome only apparently
        if ("com.android.browser".equals(browserPackageName) || "com.android.chrome".equals(browserPackageName)) {
            intent.setPackage(browserPackageName);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtra(Browser.EXTRA_APPLICATION_ID, browserPackageName);
        }

        try {
            activity.startActivity(intent);
        } catch (ActivityNotFoundException ignored) {
            Log.w(TAG, "Can't find anything to handle VIEW of URI " + url);
        }
    }
}
 
Example 17
Source File: EspressoRemote.java    From android-test with Apache License 2.0 4 votes vote down vote up
private InteractionResponse executeRequest(Bundle data) {
  byte[] protoByteArray = data.getByteArray(BUNDLE_KEY_PROTO);
  Status status = Status.Error;
  RemoteError remoteError = null;

  try {
    // Parse Interaction Request
    InteractionRequest interactionRequest =
        new InteractionRequest.Builder().setRequestProto(protoByteArray).build();

    // Check if this interaction was already executed elsewhere
    ParcelableIBinder executionStatusIBinder =
        data.getParcelable(RemoteInteraction.BUNDLE_EXECUTION_STATUS);
    boolean canExecute = false;
    if (executionStatusIBinder != null) {
      IInteractionExecutionStatus executionStatus =
          IInteractionExecutionStatus.Stub.asInterface(executionStatusIBinder.getIBinder());
      try {
        canExecute = executionStatus.canExecute();
      } catch (RemoteException e) {
        throw new RuntimeException(
            "Unable to query interaction execution status", e.getCause());
      }
    }

    if (canExecute) {
      // Execute Espresso code to un-serialize and run view matchers, actions and assertions.
      status = RemoteInteractionStrategy.from(interactionRequest, data).execute();
    }

  } catch (RemoteProtocolException rpe) {
    remoteError =
        new RemoteError(REMOTE_PROTOCOL_ERROR_CODE, Throwables.getStackTraceAsString(rpe));
  } catch (RuntimeException re) {
    remoteError =
        new RemoteError(REMOTE_ESPRESSO_ERROR_CODE, Throwables.getStackTraceAsString(re));
  } catch (Error error) {
    remoteError =
        new RemoteError(REMOTE_ESPRESSO_ERROR_CODE, Throwables.getStackTraceAsString(error));
  }

  return new InteractionResponse.Builder()
      .setStatus(status)
      .setRemoteError(remoteError)
      .build();
}
 
Example 18
Source File: Util.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public static Statistic upload(Context context, String s, Bundle bundle)
{
    if (context != null)
    {
        ConnectivityManager connectivitymanager = (ConnectivityManager)context.getSystemService("connectivity");
        if (connectivitymanager != null)
        {
            NetworkInfo networkinfo = connectivitymanager.getActiveNetworkInfo();
            if (networkinfo == null || !networkinfo.isAvailable())
            {
                throw new HttpUtils.NetworkUnavailableException("network unavailable");
            }
        }
    }
    Bundle bundle1 = new Bundle(bundle);
    String s1 = bundle1.getString("appid_for_getting_config");
    bundle1.remove("appid_for_getting_config");
    HttpClient httpclient = HttpUtils.getHttpClient(context, s1, s);
    HttpPost httppost = new HttpPost(s);
    Bundle bundle2 = new Bundle();
    Iterator iterator = bundle1.keySet().iterator();
    do
    {
        if (!iterator.hasNext())
        {
            break;
        }
        String s3 = (String)iterator.next();
        Object obj = bundle1.get(s3);
        if (obj instanceof byte[])
        {
            bundle2.putByteArray(s3, (byte[])(byte[])obj);
        }
    } while (true);
    httppost.setHeader("Content-Type", "multipart/form-data; boundary=3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f");
    httppost.setHeader("Connection", "Keep-Alive");
    ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
    bytearrayoutputstream.write("--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n".getBytes());
    bytearrayoutputstream.write(encodePostBody(bundle1, "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f").getBytes());
    if (!bundle2.isEmpty())
    {
        int k = bundle2.size();
        bytearrayoutputstream.write("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n".getBytes());
        Iterator iterator1 = bundle2.keySet().iterator();
        int l = -1;
        do
        {
            if (!iterator1.hasNext())
            {
                break;
            }
            String s2 = (String)iterator1.next();
            l++;
            bytearrayoutputstream.write((new StringBuilder()).append("Content-Disposition: form-data; name=\"").append(s2).append("\"; filename=\"").append("value.file").append("\"").append("\r\n").toString().getBytes());
            bytearrayoutputstream.write("Content-Type: application/octet-stream\r\n\r\n".getBytes());
            byte abyte1[] = bundle2.getByteArray(s2);
            if (abyte1 != null)
            {
                bytearrayoutputstream.write(abyte1);
            }
            if (l < k - 1)
            {
                bytearrayoutputstream.write("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n".getBytes());
            }
        } while (true);
    }
    bytearrayoutputstream.write("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f--\r\n".getBytes());
    byte abyte0[] = bytearrayoutputstream.toByteArray();
    int i = 0 + abyte0.length;
    bytearrayoutputstream.close();
    httppost.setEntity(new ByteArrayEntity(abyte0));
    HttpResponse httpresponse = httpclient.execute(httppost);
    int j = httpresponse.getStatusLine().getStatusCode();
    if (j == 200)
    {
        return new Statistic(a(httpresponse), i);
    } else
    {
        throw new HttpUtils.HttpStatusException((new StringBuilder()).append("http status code error:").append(j).toString());
    }
}
 
Example 19
Source File: WXEmojiObject.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public void unserialize(Bundle bundle)
{
    emojiData = bundle.getByteArray("_wxemojiobject_emojiData");
    emojiPath = bundle.getString("_wxemojiobject_emojiPath");
}
 
Example 20
Source File: WXImageObject.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public void unserialize(Bundle bundle)
{
    imageData = bundle.getByteArray("_wximageobject_imageData");
    imagePath = bundle.getString("_wximageobject_imagePath");
    imageUrl = bundle.getString("_wximageobject_imageUrl");
}