Improve code style

* Add more new lines
* Always use brackets
* Reduce amount of if levels

Change-Id: I8f23e823021668296f57e4e15c50334a7ef40f44
diff --git a/app/src/main/java/masquerade/substratum/services/JobService.java b/app/src/main/java/masquerade/substratum/services/JobService.java
index 001ca03..cc19e3b 100644
--- a/app/src/main/java/masquerade/substratum/services/JobService.java
+++ b/app/src/main/java/masquerade/substratum/services/JobService.java
@@ -127,6 +127,7 @@
             mOMS = IOverlayManager.Stub.asInterface(
                     ServiceManager.getService("overlay"));
         }
+
         return mOMS;
     }
 
@@ -135,11 +136,16 @@
             mPM = IPackageManager.Stub.asInterface(
                     ServiceManager.getService("package"));
         }
+
         return mPM;
     }
 
     public static void log(String msg) {
-        if (DEBUG) Log.e(TAG, msg);
+        if (!DEBUG) {
+            return;
+        }
+
+        Log.e(TAG, msg);
     }
 
     @Override
@@ -204,44 +210,53 @@
         } else if (TextUtils.equals(command, COMMAND_VALUE_FONTS)) {
             String pid = intent.getStringExtra(FONTS_PID);
             String fileName = intent.getStringExtra(FONTS_FILENAME);
+
             jobs_to_add.add(new FontsJob(pid, fileName));
             jobs_to_add.add(new UiResetJob());
         } else if (TextUtils.equals(command, COMMAND_VALUE_AUDIO)) {
             String pid = intent.getStringExtra(AUDIO_PID);
             String fileName = intent.getStringExtra(AUDIO_FILENAME);
+
             jobs_to_add.add(new SoundsJob(pid, fileName));
             jobs_to_add.add(new UiResetJob());
         } else if (TextUtils.equals(command, COMMAND_VALUE_ENABLE)) {
             List<String> packages = intent.getStringArrayListExtra(ENABLE_LIST_KEY);
             jobs_to_add.addAll(packages.stream().map(Enabler::new).collect(Collectors.toList()));
+
             if (intent.getBooleanExtra(WITH_RESTART_UI_KEY, false)) {
                 jobs_to_add.add(new UiResetJob());
             }
         } else if (TextUtils.equals(command, COMMAND_VALUE_DISABLE)) {
             List<String> packages = intent.getStringArrayListExtra(DISABLE_LIST_KEY);
             jobs_to_add.addAll(packages.stream().map(Disabler::new).collect(Collectors.toList()));
+
             if (intent.getBooleanExtra(WITH_RESTART_UI_KEY, false)) {
                 jobs_to_add.add(new UiResetJob());
             }
         } else if (TextUtils.equals(command, COMMAND_VALUE_PRIORITY)) {
             List<String> packages = intent.getStringArrayListExtra(PRIORITY_LIST_KEY);
             jobs_to_add.add(new PriorityJob(packages));
+
             if (intent.getBooleanExtra(WITH_RESTART_UI_KEY, false)) {
                 jobs_to_add.add(new UiResetJob());
             }
         } else if (TextUtils.equals(command, COMMAND_VALUE_COPY)) {
             String source = intent.getStringExtra(SOURCE_FILE_KEY);
             String destination = intent.getStringExtra(DESTINATION_FILE_KEY);
+
             jobs_to_add.add(new CopyJob(source, destination));
         } else if (TextUtils.equals(command, COMMAND_VALUE_MOVE)) {
             String source = intent.getStringExtra(SOURCE_FILE_KEY);
             String destination = intent.getStringExtra(DESTINATION_FILE_KEY);
+
             jobs_to_add.add(new MoveJob(source, destination));
         } else if (TextUtils.equals(command, COMMAND_VALUE_MKDIR)) {
             String destination = intent.getStringExtra(DESTINATION_FILE_KEY);
+
             jobs_to_add.add(new MkdirJob(destination));
         } else if (TextUtils.equals(command, COMMAND_VALUE_DELETE)) {
             String dir = intent.getStringExtra(SOURCE_FILE_KEY);
+
             if (intent.getBooleanExtra(WITH_DELETE_PARENT_KEY, true)) {
                 jobs_to_add.add(new DeleteJob(dir));
             } else {
@@ -254,18 +269,22 @@
             List<String> disable = intent.getStringArrayListExtra(DISABLE_LIST_KEY);
             boolean restartUi = intent.getBooleanExtra(WITH_RESTART_UI_KEY, false);
             String profile = intent.getStringExtra(PROFILE_NAME_KEY);
+
             jobs_to_add.add(new ProfileJob(profile, disable, enable, restartUi));
         }
 
         if (jobs_to_add.size() > 0) {
             log("Adding new jobs to job queue");
+
             synchronized (mJobQueue) {
                 mJobQueue.addAll(jobs_to_add);
             }
+
             if (!mJobHandler.hasMessages(JobHandler.MESSAGE_CHECK_QUEUE)) {
                 mJobHandler.sendEmptyMessage(JobHandler.MESSAGE_CHECK_QUEUE);
             }
         }
+
         return START_NOT_STICKY;
     }
 
