Reworked transparent layer & Corrected lifecycle

From ParanoidAndroid frameworks/base