# Interface: com.pnfsoftware.jeb.core.units.code.android.IGenericUnpacker

Interface for a simple Android APK unpacker that will attempt to gather resources extracted at  runtime. An unpacker may be created via an [apk unit](IApkUnit#createGenericUnpacker()) or a  [dex decompiler unit](IDexDecompilerUnit#createGenericUnpacker()).

## Abstract Method: attemptUnpack
- throws: `com.pnfsoftware.jeb.core.units.code.android.ir.DexDecEvaluationException`

Description: Start the unpacking process. This method should be called only once. Customization or results  retrieval can be done via [#getEmulatedAndroid()](#getEmulatedAndroid()) and  [#getRecoveredDexHashes()](#getRecoveredDexHashes()).
throws: if unpacking emulation fails

## Abstract Method: formatMonitorReport
- parameter: `formatType`, type: `int`
- return type: `java.lang.String`

Description: Retrieve the unpacking report generated by the monitor \(if the monitor was enabled before  unpacking\).
parameter: formatType: 0=standard report; 1=short report; 2=detailed report
return: the formatted report

## Abstract Method: getEmulatedAndroid
- return type: `com.pnfsoftware.jeb.core.units.code.android.IEmulatedAndroid`

Description: Create or retrieve the emulator that will perform the unpacking task. This method may be  called before [#attemptUnpack()](#attemptUnpack()) to customize the emulator components, or after to  retrieve fine\-grained emulation results.
return: the emulated Android environment

## Abstract Method: getRecoveredArscHashes
- return type: `java.util.Collection<java.lang.String>`

Description: Retrieve the list of sha256 hashes of recovered APK resources.
return: a collection of sha256 hashes of the recovered arsc files

## Abstract Method: getRecoveredAssetHashes
- return type: `java.util.Collection<java.lang.String>`

Description: Retrieve the list of sha256 hashes of recovered assets.
return: a collection of sha256 hashes of the recovered assets

## Abstract Method: getRecoveredDexHashes
- return type: `java.util.Collection<java.lang.String>`

Description: This method can be used to retrieve the sha256 hashes of the dex files that were collected by  the emulator during unpacking. Note that additional dex units are created as well, as  children of the 'unpacked' container unit.
return: a collection of sha256 hashes of the recovered dex files

## Abstract Method: getRecoveredSoHashes
- return type: `java.util.Collection<java.lang.String>`

Description: This method can be used to retrieve the sha256 hashes of the native library \(so\) files that  were collected by the emulator during unpacking. Note that additional native units are  created as well, as children of the 'unpacked' container unit.
return: a collection of sha256 hashes of the recovered so files

## Abstract Method: setAllowExternalPlugins
- parameter: `allowed`, type: `boolean`

Description: Allow or disallow the use of external plugins \(of type `android-emu-hooks`\) by this  unpacker. By default, the use of external plugins is allowed.
parameter: allowed: true to allow external plugins

## Abstract Method: setAttemptResourcesRecovery
- parameter: `recoveryEnabled`, type: `boolean`
- parameter: `integrationEnabled`, type: `boolean`

Description: Allow the unpacker to recover protected APK resources, such as protected XML resources.  

  Note: at the moment, the unpacker is limited to the recovery of default configuration layouts.
parameter: recoveryEnabled: true to attempt the recovery of protected resources
parameter: integrationEnabled: true to integrate recovered resources to the APK unit's Resources tree

## Abstract Method: setIntegrateRecoveredDexFiles
- parameter: `integrateRecoveredDexFiles`, type: `boolean`

Description: Determine whether the unpacked dex files should be integrated into the primary Dex unit, to  allow their use during emulation.
parameter: integrateRecoveredDexFiles: true to integrate recovered dex files

## Abstract Method: setMaxExecutionTime
- parameter: `maxExecutionTime`, type: `long`

Description: Convenience method to set the maximum emulation time for [unpacking](#attemptUnpack()).  This method redirects to [IDState#setMaxDuration(long)](IDState#setMaxDuration(long)).
parameter: maxExecutionTime: a time in ms

## Abstract Method: setMonitorEvents
- parameter: `monitorEvents`, type: `boolean`

Description: Enable or disable the events monitor. If the monitor is enabled, a report may be collected  after the unpacking process.
parameter: monitorEvents: true to monitor events

## Abstract Method: setUseRecoveredSoFiles
- parameter: `useRecoveredSoFiles`, type: `boolean`

Description: Determine whether the unpacked native library \(so\) files should be analyzed and used during  emulation.
parameter: useRecoveredSoFiles: true to use recovered native libraries

## Abstract Method: shouldAttemptUnpack
- return type: `boolean`

Description: This heuristic may be called to determine whether [#attemptUnpack()](#attemptUnpack()) has a chance of  success. The result of this method should be considered a very loose indicator. If this  method is to be used, for better performance, it should be invoked before any other method of  this interface.
return: true if unpacking is likely to be useful

## Abstract Method: teardown

Description: This method should be called after a call to [#attemptUnpack()](#attemptUnpack()), when the unpacker and  its underlying resources are no longer needed.

