themes: Relabel theme dir after creation
After creating the theme directory it will be labeled as a system_data_file. By calling SELinux.restorecon() the directory will be correctly labeled as a themeservice_app_data_file Change-Id: I73a28da883a467bf8859d879dbe22962424e4a23 TICKET: NIGHTLIES-3349
This commit is contained in:
parent
fceb077b6f
commit
06aec1f6f2
|
@ -23,6 +23,7 @@ import android.os.FileUtils;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteCallbackList;
|
import android.os.RemoteCallbackList;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.os.SELinux;
|
||||||
import android.system.ErrnoException;
|
import android.system.ErrnoException;
|
||||||
import android.system.Os;
|
import android.system.Os;
|
||||||
import android.system.StructStat;
|
import android.system.StructStat;
|
||||||
|
@ -257,7 +258,10 @@ public class ThemeManagerServiceBroker extends BrokerableCMSystemService<IThemeS
|
||||||
public void onBootPhase(int phase) {
|
public void onBootPhase(int phase) {
|
||||||
if (phase == PHASE_SYSTEM_SERVICES_READY) {
|
if (phase == PHASE_SYSTEM_SERVICES_READY) {
|
||||||
// create the main theme directory for brokered service
|
// create the main theme directory for brokered service
|
||||||
createDirIfNotExists(ThemeUtils.SYSTEM_THEME_PATH);
|
if (createDirIfNotExists(ThemeUtils.SYSTEM_THEME_PATH)) {
|
||||||
|
// ensure it has the correct selinux label after creation
|
||||||
|
SELinux.restorecon(ThemeUtils.SYSTEM_THEME_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
if (shouldMigrateFilePermissions()) {
|
if (shouldMigrateFilePermissions()) {
|
||||||
migrateFilePermissions();
|
migrateFilePermissions();
|
||||||
|
@ -354,13 +358,15 @@ public class ThemeManagerServiceBroker extends BrokerableCMSystemService<IThemeS
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createDirIfNotExists(String dirPath) {
|
private static boolean createDirIfNotExists(String dirPath) {
|
||||||
final File dir = new File(dirPath);
|
final File dir = new File(dirPath);
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
if (dir.mkdir()) {
|
if (dir.mkdir()) {
|
||||||
FileUtils.setPermissions(dir, FileUtils.S_IRWXU |
|
FileUtils.setPermissions(dir, FileUtils.S_IRWXU |
|
||||||
FileUtils.S_IRWXG| FileUtils.S_IRWXO, -1, -1);
|
FileUtils.S_IRWXG| FileUtils.S_IRWXO, -1, -1);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue