package androidx.exifinterface.media; import android.content.res.AssetManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.location.Location; import android.media.MediaDataSource; import android.media.MediaMetadataRetriever; import android.system.Os; import android.system.OsConstants; import android.util.Log; import android.util.Pair; import androidx.core.view.InputDeviceCompat; import androidx.work.WorkRequest; import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; import com.google.android.exoplayer2.C; import com.google.common.base.Ascii; import io.flutter.embedding.android.KeyboardMap; import io.sentry.protocol.ViewHierarchyNode; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.Closeable; import java.io.DataInput; import java.io.DataInputStream; import java.io.EOFException; import java.io.File; import java.io.FileDescriptor; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FilterOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.Charset; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TimeZone; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; import okhttp3.internal.ws.WebSocketProtocol; import tech.rabbit.r1launcher.BuildConfig; /* loaded from: classes2.dex */ public class ExifInterface { public static final short ALTITUDE_ABOVE_SEA_LEVEL = 0; public static final short ALTITUDE_BELOW_SEA_LEVEL = 1; static final Charset ASCII; static final short BYTE_ALIGN_II = 18761; static final short BYTE_ALIGN_MM = 19789; public static final int COLOR_SPACE_S_RGB = 1; public static final int COLOR_SPACE_UNCALIBRATED = 65535; public static final short CONTRAST_HARD = 2; public static final short CONTRAST_NORMAL = 0; public static final short CONTRAST_SOFT = 1; public static final int DATA_DEFLATE_ZIP = 8; public static final int DATA_HUFFMAN_COMPRESSED = 2; public static final int DATA_JPEG = 6; public static final int DATA_JPEG_COMPRESSED = 7; public static final int DATA_LOSSY_JPEG = 34892; public static final int DATA_PACK_BITS_COMPRESSED = 32773; public static final int DATA_UNCOMPRESSED = 1; private static final ExifTag[] EXIF_POINTER_TAGS; static final ExifTag[][] EXIF_TAGS; public static final short EXPOSURE_MODE_AUTO = 0; public static final short EXPOSURE_MODE_AUTO_BRACKET = 2; public static final short EXPOSURE_MODE_MANUAL = 1; public static final short EXPOSURE_PROGRAM_ACTION = 6; public static final short EXPOSURE_PROGRAM_APERTURE_PRIORITY = 3; public static final short EXPOSURE_PROGRAM_CREATIVE = 5; public static final short EXPOSURE_PROGRAM_LANDSCAPE_MODE = 8; public static final short EXPOSURE_PROGRAM_MANUAL = 1; public static final short EXPOSURE_PROGRAM_NORMAL = 2; public static final short EXPOSURE_PROGRAM_NOT_DEFINED = 0; public static final short EXPOSURE_PROGRAM_PORTRAIT_MODE = 7; public static final short EXPOSURE_PROGRAM_SHUTTER_PRIORITY = 4; public static final short FILE_SOURCE_DSC = 3; public static final short FILE_SOURCE_OTHER = 0; public static final short FILE_SOURCE_REFLEX_SCANNER = 2; public static final short FILE_SOURCE_TRANSPARENT_SCANNER = 1; public static final short FLAG_FLASH_FIRED = 1; public static final short FLAG_FLASH_MODE_AUTO = 24; public static final short FLAG_FLASH_MODE_COMPULSORY_FIRING = 8; public static final short FLAG_FLASH_MODE_COMPULSORY_SUPPRESSION = 16; public static final short FLAG_FLASH_NO_FLASH_FUNCTION = 32; public static final short FLAG_FLASH_RED_EYE_SUPPORTED = 64; public static final short FLAG_FLASH_RETURN_LIGHT_DETECTED = 6; public static final short FLAG_FLASH_RETURN_LIGHT_NOT_DETECTED = 4; public static final short FORMAT_CHUNKY = 1; public static final short FORMAT_PLANAR = 2; public static final short GAIN_CONTROL_HIGH_GAIN_DOWN = 4; public static final short GAIN_CONTROL_HIGH_GAIN_UP = 2; public static final short GAIN_CONTROL_LOW_GAIN_DOWN = 3; public static final short GAIN_CONTROL_LOW_GAIN_UP = 1; public static final short GAIN_CONTROL_NONE = 0; public static final String GPS_DIRECTION_MAGNETIC = "M"; public static final String GPS_DIRECTION_TRUE = "T"; public static final String GPS_DISTANCE_KILOMETERS = "K"; public static final String GPS_DISTANCE_MILES = "M"; public static final String GPS_DISTANCE_NAUTICAL_MILES = "N"; public static final String GPS_MEASUREMENT_2D = "2"; public static final String GPS_MEASUREMENT_3D = "3"; public static final short GPS_MEASUREMENT_DIFFERENTIAL_CORRECTED = 1; public static final String GPS_MEASUREMENT_INTERRUPTED = "V"; public static final String GPS_MEASUREMENT_IN_PROGRESS = "A"; public static final short GPS_MEASUREMENT_NO_DIFFERENTIAL = 0; public static final String GPS_SPEED_KILOMETERS_PER_HOUR = "K"; public static final String GPS_SPEED_KNOTS = "N"; public static final String GPS_SPEED_MILES_PER_HOUR = "M"; static final byte[] IDENTIFIER_EXIF_APP1; private static final byte[] IDENTIFIER_XMP_APP1; private static final ExifTag[] IFD_EXIF_TAGS; private static final int IFD_FORMAT_BYTE = 1; private static final int IFD_FORMAT_DOUBLE = 12; private static final int IFD_FORMAT_IFD = 13; private static final int IFD_FORMAT_SBYTE = 6; private static final int IFD_FORMAT_SINGLE = 11; private static final int IFD_FORMAT_SLONG = 9; private static final int IFD_FORMAT_SRATIONAL = 10; private static final int IFD_FORMAT_SSHORT = 8; private static final int IFD_FORMAT_STRING = 2; private static final int IFD_FORMAT_ULONG = 4; private static final int IFD_FORMAT_UNDEFINED = 7; private static final int IFD_FORMAT_URATIONAL = 5; private static final int IFD_FORMAT_USHORT = 3; private static final ExifTag[] IFD_GPS_TAGS; private static final ExifTag[] IFD_INTEROPERABILITY_TAGS; private static final int IFD_OFFSET = 8; private static final ExifTag[] IFD_THUMBNAIL_TAGS; private static final ExifTag[] IFD_TIFF_TAGS; private static final int IFD_TYPE_EXIF = 1; private static final int IFD_TYPE_GPS = 2; private static final int IFD_TYPE_INTEROPERABILITY = 3; private static final int IFD_TYPE_ORF_CAMERA_SETTINGS = 7; private static final int IFD_TYPE_ORF_IMAGE_PROCESSING = 8; private static final int IFD_TYPE_ORF_MAKER_NOTE = 6; private static final int IFD_TYPE_PEF = 9; static final int IFD_TYPE_PREVIEW = 5; static final int IFD_TYPE_PRIMARY = 0; static final int IFD_TYPE_THUMBNAIL = 4; private static final int IMAGE_TYPE_ARW = 1; private static final int IMAGE_TYPE_CR2 = 2; private static final int IMAGE_TYPE_DNG = 3; private static final int IMAGE_TYPE_HEIF = 12; private static final int IMAGE_TYPE_JPEG = 4; private static final int IMAGE_TYPE_NEF = 5; private static final int IMAGE_TYPE_NRW = 6; private static final int IMAGE_TYPE_ORF = 7; private static final int IMAGE_TYPE_PEF = 8; private static final int IMAGE_TYPE_RAF = 9; private static final int IMAGE_TYPE_RW2 = 10; private static final int IMAGE_TYPE_SRW = 11; private static final int IMAGE_TYPE_UNKNOWN = 0; private static final ExifTag JPEG_INTERCHANGE_FORMAT_LENGTH_TAG; private static final ExifTag JPEG_INTERCHANGE_FORMAT_TAG; public static final String LATITUDE_NORTH = "N"; public static final String LATITUDE_SOUTH = "S"; public static final short LIGHT_SOURCE_CLOUDY_WEATHER = 10; public static final short LIGHT_SOURCE_COOL_WHITE_FLUORESCENT = 14; public static final short LIGHT_SOURCE_D50 = 23; public static final short LIGHT_SOURCE_D55 = 20; public static final short LIGHT_SOURCE_D65 = 21; public static final short LIGHT_SOURCE_D75 = 22; public static final short LIGHT_SOURCE_DAYLIGHT = 1; public static final short LIGHT_SOURCE_DAYLIGHT_FLUORESCENT = 12; public static final short LIGHT_SOURCE_DAY_WHITE_FLUORESCENT = 13; public static final short LIGHT_SOURCE_FINE_WEATHER = 9; public static final short LIGHT_SOURCE_FLASH = 4; public static final short LIGHT_SOURCE_FLUORESCENT = 2; public static final short LIGHT_SOURCE_ISO_STUDIO_TUNGSTEN = 24; public static final short LIGHT_SOURCE_OTHER = 255; public static final short LIGHT_SOURCE_SHADE = 11; public static final short LIGHT_SOURCE_STANDARD_LIGHT_A = 17; public static final short LIGHT_SOURCE_STANDARD_LIGHT_B = 18; public static final short LIGHT_SOURCE_STANDARD_LIGHT_C = 19; public static final short LIGHT_SOURCE_TUNGSTEN = 3; public static final short LIGHT_SOURCE_UNKNOWN = 0; public static final short LIGHT_SOURCE_WARM_WHITE_FLUORESCENT = 16; public static final short LIGHT_SOURCE_WHITE_FLUORESCENT = 15; public static final String LONGITUDE_EAST = "E"; public static final String LONGITUDE_WEST = "W"; static final byte MARKER = -1; static final byte MARKER_APP1 = -31; private static final byte MARKER_COM = -2; static final byte MARKER_EOI = -39; private static final byte MARKER_SOF0 = -64; private static final byte MARKER_SOF1 = -63; private static final byte MARKER_SOF10 = -54; private static final byte MARKER_SOF11 = -53; private static final byte MARKER_SOF13 = -51; private static final byte MARKER_SOF14 = -50; private static final byte MARKER_SOF15 = -49; private static final byte MARKER_SOF2 = -62; private static final byte MARKER_SOF3 = -61; private static final byte MARKER_SOF5 = -59; private static final byte MARKER_SOF6 = -58; private static final byte MARKER_SOF7 = -57; private static final byte MARKER_SOF9 = -55; private static final byte MARKER_SOS = -38; private static final int MAX_THUMBNAIL_SIZE = 512; public static final short METERING_MODE_AVERAGE = 1; public static final short METERING_MODE_CENTER_WEIGHT_AVERAGE = 2; public static final short METERING_MODE_MULTI_SPOT = 4; public static final short METERING_MODE_OTHER = 255; public static final short METERING_MODE_PARTIAL = 6; public static final short METERING_MODE_PATTERN = 5; public static final short METERING_MODE_SPOT = 3; public static final short METERING_MODE_UNKNOWN = 0; private static final ExifTag[] ORF_CAMERA_SETTINGS_TAGS; private static final ExifTag[] ORF_IMAGE_PROCESSING_TAGS; private static final int ORF_MAKER_NOTE_HEADER_1_SIZE = 8; private static final int ORF_MAKER_NOTE_HEADER_2_SIZE = 12; private static final ExifTag[] ORF_MAKER_NOTE_TAGS; private static final short ORF_SIGNATURE_1 = 20306; private static final short ORF_SIGNATURE_2 = 21330; public static final int ORIENTATION_FLIP_HORIZONTAL = 2; public static final int ORIENTATION_FLIP_VERTICAL = 4; public static final int ORIENTATION_NORMAL = 1; public static final int ORIENTATION_ROTATE_180 = 3; public static final int ORIENTATION_ROTATE_270 = 8; public static final int ORIENTATION_ROTATE_90 = 6; public static final int ORIENTATION_TRANSPOSE = 5; public static final int ORIENTATION_TRANSVERSE = 7; public static final int ORIENTATION_UNDEFINED = 0; public static final int ORIGINAL_RESOLUTION_IMAGE = 0; private static final int PEF_MAKER_NOTE_SKIP_SIZE = 6; private static final String PEF_SIGNATURE = "PENTAX"; private static final ExifTag[] PEF_TAGS; public static final int PHOTOMETRIC_INTERPRETATION_BLACK_IS_ZERO = 1; public static final int PHOTOMETRIC_INTERPRETATION_RGB = 2; public static final int PHOTOMETRIC_INTERPRETATION_WHITE_IS_ZERO = 0; public static final int PHOTOMETRIC_INTERPRETATION_YCBCR = 6; private static final int RAF_INFO_SIZE = 160; private static final int RAF_JPEG_LENGTH_VALUE_SIZE = 4; private static final int RAF_OFFSET_TO_JPEG_IMAGE_OFFSET = 84; private static final String RAF_SIGNATURE = "FUJIFILMCCD-RAW"; public static final int REDUCED_RESOLUTION_IMAGE = 1; public static final short RENDERED_PROCESS_CUSTOM = 1; public static final short RENDERED_PROCESS_NORMAL = 0; public static final short RESOLUTION_UNIT_CENTIMETERS = 3; public static final short RESOLUTION_UNIT_INCHES = 2; private static final short RW2_SIGNATURE = 85; public static final short SATURATION_HIGH = 0; public static final short SATURATION_LOW = 0; public static final short SATURATION_NORMAL = 0; public static final short SCENE_CAPTURE_TYPE_LANDSCAPE = 1; public static final short SCENE_CAPTURE_TYPE_NIGHT = 3; public static final short SCENE_CAPTURE_TYPE_PORTRAIT = 2; public static final short SCENE_CAPTURE_TYPE_STANDARD = 0; public static final short SCENE_TYPE_DIRECTLY_PHOTOGRAPHED = 1; public static final short SENSITIVITY_TYPE_ISO_SPEED = 3; public static final short SENSITIVITY_TYPE_REI = 2; public static final short SENSITIVITY_TYPE_REI_AND_ISO = 6; public static final short SENSITIVITY_TYPE_SOS = 1; public static final short SENSITIVITY_TYPE_SOS_AND_ISO = 5; public static final short SENSITIVITY_TYPE_SOS_AND_REI = 4; public static final short SENSITIVITY_TYPE_SOS_AND_REI_AND_ISO = 7; public static final short SENSITIVITY_TYPE_UNKNOWN = 0; public static final short SENSOR_TYPE_COLOR_SEQUENTIAL = 5; public static final short SENSOR_TYPE_COLOR_SEQUENTIAL_LINEAR = 8; public static final short SENSOR_TYPE_NOT_DEFINED = 1; public static final short SENSOR_TYPE_ONE_CHIP = 2; public static final short SENSOR_TYPE_THREE_CHIP = 4; public static final short SENSOR_TYPE_TRILINEAR = 7; public static final short SENSOR_TYPE_TWO_CHIP = 3; public static final short SHARPNESS_HARD = 2; public static final short SHARPNESS_NORMAL = 0; public static final short SHARPNESS_SOFT = 1; private static final int SIGNATURE_CHECK_SIZE = 5000; static final byte START_CODE = 42; public static final short SUBJECT_DISTANCE_RANGE_CLOSE_VIEW = 2; public static final short SUBJECT_DISTANCE_RANGE_DISTANT_VIEW = 3; public static final short SUBJECT_DISTANCE_RANGE_MACRO = 1; public static final short SUBJECT_DISTANCE_RANGE_UNKNOWN = 0; public static final String TAG_APERTURE_VALUE = "ApertureValue"; public static final String TAG_ARTIST = "Artist"; public static final String TAG_BITS_PER_SAMPLE = "BitsPerSample"; public static final String TAG_BODY_SERIAL_NUMBER = "BodySerialNumber"; public static final String TAG_BRIGHTNESS_VALUE = "BrightnessValue"; @Deprecated public static final String TAG_CAMARA_OWNER_NAME = "CameraOwnerName"; public static final String TAG_CAMERA_OWNER_NAME = "CameraOwnerName"; public static final String TAG_CFA_PATTERN = "CFAPattern"; public static final String TAG_COLOR_SPACE = "ColorSpace"; public static final String TAG_COMPONENTS_CONFIGURATION = "ComponentsConfiguration"; public static final String TAG_COMPRESSED_BITS_PER_PIXEL = "CompressedBitsPerPixel"; public static final String TAG_COMPRESSION = "Compression"; public static final String TAG_CONTRAST = "Contrast"; public static final String TAG_COPYRIGHT = "Copyright"; public static final String TAG_CUSTOM_RENDERED = "CustomRendered"; public static final String TAG_DATETIME = "DateTime"; public static final String TAG_DATETIME_DIGITIZED = "DateTimeDigitized"; public static final String TAG_DATETIME_ORIGINAL = "DateTimeOriginal"; public static final String TAG_DEFAULT_CROP_SIZE = "DefaultCropSize"; public static final String TAG_DEVICE_SETTING_DESCRIPTION = "DeviceSettingDescription"; public static final String TAG_DIGITAL_ZOOM_RATIO = "DigitalZoomRatio"; public static final String TAG_DNG_VERSION = "DNGVersion"; private static final String TAG_EXIF_IFD_POINTER = "ExifIFDPointer"; public static final String TAG_EXIF_VERSION = "ExifVersion"; public static final String TAG_EXPOSURE_BIAS_VALUE = "ExposureBiasValue"; public static final String TAG_EXPOSURE_INDEX = "ExposureIndex"; public static final String TAG_EXPOSURE_MODE = "ExposureMode"; public static final String TAG_EXPOSURE_PROGRAM = "ExposureProgram"; public static final String TAG_EXPOSURE_TIME = "ExposureTime"; public static final String TAG_FILE_SOURCE = "FileSource"; public static final String TAG_FLASH = "Flash"; public static final String TAG_FLASHPIX_VERSION = "FlashpixVersion"; public static final String TAG_FLASH_ENERGY = "FlashEnergy"; public static final String TAG_FOCAL_LENGTH = "FocalLength"; public static final String TAG_FOCAL_LENGTH_IN_35MM_FILM = "FocalLengthIn35mmFilm"; public static final String TAG_FOCAL_PLANE_RESOLUTION_UNIT = "FocalPlaneResolutionUnit"; public static final String TAG_FOCAL_PLANE_X_RESOLUTION = "FocalPlaneXResolution"; public static final String TAG_FOCAL_PLANE_Y_RESOLUTION = "FocalPlaneYResolution"; public static final String TAG_F_NUMBER = "FNumber"; public static final String TAG_GAIN_CONTROL = "GainControl"; public static final String TAG_GAMMA = "Gamma"; public static final String TAG_GPS_ALTITUDE = "GPSAltitude"; public static final String TAG_GPS_ALTITUDE_REF = "GPSAltitudeRef"; public static final String TAG_GPS_AREA_INFORMATION = "GPSAreaInformation"; public static final String TAG_GPS_DATESTAMP = "GPSDateStamp"; public static final String TAG_GPS_DEST_BEARING = "GPSDestBearing"; public static final String TAG_GPS_DEST_BEARING_REF = "GPSDestBearingRef"; public static final String TAG_GPS_DEST_DISTANCE = "GPSDestDistance"; public static final String TAG_GPS_DEST_DISTANCE_REF = "GPSDestDistanceRef"; public static final String TAG_GPS_DEST_LATITUDE = "GPSDestLatitude"; public static final String TAG_GPS_DEST_LATITUDE_REF = "GPSDestLatitudeRef"; public static final String TAG_GPS_DEST_LONGITUDE = "GPSDestLongitude"; public static final String TAG_GPS_DEST_LONGITUDE_REF = "GPSDestLongitudeRef"; public static final String TAG_GPS_DIFFERENTIAL = "GPSDifferential"; public static final String TAG_GPS_DOP = "GPSDOP"; public static final String TAG_GPS_H_POSITIONING_ERROR = "GPSHPositioningError"; public static final String TAG_GPS_IMG_DIRECTION = "GPSImgDirection"; public static final String TAG_GPS_IMG_DIRECTION_REF = "GPSImgDirectionRef"; private static final String TAG_GPS_INFO_IFD_POINTER = "GPSInfoIFDPointer"; public static final String TAG_GPS_LATITUDE = "GPSLatitude"; public static final String TAG_GPS_LATITUDE_REF = "GPSLatitudeRef"; public static final String TAG_GPS_LONGITUDE = "GPSLongitude"; public static final String TAG_GPS_LONGITUDE_REF = "GPSLongitudeRef"; public static final String TAG_GPS_MAP_DATUM = "GPSMapDatum"; public static final String TAG_GPS_MEASURE_MODE = "GPSMeasureMode"; public static final String TAG_GPS_PROCESSING_METHOD = "GPSProcessingMethod"; public static final String TAG_GPS_SATELLITES = "GPSSatellites"; public static final String TAG_GPS_SPEED = "GPSSpeed"; public static final String TAG_GPS_SPEED_REF = "GPSSpeedRef"; public static final String TAG_GPS_STATUS = "GPSStatus"; public static final String TAG_GPS_TIMESTAMP = "GPSTimeStamp"; public static final String TAG_GPS_TRACK = "GPSTrack"; public static final String TAG_GPS_TRACK_REF = "GPSTrackRef"; public static final String TAG_GPS_VERSION_ID = "GPSVersionID"; private static final String TAG_HAS_THUMBNAIL = "HasThumbnail"; public static final String TAG_IMAGE_DESCRIPTION = "ImageDescription"; public static final String TAG_IMAGE_LENGTH = "ImageLength"; public static final String TAG_IMAGE_UNIQUE_ID = "ImageUniqueID"; public static final String TAG_IMAGE_WIDTH = "ImageWidth"; private static final String TAG_INTEROPERABILITY_IFD_POINTER = "InteroperabilityIFDPointer"; public static final String TAG_INTEROPERABILITY_INDEX = "InteroperabilityIndex"; public static final String TAG_ISO_SPEED = "ISOSpeed"; public static final String TAG_ISO_SPEED_LATITUDE_YYY = "ISOSpeedLatitudeyyy"; public static final String TAG_ISO_SPEED_LATITUDE_ZZZ = "ISOSpeedLatitudezzz"; @Deprecated public static final String TAG_ISO_SPEED_RATINGS = "ISOSpeedRatings"; public static final String TAG_JPEG_INTERCHANGE_FORMAT = "JPEGInterchangeFormat"; public static final String TAG_JPEG_INTERCHANGE_FORMAT_LENGTH = "JPEGInterchangeFormatLength"; public static final String TAG_LENS_MAKE = "LensMake"; public static final String TAG_LENS_MODEL = "LensModel"; public static final String TAG_LENS_SERIAL_NUMBER = "LensSerialNumber"; public static final String TAG_LENS_SPECIFICATION = "LensSpecification"; public static final String TAG_LIGHT_SOURCE = "LightSource"; public static final String TAG_MAKE = "Make"; public static final String TAG_MAKER_NOTE = "MakerNote"; public static final String TAG_MAX_APERTURE_VALUE = "MaxApertureValue"; public static final String TAG_METERING_MODE = "MeteringMode"; public static final String TAG_MODEL = "Model"; public static final String TAG_NEW_SUBFILE_TYPE = "NewSubfileType"; public static final String TAG_OECF = "OECF"; public static final String TAG_ORF_ASPECT_FRAME = "AspectFrame"; private static final String TAG_ORF_CAMERA_SETTINGS_IFD_POINTER = "CameraSettingsIFDPointer"; private static final String TAG_ORF_IMAGE_PROCESSING_IFD_POINTER = "ImageProcessingIFDPointer"; public static final String TAG_ORF_PREVIEW_IMAGE_LENGTH = "PreviewImageLength"; public static final String TAG_ORF_PREVIEW_IMAGE_START = "PreviewImageStart"; public static final String TAG_ORF_THUMBNAIL_IMAGE = "ThumbnailImage"; public static final String TAG_ORIENTATION = "Orientation"; public static final String TAG_PHOTOGRAPHIC_SENSITIVITY = "PhotographicSensitivity"; public static final String TAG_PHOTOMETRIC_INTERPRETATION = "PhotometricInterpretation"; public static final String TAG_PIXEL_X_DIMENSION = "PixelXDimension"; public static final String TAG_PIXEL_Y_DIMENSION = "PixelYDimension"; public static final String TAG_PLANAR_CONFIGURATION = "PlanarConfiguration"; public static final String TAG_PRIMARY_CHROMATICITIES = "PrimaryChromaticities"; private static final ExifTag TAG_RAF_IMAGE_SIZE; public static final String TAG_RECOMMENDED_EXPOSURE_INDEX = "RecommendedExposureIndex"; public static final String TAG_REFERENCE_BLACK_WHITE = "ReferenceBlackWhite"; public static final String TAG_RELATED_SOUND_FILE = "RelatedSoundFile"; public static final String TAG_RESOLUTION_UNIT = "ResolutionUnit"; public static final String TAG_ROWS_PER_STRIP = "RowsPerStrip"; public static final String TAG_RW2_ISO = "ISO"; public static final String TAG_RW2_JPG_FROM_RAW = "JpgFromRaw"; public static final String TAG_RW2_SENSOR_BOTTOM_BORDER = "SensorBottomBorder"; public static final String TAG_RW2_SENSOR_LEFT_BORDER = "SensorLeftBorder"; public static final String TAG_RW2_SENSOR_RIGHT_BORDER = "SensorRightBorder"; public static final String TAG_RW2_SENSOR_TOP_BORDER = "SensorTopBorder"; public static final String TAG_SAMPLES_PER_PIXEL = "SamplesPerPixel"; public static final String TAG_SATURATION = "Saturation"; public static final String TAG_SCENE_CAPTURE_TYPE = "SceneCaptureType"; public static final String TAG_SCENE_TYPE = "SceneType"; public static final String TAG_SENSING_METHOD = "SensingMethod"; public static final String TAG_SENSITIVITY_TYPE = "SensitivityType"; public static final String TAG_SHARPNESS = "Sharpness"; public static final String TAG_SHUTTER_SPEED_VALUE = "ShutterSpeedValue"; public static final String TAG_SOFTWARE = "Software"; public static final String TAG_SPATIAL_FREQUENCY_RESPONSE = "SpatialFrequencyResponse"; public static final String TAG_SPECTRAL_SENSITIVITY = "SpectralSensitivity"; public static final String TAG_STANDARD_OUTPUT_SENSITIVITY = "StandardOutputSensitivity"; public static final String TAG_STRIP_BYTE_COUNTS = "StripByteCounts"; public static final String TAG_STRIP_OFFSETS = "StripOffsets"; public static final String TAG_SUBFILE_TYPE = "SubfileType"; public static final String TAG_SUBJECT_AREA = "SubjectArea"; public static final String TAG_SUBJECT_DISTANCE = "SubjectDistance"; public static final String TAG_SUBJECT_DISTANCE_RANGE = "SubjectDistanceRange"; public static final String TAG_SUBJECT_LOCATION = "SubjectLocation"; public static final String TAG_SUBSEC_TIME = "SubSecTime"; public static final String TAG_SUBSEC_TIME_DIGITIZED = "SubSecTimeDigitized"; public static final String TAG_SUBSEC_TIME_ORIGINAL = "SubSecTimeOriginal"; private static final String TAG_SUB_IFD_POINTER = "SubIFDPointer"; private static final String TAG_THUMBNAIL_DATA = "ThumbnailData"; public static final String TAG_THUMBNAIL_IMAGE_LENGTH = "ThumbnailImageLength"; public static final String TAG_THUMBNAIL_IMAGE_WIDTH = "ThumbnailImageWidth"; private static final String TAG_THUMBNAIL_LENGTH = "ThumbnailLength"; private static final String TAG_THUMBNAIL_OFFSET = "ThumbnailOffset"; public static final String TAG_THUMBNAIL_ORIENTATION = "ThumbnailOrientation"; public static final String TAG_TRANSFER_FUNCTION = "TransferFunction"; public static final String TAG_USER_COMMENT = "UserComment"; public static final String TAG_WHITE_BALANCE = "WhiteBalance"; public static final String TAG_WHITE_POINT = "WhitePoint"; public static final String TAG_XMP = "Xmp"; public static final String TAG_X_RESOLUTION = "XResolution"; public static final String TAG_Y_CB_CR_COEFFICIENTS = "YCbCrCoefficients"; public static final String TAG_Y_CB_CR_POSITIONING = "YCbCrPositioning"; public static final String TAG_Y_CB_CR_SUB_SAMPLING = "YCbCrSubSampling"; public static final String TAG_Y_RESOLUTION = "YResolution"; @Deprecated public static final int WHITEBALANCE_AUTO = 0; @Deprecated public static final int WHITEBALANCE_MANUAL = 1; public static final short WHITE_BALANCE_AUTO = 0; public static final short WHITE_BALANCE_MANUAL = 1; public static final short Y_CB_CR_POSITIONING_CENTERED = 1; public static final short Y_CB_CR_POSITIONING_CO_SITED = 2; private static final HashMap sExifPointerTagMap; private static final HashMap[] sExifTagMapsForReading; private static final HashMap[] sExifTagMapsForWriting; private static SimpleDateFormat sFormatter; private static final Pattern sGpsTimestampPattern; private static final Pattern sNonZeroTimePattern; private static final HashSet sTagSetForCompatibility; private AssetManager.AssetInputStream mAssetInputStream; private final HashMap[] mAttributes; private Set mAttributesOffsets; private ByteOrder mExifByteOrder; private int mExifOffset; private String mFilename; private boolean mHasThumbnail; private boolean mIsSupportedFile; private int mMimeType; private boolean mModified; private int mOrfMakerNoteOffset; private int mOrfThumbnailLength; private int mOrfThumbnailOffset; private int mRw2JpgFromRawOffset; private FileDescriptor mSeekableFileDescriptor; private byte[] mThumbnailBytes; private int mThumbnailCompression; private int mThumbnailLength; private int mThumbnailOffset; private static final String TAG = "ExifInterface"; private static final boolean DEBUG = Log.isLoggable(TAG, 3); private static final List ROTATION_ORDER = Arrays.asList(1, 6, 3, 8); private static final List FLIPPED_ROTATION_ORDER = Arrays.asList(2, 7, 4, 5); public static final int[] BITS_PER_SAMPLE_RGB = {8, 8, 8}; public static final int[] BITS_PER_SAMPLE_GREYSCALE_1 = {4}; public static final int[] BITS_PER_SAMPLE_GREYSCALE_2 = {8}; private static final byte MARKER_SOI = -40; static final byte[] JPEG_SIGNATURE = {-1, MARKER_SOI, -1}; private static final byte[] HEIF_TYPE_FTYP = {102, 116, 121, 112}; private static final byte[] HEIF_BRAND_MIF1 = {109, 105, 102, 49}; private static final byte[] HEIF_BRAND_HEIC = {104, 101, 105, 99}; private static final byte[] ORF_MAKER_NOTE_HEADER_1 = {79, 76, 89, 77, 80, 0}; private static final byte[] ORF_MAKER_NOTE_HEADER_2 = {79, 76, 89, 77, 80, 85, 83, 0, 73, 73}; static final String[] IFD_FORMAT_NAMES = {"", "BYTE", "STRING", "USHORT", "ULONG", "URATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", "SRATIONAL", "SINGLE", "DOUBLE", "IFD"}; static final int[] IFD_FORMAT_BYTES_PER_FORMAT = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1}; static final byte[] EXIF_ASCII_PREFIX = {65, 83, 67, 73, 73, 0, 0, 0}; @Retention(RetentionPolicy.SOURCE) /* loaded from: classes2.dex */ public @interface IfdType { } public boolean hasThumbnail() { return this.mHasThumbnail; } public boolean isThumbnailCompressed() { if (!this.mHasThumbnail) { return false; } int i = this.mThumbnailCompression; return i == 6 || i == 7; } static { ExifTag[] exifTagArr = {new ExifTag(TAG_NEW_SUBFILE_TYPE, 254, 4), new ExifTag(TAG_SUBFILE_TYPE, 255, 4), new ExifTag(TAG_IMAGE_WIDTH, 256, 3, 4), new ExifTag(TAG_IMAGE_LENGTH, 257, 3, 4), new ExifTag(TAG_BITS_PER_SAMPLE, 258, 3), new ExifTag(TAG_COMPRESSION, 259, 3), new ExifTag(TAG_PHOTOMETRIC_INTERPRETATION, 262, 3), new ExifTag(TAG_IMAGE_DESCRIPTION, SubsamplingScaleImageView.ORIENTATION_270, 2), new ExifTag(TAG_MAKE, 271, 2), new ExifTag(TAG_MODEL, 272, 2), new ExifTag(TAG_STRIP_OFFSETS, 273, 3, 4), new ExifTag(TAG_ORIENTATION, 274, 3), new ExifTag(TAG_SAMPLES_PER_PIXEL, 277, 3), new ExifTag(TAG_ROWS_PER_STRIP, 278, 3, 4), new ExifTag(TAG_STRIP_BYTE_COUNTS, 279, 3, 4), new ExifTag(TAG_X_RESOLUTION, 282, 5), new ExifTag(TAG_Y_RESOLUTION, 283, 5), new ExifTag(TAG_PLANAR_CONFIGURATION, 284, 3), new ExifTag(TAG_RESOLUTION_UNIT, 296, 3), new ExifTag(TAG_TRANSFER_FUNCTION, 301, 3), new ExifTag(TAG_SOFTWARE, 305, 2), new ExifTag(TAG_DATETIME, 306, 2), new ExifTag(TAG_ARTIST, 315, 2), new ExifTag(TAG_WHITE_POINT, 318, 5), new ExifTag(TAG_PRIMARY_CHROMATICITIES, 319, 5), new ExifTag(TAG_SUB_IFD_POINTER, 330, 4), new ExifTag(TAG_JPEG_INTERCHANGE_FORMAT, InputDeviceCompat.SOURCE_DPAD, 4), new ExifTag(TAG_JPEG_INTERCHANGE_FORMAT_LENGTH, 514, 4), new ExifTag(TAG_Y_CB_CR_COEFFICIENTS, 529, 5), new ExifTag(TAG_Y_CB_CR_SUB_SAMPLING, 530, 3), new ExifTag(TAG_Y_CB_CR_POSITIONING, 531, 3), new ExifTag(TAG_REFERENCE_BLACK_WHITE, 532, 5), new ExifTag(TAG_COPYRIGHT, 33432, 2), new ExifTag(TAG_EXIF_IFD_POINTER, 34665, 4), new ExifTag(TAG_GPS_INFO_IFD_POINTER, 34853, 4), new ExifTag(TAG_RW2_SENSOR_TOP_BORDER, 4, 4), new ExifTag(TAG_RW2_SENSOR_LEFT_BORDER, 5, 4), new ExifTag(TAG_RW2_SENSOR_BOTTOM_BORDER, 6, 4), new ExifTag(TAG_RW2_SENSOR_RIGHT_BORDER, 7, 4), new ExifTag(TAG_RW2_ISO, 23, 3), new ExifTag(TAG_RW2_JPG_FROM_RAW, 46, 7), new ExifTag(TAG_XMP, 700, 1)}; IFD_TIFF_TAGS = exifTagArr; ExifTag[] exifTagArr2 = {new ExifTag(TAG_EXPOSURE_TIME, 33434, 5), new ExifTag(TAG_F_NUMBER, 33437, 5), new ExifTag(TAG_EXPOSURE_PROGRAM, 34850, 3), new ExifTag(TAG_SPECTRAL_SENSITIVITY, 34852, 2), new ExifTag(TAG_PHOTOGRAPHIC_SENSITIVITY, 34855, 3), new ExifTag(TAG_OECF, 34856, 7), new ExifTag(TAG_EXIF_VERSION, 36864, 2), new ExifTag(TAG_DATETIME_ORIGINAL, 36867, 2), new ExifTag(TAG_DATETIME_DIGITIZED, 36868, 2), new ExifTag(TAG_COMPONENTS_CONFIGURATION, 37121, 7), new ExifTag(TAG_COMPRESSED_BITS_PER_PIXEL, 37122, 5), new ExifTag(TAG_SHUTTER_SPEED_VALUE, 37377, 10), new ExifTag(TAG_APERTURE_VALUE, 37378, 5), new ExifTag(TAG_BRIGHTNESS_VALUE, 37379, 10), new ExifTag(TAG_EXPOSURE_BIAS_VALUE, 37380, 10), new ExifTag(TAG_MAX_APERTURE_VALUE, 37381, 5), new ExifTag(TAG_SUBJECT_DISTANCE, 37382, 5), new ExifTag(TAG_METERING_MODE, 37383, 3), new ExifTag(TAG_LIGHT_SOURCE, 37384, 3), new ExifTag(TAG_FLASH, 37385, 3), new ExifTag(TAG_FOCAL_LENGTH, 37386, 5), new ExifTag(TAG_SUBJECT_AREA, 37396, 3), new ExifTag(TAG_MAKER_NOTE, 37500, 7), new ExifTag(TAG_USER_COMMENT, 37510, 7), new ExifTag(TAG_SUBSEC_TIME, 37520, 2), new ExifTag(TAG_SUBSEC_TIME_ORIGINAL, 37521, 2), new ExifTag(TAG_SUBSEC_TIME_DIGITIZED, 37522, 2), new ExifTag(TAG_FLASHPIX_VERSION, 40960, 7), new ExifTag(TAG_COLOR_SPACE, 40961, 3), new ExifTag(TAG_PIXEL_X_DIMENSION, 40962, 3, 4), new ExifTag(TAG_PIXEL_Y_DIMENSION, 40963, 3, 4), new ExifTag(TAG_RELATED_SOUND_FILE, 40964, 2), new ExifTag(TAG_INTEROPERABILITY_IFD_POINTER, 40965, 4), new ExifTag(TAG_FLASH_ENERGY, 41483, 5), new ExifTag(TAG_SPATIAL_FREQUENCY_RESPONSE, 41484, 7), new ExifTag(TAG_FOCAL_PLANE_X_RESOLUTION, 41486, 5), new ExifTag(TAG_FOCAL_PLANE_Y_RESOLUTION, 41487, 5), new ExifTag(TAG_FOCAL_PLANE_RESOLUTION_UNIT, 41488, 3), new ExifTag(TAG_SUBJECT_LOCATION, 41492, 3), new ExifTag(TAG_EXPOSURE_INDEX, 41493, 5), new ExifTag(TAG_SENSING_METHOD, 41495, 3), new ExifTag(TAG_FILE_SOURCE, 41728, 7), new ExifTag(TAG_SCENE_TYPE, 41729, 7), new ExifTag(TAG_CFA_PATTERN, 41730, 7), new ExifTag(TAG_CUSTOM_RENDERED, 41985, 3), new ExifTag(TAG_EXPOSURE_MODE, 41986, 3), new ExifTag(TAG_WHITE_BALANCE, 41987, 3), new ExifTag(TAG_DIGITAL_ZOOM_RATIO, 41988, 5), new ExifTag(TAG_FOCAL_LENGTH_IN_35MM_FILM, 41989, 3), new ExifTag(TAG_SCENE_CAPTURE_TYPE, 41990, 3), new ExifTag(TAG_GAIN_CONTROL, 41991, 3), new ExifTag(TAG_CONTRAST, 41992, 3), new ExifTag(TAG_SATURATION, 41993, 3), new ExifTag(TAG_SHARPNESS, 41994, 3), new ExifTag(TAG_DEVICE_SETTING_DESCRIPTION, 41995, 7), new ExifTag(TAG_SUBJECT_DISTANCE_RANGE, 41996, 3), new ExifTag(TAG_IMAGE_UNIQUE_ID, 42016, 2), new ExifTag(TAG_DNG_VERSION, 50706, 1), new ExifTag(TAG_DEFAULT_CROP_SIZE, 50720, 3, 4)}; IFD_EXIF_TAGS = exifTagArr2; ExifTag[] exifTagArr3 = {new ExifTag(TAG_GPS_VERSION_ID, 0, 1), new ExifTag(TAG_GPS_LATITUDE_REF, 1, 2), new ExifTag(TAG_GPS_LATITUDE, 2, 5), new ExifTag(TAG_GPS_LONGITUDE_REF, 3, 2), new ExifTag(TAG_GPS_LONGITUDE, 4, 5), new ExifTag(TAG_GPS_ALTITUDE_REF, 5, 1), new ExifTag(TAG_GPS_ALTITUDE, 6, 5), new ExifTag(TAG_GPS_TIMESTAMP, 7, 5), new ExifTag(TAG_GPS_SATELLITES, 8, 2), new ExifTag(TAG_GPS_STATUS, 9, 2), new ExifTag(TAG_GPS_MEASURE_MODE, 10, 2), new ExifTag(TAG_GPS_DOP, 11, 5), new ExifTag(TAG_GPS_SPEED_REF, 12, 2), new ExifTag(TAG_GPS_SPEED, 13, 5), new ExifTag(TAG_GPS_TRACK_REF, 14, 2), new ExifTag(TAG_GPS_TRACK, 15, 5), new ExifTag(TAG_GPS_IMG_DIRECTION_REF, 16, 2), new ExifTag(TAG_GPS_IMG_DIRECTION, 17, 5), new ExifTag(TAG_GPS_MAP_DATUM, 18, 2), new ExifTag(TAG_GPS_DEST_LATITUDE_REF, 19, 2), new ExifTag(TAG_GPS_DEST_LATITUDE, 20, 5), new ExifTag(TAG_GPS_DEST_LONGITUDE_REF, 21, 2), new ExifTag(TAG_GPS_DEST_LONGITUDE, 22, 5), new ExifTag(TAG_GPS_DEST_BEARING_REF, 23, 2), new ExifTag(TAG_GPS_DEST_BEARING, 24, 5), new ExifTag(TAG_GPS_DEST_DISTANCE_REF, 25, 2), new ExifTag(TAG_GPS_DEST_DISTANCE, 26, 5), new ExifTag(TAG_GPS_PROCESSING_METHOD, 27, 7), new ExifTag(TAG_GPS_AREA_INFORMATION, 28, 7), new ExifTag(TAG_GPS_DATESTAMP, 29, 2), new ExifTag(TAG_GPS_DIFFERENTIAL, 30, 3)}; IFD_GPS_TAGS = exifTagArr3; ExifTag[] exifTagArr4 = {new ExifTag(TAG_INTEROPERABILITY_INDEX, 1, 2)}; IFD_INTEROPERABILITY_TAGS = exifTagArr4; ExifTag[] exifTagArr5 = {new ExifTag(TAG_NEW_SUBFILE_TYPE, 254, 4), new ExifTag(TAG_SUBFILE_TYPE, 255, 4), new ExifTag(TAG_THUMBNAIL_IMAGE_WIDTH, 256, 3, 4), new ExifTag(TAG_THUMBNAIL_IMAGE_LENGTH, 257, 3, 4), new ExifTag(TAG_BITS_PER_SAMPLE, 258, 3), new ExifTag(TAG_COMPRESSION, 259, 3), new ExifTag(TAG_PHOTOMETRIC_INTERPRETATION, 262, 3), new ExifTag(TAG_IMAGE_DESCRIPTION, SubsamplingScaleImageView.ORIENTATION_270, 2), new ExifTag(TAG_MAKE, 271, 2), new ExifTag(TAG_MODEL, 272, 2), new ExifTag(TAG_STRIP_OFFSETS, 273, 3, 4), new ExifTag(TAG_THUMBNAIL_ORIENTATION, 274, 3), new ExifTag(TAG_SAMPLES_PER_PIXEL, 277, 3), new ExifTag(TAG_ROWS_PER_STRIP, 278, 3, 4), new ExifTag(TAG_STRIP_BYTE_COUNTS, 279, 3, 4), new ExifTag(TAG_X_RESOLUTION, 282, 5), new ExifTag(TAG_Y_RESOLUTION, 283, 5), new ExifTag(TAG_PLANAR_CONFIGURATION, 284, 3), new ExifTag(TAG_RESOLUTION_UNIT, 296, 3), new ExifTag(TAG_TRANSFER_FUNCTION, 301, 3), new ExifTag(TAG_SOFTWARE, 305, 2), new ExifTag(TAG_DATETIME, 306, 2), new ExifTag(TAG_ARTIST, 315, 2), new ExifTag(TAG_WHITE_POINT, 318, 5), new ExifTag(TAG_PRIMARY_CHROMATICITIES, 319, 5), new ExifTag(TAG_SUB_IFD_POINTER, 330, 4), new ExifTag(TAG_JPEG_INTERCHANGE_FORMAT, InputDeviceCompat.SOURCE_DPAD, 4), new ExifTag(TAG_JPEG_INTERCHANGE_FORMAT_LENGTH, 514, 4), new ExifTag(TAG_Y_CB_CR_COEFFICIENTS, 529, 5), new ExifTag(TAG_Y_CB_CR_SUB_SAMPLING, 530, 3), new ExifTag(TAG_Y_CB_CR_POSITIONING, 531, 3), new ExifTag(TAG_REFERENCE_BLACK_WHITE, 532, 5), new ExifTag(TAG_COPYRIGHT, 33432, 2), new ExifTag(TAG_EXIF_IFD_POINTER, 34665, 4), new ExifTag(TAG_GPS_INFO_IFD_POINTER, 34853, 4), new ExifTag(TAG_DNG_VERSION, 50706, 1), new ExifTag(TAG_DEFAULT_CROP_SIZE, 50720, 3, 4)}; IFD_THUMBNAIL_TAGS = exifTagArr5; TAG_RAF_IMAGE_SIZE = new ExifTag(TAG_STRIP_OFFSETS, 273, 3); ExifTag[] exifTagArr6 = {new ExifTag(TAG_ORF_THUMBNAIL_IMAGE, 256, 7), new ExifTag(TAG_ORF_CAMERA_SETTINGS_IFD_POINTER, 8224, 4), new ExifTag(TAG_ORF_IMAGE_PROCESSING_IFD_POINTER, 8256, 4)}; ORF_MAKER_NOTE_TAGS = exifTagArr6; ExifTag[] exifTagArr7 = {new ExifTag(TAG_ORF_PREVIEW_IMAGE_START, 257, 4), new ExifTag(TAG_ORF_PREVIEW_IMAGE_LENGTH, 258, 4)}; ORF_CAMERA_SETTINGS_TAGS = exifTagArr7; ExifTag[] exifTagArr8 = {new ExifTag(TAG_ORF_ASPECT_FRAME, 4371, 3)}; ORF_IMAGE_PROCESSING_TAGS = exifTagArr8; ExifTag[] exifTagArr9 = {new ExifTag(TAG_COLOR_SPACE, 55, 3)}; PEF_TAGS = exifTagArr9; ExifTag[][] exifTagArr10 = {exifTagArr, exifTagArr2, exifTagArr3, exifTagArr4, exifTagArr5, exifTagArr, exifTagArr6, exifTagArr7, exifTagArr8, exifTagArr9}; EXIF_TAGS = exifTagArr10; EXIF_POINTER_TAGS = new ExifTag[]{new ExifTag(TAG_SUB_IFD_POINTER, 330, 4), new ExifTag(TAG_EXIF_IFD_POINTER, 34665, 4), new ExifTag(TAG_GPS_INFO_IFD_POINTER, 34853, 4), new ExifTag(TAG_INTEROPERABILITY_IFD_POINTER, 40965, 4), new ExifTag(TAG_ORF_CAMERA_SETTINGS_IFD_POINTER, 8224, 1), new ExifTag(TAG_ORF_IMAGE_PROCESSING_IFD_POINTER, 8256, 1)}; JPEG_INTERCHANGE_FORMAT_TAG = new ExifTag(TAG_JPEG_INTERCHANGE_FORMAT, InputDeviceCompat.SOURCE_DPAD, 4); JPEG_INTERCHANGE_FORMAT_LENGTH_TAG = new ExifTag(TAG_JPEG_INTERCHANGE_FORMAT_LENGTH, 514, 4); sExifTagMapsForReading = new HashMap[exifTagArr10.length]; sExifTagMapsForWriting = new HashMap[exifTagArr10.length]; sTagSetForCompatibility = new HashSet<>(Arrays.asList(TAG_F_NUMBER, TAG_DIGITAL_ZOOM_RATIO, TAG_EXPOSURE_TIME, TAG_SUBJECT_DISTANCE, TAG_GPS_TIMESTAMP)); sExifPointerTagMap = new HashMap<>(); Charset forName = Charset.forName(C.ASCII_NAME); ASCII = forName; IDENTIFIER_EXIF_APP1 = "Exif\u0000\u0000".getBytes(forName); IDENTIFIER_XMP_APP1 = "http://ns.adobe.com/xap/1.0/\u0000".getBytes(forName); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss"); sFormatter = simpleDateFormat; simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); int i = 0; while (true) { ExifTag[][] exifTagArr11 = EXIF_TAGS; if (i >= exifTagArr11.length) { HashMap hashMap = sExifPointerTagMap; ExifTag[] exifTagArr12 = EXIF_POINTER_TAGS; hashMap.put(Integer.valueOf(exifTagArr12[0].number), 5); hashMap.put(Integer.valueOf(exifTagArr12[1].number), 1); hashMap.put(Integer.valueOf(exifTagArr12[2].number), 2); hashMap.put(Integer.valueOf(exifTagArr12[3].number), 3); hashMap.put(Integer.valueOf(exifTagArr12[4].number), 7); hashMap.put(Integer.valueOf(exifTagArr12[5].number), 8); sNonZeroTimePattern = Pattern.compile(".*[1-9].*"); sGpsTimestampPattern = Pattern.compile("^([0-9][0-9]):([0-9][0-9]):([0-9][0-9])$"); return; } sExifTagMapsForReading[i] = new HashMap<>(); sExifTagMapsForWriting[i] = new HashMap<>(); for (ExifTag exifTag : exifTagArr11[i]) { sExifTagMapsForReading[i].put(Integer.valueOf(exifTag.number), exifTag); sExifTagMapsForWriting[i].put(exifTag.name, exifTag); } i++; } } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes2.dex */ public static class Rational { public final long denominator; public final long numerator; public double calculate() { return this.numerator / this.denominator; } Rational(double d) { this((long) (d * 10000.0d), WorkRequest.MIN_BACKOFF_MILLIS); } Rational(long j, long j2) { if (j2 == 0) { this.numerator = 0L; this.denominator = 1L; } else { this.numerator = j; this.denominator = j2; } } public String toString() { return this.numerator + "/" + this.denominator; } } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes2.dex */ public static class ExifAttribute { public static final long BYTES_OFFSET_UNKNOWN = -1; public final byte[] bytes; public final long bytesOffset; public final int format; public final int numberOfComponents; ExifAttribute(int i, int i2, byte[] bArr) { this(i, i2, -1L, bArr); } ExifAttribute(int i, int i2, long j, byte[] bArr) { this.format = i; this.numberOfComponents = i2; this.bytesOffset = j; this.bytes = bArr; } public static ExifAttribute createUShort(int[] iArr, ByteOrder byteOrder) { ByteBuffer wrap = ByteBuffer.wrap(new byte[ExifInterface.IFD_FORMAT_BYTES_PER_FORMAT[3] * iArr.length]); wrap.order(byteOrder); for (int i : iArr) { wrap.putShort((short) i); } return new ExifAttribute(3, iArr.length, wrap.array()); } public static ExifAttribute createUShort(int i, ByteOrder byteOrder) { return createUShort(new int[]{i}, byteOrder); } public static ExifAttribute createULong(long[] jArr, ByteOrder byteOrder) { ByteBuffer wrap = ByteBuffer.wrap(new byte[ExifInterface.IFD_FORMAT_BYTES_PER_FORMAT[4] * jArr.length]); wrap.order(byteOrder); for (long j : jArr) { wrap.putInt((int) j); } return new ExifAttribute(4, jArr.length, wrap.array()); } public static ExifAttribute createULong(long j, ByteOrder byteOrder) { return createULong(new long[]{j}, byteOrder); } public static ExifAttribute createSLong(int[] iArr, ByteOrder byteOrder) { ByteBuffer wrap = ByteBuffer.wrap(new byte[ExifInterface.IFD_FORMAT_BYTES_PER_FORMAT[9] * iArr.length]); wrap.order(byteOrder); for (int i : iArr) { wrap.putInt(i); } return new ExifAttribute(9, iArr.length, wrap.array()); } public static ExifAttribute createSLong(int i, ByteOrder byteOrder) { return createSLong(new int[]{i}, byteOrder); } public static ExifAttribute createByte(String str) { if (str.length() == 1 && str.charAt(0) >= '0' && str.charAt(0) <= '1') { return new ExifAttribute(1, 1, new byte[]{(byte) (str.charAt(0) - '0')}); } byte[] bytes = str.getBytes(ExifInterface.ASCII); return new ExifAttribute(1, bytes.length, bytes); } public static ExifAttribute createString(String str) { byte[] bytes = (str + (char) 0).getBytes(ExifInterface.ASCII); return new ExifAttribute(2, bytes.length, bytes); } public static ExifAttribute createURational(Rational[] rationalArr, ByteOrder byteOrder) { ByteBuffer wrap = ByteBuffer.wrap(new byte[ExifInterface.IFD_FORMAT_BYTES_PER_FORMAT[5] * rationalArr.length]); wrap.order(byteOrder); for (Rational rational : rationalArr) { wrap.putInt((int) rational.numerator); wrap.putInt((int) rational.denominator); } return new ExifAttribute(5, rationalArr.length, wrap.array()); } public static ExifAttribute createURational(Rational rational, ByteOrder byteOrder) { return createURational(new Rational[]{rational}, byteOrder); } public static ExifAttribute createSRational(Rational[] rationalArr, ByteOrder byteOrder) { ByteBuffer wrap = ByteBuffer.wrap(new byte[ExifInterface.IFD_FORMAT_BYTES_PER_FORMAT[10] * rationalArr.length]); wrap.order(byteOrder); for (Rational rational : rationalArr) { wrap.putInt((int) rational.numerator); wrap.putInt((int) rational.denominator); } return new ExifAttribute(10, rationalArr.length, wrap.array()); } public static ExifAttribute createSRational(Rational rational, ByteOrder byteOrder) { return createSRational(new Rational[]{rational}, byteOrder); } public static ExifAttribute createDouble(double[] dArr, ByteOrder byteOrder) { ByteBuffer wrap = ByteBuffer.wrap(new byte[ExifInterface.IFD_FORMAT_BYTES_PER_FORMAT[12] * dArr.length]); wrap.order(byteOrder); for (double d : dArr) { wrap.putDouble(d); } return new ExifAttribute(12, dArr.length, wrap.array()); } public static ExifAttribute createDouble(double d, ByteOrder byteOrder) { return createDouble(new double[]{d}, byteOrder); } public String toString() { return "(" + ExifInterface.IFD_FORMAT_NAMES[this.format] + ", data length:" + this.bytes.length + ")"; } /* JADX WARN: Not initialized variable reg: 3, insn: 0x019e: MOVE (r2 I:??[OBJECT, ARRAY]) = (r3 I:??[OBJECT, ARRAY]), block:B:167:0x019e */ /* JADX WARN: Removed duplicated region for block: B:170:0x01a1 A[EXC_TOP_SPLITTER, SYNTHETIC] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ java.lang.Object getValue(java.nio.ByteOrder r11) { /* Method dump skipped, instructions count: 454 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: androidx.exifinterface.media.ExifInterface.ExifAttribute.getValue(java.nio.ByteOrder):java.lang.Object"); } public double getDoubleValue(ByteOrder byteOrder) { Object value = getValue(byteOrder); if (value == null) { throw new NumberFormatException("NULL can't be converted to a double value"); } if (value instanceof String) { return Double.parseDouble((String) value); } if (value instanceof long[]) { if (((long[]) value).length == 1) { return r3[0]; } throw new NumberFormatException("There are more than one component"); } if (value instanceof int[]) { if (((int[]) value).length == 1) { return r3[0]; } throw new NumberFormatException("There are more than one component"); } if (value instanceof double[]) { double[] dArr = (double[]) value; if (dArr.length == 1) { return dArr[0]; } throw new NumberFormatException("There are more than one component"); } if (value instanceof Rational[]) { Rational[] rationalArr = (Rational[]) value; if (rationalArr.length == 1) { return rationalArr[0].calculate(); } throw new NumberFormatException("There are more than one component"); } throw new NumberFormatException("Couldn't find a double value"); } public int getIntValue(ByteOrder byteOrder) { Object value = getValue(byteOrder); if (value == null) { throw new NumberFormatException("NULL can't be converted to a integer value"); } if (value instanceof String) { return Integer.parseInt((String) value); } if (value instanceof long[]) { long[] jArr = (long[]) value; if (jArr.length == 1) { return (int) jArr[0]; } throw new NumberFormatException("There are more than one component"); } if (value instanceof int[]) { int[] iArr = (int[]) value; if (iArr.length == 1) { return iArr[0]; } throw new NumberFormatException("There are more than one component"); } throw new NumberFormatException("Couldn't find a integer value"); } public String getStringValue(ByteOrder byteOrder) { Object value = getValue(byteOrder); if (value == null) { return null; } if (value instanceof String) { return (String) value; } StringBuilder sb = new StringBuilder(); int i = 0; if (value instanceof long[]) { long[] jArr = (long[]) value; while (i < jArr.length) { sb.append(jArr[i]); i++; if (i != jArr.length) { sb.append(","); } } return sb.toString(); } if (value instanceof int[]) { int[] iArr = (int[]) value; while (i < iArr.length) { sb.append(iArr[i]); i++; if (i != iArr.length) { sb.append(","); } } return sb.toString(); } if (value instanceof double[]) { double[] dArr = (double[]) value; while (i < dArr.length) { sb.append(dArr[i]); i++; if (i != dArr.length) { sb.append(","); } } return sb.toString(); } if (!(value instanceof Rational[])) { return null; } Rational[] rationalArr = (Rational[]) value; while (i < rationalArr.length) { sb.append(rationalArr[i].numerator); sb.append('/'); sb.append(rationalArr[i].denominator); i++; if (i != rationalArr.length) { sb.append(","); } } return sb.toString(); } public int size() { return ExifInterface.IFD_FORMAT_BYTES_PER_FORMAT[this.format] * this.numberOfComponents; } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static class ExifTag { public final String name; public final int number; public final int primaryFormat; public final int secondaryFormat; boolean isFormatCompatible(int i) { int i2; int i3 = this.primaryFormat; if (i3 == 7 || i == 7 || i3 == i || (i2 = this.secondaryFormat) == i) { return true; } if ((i3 == 4 || i2 == 4) && i == 3) { return true; } if ((i3 == 9 || i2 == 9) && i == 8) { return true; } return (i3 == 12 || i2 == 12) && i == 11; } ExifTag(String str, int i, int i2) { this.name = str; this.number = i; this.primaryFormat = i2; this.secondaryFormat = -1; } ExifTag(String str, int i, int i2, int i3) { this.name = str; this.number = i; this.primaryFormat = i2; this.secondaryFormat = i3; } } public ExifInterface(File file) throws IOException { ExifTag[][] exifTagArr = EXIF_TAGS; this.mAttributes = new HashMap[exifTagArr.length]; this.mAttributesOffsets = new HashSet(exifTagArr.length); this.mExifByteOrder = ByteOrder.BIG_ENDIAN; if (file == null) { throw new NullPointerException("file cannot be null"); } initForFilename(file.getAbsolutePath()); } public ExifInterface(String str) throws IOException { ExifTag[][] exifTagArr = EXIF_TAGS; this.mAttributes = new HashMap[exifTagArr.length]; this.mAttributesOffsets = new HashSet(exifTagArr.length); this.mExifByteOrder = ByteOrder.BIG_ENDIAN; if (str == null) { throw new NullPointerException("filename cannot be null"); } initForFilename(str); } public ExifInterface(FileDescriptor fileDescriptor) throws IOException { boolean z; ExifTag[][] exifTagArr = EXIF_TAGS; this.mAttributes = new HashMap[exifTagArr.length]; this.mAttributesOffsets = new HashSet(exifTagArr.length); this.mExifByteOrder = ByteOrder.BIG_ENDIAN; if (fileDescriptor == null) { throw new NullPointerException("fileDescriptor cannot be null"); } FileInputStream fileInputStream = null; this.mAssetInputStream = null; this.mFilename = null; if (isSeekableFD(fileDescriptor)) { this.mSeekableFileDescriptor = fileDescriptor; try { fileDescriptor = Os.dup(fileDescriptor); z = true; } catch (Exception e) { throw new IOException("Failed to duplicate file descriptor", e); } } else { this.mSeekableFileDescriptor = null; z = false; } try { FileInputStream fileInputStream2 = new FileInputStream(fileDescriptor); try { loadAttributes(fileInputStream2); closeQuietly(fileInputStream2); if (z) { closeFileDescriptor(fileDescriptor); } } catch (Throwable th) { th = th; fileInputStream = fileInputStream2; closeQuietly(fileInputStream); if (z) { closeFileDescriptor(fileDescriptor); } throw th; } } catch (Throwable th2) { th = th2; } } public ExifInterface(InputStream inputStream) throws IOException { ExifTag[][] exifTagArr = EXIF_TAGS; this.mAttributes = new HashMap[exifTagArr.length]; this.mAttributesOffsets = new HashSet(exifTagArr.length); this.mExifByteOrder = ByteOrder.BIG_ENDIAN; if (inputStream == null) { throw new NullPointerException("inputStream cannot be null"); } this.mFilename = null; if (inputStream instanceof AssetManager.AssetInputStream) { this.mAssetInputStream = (AssetManager.AssetInputStream) inputStream; this.mSeekableFileDescriptor = null; } else { if (inputStream instanceof FileInputStream) { FileInputStream fileInputStream = (FileInputStream) inputStream; if (isSeekableFD(fileInputStream.getFD())) { this.mAssetInputStream = null; this.mSeekableFileDescriptor = fileInputStream.getFD(); } } this.mAssetInputStream = null; this.mSeekableFileDescriptor = null; } loadAttributes(inputStream); } private ExifAttribute getExifAttribute(String str) { if (str == null) { throw new NullPointerException("tag shouldn't be null"); } if (TAG_ISO_SPEED_RATINGS.equals(str)) { if (DEBUG) { Log.d(TAG, "getExifAttribute: Replacing TAG_ISO_SPEED_RATINGS with TAG_PHOTOGRAPHIC_SENSITIVITY."); } str = TAG_PHOTOGRAPHIC_SENSITIVITY; } for (int i = 0; i < EXIF_TAGS.length; i++) { ExifAttribute exifAttribute = this.mAttributes[i].get(str); if (exifAttribute != null) { return exifAttribute; } } return null; } public String getAttribute(String str) { if (str == null) { throw new NullPointerException("tag shouldn't be null"); } ExifAttribute exifAttribute = getExifAttribute(str); if (exifAttribute != null) { if (!sTagSetForCompatibility.contains(str)) { return exifAttribute.getStringValue(this.mExifByteOrder); } if (str.equals(TAG_GPS_TIMESTAMP)) { if (exifAttribute.format != 5 && exifAttribute.format != 10) { Log.w(TAG, "GPS Timestamp format is not rational. format=" + exifAttribute.format); return null; } Rational[] rationalArr = (Rational[]) exifAttribute.getValue(this.mExifByteOrder); if (rationalArr == null || rationalArr.length != 3) { Log.w(TAG, "Invalid GPS Timestamp array. array=" + Arrays.toString(rationalArr)); return null; } return String.format("%02d:%02d:%02d", Integer.valueOf((int) (((float) rationalArr[0].numerator) / ((float) rationalArr[0].denominator))), Integer.valueOf((int) (((float) rationalArr[1].numerator) / ((float) rationalArr[1].denominator))), Integer.valueOf((int) (((float) rationalArr[2].numerator) / ((float) rationalArr[2].denominator)))); } try { return Double.toString(exifAttribute.getDoubleValue(this.mExifByteOrder)); } catch (NumberFormatException unused) { } } return null; } public int getAttributeInt(String str, int i) { if (str == null) { throw new NullPointerException("tag shouldn't be null"); } ExifAttribute exifAttribute = getExifAttribute(str); if (exifAttribute == null) { return i; } try { return exifAttribute.getIntValue(this.mExifByteOrder); } catch (NumberFormatException unused) { return i; } } public double getAttributeDouble(String str, double d) { if (str == null) { throw new NullPointerException("tag shouldn't be null"); } ExifAttribute exifAttribute = getExifAttribute(str); if (exifAttribute == null) { return d; } try { return exifAttribute.getDoubleValue(this.mExifByteOrder); } catch (NumberFormatException unused) { return d; } } /* JADX WARN: Failed to find 'out' block for switch in B:52:0x01c5. Please report as an issue. */ public void setAttribute(String str, String str2) { ExifTag exifTag; int i; String str3; int i2; String str4; String str5 = str; String str6 = str2; if (str5 == null) { throw new NullPointerException("tag shouldn't be null"); } boolean equals = TAG_ISO_SPEED_RATINGS.equals(str5); String str7 = TAG; if (equals) { if (DEBUG) { Log.d(TAG, "setAttribute: Replacing TAG_ISO_SPEED_RATINGS with TAG_PHOTOGRAPHIC_SENSITIVITY."); } str5 = TAG_PHOTOGRAPHIC_SENSITIVITY; } int i3 = 2; int i4 = 1; if (str6 != null && sTagSetForCompatibility.contains(str5)) { if (str5.equals(TAG_GPS_TIMESTAMP)) { Matcher matcher = sGpsTimestampPattern.matcher(str6); if (!matcher.find()) { Log.w(TAG, "Invalid value for " + str5 + " : " + str6); return; } str6 = Integer.parseInt(matcher.group(1)) + "/1," + Integer.parseInt(matcher.group(2)) + "/1," + Integer.parseInt(matcher.group(3)) + "/1"; } else { try { str6 = new Rational(Double.parseDouble(str2)).toString(); } catch (NumberFormatException unused) { Log.w(TAG, "Invalid value for " + str5 + " : " + str6); return; } } } int i5 = 0; int i6 = 0; while (i6 < EXIF_TAGS.length) { if ((i6 != 4 || this.mHasThumbnail) && (exifTag = sExifTagMapsForWriting[i6].get(str5)) != null) { if (str6 == null) { this.mAttributes[i6].remove(str5); } else { Pair guessDataFormat = guessDataFormat(str6); int i7 = -1; if (exifTag.primaryFormat == ((Integer) guessDataFormat.first).intValue() || exifTag.primaryFormat == ((Integer) guessDataFormat.second).intValue()) { i = exifTag.primaryFormat; } else if (exifTag.secondaryFormat != -1 && (exifTag.secondaryFormat == ((Integer) guessDataFormat.first).intValue() || exifTag.secondaryFormat == ((Integer) guessDataFormat.second).intValue())) { i = exifTag.secondaryFormat; } else if (exifTag.primaryFormat == i4 || exifTag.primaryFormat == 7 || exifTag.primaryFormat == i3) { i = exifTag.primaryFormat; } else if (DEBUG) { StringBuilder append = new StringBuilder("Given tag (").append(str5).append(") value didn't match with one of expected formats: "); String[] strArr = IFD_FORMAT_NAMES; Log.d(str7, append.append(strArr[exifTag.primaryFormat]).append(exifTag.secondaryFormat == -1 ? "" : ", " + strArr[exifTag.secondaryFormat]).append(" (guess: ").append(strArr[((Integer) guessDataFormat.first).intValue()]).append(((Integer) guessDataFormat.second).intValue() != -1 ? ", " + strArr[((Integer) guessDataFormat.second).intValue()] : "").append(")").toString()); } switch (i) { case 1: str3 = str7; i2 = i4; this.mAttributes[i6].put(str5, ExifAttribute.createByte(str6)); str7 = str3; break; case 2: case 7: str3 = str7; i2 = i4; this.mAttributes[i6].put(str5, ExifAttribute.createString(str6)); str7 = str3; break; case 3: str3 = str7; i2 = i4; String[] split = str6.split(",", -1); int[] iArr = new int[split.length]; for (int i8 = 0; i8 < split.length; i8++) { iArr[i8] = Integer.parseInt(split[i8]); } this.mAttributes[i6].put(str5, ExifAttribute.createUShort(iArr, this.mExifByteOrder)); str7 = str3; break; case 4: str3 = str7; i2 = i4; String[] split2 = str6.split(",", -1); long[] jArr = new long[split2.length]; for (int i9 = 0; i9 < split2.length; i9++) { jArr[i9] = Long.parseLong(split2[i9]); } this.mAttributes[i6].put(str5, ExifAttribute.createULong(jArr, this.mExifByteOrder)); str7 = str3; break; case 5: str3 = str7; String[] split3 = str6.split(",", -1); Rational[] rationalArr = new Rational[split3.length]; int i10 = 0; while (i10 < split3.length) { String[] split4 = split3[i10].split("/", i7); rationalArr[i10] = new Rational((long) Double.parseDouble(split4[0]), (long) Double.parseDouble(split4[1])); i10++; i7 = -1; } i2 = 1; this.mAttributes[i6].put(str5, ExifAttribute.createURational(rationalArr, this.mExifByteOrder)); str7 = str3; break; case 6: case 8: case 11: default: str3 = str7; i2 = i4; if (DEBUG) { str7 = str3; Log.d(str7, "Data format isn't one of expected formats: " + i); break; } str7 = str3; break; case 9: str4 = str7; String[] split5 = str6.split(",", -1); int[] iArr2 = new int[split5.length]; for (int i11 = 0; i11 < split5.length; i11++) { iArr2[i11] = Integer.parseInt(split5[i11]); } this.mAttributes[i6].put(str5, ExifAttribute.createSLong(iArr2, this.mExifByteOrder)); str7 = str4; i2 = 1; break; case 10: String[] split6 = str6.split(",", -1); Rational[] rationalArr2 = new Rational[split6.length]; int i12 = i5; while (i12 < split6.length) { String[] split7 = split6[i12].split("/", -1); rationalArr2[i12] = new Rational((long) Double.parseDouble(split7[i5]), (long) Double.parseDouble(split7[i4])); i12++; str7 = str7; i4 = 1; i5 = 0; } str4 = str7; this.mAttributes[i6].put(str5, ExifAttribute.createSRational(rationalArr2, this.mExifByteOrder)); str7 = str4; i2 = 1; break; case 12: String[] split8 = str6.split(",", -1); double[] dArr = new double[split8.length]; for (int i13 = i5; i13 < split8.length; i13++) { dArr[i13] = Double.parseDouble(split8[i13]); } this.mAttributes[i6].put(str5, ExifAttribute.createDouble(dArr, this.mExifByteOrder)); break; } i6++; i4 = i2; i3 = 2; i5 = 0; } } i2 = i4; i6++; i4 = i2; i3 = 2; i5 = 0; } } public void resetOrientation() { setAttribute(TAG_ORIENTATION, Integer.toString(1)); } public void rotate(int i) { if (i % 90 != 0) { throw new IllegalArgumentException("degree should be a multiple of 90"); } int attributeInt = getAttributeInt(TAG_ORIENTATION, 1); List list = ROTATION_ORDER; if (list.contains(Integer.valueOf(attributeInt))) { int indexOf = (list.indexOf(Integer.valueOf(attributeInt)) + (i / 90)) % 4; r4 = list.get(indexOf + (indexOf < 0 ? 4 : 0)).intValue(); } else { List list2 = FLIPPED_ROTATION_ORDER; if (list2.contains(Integer.valueOf(attributeInt))) { int indexOf2 = (list2.indexOf(Integer.valueOf(attributeInt)) + (i / 90)) % 4; r4 = list2.get(indexOf2 + (indexOf2 < 0 ? 4 : 0)).intValue(); } } setAttribute(TAG_ORIENTATION, Integer.toString(r4)); } public void flipVertically() { int i = 1; switch (getAttributeInt(TAG_ORIENTATION, 1)) { case 1: i = 4; break; case 2: i = 3; break; case 3: i = 2; break; case 4: break; case 5: i = 8; break; case 6: i = 7; break; case 7: i = 6; break; case 8: i = 5; break; default: i = 0; break; } setAttribute(TAG_ORIENTATION, Integer.toString(i)); } public void flipHorizontally() { int i = 1; switch (getAttributeInt(TAG_ORIENTATION, 1)) { case 1: i = 2; break; case 2: break; case 3: i = 4; break; case 4: i = 3; break; case 5: i = 6; break; case 6: i = 5; break; case 7: i = 8; break; case 8: i = 7; break; default: i = 0; break; } setAttribute(TAG_ORIENTATION, Integer.toString(i)); } public boolean isFlipped() { int attributeInt = getAttributeInt(TAG_ORIENTATION, 1); return attributeInt == 2 || attributeInt == 7 || attributeInt == 4 || attributeInt == 5; } public int getRotationDegrees() { switch (getAttributeInt(TAG_ORIENTATION, 1)) { case 3: case 4: return SubsamplingScaleImageView.ORIENTATION_180; case 5: case 8: return SubsamplingScaleImageView.ORIENTATION_270; case 6: case 7: return 90; default: return 0; } } private boolean updateAttribute(String str, ExifAttribute exifAttribute) { boolean z = false; for (int i = 0; i < EXIF_TAGS.length; i++) { if (this.mAttributes[i].containsKey(str)) { this.mAttributes[i].put(str, exifAttribute); z = true; } } return z; } private void removeAttribute(String str) { for (int i = 0; i < EXIF_TAGS.length; i++) { this.mAttributes[i].remove(str); } } private void loadAttributes(InputStream inputStream) throws IOException { if (inputStream == null) { throw new NullPointerException("inputstream shouldn't be null"); } for (int i = 0; i < EXIF_TAGS.length; i++) { try { try { this.mAttributes[i] = new HashMap<>(); } catch (IOException e) { this.mIsSupportedFile = false; boolean z = DEBUG; if (z) { Log.w(TAG, "Invalid image: ExifInterface got an unsupported image format file(ExifInterface supports JPEG and some RAW image formats only) or a corrupted JPEG file to ExifInterface.", e); } addDefaultValuesForCompatibility(); if (!z) { return; } } } finally { addDefaultValuesForCompatibility(); if (DEBUG) { printAttributes(); } } } BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, 5000); BufferedInputStream bufferedInputStream2 = bufferedInputStream; this.mMimeType = getMimeType(bufferedInputStream); ByteOrderedDataInputStream byteOrderedDataInputStream = new ByteOrderedDataInputStream(bufferedInputStream); switch (this.mMimeType) { case 0: case 1: case 2: case 3: case 5: case 6: case 8: case 11: getRawAttributes(byteOrderedDataInputStream); break; case 4: getJpegAttributes(byteOrderedDataInputStream, 0, 0); break; case 7: getOrfAttributes(byteOrderedDataInputStream); break; case 9: getRafAttributes(byteOrderedDataInputStream); break; case 10: getRw2Attributes(byteOrderedDataInputStream); break; case 12: getHeifAttributes(byteOrderedDataInputStream); break; } setThumbnailData(byteOrderedDataInputStream); this.mIsSupportedFile = true; } private static boolean isSeekableFD(FileDescriptor fileDescriptor) throws IOException { try { Os.lseek(fileDescriptor, 0L, OsConstants.SEEK_CUR); return true; } catch (Exception unused) { return false; } } private void printAttributes() { for (int i = 0; i < this.mAttributes.length; i++) { Log.d(TAG, "The size of tag group[" + i + "]: " + this.mAttributes[i].size()); for (Map.Entry entry : this.mAttributes[i].entrySet()) { ExifAttribute value = entry.getValue(); Log.d(TAG, "tagName: " + entry.getKey() + ", tagType: " + value.toString() + ", tagValue: '" + value.getStringValue(this.mExifByteOrder) + "'"); } } } public void saveAttributes() throws IOException { FileOutputStream fileOutputStream; FileInputStream fileInputStream; File file; BufferedOutputStream bufferedOutputStream; FileOutputStream fileOutputStream2; if (!this.mIsSupportedFile || this.mMimeType != 4) { throw new IOException("ExifInterface only supports saving attributes on JPEG formats."); } if (this.mSeekableFileDescriptor == null && this.mFilename == null) { throw new IOException("ExifInterface does not support saving attributes for the current input."); } this.mModified = true; this.mThumbnailBytes = getThumbnail(); InputStream inputStream = null; File file2 = this.mFilename != null ? new File(this.mFilename) : null; try { if (this.mFilename != null) { file = new File(this.mFilename + ".tmp"); if (!file2.renameTo(file)) { throw new IOException("Couldn't rename to " + file.getAbsolutePath()); } fileInputStream = null; fileOutputStream = null; } else if (this.mSeekableFileDescriptor != null) { file = File.createTempFile("temp", "jpg"); Os.lseek(this.mSeekableFileDescriptor, 0L, OsConstants.SEEK_SET); fileInputStream = new FileInputStream(this.mSeekableFileDescriptor); try { fileOutputStream = new FileOutputStream(file); try { copy(fileInputStream, fileOutputStream); } catch (Exception e) { e = e; inputStream = fileInputStream; try { throw new IOException("Failed to copy original file to temp file", e); } catch (Throwable th) { th = th; closeQuietly(inputStream); closeQuietly(fileOutputStream); throw th; } } catch (Throwable th2) { th = th2; inputStream = fileInputStream; closeQuietly(inputStream); closeQuietly(fileOutputStream); throw th; } } catch (Exception e2) { e = e2; fileOutputStream = null; } catch (Throwable th3) { th = th3; fileOutputStream = null; } } else { fileInputStream = null; file = null; fileOutputStream = null; } closeQuietly(fileInputStream); closeQuietly(fileOutputStream); try { FileInputStream fileInputStream2 = new FileInputStream(file); if (this.mFilename != null) { fileOutputStream2 = new FileOutputStream(this.mFilename); } else { FileDescriptor fileDescriptor = this.mSeekableFileDescriptor; if (fileDescriptor != null) { Os.lseek(fileDescriptor, 0L, OsConstants.SEEK_SET); fileOutputStream2 = new FileOutputStream(this.mSeekableFileDescriptor); } else { fileOutputStream2 = null; } } BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream2); try { BufferedOutputStream bufferedOutputStream2 = new BufferedOutputStream(fileOutputStream2); try { saveJpegAttributes(bufferedInputStream, bufferedOutputStream2); closeQuietly(bufferedInputStream); closeQuietly(bufferedOutputStream2); file.delete(); this.mThumbnailBytes = null; } catch (Exception e3) { bufferedOutputStream = bufferedOutputStream2; e = e3; inputStream = bufferedInputStream; try { if (this.mFilename != null && !file.renameTo(file2)) { throw new IOException("Couldn't restore original file: " + file2.getAbsolutePath()); } throw new IOException("Failed to save new file", e); } catch (Throwable th4) { th = th4; closeQuietly(inputStream); closeQuietly(bufferedOutputStream); file.delete(); throw th; } } catch (Throwable th5) { th = th5; bufferedOutputStream = bufferedOutputStream2; inputStream = bufferedInputStream; closeQuietly(inputStream); closeQuietly(bufferedOutputStream); file.delete(); throw th; } } catch (Exception e4) { e = e4; bufferedOutputStream = null; } catch (Throwable th6) { th = th6; bufferedOutputStream = null; } } catch (Exception e5) { e = e5; bufferedOutputStream = null; } catch (Throwable th7) { th = th7; bufferedOutputStream = null; } } catch (Exception e6) { e = e6; fileOutputStream = null; } catch (Throwable th8) { th = th8; fileOutputStream = null; } } public boolean hasAttribute(String str) { return getExifAttribute(str) != null; } public byte[] getThumbnail() { int i = this.mThumbnailCompression; if (i == 6 || i == 7) { return getThumbnailBytes(); } return null; } /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Removed duplicated region for block: B:18:0x005c A[Catch: Exception -> 0x008f, all -> 0x00ab, TRY_ENTER, TRY_LEAVE, TryCatch #1 {Exception -> 0x008f, blocks: (B:18:0x005c, B:21:0x006c, B:23:0x0078, B:28:0x0083, B:29:0x0088, B:30:0x0089, B:31:0x008e, B:32:0x0091, B:33:0x0096), top: B:16:0x005a }] */ /* JADX WARN: Removed duplicated region for block: B:32:0x0091 A[Catch: Exception -> 0x008f, all -> 0x00ab, TryCatch #1 {Exception -> 0x008f, blocks: (B:18:0x005c, B:21:0x006c, B:23:0x0078, B:28:0x0083, B:29:0x0088, B:30:0x0089, B:31:0x008e, B:32:0x0091, B:33:0x0096), top: B:16:0x005a }] */ /* JADX WARN: Removed duplicated region for block: B:39:0x00a7 */ /* JADX WARN: Removed duplicated region for block: B:54:0x00b2 */ /* JADX WARN: Type inference failed for: r1v1, types: [byte[]] */ /* JADX WARN: Type inference failed for: r1v2 */ /* JADX WARN: Type inference failed for: r1v5, types: [android.content.res.AssetManager$AssetInputStream, java.io.Closeable, java.io.InputStream] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public byte[] getThumbnailBytes() { /* r9 = this; java.lang.String r0 = "ExifInterface" boolean r1 = r9.mHasThumbnail r2 = 0 if (r1 != 0) goto L8 return r2 L8: byte[] r1 = r9.mThumbnailBytes if (r1 == 0) goto Ld return r1 Ld: android.content.res.AssetManager$AssetInputStream r1 = r9.mAssetInputStream // Catch: java.lang.Throwable -> L97 java.lang.Exception -> L9a if (r1 == 0) goto L2d boolean r3 = r1.markSupported() // Catch: java.lang.Throwable -> L25 java.lang.Exception -> L29 if (r3 == 0) goto L1c r1.reset() // Catch: java.lang.Throwable -> L25 java.lang.Exception -> L29 L1a: r3 = r2 goto L5a L1c: java.lang.String r9 = "Cannot read thumbnail from inputstream without mark/reset support" android.util.Log.d(r0, r9) // Catch: java.lang.Throwable -> L25 java.lang.Exception -> L29 closeQuietly(r1) return r2 L25: r9 = move-exception r3 = r2 goto Lac L29: r9 = move-exception r3 = r2 goto L9d L2d: java.lang.String r1 = r9.mFilename // Catch: java.lang.Throwable -> L97 java.lang.Exception -> L9a if (r1 == 0) goto L39 java.io.FileInputStream r1 = new java.io.FileInputStream // Catch: java.lang.Throwable -> L97 java.lang.Exception -> L9a java.lang.String r3 = r9.mFilename // Catch: java.lang.Throwable -> L97 java.lang.Exception -> L9a r1.(r3) // Catch: java.lang.Throwable -> L97 java.lang.Exception -> L9a goto L1a L39: java.io.FileDescriptor r1 = r9.mSeekableFileDescriptor // Catch: java.lang.Throwable -> L97 java.lang.Exception -> L9a if (r1 == 0) goto L58 java.io.FileDescriptor r1 = android.system.Os.dup(r1) // Catch: java.lang.Throwable -> L97 java.lang.Exception -> L9a int r3 = android.system.OsConstants.SEEK_SET // Catch: java.lang.Throwable -> L51 java.lang.Exception -> L54 r4 = 0 android.system.Os.lseek(r1, r4, r3) // Catch: java.lang.Throwable -> L51 java.lang.Exception -> L54 java.io.FileInputStream r3 = new java.io.FileInputStream // Catch: java.lang.Throwable -> L51 java.lang.Exception -> L54 r3.(r1) // Catch: java.lang.Throwable -> L51 java.lang.Exception -> L54 r8 = r3 r3 = r1 r1 = r8 goto L5a L51: r9 = move-exception r3 = r1 goto Lad L54: r9 = move-exception r3 = r1 r1 = r2 goto L9d L58: r1 = r2 r3 = r1 L5a: if (r1 == 0) goto L91 int r4 = r9.mThumbnailOffset // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab long r4 = (long) r4 // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab long r4 = r1.skip(r4) // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab int r6 = r9.mThumbnailOffset // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab long r6 = (long) r6 int r4 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1)) java.lang.String r5 = "Corrupted image" if (r4 != 0) goto L89 int r4 = r9.mThumbnailLength // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab byte[] r4 = new byte[r4] // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab int r6 = r1.read(r4) // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab int r7 = r9.mThumbnailLength // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab if (r6 != r7) goto L83 r9.mThumbnailBytes = r4 // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab closeQuietly(r1) if (r3 == 0) goto L82 closeFileDescriptor(r3) L82: return r4 L83: java.io.IOException r9 = new java.io.IOException // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab r9.(r5) // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab throw r9 // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab L89: java.io.IOException r9 = new java.io.IOException // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab r9.(r5) // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab throw r9 // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab L8f: r9 = move-exception goto L9d L91: java.io.FileNotFoundException r9 = new java.io.FileNotFoundException // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab r9.() // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab throw r9 // Catch: java.lang.Exception -> L8f java.lang.Throwable -> Lab L97: r9 = move-exception r3 = r2 goto Lad L9a: r9 = move-exception r1 = r2 r3 = r1 L9d: java.lang.String r4 = "Encountered exception while getting thumbnail" android.util.Log.d(r0, r4, r9) // Catch: java.lang.Throwable -> Lab closeQuietly(r1) if (r3 == 0) goto Laa closeFileDescriptor(r3) Laa: return r2 Lab: r9 = move-exception Lac: r2 = r1 Lad: closeQuietly(r2) if (r3 == 0) goto Lb5 closeFileDescriptor(r3) Lb5: throw r9 */ throw new UnsupportedOperationException("Method not decompiled: androidx.exifinterface.media.ExifInterface.getThumbnailBytes():byte[]"); } public Bitmap getThumbnailBitmap() { if (!this.mHasThumbnail) { return null; } if (this.mThumbnailBytes == null) { this.mThumbnailBytes = getThumbnailBytes(); } int i = this.mThumbnailCompression; if (i == 6 || i == 7) { return BitmapFactory.decodeByteArray(this.mThumbnailBytes, 0, this.mThumbnailLength); } if (i == 1) { int length = this.mThumbnailBytes.length / 3; int[] iArr = new int[length]; for (int i2 = 0; i2 < length; i2++) { byte[] bArr = this.mThumbnailBytes; int i3 = i2 * 3; iArr[i2] = (bArr[i3] << Ascii.DLE) + (bArr[i3 + 1] << 8) + bArr[i3 + 2]; } ExifAttribute exifAttribute = this.mAttributes[4].get(TAG_IMAGE_LENGTH); ExifAttribute exifAttribute2 = this.mAttributes[4].get(TAG_IMAGE_WIDTH); if (exifAttribute != null && exifAttribute2 != null) { return Bitmap.createBitmap(iArr, exifAttribute2.getIntValue(this.mExifByteOrder), exifAttribute.getIntValue(this.mExifByteOrder), Bitmap.Config.ARGB_8888); } } return null; } public long[] getThumbnailRange() { if (this.mModified) { throw new IllegalStateException("The underlying file has been modified since being parsed"); } if (this.mHasThumbnail) { return new long[]{this.mThumbnailOffset, this.mThumbnailLength}; } return null; } public long[] getAttributeRange(String str) { if (str == null) { throw new NullPointerException("tag shouldn't be null"); } if (this.mModified) { throw new IllegalStateException("The underlying file has been modified since being parsed"); } ExifAttribute exifAttribute = getExifAttribute(str); if (exifAttribute != null) { return new long[]{exifAttribute.bytesOffset, exifAttribute.bytes.length}; } return null; } public byte[] getAttributeBytes(String str) { if (str == null) { throw new NullPointerException("tag shouldn't be null"); } ExifAttribute exifAttribute = getExifAttribute(str); if (exifAttribute != null) { return exifAttribute.bytes; } return null; } @Deprecated public boolean getLatLong(float[] fArr) { double[] latLong = getLatLong(); if (latLong == null) { return false; } fArr[0] = (float) latLong[0]; fArr[1] = (float) latLong[1]; return true; } public double[] getLatLong() { String attribute = getAttribute(TAG_GPS_LATITUDE); String attribute2 = getAttribute(TAG_GPS_LATITUDE_REF); String attribute3 = getAttribute(TAG_GPS_LONGITUDE); String attribute4 = getAttribute(TAG_GPS_LONGITUDE_REF); if (attribute == null || attribute2 == null || attribute3 == null || attribute4 == null) { return null; } try { return new double[]{convertRationalLatLonToDouble(attribute, attribute2), convertRationalLatLonToDouble(attribute3, attribute4)}; } catch (IllegalArgumentException unused) { Log.w(TAG, "Latitude/longitude values are not parsable. " + String.format("latValue=%s, latRef=%s, lngValue=%s, lngRef=%s", attribute, attribute2, attribute3, attribute4)); return null; } } public void setGpsInfo(Location location) { if (location == null) { return; } setAttribute(TAG_GPS_PROCESSING_METHOD, location.getProvider()); setLatLong(location.getLatitude(), location.getLongitude()); setAltitude(location.getAltitude()); setAttribute(TAG_GPS_SPEED_REF, "K"); setAttribute(TAG_GPS_SPEED, new Rational((location.getSpeed() * ((float) TimeUnit.HOURS.toSeconds(1L))) / 1000.0f).toString()); String[] split = sFormatter.format(new Date(location.getTime())).split("\\s+", -1); setAttribute(TAG_GPS_DATESTAMP, split[0]); setAttribute(TAG_GPS_TIMESTAMP, split[1]); } public void setLatLong(double d, double d2) { if (d < -90.0d || d > 90.0d || Double.isNaN(d)) { throw new IllegalArgumentException("Latitude value " + d + " is not valid."); } if (d2 < -180.0d || d2 > 180.0d || Double.isNaN(d2)) { throw new IllegalArgumentException("Longitude value " + d2 + " is not valid."); } setAttribute(TAG_GPS_LATITUDE_REF, d >= BuildConfig.SENTRY_SAMPLE_RATE ? "N" : LATITUDE_SOUTH); setAttribute(TAG_GPS_LATITUDE, convertDecimalDegree(Math.abs(d))); setAttribute(TAG_GPS_LONGITUDE_REF, d2 >= BuildConfig.SENTRY_SAMPLE_RATE ? LONGITUDE_EAST : LONGITUDE_WEST); setAttribute(TAG_GPS_LONGITUDE, convertDecimalDegree(Math.abs(d2))); } public double getAltitude(double d) { double attributeDouble = getAttributeDouble(TAG_GPS_ALTITUDE, -1.0d); int attributeInt = getAttributeInt(TAG_GPS_ALTITUDE_REF, -1); if (attributeDouble < BuildConfig.SENTRY_SAMPLE_RATE || attributeInt < 0) { return d; } return attributeDouble * (attributeInt != 1 ? 1 : -1); } public void setAltitude(double d) { String str = d >= BuildConfig.SENTRY_SAMPLE_RATE ? "0" : "1"; setAttribute(TAG_GPS_ALTITUDE, new Rational(Math.abs(d)).toString()); setAttribute(TAG_GPS_ALTITUDE_REF, str); } public void setDateTime(long j) { setAttribute(TAG_DATETIME, sFormatter.format(new Date(j))); setAttribute(TAG_SUBSEC_TIME, Long.toString(j % 1000)); } public long getDateTime() { return parseDateTime(getAttribute(TAG_DATETIME), getAttribute(TAG_SUBSEC_TIME)); } public long getDateTimeDigitized() { return parseDateTime(getAttribute(TAG_DATETIME_DIGITIZED), getAttribute(TAG_SUBSEC_TIME_DIGITIZED)); } public long getDateTimeOriginal() { return parseDateTime(getAttribute(TAG_DATETIME_ORIGINAL), getAttribute(TAG_SUBSEC_TIME_ORIGINAL)); } private static long parseDateTime(String str, String str2) { if (str != null && sNonZeroTimePattern.matcher(str).matches()) { try { Date parse = sFormatter.parse(str, new ParsePosition(0)); if (parse == null) { return -1L; } long time = parse.getTime(); if (str2 == null) { return time; } try { long parseLong = Long.parseLong(str2); while (parseLong > 1000) { parseLong /= 10; } return time + parseLong; } catch (NumberFormatException unused) { return time; } } catch (IllegalArgumentException unused2) { } } return -1L; } public long getGpsDateTime() { String attribute = getAttribute(TAG_GPS_DATESTAMP); String attribute2 = getAttribute(TAG_GPS_TIMESTAMP); if (attribute != null && attribute2 != null) { Pattern pattern = sNonZeroTimePattern; if (pattern.matcher(attribute).matches() || pattern.matcher(attribute2).matches()) { try { Date parse = sFormatter.parse(attribute + ' ' + attribute2, new ParsePosition(0)); if (parse == null) { return -1L; } return parse.getTime(); } catch (IllegalArgumentException unused) { } } } return -1L; } private void initForFilename(String str) throws IOException { if (str == null) { throw new NullPointerException("filename cannot be null"); } FileInputStream fileInputStream = null; this.mAssetInputStream = null; this.mFilename = str; try { FileInputStream fileInputStream2 = new FileInputStream(str); try { if (isSeekableFD(fileInputStream2.getFD())) { this.mSeekableFileDescriptor = fileInputStream2.getFD(); } else { this.mSeekableFileDescriptor = null; } loadAttributes(fileInputStream2); closeQuietly(fileInputStream2); } catch (Throwable th) { th = th; fileInputStream = fileInputStream2; closeQuietly(fileInputStream); throw th; } } catch (Throwable th2) { th = th2; } } private static double convertRationalLatLonToDouble(String str, String str2) { try { String[] split = str.split(",", -1); String[] split2 = split[0].split("/", -1); double parseDouble = Double.parseDouble(split2[0].trim()) / Double.parseDouble(split2[1].trim()); String[] split3 = split[1].split("/", -1); double parseDouble2 = Double.parseDouble(split3[0].trim()) / Double.parseDouble(split3[1].trim()); String[] split4 = split[2].split("/", -1); double parseDouble3 = parseDouble + (parseDouble2 / 60.0d) + ((Double.parseDouble(split4[0].trim()) / Double.parseDouble(split4[1].trim())) / 3600.0d); if (!str2.equals(LATITUDE_SOUTH) && !str2.equals(LONGITUDE_WEST)) { if (!str2.equals("N") && !str2.equals(LONGITUDE_EAST)) { throw new IllegalArgumentException(); } return parseDouble3; } return -parseDouble3; } catch (ArrayIndexOutOfBoundsException | NumberFormatException unused) { throw new IllegalArgumentException(); } } private String convertDecimalDegree(double d) { long j = (long) d; double d2 = d - j; long j2 = (long) (d2 * 60.0d); return j + "/1," + j2 + "/1," + Math.round((d2 - (j2 / 60.0d)) * 3600.0d * 1.0E7d) + "/10000000"; } private int getMimeType(BufferedInputStream bufferedInputStream) throws IOException { bufferedInputStream.mark(5000); byte[] bArr = new byte[5000]; bufferedInputStream.read(bArr); bufferedInputStream.reset(); if (isJpegFormat(bArr)) { return 4; } if (isRafFormat(bArr)) { return 9; } if (isHeifFormat(bArr)) { return 12; } if (isOrfFormat(bArr)) { return 7; } return isRw2Format(bArr) ? 10 : 0; } private static boolean isJpegFormat(byte[] bArr) throws IOException { int i = 0; while (true) { byte[] bArr2 = JPEG_SIGNATURE; if (i >= bArr2.length) { return true; } if (bArr[i] != bArr2[i]) { return false; } i++; } } private boolean isRafFormat(byte[] bArr) throws IOException { byte[] bytes = RAF_SIGNATURE.getBytes(Charset.defaultCharset()); for (int i = 0; i < bytes.length; i++) { if (bArr[i] != bytes[i]) { return false; } } return true; } private boolean isHeifFormat(byte[] bArr) throws IOException { ByteOrderedDataInputStream byteOrderedDataInputStream; long readInt; byte[] bArr2; long j; ByteOrderedDataInputStream byteOrderedDataInputStream2 = null; try { try { byteOrderedDataInputStream = new ByteOrderedDataInputStream(bArr); } catch (Throwable th) { th = th; } } catch (Exception e) { e = e; } try { byteOrderedDataInputStream.setByteOrder(ByteOrder.BIG_ENDIAN); readInt = byteOrderedDataInputStream.readInt(); bArr2 = new byte[4]; byteOrderedDataInputStream.read(bArr2); } catch (Exception e2) { e = e2; byteOrderedDataInputStream2 = byteOrderedDataInputStream; if (DEBUG) { Log.d(TAG, "Exception parsing HEIF file type box.", e); } if (byteOrderedDataInputStream2 != null) { byteOrderedDataInputStream2.close(); } return false; } catch (Throwable th2) { th = th2; byteOrderedDataInputStream2 = byteOrderedDataInputStream; if (byteOrderedDataInputStream2 != null) { byteOrderedDataInputStream2.close(); } throw th; } if (!Arrays.equals(bArr2, HEIF_TYPE_FTYP)) { byteOrderedDataInputStream.close(); return false; } if (readInt == 1) { readInt = byteOrderedDataInputStream.readLong(); j = 16; if (readInt < 16) { byteOrderedDataInputStream.close(); return false; } } else { j = 8; } if (readInt > bArr.length) { readInt = bArr.length; } long j2 = readInt - j; if (j2 < 8) { byteOrderedDataInputStream.close(); return false; } byte[] bArr3 = new byte[4]; boolean z = false; boolean z2 = false; for (long j3 = 0; j3 < j2 / 4; j3++) { if (byteOrderedDataInputStream.read(bArr3) != 4) { byteOrderedDataInputStream.close(); return false; } if (j3 != 1) { if (Arrays.equals(bArr3, HEIF_BRAND_MIF1)) { z = true; } else if (Arrays.equals(bArr3, HEIF_BRAND_HEIC)) { z2 = true; } if (z && z2) { byteOrderedDataInputStream.close(); return true; } } } byteOrderedDataInputStream.close(); return false; } private boolean isOrfFormat(byte[] bArr) throws IOException { ByteOrderedDataInputStream byteOrderedDataInputStream = new ByteOrderedDataInputStream(bArr); ByteOrder readByteOrder = readByteOrder(byteOrderedDataInputStream); this.mExifByteOrder = readByteOrder; byteOrderedDataInputStream.setByteOrder(readByteOrder); short readShort = byteOrderedDataInputStream.readShort(); byteOrderedDataInputStream.close(); return readShort == 20306 || readShort == 21330; } private boolean isRw2Format(byte[] bArr) throws IOException { ByteOrderedDataInputStream byteOrderedDataInputStream = new ByteOrderedDataInputStream(bArr); ByteOrder readByteOrder = readByteOrder(byteOrderedDataInputStream); this.mExifByteOrder = readByteOrder; byteOrderedDataInputStream.setByteOrder(readByteOrder); short readShort = byteOrderedDataInputStream.readShort(); byteOrderedDataInputStream.close(); return readShort == 85; } /* JADX WARN: Code restructure failed: missing block: B:70:0x0191, code lost: r21.setByteOrder(r20.mExifByteOrder); */ /* JADX WARN: Code restructure failed: missing block: B:71:0x0196, code lost: return; */ /* JADX WARN: Failed to find 'out' block for switch in B:30:0x00b4. Please report as an issue. */ /* JADX WARN: Removed duplicated region for block: B:32:0x016c */ /* JADX WARN: Removed duplicated region for block: B:39:0x017d A[SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:42:0x00b9 A[FALL_THROUGH] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private void getJpegAttributes(androidx.exifinterface.media.ExifInterface.ByteOrderedDataInputStream r21, int r22, int r23) throws java.io.IOException { /* Method dump skipped, instructions count: 526 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: androidx.exifinterface.media.ExifInterface.getJpegAttributes(androidx.exifinterface.media.ExifInterface$ByteOrderedDataInputStream, int, int):void"); } private void getRawAttributes(ByteOrderedDataInputStream byteOrderedDataInputStream) throws IOException { ExifAttribute exifAttribute; parseTiffHeaders(byteOrderedDataInputStream, byteOrderedDataInputStream.available()); readImageFileDirectory(byteOrderedDataInputStream, 0); updateImageSizeValues(byteOrderedDataInputStream, 0); updateImageSizeValues(byteOrderedDataInputStream, 5); updateImageSizeValues(byteOrderedDataInputStream, 4); validateImages(byteOrderedDataInputStream); if (this.mMimeType != 8 || (exifAttribute = this.mAttributes[1].get(TAG_MAKER_NOTE)) == null) { return; } ByteOrderedDataInputStream byteOrderedDataInputStream2 = new ByteOrderedDataInputStream(exifAttribute.bytes); byteOrderedDataInputStream2.setByteOrder(this.mExifByteOrder); byteOrderedDataInputStream2.seek(6L); readImageFileDirectory(byteOrderedDataInputStream2, 9); ExifAttribute exifAttribute2 = this.mAttributes[9].get(TAG_COLOR_SPACE); if (exifAttribute2 != null) { this.mAttributes[1].put(TAG_COLOR_SPACE, exifAttribute2); } } private void getRafAttributes(ByteOrderedDataInputStream byteOrderedDataInputStream) throws IOException { byteOrderedDataInputStream.skipBytes(RAF_OFFSET_TO_JPEG_IMAGE_OFFSET); byte[] bArr = new byte[4]; byte[] bArr2 = new byte[4]; byteOrderedDataInputStream.read(bArr); byteOrderedDataInputStream.skipBytes(4); byteOrderedDataInputStream.read(bArr2); int i = ByteBuffer.wrap(bArr).getInt(); int i2 = ByteBuffer.wrap(bArr2).getInt(); getJpegAttributes(byteOrderedDataInputStream, i, 5); byteOrderedDataInputStream.seek(i2); byteOrderedDataInputStream.setByteOrder(ByteOrder.BIG_ENDIAN); int readInt = byteOrderedDataInputStream.readInt(); if (DEBUG) { Log.d(TAG, "numberOfDirectoryEntry: " + readInt); } for (int i3 = 0; i3 < readInt; i3++) { int readUnsignedShort = byteOrderedDataInputStream.readUnsignedShort(); int readUnsignedShort2 = byteOrderedDataInputStream.readUnsignedShort(); if (readUnsignedShort == TAG_RAF_IMAGE_SIZE.number) { short readShort = byteOrderedDataInputStream.readShort(); short readShort2 = byteOrderedDataInputStream.readShort(); ExifAttribute createUShort = ExifAttribute.createUShort(readShort, this.mExifByteOrder); ExifAttribute createUShort2 = ExifAttribute.createUShort(readShort2, this.mExifByteOrder); this.mAttributes[0].put(TAG_IMAGE_LENGTH, createUShort); this.mAttributes[0].put(TAG_IMAGE_WIDTH, createUShort2); if (DEBUG) { Log.d(TAG, "Updated to length: " + ((int) readShort) + ", width: " + ((int) readShort2)); return; } return; } byteOrderedDataInputStream.skipBytes(readUnsignedShort2); } } private void getHeifAttributes(final ByteOrderedDataInputStream byteOrderedDataInputStream) throws IOException { String str; String str2; String str3; MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever(); try { mediaMetadataRetriever.setDataSource(new MediaDataSource() { // from class: androidx.exifinterface.media.ExifInterface.1 long mPosition; @Override // java.io.Closeable, java.lang.AutoCloseable public void close() throws IOException { } @Override // android.media.MediaDataSource public long getSize() throws IOException { return -1L; } @Override // android.media.MediaDataSource public int readAt(long j, byte[] bArr, int i, int i2) throws IOException { if (i2 == 0) { return 0; } if (j < 0) { return -1; } try { long j2 = this.mPosition; if (j2 != j) { if (j2 >= 0 && j >= j2 + byteOrderedDataInputStream.available()) { return -1; } byteOrderedDataInputStream.seek(j); this.mPosition = j; } if (i2 > byteOrderedDataInputStream.available()) { i2 = byteOrderedDataInputStream.available(); } int read = byteOrderedDataInputStream.read(bArr, i, i2); if (read >= 0) { this.mPosition += read; return read; } } catch (IOException unused) { } this.mPosition = -1L; return -1; } }); String extractMetadata = mediaMetadataRetriever.extractMetadata(33); String extractMetadata2 = mediaMetadataRetriever.extractMetadata(34); String extractMetadata3 = mediaMetadataRetriever.extractMetadata(26); String extractMetadata4 = mediaMetadataRetriever.extractMetadata(17); if ("yes".equals(extractMetadata3)) { str = mediaMetadataRetriever.extractMetadata(29); str2 = mediaMetadataRetriever.extractMetadata(30); str3 = mediaMetadataRetriever.extractMetadata(31); } else if ("yes".equals(extractMetadata4)) { str = mediaMetadataRetriever.extractMetadata(18); str2 = mediaMetadataRetriever.extractMetadata(19); str3 = mediaMetadataRetriever.extractMetadata(24); } else { str = null; str2 = null; str3 = null; } if (str != null) { this.mAttributes[0].put(TAG_IMAGE_WIDTH, ExifAttribute.createUShort(Integer.parseInt(str), this.mExifByteOrder)); } if (str2 != null) { this.mAttributes[0].put(TAG_IMAGE_LENGTH, ExifAttribute.createUShort(Integer.parseInt(str2), this.mExifByteOrder)); } if (str3 != null) { int parseInt = Integer.parseInt(str3); this.mAttributes[0].put(TAG_ORIENTATION, ExifAttribute.createUShort(parseInt != 90 ? parseInt != 180 ? parseInt != 270 ? 1 : 8 : 3 : 6, this.mExifByteOrder)); } if (extractMetadata != null && extractMetadata2 != null) { int parseInt2 = Integer.parseInt(extractMetadata); int parseInt3 = Integer.parseInt(extractMetadata2); if (parseInt3 <= 6) { throw new IOException("Invalid exif length"); } byteOrderedDataInputStream.seek(parseInt2); byte[] bArr = new byte[6]; if (byteOrderedDataInputStream.read(bArr) != 6) { throw new IOException("Can't read identifier"); } int i = parseInt3 - 6; if (!Arrays.equals(bArr, IDENTIFIER_EXIF_APP1)) { throw new IOException("Invalid identifier"); } byte[] bArr2 = new byte[i]; if (byteOrderedDataInputStream.read(bArr2) != i) { throw new IOException("Can't read exif"); } readExifSegment(bArr2, 0); } if (DEBUG) { Log.d(TAG, "Heif meta: " + str + ViewHierarchyNode.JsonKeys.X + str2 + ", rotation " + str3); } } finally { mediaMetadataRetriever.release(); } } private void getOrfAttributes(ByteOrderedDataInputStream byteOrderedDataInputStream) throws IOException { int i; int i2; getRawAttributes(byteOrderedDataInputStream); ExifAttribute exifAttribute = this.mAttributes[1].get(TAG_MAKER_NOTE); if (exifAttribute != null) { ByteOrderedDataInputStream byteOrderedDataInputStream2 = new ByteOrderedDataInputStream(exifAttribute.bytes); byteOrderedDataInputStream2.setByteOrder(this.mExifByteOrder); byte[] bArr = ORF_MAKER_NOTE_HEADER_1; byte[] bArr2 = new byte[bArr.length]; byteOrderedDataInputStream2.readFully(bArr2); byteOrderedDataInputStream2.seek(0L); byte[] bArr3 = ORF_MAKER_NOTE_HEADER_2; byte[] bArr4 = new byte[bArr3.length]; byteOrderedDataInputStream2.readFully(bArr4); if (Arrays.equals(bArr2, bArr)) { byteOrderedDataInputStream2.seek(8L); } else if (Arrays.equals(bArr4, bArr3)) { byteOrderedDataInputStream2.seek(12L); } readImageFileDirectory(byteOrderedDataInputStream2, 6); ExifAttribute exifAttribute2 = this.mAttributes[7].get(TAG_ORF_PREVIEW_IMAGE_START); ExifAttribute exifAttribute3 = this.mAttributes[7].get(TAG_ORF_PREVIEW_IMAGE_LENGTH); if (exifAttribute2 != null && exifAttribute3 != null) { this.mAttributes[5].put(TAG_JPEG_INTERCHANGE_FORMAT, exifAttribute2); this.mAttributes[5].put(TAG_JPEG_INTERCHANGE_FORMAT_LENGTH, exifAttribute3); } ExifAttribute exifAttribute4 = this.mAttributes[8].get(TAG_ORF_ASPECT_FRAME); if (exifAttribute4 != null) { int[] iArr = (int[]) exifAttribute4.getValue(this.mExifByteOrder); if (iArr == null || iArr.length != 4) { Log.w(TAG, "Invalid aspect frame values. frame=" + Arrays.toString(iArr)); return; } int i3 = iArr[2]; int i4 = iArr[0]; if (i3 <= i4 || (i = iArr[3]) <= (i2 = iArr[1])) { return; } int i5 = (i3 - i4) + 1; int i6 = (i - i2) + 1; if (i5 < i6) { int i7 = i5 + i6; i6 = i7 - i6; i5 = i7 - i6; } ExifAttribute createUShort = ExifAttribute.createUShort(i5, this.mExifByteOrder); ExifAttribute createUShort2 = ExifAttribute.createUShort(i6, this.mExifByteOrder); this.mAttributes[0].put(TAG_IMAGE_WIDTH, createUShort); this.mAttributes[0].put(TAG_IMAGE_LENGTH, createUShort2); } } } private void getRw2Attributes(ByteOrderedDataInputStream byteOrderedDataInputStream) throws IOException { getRawAttributes(byteOrderedDataInputStream); if (this.mAttributes[0].get(TAG_RW2_JPG_FROM_RAW) != null) { getJpegAttributes(byteOrderedDataInputStream, this.mRw2JpgFromRawOffset, 5); } ExifAttribute exifAttribute = this.mAttributes[0].get(TAG_RW2_ISO); ExifAttribute exifAttribute2 = this.mAttributes[1].get(TAG_PHOTOGRAPHIC_SENSITIVITY); if (exifAttribute == null || exifAttribute2 != null) { return; } this.mAttributes[1].put(TAG_PHOTOGRAPHIC_SENSITIVITY, exifAttribute); } private void saveJpegAttributes(InputStream inputStream, OutputStream outputStream) throws IOException { if (DEBUG) { Log.d(TAG, "saveJpegAttributes starting with (inputStream: " + inputStream + ", outputStream: " + outputStream + ")"); } DataInputStream dataInputStream = new DataInputStream(inputStream); ByteOrderedDataOutputStream byteOrderedDataOutputStream = new ByteOrderedDataOutputStream(outputStream, ByteOrder.BIG_ENDIAN); if (dataInputStream.readByte() != -1) { throw new IOException("Invalid marker"); } byteOrderedDataOutputStream.writeByte(-1); if (dataInputStream.readByte() != -40) { throw new IOException("Invalid marker"); } byteOrderedDataOutputStream.writeByte(-40); byteOrderedDataOutputStream.writeByte(-1); byteOrderedDataOutputStream.writeByte(-31); writeExifSegment(byteOrderedDataOutputStream, 6); byte[] bArr = new byte[4096]; while (dataInputStream.readByte() == -1) { byte readByte = dataInputStream.readByte(); if (readByte == -39 || readByte == -38) { byteOrderedDataOutputStream.writeByte(-1); byteOrderedDataOutputStream.writeByte(readByte); copy(dataInputStream, byteOrderedDataOutputStream); return; } if (readByte == -31) { int readUnsignedShort = dataInputStream.readUnsignedShort(); int i = readUnsignedShort - 2; if (i < 0) { throw new IOException("Invalid length"); } byte[] bArr2 = new byte[6]; if (i >= 6) { if (dataInputStream.read(bArr2) != 6) { throw new IOException("Invalid exif"); } if (Arrays.equals(bArr2, IDENTIFIER_EXIF_APP1)) { int i2 = readUnsignedShort - 8; if (dataInputStream.skipBytes(i2) != i2) { throw new IOException("Invalid length"); } } } byteOrderedDataOutputStream.writeByte(-1); byteOrderedDataOutputStream.writeByte(readByte); byteOrderedDataOutputStream.writeUnsignedShort(readUnsignedShort); if (i >= 6) { i = readUnsignedShort - 8; byteOrderedDataOutputStream.write(bArr2); } while (i > 0) { int read = dataInputStream.read(bArr, 0, Math.min(i, 4096)); if (read >= 0) { byteOrderedDataOutputStream.write(bArr, 0, read); i -= read; } } } else { byteOrderedDataOutputStream.writeByte(-1); byteOrderedDataOutputStream.writeByte(readByte); int readUnsignedShort2 = dataInputStream.readUnsignedShort(); byteOrderedDataOutputStream.writeUnsignedShort(readUnsignedShort2); int i3 = readUnsignedShort2 - 2; if (i3 < 0) { throw new IOException("Invalid length"); } while (i3 > 0) { int read2 = dataInputStream.read(bArr, 0, Math.min(i3, 4096)); if (read2 >= 0) { byteOrderedDataOutputStream.write(bArr, 0, read2); i3 -= read2; } } } } throw new IOException("Invalid marker"); } private void readExifSegment(byte[] bArr, int i) throws IOException { ByteOrderedDataInputStream byteOrderedDataInputStream = new ByteOrderedDataInputStream(bArr); parseTiffHeaders(byteOrderedDataInputStream, bArr.length); readImageFileDirectory(byteOrderedDataInputStream, i); } private void addDefaultValuesForCompatibility() { String attribute = getAttribute(TAG_DATETIME_ORIGINAL); if (attribute != null && getAttribute(TAG_DATETIME) == null) { this.mAttributes[0].put(TAG_DATETIME, ExifAttribute.createString(attribute)); } if (getAttribute(TAG_IMAGE_WIDTH) == null) { this.mAttributes[0].put(TAG_IMAGE_WIDTH, ExifAttribute.createULong(0L, this.mExifByteOrder)); } if (getAttribute(TAG_IMAGE_LENGTH) == null) { this.mAttributes[0].put(TAG_IMAGE_LENGTH, ExifAttribute.createULong(0L, this.mExifByteOrder)); } if (getAttribute(TAG_ORIENTATION) == null) { this.mAttributes[0].put(TAG_ORIENTATION, ExifAttribute.createULong(0L, this.mExifByteOrder)); } if (getAttribute(TAG_LIGHT_SOURCE) == null) { this.mAttributes[1].put(TAG_LIGHT_SOURCE, ExifAttribute.createULong(0L, this.mExifByteOrder)); } } private ByteOrder readByteOrder(ByteOrderedDataInputStream byteOrderedDataInputStream) throws IOException { short readShort = byteOrderedDataInputStream.readShort(); if (readShort == 18761) { if (DEBUG) { Log.d(TAG, "readExifSegment: Byte Align II"); } return ByteOrder.LITTLE_ENDIAN; } if (readShort == 19789) { if (DEBUG) { Log.d(TAG, "readExifSegment: Byte Align MM"); } return ByteOrder.BIG_ENDIAN; } throw new IOException("Invalid byte order: " + Integer.toHexString(readShort)); } private void parseTiffHeaders(ByteOrderedDataInputStream byteOrderedDataInputStream, int i) throws IOException { ByteOrder readByteOrder = readByteOrder(byteOrderedDataInputStream); this.mExifByteOrder = readByteOrder; byteOrderedDataInputStream.setByteOrder(readByteOrder); int readUnsignedShort = byteOrderedDataInputStream.readUnsignedShort(); int i2 = this.mMimeType; if (i2 != 7 && i2 != 10 && readUnsignedShort != 42) { throw new IOException("Invalid start code: " + Integer.toHexString(readUnsignedShort)); } int readInt = byteOrderedDataInputStream.readInt(); if (readInt < 8 || readInt >= i) { throw new IOException("Invalid first Ifd offset: " + readInt); } int i3 = readInt - 8; if (i3 > 0 && byteOrderedDataInputStream.skipBytes(i3) != i3) { throw new IOException("Couldn't jump to first Ifd: " + i3); } } /* JADX WARN: Code restructure failed: missing block: B:90:0x0366, code lost: if (r5.getIntValue(r29.mExifByteOrder) == 65535) goto L130; */ /* JADX WARN: Removed duplicated region for block: B:28:0x0149 */ /* JADX WARN: Removed duplicated region for block: B:31:0x0154 */ /* JADX WARN: Removed duplicated region for block: B:61:0x0289 */ /* JADX WARN: Removed duplicated region for block: B:74:0x02e8 */ /* JADX WARN: Removed duplicated region for block: B:94:0x0373 */ /* JADX WARN: Removed duplicated region for block: B:96:0x0376 A[SYNTHETIC] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private void readImageFileDirectory(androidx.exifinterface.media.ExifInterface.ByteOrderedDataInputStream r30, int r31) throws java.io.IOException { /* Method dump skipped, instructions count: 1030 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: androidx.exifinterface.media.ExifInterface.readImageFileDirectory(androidx.exifinterface.media.ExifInterface$ByteOrderedDataInputStream, int):void"); } private void retrieveJpegImageSize(ByteOrderedDataInputStream byteOrderedDataInputStream, int i) throws IOException { ExifAttribute exifAttribute; ExifAttribute exifAttribute2 = this.mAttributes[i].get(TAG_IMAGE_LENGTH); ExifAttribute exifAttribute3 = this.mAttributes[i].get(TAG_IMAGE_WIDTH); if ((exifAttribute2 == null || exifAttribute3 == null) && (exifAttribute = this.mAttributes[i].get(TAG_JPEG_INTERCHANGE_FORMAT)) != null) { getJpegAttributes(byteOrderedDataInputStream, exifAttribute.getIntValue(this.mExifByteOrder), i); } } private void setThumbnailData(ByteOrderedDataInputStream byteOrderedDataInputStream) throws IOException { HashMap hashMap = this.mAttributes[4]; ExifAttribute exifAttribute = hashMap.get(TAG_COMPRESSION); if (exifAttribute != null) { int intValue = exifAttribute.getIntValue(this.mExifByteOrder); this.mThumbnailCompression = intValue; if (intValue != 1) { if (intValue == 6) { handleThumbnailFromJfif(byteOrderedDataInputStream, hashMap); return; } else if (intValue != 7) { return; } } if (isSupportedDataType(hashMap)) { handleThumbnailFromStrips(byteOrderedDataInputStream, hashMap); return; } return; } this.mThumbnailCompression = 6; handleThumbnailFromJfif(byteOrderedDataInputStream, hashMap); } /* JADX WARN: Removed duplicated region for block: B:16:0x0044 */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private void handleThumbnailFromJfif(androidx.exifinterface.media.ExifInterface.ByteOrderedDataInputStream r4, java.util.HashMap r5) throws java.io.IOException { /* r3 = this; java.lang.String r0 = "JPEGInterchangeFormat" java.lang.Object r0 = r5.get(r0) androidx.exifinterface.media.ExifInterface$ExifAttribute r0 = (androidx.exifinterface.media.ExifInterface.ExifAttribute) r0 java.lang.String r1 = "JPEGInterchangeFormatLength" java.lang.Object r5 = r5.get(r1) androidx.exifinterface.media.ExifInterface$ExifAttribute r5 = (androidx.exifinterface.media.ExifInterface.ExifAttribute) r5 if (r0 == 0) goto L84 if (r5 == 0) goto L84 java.nio.ByteOrder r1 = r3.mExifByteOrder int r0 = r0.getIntValue(r1) java.nio.ByteOrder r1 = r3.mExifByteOrder int r5 = r5.getIntValue(r1) int r1 = r4.getLength() int r1 = r1 - r0 int r5 = java.lang.Math.min(r5, r1) int r1 = r3.mMimeType r2 = 4 if (r1 == r2) goto L3d r2 = 9 if (r1 == r2) goto L3d r2 = 10 if (r1 != r2) goto L37 goto L3d L37: r2 = 7 if (r1 != r2) goto L40 int r1 = r3.mOrfMakerNoteOffset goto L3f L3d: int r1 = r3.mExifOffset L3f: int r0 = r0 + r1 L40: boolean r1 = androidx.exifinterface.media.ExifInterface.DEBUG if (r1 == 0) goto L62 java.lang.StringBuilder r1 = new java.lang.StringBuilder java.lang.String r2 = "Setting thumbnail attributes with offset: " r1.(r2) java.lang.StringBuilder r1 = r1.append(r0) java.lang.String r2 = ", length: " java.lang.StringBuilder r1 = r1.append(r2) java.lang.StringBuilder r1 = r1.append(r5) java.lang.String r1 = r1.toString() java.lang.String r2 = "ExifInterface" android.util.Log.d(r2, r1) L62: if (r0 <= 0) goto L84 if (r5 <= 0) goto L84 r1 = 1 r3.mHasThumbnail = r1 r3.mThumbnailOffset = r0 r3.mThumbnailLength = r5 java.lang.String r1 = r3.mFilename if (r1 != 0) goto L84 android.content.res.AssetManager$AssetInputStream r1 = r3.mAssetInputStream if (r1 != 0) goto L84 java.io.FileDescriptor r1 = r3.mSeekableFileDescriptor if (r1 != 0) goto L84 byte[] r5 = new byte[r5] long r0 = (long) r0 r4.seek(r0) r4.readFully(r5) r3.mThumbnailBytes = r5 L84: return */ throw new UnsupportedOperationException("Method not decompiled: androidx.exifinterface.media.ExifInterface.handleThumbnailFromJfif(androidx.exifinterface.media.ExifInterface$ByteOrderedDataInputStream, java.util.HashMap):void"); } private void handleThumbnailFromStrips(ByteOrderedDataInputStream byteOrderedDataInputStream, HashMap hashMap) throws IOException { ExifAttribute exifAttribute = (ExifAttribute) hashMap.get(TAG_STRIP_OFFSETS); ExifAttribute exifAttribute2 = (ExifAttribute) hashMap.get(TAG_STRIP_BYTE_COUNTS); if (exifAttribute == null || exifAttribute2 == null) { return; } long[] convertToLongArray = convertToLongArray(exifAttribute.getValue(this.mExifByteOrder)); long[] convertToLongArray2 = convertToLongArray(exifAttribute2.getValue(this.mExifByteOrder)); if (convertToLongArray == null) { Log.w(TAG, "stripOffsets should not be null."); return; } if (convertToLongArray2 == null) { Log.w(TAG, "stripByteCounts should not be null."); return; } long j = 0; for (long j2 : convertToLongArray2) { j += j2; } int i = (int) j; byte[] bArr = new byte[i]; int i2 = 0; int i3 = 0; for (int i4 = 0; i4 < convertToLongArray.length; i4++) { int i5 = (int) convertToLongArray[i4]; int i6 = (int) convertToLongArray2[i4]; int i7 = i5 - i2; if (i7 < 0) { Log.d(TAG, "Invalid strip offset value"); } byteOrderedDataInputStream.seek(i7); int i8 = i2 + i7; byte[] bArr2 = new byte[i6]; byteOrderedDataInputStream.read(bArr2); i2 = i8 + i6; System.arraycopy(bArr2, 0, bArr, i3, i6); i3 += i6; } this.mHasThumbnail = true; this.mThumbnailBytes = bArr; this.mThumbnailLength = i; } private boolean isSupportedDataType(HashMap hashMap) throws IOException { ExifAttribute exifAttribute; int intValue; ExifAttribute exifAttribute2 = (ExifAttribute) hashMap.get(TAG_BITS_PER_SAMPLE); if (exifAttribute2 != null) { int[] iArr = (int[]) exifAttribute2.getValue(this.mExifByteOrder); int[] iArr2 = BITS_PER_SAMPLE_RGB; if (Arrays.equals(iArr2, iArr)) { return true; } if (this.mMimeType == 3 && (exifAttribute = (ExifAttribute) hashMap.get(TAG_PHOTOMETRIC_INTERPRETATION)) != null && (((intValue = exifAttribute.getIntValue(this.mExifByteOrder)) == 1 && Arrays.equals(iArr, BITS_PER_SAMPLE_GREYSCALE_2)) || (intValue == 6 && Arrays.equals(iArr, iArr2)))) { return true; } } if (!DEBUG) { return false; } Log.d(TAG, "Unsupported data type value"); return false; } private boolean isThumbnail(HashMap hashMap) throws IOException { ExifAttribute exifAttribute = (ExifAttribute) hashMap.get(TAG_IMAGE_LENGTH); ExifAttribute exifAttribute2 = (ExifAttribute) hashMap.get(TAG_IMAGE_WIDTH); if (exifAttribute == null || exifAttribute2 == null) { return false; } return exifAttribute.getIntValue(this.mExifByteOrder) <= 512 && exifAttribute2.getIntValue(this.mExifByteOrder) <= 512; } private void validateImages(InputStream inputStream) throws IOException { swapBasedOnImageSize(0, 5); swapBasedOnImageSize(0, 4); swapBasedOnImageSize(5, 4); ExifAttribute exifAttribute = this.mAttributes[1].get(TAG_PIXEL_X_DIMENSION); ExifAttribute exifAttribute2 = this.mAttributes[1].get(TAG_PIXEL_Y_DIMENSION); if (exifAttribute != null && exifAttribute2 != null) { this.mAttributes[0].put(TAG_IMAGE_WIDTH, exifAttribute); this.mAttributes[0].put(TAG_IMAGE_LENGTH, exifAttribute2); } if (this.mAttributes[4].isEmpty() && isThumbnail(this.mAttributes[5])) { HashMap[] hashMapArr = this.mAttributes; hashMapArr[4] = hashMapArr[5]; hashMapArr[5] = new HashMap<>(); } if (isThumbnail(this.mAttributes[4])) { return; } Log.d(TAG, "No image meets the size requirements of a thumbnail image."); } private void updateImageSizeValues(ByteOrderedDataInputStream byteOrderedDataInputStream, int i) throws IOException { ExifAttribute createUShort; ExifAttribute createUShort2; ExifAttribute exifAttribute = this.mAttributes[i].get(TAG_DEFAULT_CROP_SIZE); ExifAttribute exifAttribute2 = this.mAttributes[i].get(TAG_RW2_SENSOR_TOP_BORDER); ExifAttribute exifAttribute3 = this.mAttributes[i].get(TAG_RW2_SENSOR_LEFT_BORDER); ExifAttribute exifAttribute4 = this.mAttributes[i].get(TAG_RW2_SENSOR_BOTTOM_BORDER); ExifAttribute exifAttribute5 = this.mAttributes[i].get(TAG_RW2_SENSOR_RIGHT_BORDER); if (exifAttribute != null) { if (exifAttribute.format == 5) { Rational[] rationalArr = (Rational[]) exifAttribute.getValue(this.mExifByteOrder); if (rationalArr == null || rationalArr.length != 2) { Log.w(TAG, "Invalid crop size values. cropSize=" + Arrays.toString(rationalArr)); return; } else { createUShort = ExifAttribute.createURational(rationalArr[0], this.mExifByteOrder); createUShort2 = ExifAttribute.createURational(rationalArr[1], this.mExifByteOrder); } } else { int[] iArr = (int[]) exifAttribute.getValue(this.mExifByteOrder); if (iArr == null || iArr.length != 2) { Log.w(TAG, "Invalid crop size values. cropSize=" + Arrays.toString(iArr)); return; } else { createUShort = ExifAttribute.createUShort(iArr[0], this.mExifByteOrder); createUShort2 = ExifAttribute.createUShort(iArr[1], this.mExifByteOrder); } } this.mAttributes[i].put(TAG_IMAGE_WIDTH, createUShort); this.mAttributes[i].put(TAG_IMAGE_LENGTH, createUShort2); return; } if (exifAttribute2 != null && exifAttribute3 != null && exifAttribute4 != null && exifAttribute5 != null) { int intValue = exifAttribute2.getIntValue(this.mExifByteOrder); int intValue2 = exifAttribute4.getIntValue(this.mExifByteOrder); int intValue3 = exifAttribute5.getIntValue(this.mExifByteOrder); int intValue4 = exifAttribute3.getIntValue(this.mExifByteOrder); if (intValue2 <= intValue || intValue3 <= intValue4) { return; } ExifAttribute createUShort3 = ExifAttribute.createUShort(intValue2 - intValue, this.mExifByteOrder); ExifAttribute createUShort4 = ExifAttribute.createUShort(intValue3 - intValue4, this.mExifByteOrder); this.mAttributes[i].put(TAG_IMAGE_LENGTH, createUShort3); this.mAttributes[i].put(TAG_IMAGE_WIDTH, createUShort4); return; } retrieveJpegImageSize(byteOrderedDataInputStream, i); } private int writeExifSegment(ByteOrderedDataOutputStream byteOrderedDataOutputStream, int i) throws IOException { ExifTag[][] exifTagArr = EXIF_TAGS; int[] iArr = new int[exifTagArr.length]; int[] iArr2 = new int[exifTagArr.length]; for (ExifTag exifTag : EXIF_POINTER_TAGS) { removeAttribute(exifTag.name); } removeAttribute(JPEG_INTERCHANGE_FORMAT_TAG.name); removeAttribute(JPEG_INTERCHANGE_FORMAT_LENGTH_TAG.name); for (int i2 = 0; i2 < EXIF_TAGS.length; i2++) { for (Object obj : this.mAttributes[i2].entrySet().toArray()) { Map.Entry entry = (Map.Entry) obj; if (entry.getValue() == null) { this.mAttributes[i2].remove(entry.getKey()); } } } if (!this.mAttributes[1].isEmpty()) { this.mAttributes[0].put(EXIF_POINTER_TAGS[1].name, ExifAttribute.createULong(0L, this.mExifByteOrder)); } if (!this.mAttributes[2].isEmpty()) { this.mAttributes[0].put(EXIF_POINTER_TAGS[2].name, ExifAttribute.createULong(0L, this.mExifByteOrder)); } if (!this.mAttributes[3].isEmpty()) { this.mAttributes[1].put(EXIF_POINTER_TAGS[3].name, ExifAttribute.createULong(0L, this.mExifByteOrder)); } if (this.mHasThumbnail) { this.mAttributes[4].put(JPEG_INTERCHANGE_FORMAT_TAG.name, ExifAttribute.createULong(0L, this.mExifByteOrder)); this.mAttributes[4].put(JPEG_INTERCHANGE_FORMAT_LENGTH_TAG.name, ExifAttribute.createULong(this.mThumbnailLength, this.mExifByteOrder)); } for (int i3 = 0; i3 < EXIF_TAGS.length; i3++) { Iterator> it = this.mAttributes[i3].entrySet().iterator(); int i4 = 0; while (it.hasNext()) { int size = it.next().getValue().size(); if (size > 4) { i4 += size; } } iArr2[i3] = iArr2[i3] + i4; } int i5 = 8; for (int i6 = 0; i6 < EXIF_TAGS.length; i6++) { if (!this.mAttributes[i6].isEmpty()) { iArr[i6] = i5; i5 += (this.mAttributes[i6].size() * 12) + 6 + iArr2[i6]; } } if (this.mHasThumbnail) { this.mAttributes[4].put(JPEG_INTERCHANGE_FORMAT_TAG.name, ExifAttribute.createULong(i5, this.mExifByteOrder)); this.mThumbnailOffset = i + i5; i5 += this.mThumbnailLength; } int i7 = i5 + 8; if (DEBUG) { Log.d(TAG, "totalSize length: " + i7); for (int i8 = 0; i8 < EXIF_TAGS.length; i8++) { Log.d(TAG, String.format("index: %d, offsets: %d, tag count: %d, data sizes: %d", Integer.valueOf(i8), Integer.valueOf(iArr[i8]), Integer.valueOf(this.mAttributes[i8].size()), Integer.valueOf(iArr2[i8]))); } } if (!this.mAttributes[1].isEmpty()) { this.mAttributes[0].put(EXIF_POINTER_TAGS[1].name, ExifAttribute.createULong(iArr[1], this.mExifByteOrder)); } if (!this.mAttributes[2].isEmpty()) { this.mAttributes[0].put(EXIF_POINTER_TAGS[2].name, ExifAttribute.createULong(iArr[2], this.mExifByteOrder)); } if (!this.mAttributes[3].isEmpty()) { this.mAttributes[1].put(EXIF_POINTER_TAGS[3].name, ExifAttribute.createULong(iArr[3], this.mExifByteOrder)); } byteOrderedDataOutputStream.writeUnsignedShort(i7); byteOrderedDataOutputStream.write(IDENTIFIER_EXIF_APP1); byteOrderedDataOutputStream.writeShort(this.mExifByteOrder == ByteOrder.BIG_ENDIAN ? BYTE_ALIGN_MM : BYTE_ALIGN_II); byteOrderedDataOutputStream.setByteOrder(this.mExifByteOrder); byteOrderedDataOutputStream.writeUnsignedShort(42); byteOrderedDataOutputStream.writeUnsignedInt(8L); for (int i9 = 0; i9 < EXIF_TAGS.length; i9++) { if (!this.mAttributes[i9].isEmpty()) { byteOrderedDataOutputStream.writeUnsignedShort(this.mAttributes[i9].size()); int size2 = iArr[i9] + 2 + (this.mAttributes[i9].size() * 12) + 4; for (Map.Entry entry2 : this.mAttributes[i9].entrySet()) { int i10 = sExifTagMapsForWriting[i9].get(entry2.getKey()).number; ExifAttribute value = entry2.getValue(); int size3 = value.size(); byteOrderedDataOutputStream.writeUnsignedShort(i10); byteOrderedDataOutputStream.writeUnsignedShort(value.format); byteOrderedDataOutputStream.writeInt(value.numberOfComponents); if (size3 > 4) { byteOrderedDataOutputStream.writeUnsignedInt(size2); size2 += size3; } else { byteOrderedDataOutputStream.write(value.bytes); if (size3 < 4) { while (size3 < 4) { byteOrderedDataOutputStream.writeByte(0); size3++; } } } } if (i9 == 0 && !this.mAttributes[4].isEmpty()) { byteOrderedDataOutputStream.writeUnsignedInt(iArr[4]); } else { byteOrderedDataOutputStream.writeUnsignedInt(0L); } Iterator> it2 = this.mAttributes[i9].entrySet().iterator(); while (it2.hasNext()) { ExifAttribute value2 = it2.next().getValue(); if (value2.bytes.length > 4) { byteOrderedDataOutputStream.write(value2.bytes, 0, value2.bytes.length); } } } } if (this.mHasThumbnail) { byteOrderedDataOutputStream.write(getThumbnailBytes()); } byteOrderedDataOutputStream.setByteOrder(ByteOrder.BIG_ENDIAN); return i7; } private static Pair guessDataFormat(String str) { if (str.contains(",")) { String[] split = str.split(",", -1); Pair guessDataFormat = guessDataFormat(split[0]); if (((Integer) guessDataFormat.first).intValue() == 2) { return guessDataFormat; } for (int i = 1; i < split.length; i++) { Pair guessDataFormat2 = guessDataFormat(split[i]); int intValue = (((Integer) guessDataFormat2.first).equals(guessDataFormat.first) || ((Integer) guessDataFormat2.second).equals(guessDataFormat.first)) ? ((Integer) guessDataFormat.first).intValue() : -1; int intValue2 = (((Integer) guessDataFormat.second).intValue() == -1 || !(((Integer) guessDataFormat2.first).equals(guessDataFormat.second) || ((Integer) guessDataFormat2.second).equals(guessDataFormat.second))) ? -1 : ((Integer) guessDataFormat.second).intValue(); if (intValue == -1 && intValue2 == -1) { return new Pair<>(2, -1); } if (intValue == -1) { guessDataFormat = new Pair<>(Integer.valueOf(intValue2), -1); } else if (intValue2 == -1) { guessDataFormat = new Pair<>(Integer.valueOf(intValue), -1); } } return guessDataFormat; } if (str.contains("/")) { String[] split2 = str.split("/", -1); if (split2.length == 2) { try { long parseDouble = (long) Double.parseDouble(split2[0]); long parseDouble2 = (long) Double.parseDouble(split2[1]); if (parseDouble >= 0 && parseDouble2 >= 0) { if (parseDouble <= 2147483647L && parseDouble2 <= 2147483647L) { return new Pair<>(10, 5); } return new Pair<>(5, -1); } return new Pair<>(10, -1); } catch (NumberFormatException unused) { } } return new Pair<>(2, -1); } try { try { Long valueOf = Long.valueOf(Long.parseLong(str)); if (valueOf.longValue() >= 0 && valueOf.longValue() <= WebSocketProtocol.PAYLOAD_SHORT_MAX) { return new Pair<>(3, 4); } if (valueOf.longValue() < 0) { return new Pair<>(9, -1); } return new Pair<>(4, -1); } catch (NumberFormatException unused2) { return new Pair<>(2, -1); } } catch (NumberFormatException unused3) { Double.parseDouble(str); return new Pair<>(12, -1); } } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes2.dex */ public static class ByteOrderedDataInputStream extends InputStream implements DataInput { private ByteOrder mByteOrder; private DataInputStream mDataInputStream; final int mLength; int mPosition; private static final ByteOrder LITTLE_ENDIAN = ByteOrder.LITTLE_ENDIAN; private static final ByteOrder BIG_ENDIAN = ByteOrder.BIG_ENDIAN; public int getLength() { return this.mLength; } public int peek() { return this.mPosition; } public void setByteOrder(ByteOrder byteOrder) { this.mByteOrder = byteOrder; } public ByteOrderedDataInputStream(InputStream inputStream) throws IOException { this.mByteOrder = ByteOrder.BIG_ENDIAN; DataInputStream dataInputStream = new DataInputStream(inputStream); this.mDataInputStream = dataInputStream; int available = dataInputStream.available(); this.mLength = available; this.mPosition = 0; this.mDataInputStream.mark(available); } public ByteOrderedDataInputStream(byte[] bArr) throws IOException { this(new ByteArrayInputStream(bArr)); } public void seek(long j) throws IOException { int i = this.mPosition; if (i > j) { this.mPosition = 0; this.mDataInputStream.reset(); this.mDataInputStream.mark(this.mLength); } else { j -= i; } int i2 = (int) j; if (skipBytes(i2) != i2) { throw new IOException("Couldn't seek up to the byteCount"); } } @Override // java.io.InputStream public int available() throws IOException { return this.mDataInputStream.available(); } @Override // java.io.InputStream public int read() throws IOException { this.mPosition++; return this.mDataInputStream.read(); } @Override // java.io.InputStream public int read(byte[] bArr, int i, int i2) throws IOException { int read = this.mDataInputStream.read(bArr, i, i2); this.mPosition += read; return read; } @Override // java.io.DataInput public int readUnsignedByte() throws IOException { this.mPosition++; return this.mDataInputStream.readUnsignedByte(); } @Override // java.io.DataInput public String readLine() throws IOException { Log.d(ExifInterface.TAG, "Currently unsupported"); return null; } @Override // java.io.DataInput public boolean readBoolean() throws IOException { this.mPosition++; return this.mDataInputStream.readBoolean(); } @Override // java.io.DataInput public char readChar() throws IOException { this.mPosition += 2; return this.mDataInputStream.readChar(); } @Override // java.io.DataInput public String readUTF() throws IOException { this.mPosition += 2; return this.mDataInputStream.readUTF(); } @Override // java.io.DataInput public void readFully(byte[] bArr, int i, int i2) throws IOException { int i3 = this.mPosition + i2; this.mPosition = i3; if (i3 > this.mLength) { throw new EOFException(); } if (this.mDataInputStream.read(bArr, i, i2) != i2) { throw new IOException("Couldn't read up to the length of buffer"); } } @Override // java.io.DataInput public void readFully(byte[] bArr) throws IOException { int length = this.mPosition + bArr.length; this.mPosition = length; if (length > this.mLength) { throw new EOFException(); } if (this.mDataInputStream.read(bArr, 0, bArr.length) != bArr.length) { throw new IOException("Couldn't read up to the length of buffer"); } } @Override // java.io.DataInput public byte readByte() throws IOException { int i = this.mPosition + 1; this.mPosition = i; if (i > this.mLength) { throw new EOFException(); } int read = this.mDataInputStream.read(); if (read >= 0) { return (byte) read; } throw new EOFException(); } @Override // java.io.DataInput public short readShort() throws IOException { int i; int i2 = this.mPosition + 2; this.mPosition = i2; if (i2 > this.mLength) { throw new EOFException(); } int read = this.mDataInputStream.read(); int read2 = this.mDataInputStream.read(); if ((read | read2) < 0) { throw new EOFException(); } ByteOrder byteOrder = this.mByteOrder; if (byteOrder == LITTLE_ENDIAN) { i = (read2 << 8) + read; } else { if (byteOrder != BIG_ENDIAN) { throw new IOException("Invalid byte order: " + this.mByteOrder); } i = (read << 8) + read2; } return (short) i; } @Override // java.io.DataInput public int readInt() throws IOException { int i = this.mPosition + 4; this.mPosition = i; if (i > this.mLength) { throw new EOFException(); } int read = this.mDataInputStream.read(); int read2 = this.mDataInputStream.read(); int read3 = this.mDataInputStream.read(); int read4 = this.mDataInputStream.read(); if ((read | read2 | read3 | read4) < 0) { throw new EOFException(); } ByteOrder byteOrder = this.mByteOrder; if (byteOrder == LITTLE_ENDIAN) { return (read4 << 24) + (read3 << 16) + (read2 << 8) + read; } if (byteOrder == BIG_ENDIAN) { return (read << 24) + (read2 << 16) + (read3 << 8) + read4; } throw new IOException("Invalid byte order: " + this.mByteOrder); } @Override // java.io.DataInput public int skipBytes(int i) throws IOException { int min = Math.min(i, this.mLength - this.mPosition); int i2 = 0; while (i2 < min) { i2 += this.mDataInputStream.skipBytes(min - i2); } this.mPosition += i2; return i2; } @Override // java.io.DataInput public int readUnsignedShort() throws IOException { int i = this.mPosition + 2; this.mPosition = i; if (i > this.mLength) { throw new EOFException(); } int read = this.mDataInputStream.read(); int read2 = this.mDataInputStream.read(); if ((read | read2) < 0) { throw new EOFException(); } ByteOrder byteOrder = this.mByteOrder; if (byteOrder == LITTLE_ENDIAN) { return (read2 << 8) + read; } if (byteOrder == BIG_ENDIAN) { return (read << 8) + read2; } throw new IOException("Invalid byte order: " + this.mByteOrder); } public long readUnsignedInt() throws IOException { return readInt() & KeyboardMap.kValueMask; } @Override // java.io.DataInput public long readLong() throws IOException { int i = this.mPosition + 8; this.mPosition = i; if (i > this.mLength) { throw new EOFException(); } int read = this.mDataInputStream.read(); int read2 = this.mDataInputStream.read(); int read3 = this.mDataInputStream.read(); int read4 = this.mDataInputStream.read(); int read5 = this.mDataInputStream.read(); int read6 = this.mDataInputStream.read(); int read7 = this.mDataInputStream.read(); int read8 = this.mDataInputStream.read(); if ((read | read2 | read3 | read4 | read5 | read6 | read7 | read8) < 0) { throw new EOFException(); } ByteOrder byteOrder = this.mByteOrder; if (byteOrder == LITTLE_ENDIAN) { return (read8 << 56) + (read7 << 48) + (read6 << 40) + (read5 << 32) + (read4 << 24) + (read3 << 16) + (read2 << 8) + read; } if (byteOrder == BIG_ENDIAN) { return (read << 56) + (read2 << 48) + (read3 << 40) + (read4 << 32) + (read5 << 24) + (read6 << 16) + (read7 << 8) + read8; } throw new IOException("Invalid byte order: " + this.mByteOrder); } @Override // java.io.DataInput public float readFloat() throws IOException { return Float.intBitsToFloat(readInt()); } @Override // java.io.DataInput public double readDouble() throws IOException { return Double.longBitsToDouble(readLong()); } } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes2.dex */ public static class ByteOrderedDataOutputStream extends FilterOutputStream { private ByteOrder mByteOrder; private final OutputStream mOutputStream; public void setByteOrder(ByteOrder byteOrder) { this.mByteOrder = byteOrder; } public ByteOrderedDataOutputStream(OutputStream outputStream, ByteOrder byteOrder) { super(outputStream); this.mOutputStream = outputStream; this.mByteOrder = byteOrder; } @Override // java.io.FilterOutputStream, java.io.OutputStream public void write(byte[] bArr) throws IOException { this.mOutputStream.write(bArr); } @Override // java.io.FilterOutputStream, java.io.OutputStream public void write(byte[] bArr, int i, int i2) throws IOException { this.mOutputStream.write(bArr, i, i2); } public void writeByte(int i) throws IOException { this.mOutputStream.write(i); } public void writeShort(short s) throws IOException { if (this.mByteOrder == ByteOrder.LITTLE_ENDIAN) { this.mOutputStream.write(s & 255); this.mOutputStream.write((s >>> 8) & 255); } else if (this.mByteOrder == ByteOrder.BIG_ENDIAN) { this.mOutputStream.write((s >>> 8) & 255); this.mOutputStream.write(s & 255); } } public void writeInt(int i) throws IOException { if (this.mByteOrder == ByteOrder.LITTLE_ENDIAN) { this.mOutputStream.write(i & 255); this.mOutputStream.write((i >>> 8) & 255); this.mOutputStream.write((i >>> 16) & 255); this.mOutputStream.write((i >>> 24) & 255); return; } if (this.mByteOrder == ByteOrder.BIG_ENDIAN) { this.mOutputStream.write((i >>> 24) & 255); this.mOutputStream.write((i >>> 16) & 255); this.mOutputStream.write((i >>> 8) & 255); this.mOutputStream.write(i & 255); } } public void writeUnsignedShort(int i) throws IOException { writeShort((short) i); } public void writeUnsignedInt(long j) throws IOException { writeInt((int) j); } } private void swapBasedOnImageSize(int i, int i2) throws IOException { if (this.mAttributes[i].isEmpty() || this.mAttributes[i2].isEmpty()) { if (DEBUG) { Log.d(TAG, "Cannot perform swap since only one image data exists"); return; } return; } ExifAttribute exifAttribute = this.mAttributes[i].get(TAG_IMAGE_LENGTH); ExifAttribute exifAttribute2 = this.mAttributes[i].get(TAG_IMAGE_WIDTH); ExifAttribute exifAttribute3 = this.mAttributes[i2].get(TAG_IMAGE_LENGTH); ExifAttribute exifAttribute4 = this.mAttributes[i2].get(TAG_IMAGE_WIDTH); if (exifAttribute == null || exifAttribute2 == null) { if (DEBUG) { Log.d(TAG, "First image does not contain valid size information"); return; } return; } if (exifAttribute3 == null || exifAttribute4 == null) { if (DEBUG) { Log.d(TAG, "Second image does not contain valid size information"); return; } return; } int intValue = exifAttribute.getIntValue(this.mExifByteOrder); int intValue2 = exifAttribute2.getIntValue(this.mExifByteOrder); int intValue3 = exifAttribute3.getIntValue(this.mExifByteOrder); int intValue4 = exifAttribute4.getIntValue(this.mExifByteOrder); if (intValue >= intValue3 || intValue2 >= intValue4) { return; } HashMap[] hashMapArr = this.mAttributes; HashMap hashMap = hashMapArr[i]; hashMapArr[i] = hashMapArr[i2]; hashMapArr[i2] = hashMap; } private static void closeQuietly(Closeable closeable) { if (closeable != null) { try { closeable.close(); } catch (RuntimeException e) { throw e; } catch (Exception unused) { } } } private static void closeFileDescriptor(FileDescriptor fileDescriptor) { try { Os.close(fileDescriptor); } catch (Exception unused) { Log.e(TAG, "Error closing fd."); } } private static int copy(InputStream inputStream, OutputStream outputStream) throws IOException { byte[] bArr = new byte[8192]; int i = 0; while (true) { int read = inputStream.read(bArr); if (read == -1) { return i; } i += read; outputStream.write(bArr, 0, read); } } private static long[] convertToLongArray(Object obj) { if (obj instanceof int[]) { int[] iArr = (int[]) obj; long[] jArr = new long[iArr.length]; for (int i = 0; i < iArr.length; i++) { jArr[i] = iArr[i]; } return jArr; } if (obj instanceof long[]) { return (long[]) obj; } return null; } private static boolean startsWith(byte[] bArr, byte[] bArr2) { if (bArr == null || bArr2 == null || bArr.length < bArr2.length) { return false; } for (int i = 0; i < bArr2.length; i++) { if (bArr[i] != bArr2[i]) { return false; } } return true; } }