@@ -275,8 +294,7 @@
     }
 
     @Override
-    public void onDestroy() {
-    }
+    public void onDestroy() {}
 
     private boolean isProcessing() {
         return mJobQueue.size() > 0;
@@ -313,6 +331,7 @@
 
     private boolean isOverlayEnabled(String packageName) {
         boolean enabled = false;
+
         try {
             OverlayInfo info = getOMS().getOverlayInfo(packageName, UserHandle.USER_SYSTEM);
             if (info != null) {
@@ -323,18 +342,23 @@
         } catch (RemoteException e) {
             Log.e(TAG, "", e);
         }
+
         return enabled;
     }
 
     private void copyFonts(String pid, String zipFileName) {
         // Prepare local cache dir for font package assembly
         log("Copy Fonts - Package ID = " + pid + " filename = " + zipFileName);
+
         File cacheDir = new File(getCacheDir(), "/FontCache/");
         if (cacheDir.exists()) {
             IOUtils.deleteRecursive(cacheDir);
         }
+
         boolean created = cacheDir.mkdir();
-        if (!created) log("Could not create cache directory...");
+        if (!created) {
+            log("Could not create cache directory...");
+        }
 
         // Copy system fonts into our cache dir
         IOUtils.copyFolder("/system/fonts", cacheDir.getAbsolutePath());
@@ -360,8 +384,11 @@
         // Unzip new fonts and delete zip file, overwriting any system fonts
         File fontZip = new File(getCacheDir(), "/FontCache/" + zipFileName);
         IOUtils.unzip(fontZip.getAbsolutePath(), cacheDir.getAbsolutePath());
+
         boolean deleted = fontZip.delete();
-        if (!deleted) log("Could not delete ZIP file...");
+        if (!deleted) {
+            log("Could not delete ZIP file...");
+        }
 
         // Check if theme zip included a fonts.xml. If not, Substratum
         // is kind enough to provide one for us in it's assets
@@ -415,12 +442,16 @@
         // Prepare local cache dir for font package assembly
         log("CopySounds - Package ID = \'" + pid + "\'");
         log("CopySounds - File name = \'" + zipFileName + "\'");
+
         File cacheDir = new File(getCacheDir(), "/SoundsCache/");
         if (cacheDir.exists()) {
             IOUtils.deleteRecursive(cacheDir);
         }
+
         boolean created = cacheDir.mkdir();
-        if (!created) log("Could not create cache directory...");
+        if (!created) {
+            log("Could not create cache directory...");
+        }
 
         // Append zip to filename since it is probably removed
         // for list presentation
@@ -443,8 +474,11 @@
         // Unzip new sounds and delete zip file
         File soundsZip = new File(getCacheDir(), "/SoundsCache/" + zipFileName);
         IOUtils.unzip(soundsZip.getAbsolutePath(), cacheDir.getAbsolutePath());
+
         boolean deleted = soundsZip.delete();
-        if (!deleted) log("Could not delete ZIP file...");
+        if (!deleted) {
+            log("Could not delete ZIP file...");
+        }
 
         clearSounds(this);
         IOUtils.createAudioDirIfNotExists();
@@ -452,6 +486,7 @@
         File uiSoundsCache = new File(getCacheDir(), "/SoundsCache/ui/");
         if (uiSoundsCache.exists() && uiSoundsCache.isDirectory()) {
             IOUtils.createUiSoundsDirIfNotExists();
+
             File effect_tick_mp3 = new File(getCacheDir(), "/SoundsCache/ui/Effect_Tick.mp3");
             File effect_tick_ogg = new File(getCacheDir(), "/SoundsCache/ui/Effect_Tick.ogg");
             if (effect_tick_ogg.exists()) {
@@ -461,6 +496,7 @@
                 IOUtils.bufferedCopy(effect_tick_mp3, new File(IOUtils
                         .SYSTEM_THEME_UI_SOUNDS_PATH + File.separator + "Effect_Tick.mp3"));
             }
+
             File new_lock_mp3 = new File(getCacheDir(), "/SoundsCache/ui/Lock.mp3");
             File new_lock_ogg = new File(getCacheDir(), "/SoundsCache/ui/Lock.ogg");
             if (new_lock_ogg.exists()) {
@@ -470,6 +506,7 @@
                 IOUtils.bufferedCopy(new_lock_mp3, new File(IOUtils.SYSTEM_THEME_UI_SOUNDS_PATH +
                         File.separator + "Lock.mp3"));
             }
+
             File new_unlock_mp3 = new File(getCacheDir(), "/SoundsCache/ui/Unlock.mp3");
             File new_unlock_ogg = new File(getCacheDir(), "/SoundsCache/ui/Unlock.ogg");
             if (new_unlock_ogg.exists()) {
@@ -479,6 +516,7 @@
                 IOUtils.bufferedCopy(new_unlock_mp3, new File(IOUtils.SYSTEM_THEME_UI_SOUNDS_PATH
                         + File.separator + "Unlock.mp3"));
             }
+
             File new_lowbattery_mp3 = new File(getCacheDir(), "/SoundsCache/ui/LowBattery.mp3");
             File new_lowbattery_ogg = new File(getCacheDir(), "/SoundsCache/ui/LowBattery.ogg");
             if (new_lowbattery_ogg.exists()) {
@@ -489,9 +527,11 @@
                         .SYSTEM_THEME_UI_SOUNDS_PATH + File.separator + "LowBattery.mp3"));
             }
         }
+
         File alarmCache = new File(getCacheDir(), "/SoundsCache/alarms/");
         if (alarmCache.exists() && alarmCache.isDirectory()) {
             IOUtils.createAlarmDirIfNotExists();
+
             File new_alarm_mp3 = new File(getCacheDir(), "/SoundsCache/alarms/alarm.mp3");
             File new_alarm_ogg = new File(getCacheDir(), "/SoundsCache/alarms/alarm.ogg");
             if (new_alarm_ogg.exists()) {
@@ -502,9 +542,11 @@
                         File.separator + "alarm.mp3"));
             }
         }
