See 21 | * 22 | * DoCoMo's documentation about the result types represented by subclasses of this class.
23 | * 24 | *Thanks to Jeff Griffin for proposing rewrite of these classes that relies less 25 | * on exception-based mechanisms during parsing.
26 | * 27 | * @author Sean Owen 28 | */ 29 | abstract class AbstractDoCoMoResultParser extends ResultParser { 30 | 31 | static String[] matchDoCoMoPrefixedField(String prefix, String rawText, boolean trim) { 32 | return matchPrefixedField(prefix, rawText, ';', trim); 33 | } 34 | 35 | static String matchSingleDoCoMoPrefixedField(String prefix, String rawText, boolean trim) { 36 | return matchSinglePrefixedField(prefix, rawText, ';', trim); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/client/result/BookmarkDoCoMoResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | import com.google.zxing.Result; 20 | 21 | /** 22 | * @author Sean Owen 23 | */ 24 | public final class BookmarkDoCoMoResultParser extends AbstractDoCoMoResultParser { 25 | 26 | @Override 27 | public URIParsedResult parse(Result result) { 28 | String rawText = result.getText(); 29 | if (!rawText.startsWith("MEBKM:")) { 30 | return null; 31 | } 32 | String title = matchSingleDoCoMoPrefixedField("TITLE:", rawText, true); 33 | String[] rawUri = matchDoCoMoPrefixedField("URL:", rawText, true); 34 | if (rawUri == null) { 35 | return null; 36 | } 37 | String uri = rawUri[0]; 38 | return URIResultParser.isBasicallyValidURI(uri) ? new URIParsedResult(uri, title) : null; 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/client/result/ISBNParsedResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | /** 20 | * @author jbreiden@google.com (Jeff Breidenbach) 21 | */ 22 | public final class ISBNParsedResult extends ParsedResult { 23 | 24 | private final String isbn; 25 | 26 | ISBNParsedResult(String isbn) { 27 | super(ParsedResultType.ISBN); 28 | this.isbn = isbn; 29 | } 30 | 31 | public String getISBN() { 32 | return isbn; 33 | } 34 | 35 | @Override 36 | public String getDisplayResult() { 37 | return isbn; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/client/result/ISBNResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | import com.google.zxing.BarcodeFormat; 20 | import com.google.zxing.Result; 21 | 22 | /** 23 | * Parses strings of digits that represent a ISBN. 24 | * 25 | * @author jbreiden@google.com (Jeff Breidenbach) 26 | */ 27 | public final class ISBNResultParser extends ResultParser { 28 | 29 | /** 30 | * See ISBN-13 For Dummies 31 | */ 32 | @Override 33 | public ISBNParsedResult parse(Result result) { 34 | BarcodeFormat format = result.getBarcodeFormat(); 35 | if (format != BarcodeFormat.EAN_13) { 36 | return null; 37 | } 38 | String rawText = getMassagedText(result); 39 | int length = rawText.length(); 40 | if (length != 13) { 41 | return null; 42 | } 43 | if (!rawText.startsWith("978") && !rawText.startsWith("979")) { 44 | return null; 45 | } 46 | 47 | return new ISBNParsedResult(rawText); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/client/result/ParsedResultType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | /** 20 | * Represents the type of data encoded by a barcode -- from plain text, to a 21 | * URI, to an e-mail address, etc. 22 | * 23 | * @author Sean Owen 24 | */ 25 | public enum ParsedResultType { 26 | 27 | ADDRESSBOOK, 28 | EMAIL_ADDRESS, 29 | PRODUCT, 30 | URI, 31 | TEXT, 32 | GEO, 33 | TEL, 34 | SMS, 35 | CALENDAR, 36 | WIFI, 37 | ISBN, 38 | VIN, 39 | 40 | } 41 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/client/result/ProductParsedResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | /** 20 | * @author dswitkin@google.com (Daniel Switkin) 21 | */ 22 | public final class ProductParsedResult extends ParsedResult { 23 | 24 | private final String productID; 25 | private final String normalizedProductID; 26 | 27 | ProductParsedResult(String productID) { 28 | this(productID, productID); 29 | } 30 | 31 | ProductParsedResult(String productID, String normalizedProductID) { 32 | super(ParsedResultType.PRODUCT); 33 | this.productID = productID; 34 | this.normalizedProductID = normalizedProductID; 35 | } 36 | 37 | public String getProductID() { 38 | return productID; 39 | } 40 | 41 | public String getNormalizedProductID() { 42 | return normalizedProductID; 43 | } 44 | 45 | @Override 46 | public String getDisplayResult() { 47 | return productID; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/client/result/TelParsedResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | /** 20 | * @author Sean Owen 21 | */ 22 | public final class TelParsedResult extends ParsedResult { 23 | 24 | private final String number; 25 | private final String telURI; 26 | private final String title; 27 | 28 | public TelParsedResult(String number, String telURI, String title) { 29 | super(ParsedResultType.TEL); 30 | this.number = number; 31 | this.telURI = telURI; 32 | this.title = title; 33 | } 34 | 35 | public String getNumber() { 36 | return number; 37 | } 38 | 39 | public String getTelURI() { 40 | return telURI; 41 | } 42 | 43 | public String getTitle() { 44 | return title; 45 | } 46 | 47 | @Override 48 | public String getDisplayResult() { 49 | StringBuilder result = new StringBuilder(20); 50 | maybeAppend(number, result); 51 | maybeAppend(title, result); 52 | return result.toString(); 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/client/result/TelResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | import com.google.zxing.Result; 20 | 21 | /** 22 | * Parses a "tel:" URI result, which specifies a phone number. 23 | * 24 | * @author Sean Owen 25 | */ 26 | public final class TelResultParser extends ResultParser { 27 | 28 | @Override 29 | public TelParsedResult parse(Result result) { 30 | String rawText = getMassagedText(result); 31 | if (!rawText.startsWith("tel:") && !rawText.startsWith("TEL:")) { 32 | return null; 33 | } 34 | // Normalize "TEL:" to "tel:" 35 | String telURI = rawText.startsWith("TEL:") ? "tel:" + rawText.substring(4) : rawText; 36 | // Drop tel, query portion 37 | int queryStart = rawText.indexOf('?', 4); 38 | String number = queryStart < 0 ? rawText.substring(4) : rawText.substring(4, queryStart); 39 | return new TelParsedResult(number, telURI, null); 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/client/result/TextParsedResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | /** 20 | * A simple result type encapsulating a string that has no further 21 | * interpretation. 22 | * 23 | * @author Sean Owen 24 | */ 25 | public final class TextParsedResult extends ParsedResult { 26 | 27 | private final String text; 28 | private final String language; 29 | 30 | public TextParsedResult(String text, String language) { 31 | super(ParsedResultType.TEXT); 32 | this.text = text; 33 | this.language = language; 34 | } 35 | 36 | public String getText() { 37 | return text; 38 | } 39 | 40 | public String getLanguage() { 41 | return language; 42 | } 43 | 44 | @Override 45 | public String getDisplayResult() { 46 | return text; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/client/result/URLTOResultParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.client.result; 18 | 19 | import com.google.zxing.Result; 20 | 21 | /** 22 | * Parses the "URLTO" result format, which is of the form "URLTO:[title]:[url]". 23 | * This seems to be used sometimes, but I am not able to find documentation 24 | * on its origin or official format? 25 | * 26 | * @author Sean Owen 27 | */ 28 | public final class URLTOResultParser extends ResultParser { 29 | 30 | @Override 31 | public URIParsedResult parse(Result result) { 32 | String rawText = getMassagedText(result); 33 | if (!rawText.startsWith("urlto:") && !rawText.startsWith("URLTO:")) { 34 | return null; 35 | } 36 | int titleEnd = rawText.indexOf(':', 6); 37 | if (titleEnd < 0) { 38 | return null; 39 | } 40 | String title = titleEnd <= 6 ? null : rawText.substring(6, titleEnd); 41 | String uri = rawText.substring(titleEnd + 1); 42 | return new URIParsedResult(uri, title); 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/common/DetectorResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.common; 18 | 19 | import com.google.zxing.ResultPoint; 20 | 21 | /** 22 | *Encapsulates the result of detecting a barcode in an image. This includes the raw 23 | * matrix of black/white pixels corresponding to the barcode, and possibly points of interest 24 | * in the image, like the location of finder patterns or corners of the barcode in the image.
25 | * 26 | * @author Sean Owen 27 | */ 28 | public class DetectorResult { 29 | 30 | private final BitMatrix bits; 31 | private final ResultPoint[] points; 32 | 33 | public DetectorResult(BitMatrix bits, ResultPoint[] points) { 34 | this.bits = bits; 35 | this.points = points; 36 | } 37 | 38 | public final BitMatrix getBits() { 39 | return bits; 40 | } 41 | 42 | public final ResultPoint[] getPoints() { 43 | return points; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/common/detector/MathUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.common.detector; 18 | 19 | public final class MathUtils { 20 | 21 | private MathUtils() { 22 | } 23 | 24 | /** 25 | * Ends up being a bit faster than {@link Math#round(float)}. This merely rounds its 26 | * argument to the nearest int, where x.5 rounds up to x+1. Semantics of this shortcut 27 | * differ slightly from {@link Math#round(float)} in that half rounds down for negative 28 | * values. -2.5 rounds to -3, not -2. For purposes here it makes no difference. 29 | * 30 | * @param d real value to round 31 | * @return nearest {@code int} 32 | */ 33 | public static int round(float d) { 34 | return (int) (d + (d < 0.0f ? -0.5f : 0.5f)); 35 | } 36 | 37 | public static float distance(float aX, float aY, float bX, float bY) { 38 | float xDiff = aX - bX; 39 | float yDiff = aY - bY; 40 | return (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff); 41 | } 42 | 43 | public static float distance(int aX, int aY, int bX, int bY) { 44 | int xDiff = aX - bX; 45 | int yDiff = aY - bY; 46 | return (float) Math.sqrt(xDiff * xDiff + yDiff * yDiff); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/common/reedsolomon/ReedSolomonException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.common.reedsolomon; 18 | 19 | /** 20 | *Thrown when an exception occurs during Reed-Solomon decoding, such as when 21 | * there are too many errors to correct.
22 | * 23 | * @author Sean Owen 24 | */ 25 | public final class ReedSolomonException extends Exception { 26 | 27 | public ReedSolomonException(String message) { 28 | super(message); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/datamatrix/encoder/DataMatrixSymbolInfo144.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 Jeremias Maerki 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.datamatrix.encoder; 18 | 19 | final class DataMatrixSymbolInfo144 extends SymbolInfo { 20 | 21 | DataMatrixSymbolInfo144() { 22 | super(false, 1558, 620, 22, 22, 36, -1, 62); 23 | } 24 | 25 | @Override 26 | public int getInterleavedBlockCount() { 27 | return 10; 28 | } 29 | 30 | @Override 31 | public int getDataLengthForInterleavedBlock(int index) { 32 | return (index <= 8) ? 156 : 155; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/datamatrix/encoder/Encoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006-2007 Jeremias Maerki. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.datamatrix.encoder; 18 | 19 | interface Encoder { 20 | 21 | int getEncodingMode(); 22 | 23 | void encode(EncoderContext context); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/datamatrix/encoder/SymbolShapeHint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Jeremias Maerki. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.datamatrix.encoder; 18 | 19 | /** 20 | * Enumeration for DataMatrix symbol shape hint. It can be used to force square or rectangular 21 | * symbols. 22 | */ 23 | public enum SymbolShapeHint { 24 | 25 | FORCE_NONE, 26 | FORCE_SQUARE, 27 | FORCE_RECTANGLE, 28 | 29 | } 30 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/multi/MultipleBarcodeReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.multi; 18 | 19 | import java.util.Map; 20 | 21 | import com.google.zxing.BinaryBitmap; 22 | import com.google.zxing.DecodeHintType; 23 | import com.google.zxing.NotFoundException; 24 | import com.google.zxing.Result; 25 | 26 | /** 27 | * Implementation of this interface attempt to read several barcodes from one image. 28 | * 29 | * @see com.google.zxing.Reader 30 | * @author Sean Owen 31 | */ 32 | public interface MultipleBarcodeReader { 33 | 34 | Result[] decodeMultiple(BinaryBitmap image) throws NotFoundException; 35 | 36 | Result[] decodeMultiple(BinaryBitmap image, 37 | MapEncapsulates functionality and implementation that is common to UPC and EAN families 21 | * of one-dimensional barcodes.
22 | * 23 | * @author aripollak@gmail.com (Ari Pollak) 24 | * @author dsbnatut@gmail.com (Kazuki Nishiura) 25 | */ 26 | public abstract class UPCEANWriter extends OneDimensionalCodeWriter { 27 | 28 | @Override 29 | public int getDefaultMargin() { 30 | // Use a different default more appropriate for UPC/EAN 31 | return UPCEANReader.START_END_PATTERN.length; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/oned/rss/DataCharacter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.oned.rss; 18 | 19 | public class DataCharacter { 20 | 21 | private final int value; 22 | private final int checksumPortion; 23 | 24 | public DataCharacter(int value, int checksumPortion) { 25 | this.value = value; 26 | this.checksumPortion = checksumPortion; 27 | } 28 | 29 | public final int getValue() { 30 | return value; 31 | } 32 | 33 | public final int getChecksumPortion() { 34 | return checksumPortion; 35 | } 36 | 37 | @Override 38 | public final String toString() { 39 | return value + "(" + checksumPortion + ')'; 40 | } 41 | 42 | @Override 43 | public final boolean equals(Object o) { 44 | if(!(o instanceof DataCharacter)) { 45 | return false; 46 | } 47 | DataCharacter that = (DataCharacter) o; 48 | return value == that.value && checksumPortion == that.checksumPortion; 49 | } 50 | 51 | @Override 52 | public final int hashCode() { 53 | return value ^ checksumPortion; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/oned/rss/Pair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.oned.rss; 18 | 19 | final class Pair extends DataCharacter { 20 | 21 | private final FinderPattern finderPattern; 22 | private int count; 23 | 24 | Pair(int value, int checksumPortion, FinderPattern finderPattern) { 25 | super(value, checksumPortion); 26 | this.finderPattern = finderPattern; 27 | } 28 | 29 | FinderPattern getFinderPattern() { 30 | return finderPattern; 31 | } 32 | 33 | int getCount() { 34 | return count; 35 | } 36 | 37 | void incrementCount() { 38 | count++; 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/oned/rss/expanded/decoders/AI013103decoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded.decoders; 28 | 29 | import com.google.zxing.common.BitArray; 30 | 31 | /** 32 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 33 | */ 34 | final class AI013103decoder extends AI013x0xDecoder { 35 | 36 | AI013103decoder(BitArray information) { 37 | super(information); 38 | } 39 | 40 | @Override 41 | protected void addWeightCode(StringBuilder buf, int weight) { 42 | buf.append("(3103)"); 43 | } 44 | 45 | @Override 46 | protected int checkWeight(int weight) { 47 | return weight; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/oned/rss/expanded/decoders/DecodedChar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded.decoders; 28 | 29 | /** 30 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 31 | * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) 32 | */ 33 | final class DecodedChar extends DecodedObject { 34 | 35 | private final char value; 36 | 37 | static final char FNC1 = '$'; // It's not in Alphanumeric neither in ISO/IEC 646 charset 38 | 39 | DecodedChar(int newPosition, char value) { 40 | super(newPosition); 41 | this.value = value; 42 | } 43 | 44 | char getValue(){ 45 | return this.value; 46 | } 47 | 48 | boolean isFNC1(){ 49 | return this.value == FNC1; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/oned/rss/expanded/decoders/DecodedObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * These authors would like to acknowledge the Spanish Ministry of Industry, 19 | * Tourism and Trade, for the support in the project TSI020301-2008-2 20 | * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled 21 | * Mobile Dynamic Environments", led by Treelogic 22 | * ( http://www.treelogic.com/ ): 23 | * 24 | * http://www.piramidepse.com/ 25 | */ 26 | 27 | package com.google.zxing.oned.rss.expanded.decoders; 28 | 29 | /** 30 | * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) 31 | */ 32 | abstract class DecodedObject { 33 | 34 | private final int newPosition; 35 | 36 | DecodedObject(int newPosition){ 37 | this.newPosition = newPosition; 38 | } 39 | 40 | final int getNewPosition() { 41 | return this.newPosition; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/pdf417/PDF417ResultMetadata.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.pdf417; 18 | 19 | /** 20 | * @author Guenther Grau 21 | */ 22 | public final class PDF417ResultMetadata { 23 | 24 | private int segmentIndex; 25 | private String fileId; 26 | private int[] optionalData; 27 | private boolean lastSegment; 28 | 29 | public int getSegmentIndex() { 30 | return segmentIndex; 31 | } 32 | 33 | public void setSegmentIndex(int segmentIndex) { 34 | this.segmentIndex = segmentIndex; 35 | } 36 | 37 | public String getFileId() { 38 | return fileId; 39 | } 40 | 41 | public void setFileId(String fileId) { 42 | this.fileId = fileId; 43 | } 44 | 45 | public int[] getOptionalData() { 46 | return optionalData; 47 | } 48 | 49 | public void setOptionalData(int[] optionalData) { 50 | this.optionalData = optionalData; 51 | } 52 | 53 | public boolean isLastSegment() { 54 | return lastSegment; 55 | } 56 | 57 | public void setLastSegment(boolean lastSegment) { 58 | this.lastSegment = lastSegment; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/pdf417/detector/PDF417DetectorResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.pdf417.detector; 18 | 19 | import java.util.List; 20 | 21 | import com.google.zxing.ResultPoint; 22 | import com.google.zxing.common.BitMatrix; 23 | 24 | /** 25 | * @author Guenther Grau 26 | */ 27 | public final class PDF417DetectorResult { 28 | 29 | private final BitMatrix bits; 30 | private final ListEncapsulates information about finder patterns in an image, including the location of 21 | * the three finder patterns, and their estimated module size.
22 | * 23 | * @author Sean Owen 24 | */ 25 | public final class FinderPatternInfo { 26 | 27 | private final FinderPattern bottomLeft; 28 | private final FinderPattern topLeft; 29 | private final FinderPattern topRight; 30 | 31 | public FinderPatternInfo(FinderPattern[] patternCenters) { 32 | this.bottomLeft = patternCenters[0]; 33 | this.topLeft = patternCenters[1]; 34 | this.topRight = patternCenters[2]; 35 | } 36 | 37 | public FinderPattern getBottomLeft() { 38 | return bottomLeft; 39 | } 40 | 41 | public FinderPattern getTopLeft() { 42 | return topLeft; 43 | } 44 | 45 | public FinderPattern getTopRight() { 46 | return topRight; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /playground/app/src/main/java_zxing/com/google/zxing/qrcode/encoder/BlockPair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 ZXing authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.zxing.qrcode.encoder; 18 | 19 | final class BlockPair { 20 | 21 | private final byte[] dataBytes; 22 | private final byte[] errorCorrectionBytes; 23 | 24 | BlockPair(byte[] data, byte[] errorCorrection) { 25 | dataBytes = data; 26 | errorCorrectionBytes = errorCorrection; 27 | } 28 | 29 | public byte[] getDataBytes() { 30 | return dataBytes; 31 | } 32 | 33 | public byte[] getErrorCorrectionBytes() { 34 | return errorCorrectionBytes; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /playground/app/src/main/res/drawable-hdpi/ic_action_refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/playground/app/src/main/res/drawable-hdpi/ic_action_refresh.png -------------------------------------------------------------------------------- /playground/app/src/main/res/drawable-hdpi/ic_action_scan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/playground/app/src/main/res/drawable-hdpi/ic_action_scan.png -------------------------------------------------------------------------------- /playground/app/src/main/res/drawable-mdpi/ic_action_refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/playground/app/src/main/res/drawable-mdpi/ic_action_refresh.png -------------------------------------------------------------------------------- /playground/app/src/main/res/drawable-mdpi/ic_action_scan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/playground/app/src/main/res/drawable-mdpi/ic_action_scan.png -------------------------------------------------------------------------------- /playground/app/src/main/res/drawable-v21/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | Created by rowandjj(chuyi)
Date: 2016/10/27
Time: 下午4:56
12 | */
13 |
14 | public interface IWXDevOptions {
15 | void onCreate();
16 |
17 | void onStart();
18 |
19 | void onResume();
20 |
21 | void onPause();
22 |
23 | void onStop();
24 |
25 | void onDestroy();
26 |
27 | void onWeexRenderSuccess(@Nullable WXSDKInstance instance);
28 |
29 | View onWeexViewCreated(WXSDKInstance instance, View view);
30 |
31 | boolean onKeyUp(int keyCode, KeyEvent event);
32 |
33 | void onException(WXSDKInstance instance, String errCode, String msg);
34 |
35 | public void onReceiveTouchEvent(MotionEvent ev);
36 | }
37 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/core/Constants.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.core;
2 |
3 | /**
4 | * Description:
5 | *
6 | * Created by rowandjj(chuyi)
7 | */
8 |
9 | public class Constants {
10 | public static final String TAG = "weex-analyzer";
11 | }
12 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/core/HandlerThreadWrapper.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.core;
2 |
3 | import android.os.Handler;
4 | import android.os.HandlerThread;
5 | import android.support.annotation.NonNull;
6 | import android.support.annotation.Nullable;
7 |
8 | /**
9 | * Description:
10 | *
11 | * Created by rowandjj(chuyi) Created by rowandjj(chuyi)
8 | * Created by rowandjj(chuyi)
8 | * Created by rowandjj(chuyi)
11 | * Created by rowandjj(chuyi)
6 | * Created by rowandjj(chuyi)
6 | * Created by rowandjj(chuyi)
12 | * Created by rowandjj(chuyi)
6 | * Created by rowandjj(chuyi)
12 | * Date: 2016/11/7
13 | * Time: 下午8:07
14 | */
15 |
16 | public class HandlerThreadWrapper {
17 | private Handler mHandler;
18 |
19 | private HandlerThread mHandlerThread;
20 |
21 | public HandlerThreadWrapper(@NonNull String threadName) {
22 | this(threadName,null);
23 | }
24 |
25 | public HandlerThreadWrapper(@NonNull String threadName, @Nullable Handler.Callback callback) {
26 | mHandlerThread = new HandlerThread(threadName);
27 | mHandlerThread.start();
28 | mHandler = new Handler(mHandlerThread.getLooper(),callback);
29 | }
30 |
31 | public @NonNull Handler getHandler() {
32 | return this.mHandler;
33 | }
34 |
35 | public boolean isAlive(){
36 | if(mHandlerThread == null){
37 | return false;
38 | }
39 | return mHandlerThread.isAlive();
40 | }
41 |
42 | public void quit() {
43 | if(mHandlerThread != null){
44 | if(mHandler != null){
45 | mHandler.removeCallbacksAndMessages(null);
46 | }
47 | mHandlerThread.quit();
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/core/TaskEntity.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.core;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | /**
6 | * Description:
7 | *
8 | * Created by rowandjj(chuyi)
9 | */
10 |
11 | public interface TaskEntity
Date: 2016/11/7
Time: 下午4:14
13 | */
14 |
15 | class CpuSampler {
16 |
17 | private CpuSampler(){}
18 | static String sampleCpuRate() {
19 | return doSample("/proc/stat");
20 | }
21 |
22 | static String samplePidCpuRate() {
23 | int pid = android.os.Process.myPid();
24 | return doSample("/proc/" + pid + "/stat");
25 | }
26 |
27 | @VisibleForTesting
28 | static String doSample(@NonNull String filename) {
29 | BufferedReader cpuReader = null;
30 | String cpuRate = "";
31 | try {
32 | cpuReader = new BufferedReader(new InputStreamReader(new FileInputStream(filename)), 1024);
33 | cpuRate = cpuReader.readLine();
34 | } catch (Exception e) {
35 | e.printStackTrace();
36 | } finally {
37 | try {
38 | if (cpuReader != null) {
39 | cpuReader.close();
40 | }
41 | } catch (IOException e) {
42 | e.printStackTrace();
43 | }
44 | }
45 | return cpuRate;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/core/debug/DebugTool.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.core.debug;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import com.taobao.weex.WXEnvironment;
6 | import com.taobao.weex.WXSDKEngine;
7 | import com.taobao.weex.bridge.WXBridgeManager;
8 | import com.taobao.weex.utils.WXLogUtils;
9 |
10 | import java.lang.reflect.Method;
11 |
12 | /**
13 | * Description:
14 | *
15 | * Created by rowandjj(chuyi)
16 | */
17 |
18 | public class DebugTool {
19 |
20 | private static final String TAG = "DebugTool";
21 |
22 | private DebugTool() {
23 | }
24 |
25 | public static void startRemoteDebug(@NonNull String serverAddress) {
26 | try {
27 | WXEnvironment.sRemoteDebugProxyUrl = serverAddress;
28 | WXEnvironment.sRemoteDebugMode = true;
29 | WXSDKEngine.reload();
30 | }catch (Exception e) {
31 | WXLogUtils.e(TAG,e.getMessage());
32 | }
33 | }
34 |
35 | public static boolean stopRemoteDebug() {
36 | try {
37 | WXBridgeManager manager = WXBridgeManager.getInstance();
38 | Method method = manager.getClass().getDeclaredMethod("stopRemoteDebug");
39 | method.setAccessible(true);
40 | method.invoke(manager);
41 | return true;
42 | }catch (Exception e) {
43 | WXLogUtils.e(TAG,e.getMessage());
44 | return false;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/core/fps/FpsTaskEntity.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.core.fps;
2 |
3 | import android.annotation.TargetApi;
4 | import android.os.Build;
5 | import android.support.annotation.NonNull;
6 | import android.view.Choreographer;
7 |
8 | import com.taobao.weex.analyzer.core.TaskEntity;
9 |
10 | /**
11 | * Description:
12 | *
13 | * Created by rowandjj(chuyi)
14 | */
15 |
16 | public class FpsTaskEntity implements TaskEntity
11 | */
12 |
13 | public interface IVDomMonitor {
14 | void monitor(@NonNull final WXSDKInstance instance);
15 |
16 | void destroy();
17 | }
18 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/core/lint/VDomController.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.core.lint;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import com.taobao.weex.WXSDKInstance;
6 |
7 | /**
8 | * Description:
9 | *
10 | * Created by rowandjj(chuyi)
11 | */
12 |
13 | public class VDomController implements IVDomMonitor {
14 | public static boolean isPollingMode = false;
15 | public static boolean isStandardMode = false;
16 |
17 | private PollingVDomMonitor mPollingVDomMonitor;
18 | private StandardVDomMonitor mStandardVDomMonitor;
19 |
20 | public VDomController(@NonNull PollingVDomMonitor pollingVDomMonitor,@NonNull StandardVDomMonitor standardVDomMonitor) {
21 | mPollingVDomMonitor = pollingVDomMonitor;
22 | mStandardVDomMonitor = standardVDomMonitor;
23 | }
24 |
25 | @Override
26 | public void monitor(@NonNull WXSDKInstance instance) {
27 | if (isPollingMode) {
28 | mPollingVDomMonitor.monitor(instance);
29 | } else if(isStandardMode) {
30 | mStandardVDomMonitor.monitor(instance);
31 | }
32 | }
33 |
34 | @Override
35 | public void destroy() {
36 | mPollingVDomMonitor.destroy();
37 | mStandardVDomMonitor.destroy();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/core/logcat/LogConfig.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.core.logcat;
2 |
3 | import com.taobao.weex.analyzer.view.overlay.IResizableView;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Description:
9 | *
10 | * Created by rowandjj(chuyi)
11 | */
12 |
13 | public class LogConfig {
14 | private boolean showLogLevelPanel = true;
15 | private boolean showLogFilterPanel = true;
16 | private boolean showSearchPanel = true;
17 |
18 | private int viewSize = -1;
19 |
20 | private List
9 | * Date: 16/10/8
10 | * Time: 下午4:22
11 | */
12 |
13 | public class MemorySampler {
14 | private MemorySampler() {
15 | }
16 |
17 | /**
18 | * 获取当前内存占用,单位是MB
19 | */
20 | public static double getMemoryUsage() {
21 | Runtime runtime = Runtime.getRuntime();
22 | return (runtime.totalMemory() - runtime.freeMemory()) / (double) 1048576;
23 | }
24 |
25 | /**
26 | * 获取当前应用能获取的总内存,单位是MB
27 | */
28 | public static double maxMemory() {
29 | return Runtime.getRuntime().maxMemory() / (double) 1048576;
30 | }
31 |
32 | /**
33 | * 获取当前应用总内存
34 | * */
35 | public static double totalMemory() {
36 | return Runtime.getRuntime().totalMemory() / (double) 1048576;
37 | }
38 |
39 | @WorkerThread
40 | public static void tryForceGC() {
41 | // System.gc() does not garbage collect every time. Runtime.gc() is
42 | // more likely to perfom a gc.
43 | Runtime.getRuntime().gc();
44 | enqueueReferences();
45 | System.runFinalization();
46 | }
47 |
48 | private static void enqueueReferences() {
49 | /*
50 | * Hack. We don't have a programmatic way to wait for the reference queue
51 | * daemon to move references to the appropriate queues.
52 | */
53 | try {
54 | Thread.sleep(100);
55 | } catch (InterruptedException e) {
56 | throw new AssertionError();
57 | }
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/core/memory/MemoryTaskEntity.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.core.memory;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import com.taobao.weex.analyzer.core.TaskEntity;
6 |
7 | /**
8 | * Description:
9 | *
10 | * Created by rowandjj(chuyi)
11 | */
12 |
13 | public class MemoryTaskEntity implements TaskEntity
14 | */
15 |
16 | class DataReporterFactory {
17 | private DataReporterFactory(){}
18 |
19 | private static final String MDS = "mds";
20 |
21 |
22 | static IDataReporter
12 | */
13 |
14 | class LogReporter implements IDataReporter
7 | */
8 |
9 | public interface IWebSocketBridge {
10 | public void handleMessage(String message);
11 | }
12 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/core/reporter/ws/SimpleSession.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | package com.taobao.weex.analyzer.core.reporter.ws;
11 |
12 | /**
13 | * Alternative to JSR-356's Session class but with a less insane J2EE-style API.
14 | */
15 | interface SimpleSession {
16 | void sendText(String payload);
17 |
18 | void sendBinary(byte[] payload);
19 |
20 | /**
21 | * Request that the session be closed.
22 | *
23 | * @param closeReason Close reason, as per RFC6455
24 | * @param reasonPhrase Possibly arbitrary close reason phrase.
25 | */
26 | void close(int closeReason, String reasonPhrase);
27 |
28 | boolean isOpen();
29 | }
30 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/core/reporter/ws/WebSocketClientFactory.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.core.reporter.ws;
2 |
3 |
4 | import android.support.annotation.NonNull;
5 |
6 | import com.taobao.weex.analyzer.utils.ReflectionUtil;
7 |
8 |
9 | public class WebSocketClientFactory {
10 | public static WebSocketClient create(@NonNull IWebSocketBridge bridge) {
11 | if (ReflectionUtil.tryGetClassForName("okhttp3.ws.WebSocketListener") != null) {
12 | return new OkHttp3WebSocketClient(bridge);
13 | } else if (ReflectionUtil.tryGetClassForName("com.squareup.okhttp.ws.WebSocketListener") != null) {
14 | return new OkHttpWebSocketClient(bridge);
15 | }
16 | return null;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/core/traffic/TrafficSampler.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.core.traffic;
2 |
3 | import android.net.TrafficStats;
4 |
5 | /**
6 | * Description:
7 | *
8 | * Created by rowandjj(chuyi)
9 | */
10 |
11 | public class TrafficSampler {
12 |
13 | public static double getUidRxBytes(int uid) {
14 | return TrafficStats.getUidRxBytes(uid) == TrafficStats.UNSUPPORTED ? 0 : TrafficStats.getUidRxBytes(uid);
15 | }
16 |
17 |
18 | public static double getUidTxBytes(int uid) {
19 | return TrafficStats.getUidTxBytes(uid) == TrafficStats.UNSUPPORTED ? 0 : TrafficStats.getUidTxBytes(uid);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/view/DevOption.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.view;
2 |
3 | import android.support.annotation.DrawableRes;
4 |
5 | /**
6 | * Description:
7 | *
9 | * Date: 2016/11/4
10 | * Time: 下午3:40
11 | */
12 |
13 | public class DevOption {
14 | public String optionName;
15 | @DrawableRes public int iconRes;
16 | public OnOptionClickListener listener;
17 | public boolean isOverlayView;
18 | public boolean isPermissionGranted = true;
19 |
20 | public DevOption(){
21 | }
22 |
23 | public DevOption(String optionName,int iconRes, OnOptionClickListener listener){
24 | this(optionName,iconRes,listener,false);
25 | }
26 |
27 | public DevOption(String optionName, int iconRes, OnOptionClickListener listener, boolean isOverlayView) {
28 | this(optionName,iconRes,listener,isOverlayView,true);
29 | }
30 |
31 | public DevOption(String optionName, int iconRes, OnOptionClickListener listener, boolean isOverlayView, boolean isPermissionGranted) {
32 | this.optionName = optionName;
33 | this.iconRes = iconRes;
34 | this.listener = listener;
35 | this.isOverlayView = isOverlayView;
36 | this.isPermissionGranted = isPermissionGranted;
37 | }
38 |
39 | public interface OnOptionClickListener {
40 | void onOptionClick();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/view/alert/CompatibleAlertDialogBuilder.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.view.alert;
2 |
3 | import android.app.AlertDialog;
4 | import android.content.Context;
5 | import android.os.Build;
6 | import android.view.WindowManager;
7 |
8 | /**
9 | * Description:
10 | *
12 | * Date: 2016/10/31
13 | * Time: 上午11:56
14 | */
15 |
16 | public class CompatibleAlertDialogBuilder extends AlertDialog.Builder {
17 | public CompatibleAlertDialogBuilder(Context context) {
18 | super(context);
19 | }
20 |
21 | @Override
22 | public AlertDialog create() {
23 | AlertDialog dialog = super.create();
24 | try {
25 | if (dialog.getWindow() != null) {
26 | if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
27 | int type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
28 | dialog.getWindow().setType(type);
29 | }
30 | }
31 | } catch (Exception e) {
32 | e.printStackTrace();
33 | }
34 | return dialog;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/view/alert/IAlertView.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.view.alert;
2 |
3 | /**
4 | * Description:
5 | *
7 | * Date: 16/10/19
8 | * Time: 上午11:36
9 | */
10 |
11 | public interface IAlertView {
12 | void show();
13 |
14 | void dismiss();
15 | }
16 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/view/alert/PermissionAlertView.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.view.alert;
2 |
3 | import android.content.Context;
4 |
5 | import com.taobao.weex.analyzer.Config;
6 | import com.taobao.weex.analyzer.IPermissionHandler;
7 |
8 | /**
9 | * Description:
10 | *
11 | * Created by rowandjj(chuyi)
12 | */
13 |
14 | public abstract class PermissionAlertView extends AbstractAlertView implements IPermissionHandler {
15 | private Config mConfig;
16 | public PermissionAlertView(Context context, Config config) {
17 | super(context);
18 | this.mConfig = config;
19 | }
20 |
21 | @Override
22 | public void show() {
23 | if(mConfig != null && !isPermissionGranted(mConfig)) {
24 | return;
25 | }
26 | super.show();
27 | }
28 | }
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/view/chart/DataPoint.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.view.chart;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * default data point implementation.
7 | * This stores the x and y values.
8 | */
9 | public class DataPoint implements DataPointInterface, Serializable {
10 | private static final long serialVersionUID=1428263322645L;
11 |
12 | private double x;
13 | private double y;
14 |
15 | public DataPoint(double x, double y) {
16 | this.x=x;
17 | this.y=y;
18 | }
19 |
20 | @Override
21 | public double getX() {
22 | return x;
23 | }
24 |
25 | @Override
26 | public double getY() {
27 | return y;
28 | }
29 |
30 | @Override
31 | public String toString() {
32 | return "["+x+"/"+y+"]";
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/view/chart/DataPointInterface.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.view.chart;
2 |
3 | public interface DataPointInterface {
4 | /**
5 | * @return the x value
6 | */
7 | public double getX();
8 |
9 | /**
10 | * @return the y value
11 | */
12 | public double getY();
13 | }
14 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/view/chart/LabelFormatter.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.view.chart;
2 |
3 | /**
4 | * Interface to use as label formatter.
5 | * Implement this in order to generate
6 | * your own labels format.
7 | */
8 | public interface LabelFormatter {
9 | /**
10 | * converts a raw number as input to
11 | * a formatted string for the label.
12 | *
13 | * @param value raw input number
14 | * @param isValueX true if it is a value for the x axis
15 | * false if it is a value for the y axis
16 | * @return the formatted number as string
17 | */
18 | public String formatLabel(double value, boolean isValueX);
19 |
20 | /**
21 | * will be called in order to have a
22 | * reference to the current viewport.
23 | * This is useful if you need the bounds
24 | * to generate your labels.
25 | * You store this viewport in as member variable
26 | * and access it e.g. in the {@link #formatLabel(double, boolean)}
27 | * method.
28 | *
29 | * @param viewport the used viewport
30 | */
31 | public void setViewport(Viewport viewport);
32 | }
33 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/view/chart/OnDataPointTapListener.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.view.chart;
2 |
3 | /**
4 | * Listener for the tap event which will be
5 | * triggered when the user touches on a datapoint.
6 | */
7 | public interface OnDataPointTapListener {
8 | /**
9 | * gets called when the user touches on a datapoint.
10 | *
11 | * @param series the corresponding series
12 | * @param dataPoint the data point that was tapped on
13 | */
14 | void onTap(Series series, DataPointInterface dataPoint);
15 | }
16 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/view/chart/TimestampLabelFormatter.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.view.chart;
2 |
3 | /**
4 | * Description:
5 | *
7 | * Date: 16/10/17
8 | * Time: 下午1:54
9 | */
10 |
11 | public class TimestampLabelFormatter extends DefaultLabelFormatter {
12 | public TimestampLabelFormatter() {
13 | }
14 |
15 | @Override
16 | public String formatLabel(double value, boolean isValueX) {
17 | if (isValueX) {
18 | return formatTime(value);
19 | } else {
20 | return super.formatLabel(value, false);
21 | }
22 | }
23 |
24 | private String formatTime(double value) {
25 | if(value < 60){
26 | return ((int)value)+"s";
27 | }
28 |
29 | int seconds = (int) (value % 60);
30 | int minutes = (int) ((value / 60) % 60);
31 | int hours = (int) (value / (60 * 60));
32 |
33 | StringBuilder builder = new StringBuilder();
34 |
35 | if(hours > 0){
36 | builder.append(hours).append("h");
37 | }
38 | if(minutes > 0){
39 | builder.append(minutes).append("m");
40 | }
41 | if(seconds > 0){
42 | builder.append(seconds).append("s");
43 | }
44 | return builder.toString();
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/view/overlay/AbstractBizItemView.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.view.overlay;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.LayoutRes;
5 | import android.util.AttributeSet;
6 | import android.view.LayoutInflater;
7 | import android.widget.FrameLayout;
8 |
9 | /**
10 | * Description:
11 | *
13 | * Date: 2016/11/3
14 | * Time: 下午4:49
15 | */
16 |
17 | public abstract class AbstractBizItemView
7 | * Date: 16/10/12
8 | * Time: 上午10:52
9 | */
10 |
11 | public interface IOverlayView {
12 | boolean isViewAttached();
13 |
14 | void show();
15 |
16 | void dismiss();
17 |
18 | interface OnCloseListener {
19 | void close(IOverlayView host);
20 | }
21 |
22 | interface ITask{
23 | void start();
24 | void stop();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/view/overlay/IResizableView.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.view.overlay;
2 |
3 | import android.support.annotation.IntDef;
4 | import android.view.View;
5 |
6 | import com.taobao.weex.analyzer.core.logcat.LogView;
7 |
8 | import java.lang.annotation.Retention;
9 | import java.lang.annotation.RetentionPolicy;
10 |
11 | /**
12 | * Description:
13 | *
14 | * Created by rowandjj(chuyi)
15 | */
16 |
17 | public interface IResizableView {
18 |
19 | @IntDef({LogView.Size.SMALL, LogView.Size.MEDIUM, LogView.Size.LARGE})
20 | @Retention(RetentionPolicy.SOURCE)
21 | @interface Size {
22 | int SMALL = 0;
23 | int MEDIUM = 1;
24 | int LARGE = 2;
25 | }
26 |
27 | interface OnSizeChangedListener {
28 | void onSizeChanged(@Size int size);
29 | }
30 |
31 | void setViewSize(@LogView.Size int size, View contentView, boolean allowFireEvent);
32 | }
33 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/java/com/taobao/weex/analyzer/view/overlay/PermissionOverlayView.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.view.overlay;
2 |
3 | import android.content.Context;
4 |
5 | import com.taobao.weex.analyzer.Config;
6 | import com.taobao.weex.analyzer.IPermissionHandler;
7 |
8 | /**
9 | * Description:
10 | *
11 | * Created by rowandjj(chuyi)
12 | */
13 |
14 | public abstract class PermissionOverlayView extends DragSupportOverlayView implements IPermissionHandler{
15 | protected Config mConfig;
16 |
17 | public PermissionOverlayView(Context application) {
18 | super(application);
19 | mConfig = null;
20 | }
21 |
22 | public PermissionOverlayView(Context application, boolean enableDrag) {
23 | super(application, enableDrag);
24 | mConfig = null;
25 | }
26 |
27 | public PermissionOverlayView(Context application, boolean enableDrag, Config config) {
28 | super(application, enableDrag);
29 | mConfig = config;
30 | }
31 |
32 | @Override
33 | public void show() {
34 | if(mConfig != null && !isPermissionGranted(mConfig)) {
35 | return;
36 | }
37 | super.show();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xhdpi/wxt_icon_debug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xhdpi/wxt_icon_debug.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_3d_rotation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_3d_rotation.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_checked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_checked.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_cpu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_cpu.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_debug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_debug.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_fps.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_fps.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_log.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_log.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_memory.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_memory.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_mtop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_mtop.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_multi_performance.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_multi_performance.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_performance.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_performance.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_render_analysis.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_render_analysis.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_settings.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_storage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_storage.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_traffic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_traffic.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_unchecked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_unchecked.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_view_inspector.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weexteam/analyzer-of-android-for-Apache-Weex/a79af9bf684d825348b4bd23d3ad5c5d7eec3b1f/weex_analyzer/src/main/res/drawable-xxhdpi/wxt_icon_view_inspector.png
--------------------------------------------------------------------------------
/weex_analyzer/src/main/res/drawable/wxt_btn_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 | */
21 | @RunWith(RobolectricTestRunner.class)
22 | @Config(manifest = "src/main/AndroidManifest.xml",sdk = 21)
23 | public class AnalyzerServiceTest {
24 | static {
25 | ShadowLog.stream = System.out;
26 | }
27 | @Test
28 | public void onStartCommand() throws Exception {
29 | Intent intent = new Intent(ShadowApplication.getInstance().getApplicationContext(), AnalyzerService.class);
30 | ShadowApplication.getInstance().startService(intent);
31 |
32 | Intent i = ShadowApplication.getInstance().peekNextStartedService();
33 | assertEquals(i.getComponent().getClassName(),AnalyzerService.class.getCanonicalName());
34 |
35 | }
36 |
37 | }
--------------------------------------------------------------------------------
/weex_analyzer/src/test/java/com/taobao/weex/analyzer/core/HandlerThreadWrapperTest.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.core;
2 |
3 | import android.os.Handler;
4 |
5 | import org.junit.After;
6 | import org.junit.Before;
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 | import org.robolectric.RobolectricTestRunner;
10 | import org.robolectric.annotation.Config;
11 |
12 | import static org.junit.Assert.assertFalse;
13 | import static org.junit.Assert.assertNotNull;
14 | import static org.junit.Assert.assertTrue;
15 |
16 | /**
17 | * Description:
18 | *
19 | * Created by rowandjj(chuyi)
20 | */
21 | @RunWith(RobolectricTestRunner.class)
22 | @Config(manifest = Config.NONE)
23 | public class HandlerThreadWrapperTest {
24 | @Before
25 | public void setUp() throws Exception {
26 | }
27 |
28 | @After
29 | public void tearDown() throws Exception {
30 | }
31 |
32 | @Test
33 | public void getHandler() throws Exception {
34 | HandlerThreadWrapper mHandlerThreadWrapper = new HandlerThreadWrapper("test");
35 | Handler handler = mHandlerThreadWrapper.getHandler();
36 | assertNotNull(handler);
37 | }
38 |
39 | @Test
40 | public void isAlive() throws Exception {
41 | HandlerThreadWrapper mHandlerThreadWrapper = new HandlerThreadWrapper("test");
42 | boolean result = mHandlerThreadWrapper.isAlive();
43 | assertTrue(result);
44 |
45 | mHandlerThreadWrapper.quit();
46 | //make sure thread has quited
47 | Thread.sleep(200);
48 | result = mHandlerThreadWrapper.isAlive();
49 | assertFalse(result);
50 | }
51 |
52 | }
--------------------------------------------------------------------------------
/weex_analyzer/src/test/java/com/taobao/weex/analyzer/core/JSExceptionCatcherTest.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.core;
2 |
3 | import android.app.AlertDialog;
4 |
5 | import com.taobao.weex.analyzer.core.exception.JSExceptionCatcher;
6 |
7 | import org.junit.After;
8 | import org.junit.Before;
9 | import org.junit.Test;
10 | import org.junit.runner.RunWith;
11 | import org.robolectric.RobolectricTestRunner;
12 | import org.robolectric.RuntimeEnvironment;
13 | import org.robolectric.shadows.ShadowAlertDialog;
14 |
15 | import static org.junit.Assert.assertEquals;
16 | import static org.junit.Assert.assertNotNull;
17 | import static org.robolectric.Shadows.shadowOf;
18 |
19 | /**
20 | * Description:
21 | *
22 | * Created by rowandjj(chuyi)
23 | */
24 | @RunWith(RobolectricTestRunner.class)
25 | public class JSExceptionCatcherTest {
26 | @Before
27 | public void setUp() throws Exception {
28 |
29 | }
30 |
31 | @After
32 | public void tearDown() throws Exception {
33 |
34 | }
35 |
36 | @Test
37 | public void catchException() throws Exception {
38 | String fakeErrCode = "fake_error_code";
39 | String fakeMsg = "fake_msg";
40 | AlertDialog dialog = JSExceptionCatcher.catchException(RuntimeEnvironment.application,null,null,fakeErrCode,fakeMsg);
41 |
42 | assertNotNull(dialog);
43 | ShadowAlertDialog shadowAlertDialog = shadowOf(dialog);
44 | assertEquals(dialog.isShowing(),true);
45 | assertEquals(ShadowAlertDialog.getLatestAlertDialog(),dialog);
46 |
47 | assertEquals("WeexAnalyzer捕捉到异常",shadowAlertDialog.getTitle());
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/weex_analyzer/src/test/java/com/taobao/weex/analyzer/core/MemorySamplerTest.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.core;
2 |
3 | import com.taobao.weex.analyzer.core.memory.MemorySampler;
4 |
5 | import org.junit.After;
6 | import org.junit.Before;
7 | import org.junit.Test;
8 |
9 | import static org.junit.Assert.assertTrue;
10 |
11 |
12 | /**
13 | * Description:
14 | *
15 | * Created by rowandjj(chuyi)
16 | */
17 |
18 | public class MemorySamplerTest {
19 |
20 |
21 | @Before
22 | public void setUp() throws Exception {
23 | }
24 |
25 | @After
26 | public void tearDown() throws Exception {
27 |
28 | }
29 |
30 | @Test
31 | public void getMemoryUsage() throws Exception {
32 | double d = MemorySampler.getMemoryUsage();
33 | System.out.println("usage:"+d);
34 | assertTrue(d>=0);
35 | }
36 |
37 | @Test
38 | public void maxMemory() throws Exception {
39 | double d = MemorySampler.maxMemory();
40 | System.out.println("max:"+d);
41 | assertTrue(d>=0);
42 | }
43 |
44 | @Test
45 | public void totalMemory() throws Exception {
46 | double d = MemorySampler.totalMemory();
47 | System.out.println("total:"+d);
48 | assertTrue(d>=0);
49 | }
50 |
51 | }
--------------------------------------------------------------------------------
/weex_analyzer/src/test/java/com/taobao/weex/analyzer/core/MemoryTaskEntityTest.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.core;
2 |
3 | import com.taobao.weex.analyzer.core.memory.MemorySampler;
4 | import com.taobao.weex.analyzer.core.memory.MemoryTaskEntity;
5 |
6 | import org.junit.After;
7 | import org.junit.Before;
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 | import org.mockito.Mockito;
11 | import org.powermock.api.mockito.PowerMockito;
12 | import org.powermock.core.classloader.annotations.PrepareForTest;
13 | import org.powermock.modules.junit4.PowerMockRunner;
14 |
15 | import static org.junit.Assert.assertEquals;
16 |
17 | /**
18 | * Description:
19 | *
20 | * Created by rowandjj(chuyi)
21 | */
22 | @RunWith(PowerMockRunner.class)
23 | @PrepareForTest(MemorySampler.class)
24 | public class MemoryTaskEntityTest {
25 |
26 | private MemoryTaskEntity entity;
27 | @Before
28 | public void setUp() throws Exception {
29 | PowerMockito.mockStatic(MemorySampler.class);
30 | Mockito.when(MemorySampler.getMemoryUsage()).thenReturn(1.5);
31 | entity = new MemoryTaskEntity();
32 | }
33 |
34 | @After
35 | public void tearDown() throws Exception {
36 | entity = null;
37 | }
38 |
39 | @Test
40 | public void onTaskRun() throws Exception {
41 | double result = entity.onTaskRun();
42 | assertEquals(result,1.5,0);
43 | }
44 |
45 | }
--------------------------------------------------------------------------------
/weex_analyzer/src/test/java/com/taobao/weex/analyzer/core/PerformanceTest.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.core;
2 |
3 | import com.taobao.weex.analyzer.core.weex.Performance;
4 |
5 | import org.junit.After;
6 | import org.junit.Before;
7 | import org.junit.Test;
8 |
9 | import java.util.List;
10 |
11 | import static org.hamcrest.CoreMatchers.hasItem;
12 | import static org.hamcrest.MatcherAssert.assertThat;
13 | import static org.junit.Assert.assertEquals;
14 |
15 | /**
16 | * Description:
17 | *
18 | * Created by rowandjj(chuyi)
19 | */
20 | public class PerformanceTest {
21 |
22 | private Performance mFakePerformance;
23 |
24 | @Before
25 | public void setUp() throws Exception {
26 | mFakePerformance = new Performance();
27 | mFakePerformance.requestType = "fakeType";
28 | mFakePerformance.pageName = "fakeUrl";
29 | }
30 |
31 | @After
32 | public void tearDown() throws Exception {
33 | mFakePerformance = null;
34 | }
35 |
36 | @Test
37 | public void transfer() throws Exception {
38 | List
19 | */
20 | public class ShakeDetectorTest {
21 |
22 | @Mock
23 | private SensorManager mSensorManager;
24 |
25 | @Before
26 | public void setup() {
27 | MockitoAnnotations.initMocks(this);
28 | }
29 |
30 | @Test
31 | public void start() throws Exception {
32 |
33 | ShakeDetector.ShakeListener mockListener = mock(ShakeDetector.ShakeListener.class);
34 | Sensor sensor = mock(Sensor.class);
35 | ShakeDetector detector = new ShakeDetector(mockListener,null);
36 | when(mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)).thenReturn(sensor);
37 |
38 | detector.start(mSensorManager);
39 |
40 | verify(mSensorManager).getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
41 | verify(mSensorManager).registerListener(detector,sensor,SensorManager.SENSOR_DELAY_UI);
42 | }
43 |
44 | @Test
45 | public void stop() throws Exception {
46 |
47 | }
48 |
49 |
50 | }
--------------------------------------------------------------------------------
/weex_analyzer/src/test/java/com/taobao/weex/analyzer/core/TrafficTaskEntityTest.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.core;
2 |
3 | import android.os.Process;
4 |
5 | import com.taobao.weex.analyzer.core.traffic.TrafficSampler;
6 | import com.taobao.weex.analyzer.core.traffic.TrafficTaskEntity;
7 |
8 | import org.junit.After;
9 | import org.junit.Before;
10 | import org.junit.Test;
11 | import org.junit.runner.RunWith;
12 | import org.powermock.api.mockito.PowerMockito;
13 | import org.powermock.core.classloader.annotations.PrepareForTest;
14 | import org.powermock.modules.junit4.PowerMockRunner;
15 |
16 | import static org.mockito.Matchers.anyInt;
17 | import static org.mockito.Mockito.times;
18 |
19 | /**
20 | * Description:
21 | *
22 | * Created by rowandjj(chuyi)
23 | */
24 | @RunWith(PowerMockRunner.class)
25 | @PrepareForTest({Process.class,TrafficSampler.class})
26 | public class TrafficTaskEntityTest {
27 | @Before
28 | public void setUp() throws Exception {
29 | PowerMockito.mockStatic(TrafficSampler.class);
30 | PowerMockito.mockStatic(Process.class);
31 | }
32 |
33 | @After
34 | public void tearDown() throws Exception {
35 |
36 | }
37 |
38 | @Test
39 | public void onTaskInit() throws Exception {
40 |
41 | }
42 |
43 | @Test
44 | public void onTaskRun() throws Exception {
45 | TrafficTaskEntity entity = new TrafficTaskEntity(200);
46 | entity.onTaskRun();
47 |
48 | PowerMockito.verifyStatic(times(2));
49 | Process.myUid();
50 | PowerMockito.verifyStatic();
51 | TrafficSampler.getUidRxBytes(anyInt());
52 | PowerMockito.verifyStatic();
53 | TrafficSampler.getUidTxBytes(anyInt());
54 | }
55 |
56 | @Test
57 | public void onTaskStop() throws Exception {
58 |
59 | }
60 |
61 | }
--------------------------------------------------------------------------------
/weex_analyzer/src/test/java/com/taobao/weex/analyzer/view/WXInspectorItemViewTest.java:
--------------------------------------------------------------------------------
1 | package com.taobao.weex.analyzer.view;
2 |
3 | import com.taobao.weex.analyzer.core.inspector.view.WXInspectorItemView;
4 |
5 | import org.junit.After;
6 | import org.junit.Before;
7 | import org.junit.Test;
8 |
9 | import static org.junit.Assert.assertEquals;
10 |
11 | /**
12 | * Description:
13 | *
14 | * Created by rowandjj(chuyi)
15 | */
16 | public class WXInspectorItemViewTest {
17 | @Before
18 | public void setUp() throws Exception {
19 |
20 | }
21 |
22 | @After
23 | public void tearDown() throws Exception {
24 |
25 | }
26 |
27 | @Test
28 | public void getPureValue() throws Exception {
29 | assertEquals("13", WXInspectorItemView.getPureValue("12.78"));
30 | assertEquals("12",WXInspectorItemView.getPureValue("12."));
31 | assertEquals("-13",WXInspectorItemView.getPureValue("-12.78"));
32 | assertEquals("13",WXInspectorItemView.getPureValue("12.a78"));
33 | assertEquals("-13",WXInspectorItemView.getPureValue("-12.78px"));
34 | assertEquals("12",WXInspectorItemView.getPureValue("12wx"));
35 | assertEquals("3",WXInspectorItemView.getPureValue("3.424223324244"));
36 | assertEquals("-3",WXInspectorItemView.getPureValue("-3.424223324244"));
37 | assertEquals("0",WXInspectorItemView.getPureValue(".424223324244"));
38 | assertEquals("1",WXInspectorItemView.getPureValue("0.8"));
39 |
40 | }
41 |
42 | }
--------------------------------------------------------------------------------
/weex_analyzer/src/test/resources/cpu/pid_stat:
--------------------------------------------------------------------------------
1 | 2815 (com.alibaba.weex) S 1163 1163 0 0 -1 1077961024 20146 367 0 0 273 214 0 3 20 0 22 0 4908 788004864 13729 4294967295 3078434816 3078440316 3218548544 3218546108 3077705499 0 4612 0 38136 4294967295 0 0 17 3 0 0 0 0 0 3078446592 3078447088 3093508096 3218549823 3218549899 3218549899 3218550756 0
2 |
--------------------------------------------------------------------------------
/weex_analyzer/src/test/resources/cpu/stat:
--------------------------------------------------------------------------------
1 | cpu 1317 473 3808 48467 308 1 4 0 0 0
2 | cpu0 345 85 1209 11601 157 1 4 0 0 0
3 | cpu1 326 152 873 12247 51 0 0 0 0 0
4 | cpu2 351 94 801 12335 65 0 0 0 0 0
5 | cpu3 295 142 925 12284 35 0 0 0 0 0
6 | intr 189713 29 0 0 0 6 0 0 0 1 0 3527 6681 0 0 0 9 0 440 18595 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7 | ctxt 733959
8 | btime 1488339905
9 | processes 3011
10 | procs_running 2
11 | procs_blocked 0
12 | softirq 38041 0 14629 0 237 3 0 153 9136 48 13835
13 |
--------------------------------------------------------------------------------