+
         File notifCache = new File(getCacheDir(), "/SoundsCache/notifications/");
         if (notifCache.exists() && notifCache.isDirectory()) {
             IOUtils.createNotificationDirIfNotExists();
+
             File new_notif_mp3 = new File(getCacheDir(), "/SoundsCache/notifications/notification" +
                     ".mp3");
             File new_notif_ogg = new File(getCacheDir(), "/SoundsCache/notifications/notification" +
@@ -517,9 +559,11 @@
                         .SYSTEM_THEME_NOTIFICATION_PATH + File.separator + "notification.mp3"));
             }
         }
+
         File ringtoneCache = new File(getCacheDir(), "/SoundsCache/ringtones/");
         if (ringtoneCache.exists() && ringtoneCache.isDirectory()) {
             IOUtils.createRingtoneDirIfNotExists();
+
             File new_ring_mp3 = new File(getCacheDir(), "/SoundsCache/ringtones/ringtone.mp3");
             File new_ring_ogg = new File(getCacheDir(), "/SoundsCache/ringtones/ringtone.ogg");
             if (new_ring_ogg.exists()) {
@@ -664,13 +708,20 @@
 
     private void copyBootAnimation(String fileName) {
         IOUtils.createThemeDirIfNotExists();
+
         try {
             clearBootAnimation();
+
             File source = new File(fileName);
             File dest = new File(IOUtils.SYSTEM_THEME_BOOTANIMATION_PATH);
+
             IOUtils.bufferedCopy(source, dest);
+
             boolean deleted = source.delete();
-            if (!deleted) log("Could not delete source file...");
+            if (!deleted) {
+                log("Could not delete source file...");
+            }
+
             IOUtils.setPermissions(dest,
                     FileUtils.S_IRWXU | FileUtils.S_IRGRP | FileUtils.S_IROTH);
         } catch (Exception e) {
@@ -683,7 +734,9 @@
             File f = new File(IOUtils.SYSTEM_THEME_BOOTANIMATION_PATH);
             if (f.exists()) {
                 boolean deleted = f.delete();
-                if (!deleted) log("Could not delete themed boot animation...");
+                if (!deleted) {
+                    log("Could not delete themed boot animation...");
+                }
             }
         } catch (Exception e) {
             Log.e(TAG, "", e);
@@ -699,9 +752,11 @@
             Object amn = getDefault.invoke(null, null);
             Method killApplicationProcess = amn.getClass().getDeclaredMethod
                     ("killApplicationProcess", String.class, int.class);
+
             stopService(new Intent().setComponent(new ComponentName("com.android.systemui", "com" +
                     ".android.systemui.SystemUIService")));
             am.killBackgroundProcesses("com.android.systemui");
+
             for (ActivityManager.RunningAppProcessInfo app : am.getRunningAppProcesses()) {
                 if ("com.android.systemui".equals(app.processName)) {
                     killApplicationProcess.invoke(amn, app.processName, app.uid);
@@ -719,23 +774,30 @@
 
     private Context getAppContext(String packageName) {
         Context ctx = null;
+
         try {
             ctx = getApplicationContext().createPackageContext(packageName,
                     Context.CONTEXT_IGNORE_SECURITY);
         } catch (NameNotFoundException e) {
             Log.e(TAG, "", e);
         }
+
         return ctx;
     }
 
     private boolean isCallerAuthorized(Intent intent) {
         PendingIntent token = null;
+
         try {
             token = intent.getParcelableExtra(MASQUERADE_TOKEN);
         } catch (Exception e) {
             log("Attempting to start service without a token - unauthorized!");
         }
-        if (token == null) return false;
+
+        if (token == null) {
+            return false;
+        }
+
         // SECOND: We got a token, validate originating package
         // if not in our white list, return null
         String callingPackage = token.getCreatorPackage();
@@ -749,10 +811,12 @@
                 break;
             }
         }
+
         if (!isValidPackage) {
             log("\'" + callingPackage + "\' is not an authorized calling package.");
             return false;
         }
+
         return true;
     }
 
@@ -788,24 +852,33 @@
             switch (msg.what) {
                 case MESSAGE_CHECK_QUEUE:
                     Runnable job;
+
                     synchronized (mJobQueue) {
                         job = mJobQueue.get(0);
                     }
-                    if (job != null && !mIsRunning) job.run();
+
+                    if (job != null && !mIsRunning) {
+                        job.run();
+                    }
+
                     break;
                 case MESSAGE_DEQUEUE:
                     Runnable toRemove = (Runnable) msg.obj;
+
                     synchronized (mJobQueue) {
                         mJobQueue.remove(toRemove);
+
                         if (mJobQueue.size() > 0) {
                             mIsRunning = false;
                             this.sendEmptyMessage(MESSAGE_CHECK_QUEUE);
                         } else {
-                            mIsRunning = false;
                             log("Job queue is empty. All done!");
+
+                            mIsRunning = false;
                             mMainHandler.sendEmptyMessage(MainHandler.MSG_JOB_QUEUE_EMPTY);
                         }
                     }
+
                     break;
                 default:
                     log("Unknown message " + msg.what);
@@ -848,6 +921,7 @@
                 log("Configuring theme font...");
                 copyFonts(mPid, mFileName);
             }
+
             Intent intent = new Intent(INTENT_STATUS_CHANGED);
             intent.putExtra(PRIMARY_COMMAND_KEY, COMMAND_VALUE_FONTS);
             sendBroadcastAsUser(intent, UserHandle.ALL);
@@ -880,6 +954,7 @@
                 log("Configuring theme sounds...");
                 applyThemedSounds(mPid, mFileName);
             }
+
             Intent intent = new Intent(INTENT_STATUS_CHANGED);
             intent.putExtra(PRIMARY_COMMAND_KEY, COMMAND_VALUE_AUDIO);
             sendBroadcastAsUser(intent, UserHandle.ALL);
@@ -911,6 +986,7 @@
                 log("Configuring themed boot animation...");
                 copyBootAnimation(mFileName);
             }
+
             Intent intent = new Intent(INTENT_STATUS_CHANGED);
             intent.putExtra(PRIMARY_COMMAND_KEY, COMMAND_VALUE_BOOTANIMATION);
             sendBroadcastAsUser(intent, UserHandle.ALL);
@@ -1033,16 +1109,18 @@
         @Override
         public void run() {
             log("PriorityJob - processing priority changes...");
+
             try {
-                int size = mPackages.size();
-                for (int i = 0; i < size - 1; i++) {
+                for (int i = 0; i < mPackages.size() - 1; i++) {
                     String parentName = mPackages.get(i);
                     String packageName = mPackages.get(i + 1);
+
                     getOMS().setPriority(packageName, parentName, UserHandle.USER_SYSTEM);
                 }
             } catch (RemoteException e) {
                 Log.e(TAG, "", e);
             }
+
             Message message = mJobHandler.obtainMessage(JobHandler.MESSAGE_DEQUEUE,
                     PriorityJob.this);
             mJobHandler.sendMessage(message);
@@ -1061,6 +1139,7 @@
         @Override
         public void run() {
             log("CopyJob - copying \'" + mSource + "\' to \'" + mDestination + "\'...");
+
             File sourceFile = new File(mSource);
             if (sourceFile.exists()) {
                 if (sourceFile.isFile()) {
@@ -1071,6 +1150,7 @@
             } else {
                 log("CopyJob - \'" + mSource + "\' does not exist, aborting...");
             }
+
             Message message = mJobHandler.obtainMessage(JobHandler.MESSAGE_DEQUEUE,
                     CopyJob.this);
             mJobHandler.sendMessage(message);
@@ -1089,6 +1169,7 @@
         @Override
         public void run() {
             log("MoveJob - moving \'" + mSource + "\' to \'" + mDestination + "\'...");
+
             File sourceFile = new File(mSource);
             if (sourceFile.exists()) {
                 if (sourceFile.isFile()) {
@@ -1100,6 +1181,7 @@
             } else {
                 log("MoveJob - \'" + mSource + "\' does not exist, aborting...");
             }
+
             Message message = mJobHandler.obtainMessage(JobHandler.MESSAGE_DEQUEUE,
                     MoveJob.this);
             mJobHandler.sendMessage(message);
@@ -1134,12 +1216,14 @@
         @Override
         public void run() {
             log("DeleteJob - deleting \'" + mFileOrDirectory + "\'...");
+
             File file = new File(mFileOrDirectory);
             if (file.exists()) {
                 IOUtils.deleteRecursive(file);
             } else {
                 log("DeleteJob - \'" + mFileOrDirectory + "\' is already deleted.");
             }
+
             Message message = mJobHandler.obtainMessage(JobHandler.MESSAGE_DEQUEUE,
                     DeleteJob.this);
             mJobHandler.sendMessage(message);
@@ -1233,38 +1317,49 @@
         public void run() {
             Intent i = new Intent(Intent.ACTION_MAIN);
             i.addCategory(Intent.CATEGORY_HOME);
+
             mContext.startActivity(i);
             mHandler.postDelayed(this::spoofLocale, 500);
         }
 
         private void register() {
-            if (!mIsRegistered) {
-                IntentFilter filter = new IntentFilter();
-                filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
-                mContext.registerReceiver(LocaleChanger.this, filter);
-                mIsRegistered = true;
+            if (mIsRegistered) {
+                return;
             }
+
+            IntentFilter filter = new IntentFilter();
+            filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
+
+            mContext.registerReceiver(LocaleChanger.this, filter);
+            mIsRegistered = true;
         }
 
         private void unregister() {
-            if (mIsRegistered) {
-                mContext.unregisterReceiver(LocaleChanger.this);
-                mIsRegistered = false;
+            if (!mIsRegistered) {
+                return;
             }
+
+            mContext.unregisterReceiver(LocaleChanger.this);
+            mIsRegistered = false;
         }
 
         @SuppressWarnings("deprecation")
         private void spoofLocale() {
             Configuration config;
+
             log("LocaleChanger - spoofing locale for configuration change shim...");
+
             try {
                 register();
+
                 config = ActivityManagerNative.getDefault().getConfiguration();
                 mCurrentLocale = config.locale;
+
                 Locale toSpoof = Locale.JAPAN;
                 if (mCurrentLocale == Locale.JAPAN) {
                     toSpoof = Locale.CHINA;
                 }
+
                 config.setLocale(toSpoof);
                 config.userSetLocale = true;
                 ActivityManagerNative.getDefault().updateConfiguration(config);
@@ -1276,16 +1371,20 @@
         private void restoreLocale() {
             Configuration config;
             log("LocaleChanger - restoring original locale for configuration change shim...");
+
             try {
                 unregister();
+
                 config = ActivityManagerNative.getDefault().getConfiguration();
                 config.setLocale(mCurrentLocale);
                 config.userSetLocale = true;
+
                 ActivityManagerNative.getDefault().updateConfiguration(config);
             } catch (RemoteException e) {
                 Log.e(TAG, "", e);
                 return;
             }
+
             Message message = mJobHandler.obtainMessage(JobHandler.MESSAGE_DEQUEUE,
                     LocaleChanger.this);
             mJobHandler.sendMessage(message);
diff --git a/app/src/main/java/masquerade/substratum/utils/IOUtils.java b/app/src/main/java/masquerade/substratum/utils/IOUtils.java
index 6f856ad..bbed46e 100644
--- a/app/src/main/java/masquerade/substratum/utils/IOUtils.java
+++ b/app/src/main/java/masquerade/substratum/utils/IOUtils.java
@@ -54,16 +54,19 @@
 
     private static boolean dirExists(String dirPath) {
         final File dir = new File(dirPath);
+
         return dir.exists() && dir.isDirectory();
     }
 
     public static void createDirIfNotExists(String dirPath) {
-        if (!dirExists(dirPath)) {
-            File dir = new File(dirPath);
-            if (dir.mkdir()) {
-                setPermissions(dir, FileUtils.S_IRWXU | FileUtils.S_IRWXG |
-                        FileUtils.S_IROTH | FileUtils.S_IXOTH);
-            }
+        if (dirExists(dirPath)) {
+            return;
+        }
+
+        File dir = new File(dirPath);
+        if (dir.mkdir()) {
+            setPermissions(dir, FileUtils.S_IRWXU | FileUtils.S_IRWXG |
+                    FileUtils.S_IROTH | FileUtils.S_IXOTH);
         }
     }
 
@@ -114,8 +117,11 @@
     public static void copyFolder(File source, File dest) {
         if (!dest.exists()) {
             boolean created = dest.mkdirs();
-            if (!created) Log.e(TAG, "Could not create destination folder...");
+            if (!created) {
+                Log.e(TAG, "Could not create destination folder...");
+            }
         }
+
         File[] files = source.listFiles();
         for (File file : files) {
             try {
@@ -142,17 +148,24 @@
             ZipEntry zipEntry;
             int count;
             byte[] buffer = new byte[8192];
+
             while ((zipEntry = inputStream.getNextEntry()) != null) {
                 File file = new File(destination, zipEntry.getName());
                 File dir = zipEntry.isDirectory() ? file : file.getParentFile();
-                if (!dir.isDirectory() && !dir.mkdirs())
+
+                if (!dir.isDirectory() && !dir.mkdirs()) {
                     throw new FileNotFoundException("Failed to ensure directory: " +
                             dir.getAbsolutePath());
-                if (zipEntry.isDirectory())
+                }
+
+                if (zipEntry.isDirectory()) {
                     continue;
+                }
+
                 try (FileOutputStream outputStream = new FileOutputStream(file)) {
-                    while ((count = inputStream.read(buffer)) != -1)
+                    while ((count = inputStream.read(buffer)) != -1) {
                         outputStream.write(buffer, 0, count);
+                    }
                 }
             }
         } catch (Exception e) {
@@ -182,10 +195,12 @@
             BufferedOutputStream out = new BufferedOutputStream(dest);
             byte[] buff = new byte[32 * 1024];
             int len;
+
             // Let's bulletproof this a bit
             while ((len = in.read(buff)) != -1) {
                 out.write(buff, 0, len);
             }
+
             in.close();
             out.close();
         } catch (Exception e) {
@@ -194,13 +209,17 @@
     }
 
     public static void deleteRecursive(File fileOrDirectory) {
-        if (fileOrDirectory.isDirectory())
-            for (File child : fileOrDirectory.listFiles())
+        if (fileOrDirectory.isDirectory()) {
+            for (File child : fileOrDirectory.listFiles()) {
                 deleteRecursive(child);
+            }
+        }
 
         boolean deleted = fileOrDirectory.delete();
-        if (!deleted) Log.e(TAG, "Could not delete file or directory - \'" +
-                fileOrDirectory.getName() + "\'");
+        if (!deleted) {
+            Log.e(TAG, "Could not delete file or directory - \'" +
+                    fileOrDirectory.getName() + "\'");
+        }
     }
 
     public static void setPermissions(File path, int permissions) {
@@ -208,18 +227,20 @@
     }
 
     public static void setPermissionsRecursive(File dir, int file, int folder) {
-        if (dir.isDirectory()) {
-            for (File child : dir.listFiles()) {
-                if (child.isDirectory()) {
-                    setPermissionsRecursive(child, file, folder);
-                    setPermissions(child, folder);
-                } else {
-                    setPermissions(child, file);
-                }
-            }
-            setPermissions(dir, folder);
-        } else {
+        if (!dir.isDirectory()) {
             setPermissions(dir, file);
+            return;
         }
+
+        for (File child : dir.listFiles()) {
+            if (child.isDirectory()) {
+                setPermissionsRecursive(child, file, folder);
+                setPermissions(child, folder);
+            } else {
+                setPermissions(child, file);
+            }
+        }
+
+        setPermissions(dir, folder);
     }
 }
diff --git a/app/src/main/java/masquerade/substratum/utils/SoundUtils.java b/app/src/main/java/masquerade/substratum/utils/SoundUtils.java
index 5d613a9..4fadd12 100644
--- a/app/src/main/java/masquerade/substratum/utils/SoundUtils.java
+++ b/app/src/main/java/masquerade/substratum/utils/SoundUtils.java
@@ -56,6 +56,7 @@
             updateGlobalSettings(resolver, sound_name, location);
             return true;
         }
+
         return false;
     }
 
@@ -71,12 +72,14 @@
                 "unlock_sound",
                 "low_battery_sound"
         };
+
         return Arrays.asList(allowed_themable).contains(targetValue);
     }
 
     private static String getDefaultAudiblePath(int type) {
         final String name;
         final String path;
+
         switch (type) {
             case RingtoneManager.TYPE_ALARM:
                 name = SystemProperties.get("ro.config.alarm_alert");
@@ -94,6 +97,7 @@
                 path = null;
                 break;
         }
+
         return path;
     }
 
@@ -102,6 +106,7 @@
         final String path = ringtone.getAbsolutePath();
         final String mimeType = name.endsWith(".ogg") ? "application/ogg" : "application/mp3";
         ContentValues values = new ContentValues();
+
         values.put(MediaStore.MediaColumns.DATA, path);
         values.put(MediaStore.MediaColumns.TITLE, name);
         values.put(MediaStore.MediaColumns.MIME_TYPE, mimeType);
@@ -120,6 +125,7 @@
                 },
                 MediaStore.MediaColumns.DATA + "='" + path + "'",
                 null, null);
+
         if (c != null && c.getCount() > 0) {
             c.moveToFirst();
             long id = c.getLong(0);
@@ -128,13 +134,17 @@
             context.getContentResolver().update(uri, values,
                     MediaStore.MediaColumns._ID + "=" + id, null);
         }
-        if (newUri == null)
+
+        if (newUri == null) {
             newUri = context.getContentResolver().insert(uri, values);
+        }
+
         try {
             RingtoneManager.setActualDefaultRingtoneUri(context, type, newUri);
         } catch (Exception e) {
             return false;
         }
+
         return true;
     }
 
@@ -162,12 +172,14 @@
                 },
                 MediaStore.MediaColumns.DATA + "='" + path_clone + "'",
                 null, null);
+
         if (c != null && c.getCount() > 0) {
             c.moveToFirst();
             long id = c.getLong(0);
             Log.e(TAG, id + "");
             c.close();
             newUri = Uri.withAppendedPath(Uri.parse(MEDIA_CONTENT_URI), "" + id);
+
             try {
                 context.getContentResolver().update(uri, values,
                         MediaStore.MediaColumns._ID + "=" + id, null);
@@ -175,39 +187,46 @@
                 Log.d(TAG, "The content provider does not need to be updated.");
             }
         }
-        if (newUri == null)
+
+        if (newUri == null) {
             newUri = context.getContentResolver().insert(uri, values);
+        }
+
         try {
             RingtoneManager.setActualDefaultRingtoneUri(context, type, newUri);
         } catch (Exception e) {
             Log.e(TAG, "", e);
             return false;
         }
+
         return true;
     }
 
     public static boolean setDefaultAudible(Context context, int type) {
         final String audiblePath = getDefaultAudiblePath(type);
-        if (audiblePath != null) {
-            Uri uri = MediaStore.Audio.Media.getContentUriForPath(audiblePath);
-            Cursor c = context.getContentResolver().query(uri,
-                    new String[]{
-                            MediaStore.MediaColumns._ID
-                    },
-                    MediaStore.MediaColumns.DATA + "='" + audiblePath + "'",
-                    null, null);
-            if (c != null && c.getCount() > 0) {
-                c.moveToFirst();
-                long id = c.getLong(0);
-                c.close();
-                uri = Uri.withAppendedPath(
-                        Uri.parse(MEDIA_CONTENT_URI), "" + id);
-            }
-            if (uri != null)
-                RingtoneManager.setActualDefaultRingtoneUri(context, type, uri);
-        } else {
+        if (audiblePath == null) {
             return false;
         }
+
+        Uri uri = MediaStore.Audio.Media.getContentUriForPath(audiblePath);
+        Cursor c = context.getContentResolver().query(uri,
+                new String[]{
+                        MediaStore.MediaColumns._ID
+                },
+                MediaStore.MediaColumns.DATA + "='" + audiblePath + "'",
+                null, null);
+
+        if (c != null && c.getCount() > 0) {
+            c.moveToFirst();
+            long id = c.getLong(0);
+            c.close();
+            uri = Uri.withAppendedPath(Uri.parse(MEDIA_CONTENT_URI), "" + id);
+        }
+
+        if (uri != null) {
+            RingtoneManager.setActualDefaultRingtoneUri(context, type, uri);
+        }
+
         return true;
     }
 }