Skip to content

Commit

Permalink
Fix for SELinux enforcing
Browse files Browse the repository at this point in the history
  • Loading branch information
DSteve595 committed Oct 25, 2016
1 parent 7548c71 commit 111b467
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 18 deletions.
20 changes: 10 additions & 10 deletions Emoji Switcher/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
compileSdkVersion 25
buildToolsVersion '24.0.2'

defaultConfig {
applicationId 'com.stevenschoen.emojiswitcher'
minSdkVersion 19
targetSdkVersion 23
versionCode 19
versionName "2.1"
targetSdkVersion 25
versionCode 20
versionName "2.1.1"
}

compileOptions {
Expand All @@ -19,15 +19,15 @@ android {
}

dependencies {
compile 'com.google.android.gms:play-services-ads:9.0.2'
compile 'com.google.android.gms:play-services-ads:9.8.0'
compile 'commons-io:commons-io:2.5'
compile 'com.google.guava:guava:19.0'
compile 'io.reactivex:rxandroid:1.2.0'
compile 'com.trello:rxlifecycle:0.6.1'
compile 'com.trello:rxlifecycle-components:0.6.1'
compile 'com.trello:rxlifecycle:0.8.0'
compile 'com.trello:rxlifecycle-components:0.8.0'
compile files('libs/RootTools-4.2.jar')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:recyclerview-v7:25.0.0'
compile 'com.yqritc:recyclerview-flexibledivider:1.2.9'
compile 'org.solovyev.android.views:linear-layout-manager:0.5@aar'
compile 'com.squareup.retrofit:retrofit:1.9.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ public void onNext(Boolean ready) {
File backupFile = new File(systemEmojiBackupFilePath(context));
RootTools.copyFile(systemEmojiSetFile.getAbsolutePath(),
backupFile.getAbsolutePath(), true, false);
try {
fixSELinuxContextIfNeeded(backupFile.getAbsolutePath());
} catch (IOException | TimeoutException | RootDeniedException e) {
e.printStackTrace();
}
}

InstallProgress progress = new InstallProgress();
Expand Down Expand Up @@ -303,8 +308,21 @@ public static String filePath(Context context, EmojiSetListing listing) {
public static void applyPermissions(String permissions, String path) throws TimeoutException, RootDeniedException, IOException {
RootTools.remount(path, "RW");
Shell shell = RootTools.getShell(true);
Command commandPermission = new Command(0, "chmod " + permissions + " " + path);
shell.add(commandPermission);
shell.add(new Command(0, "chmod " + permissions + " " + path));
shell.close();
}

public static void fixSELinuxContextIfNeeded(final String path) throws IOException, TimeoutException, RootDeniedException {
Shell shell = RootTools.getShell(true);
if (shell.isSELinuxEnforcing()) {
shell.add(new Command(0, "restorecon " + path));
// TODO Why doesn't sleep work in shell?
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
shell.close();
}

Expand Down Expand Up @@ -336,6 +354,7 @@ public void call(Subscriber<? super EmojiSetListing> subscriber) {
RootTools.copyFile(getSystemFontFilePath(), emojiSetDestinationFile.getAbsolutePath(), true, false);
try {
applyPermissions("777", emojiSetDestinationFile.getAbsolutePath());
fixSELinuxContextIfNeeded(emojiSetDestinationFile.getAbsolutePath());
} catch (Exception e) {
subscriber.onError(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.stericson.RootShell.RootShell;
import com.stericson.RootTools.RootTools;
import com.stevenschoen.emojiswitcher.billing.IabHelper;
import com.stevenschoen.emojiswitcher.billing.IabResult;
import com.stevenschoen.emojiswitcher.billing.Inventory;
Expand Down Expand Up @@ -54,6 +56,11 @@ public class SwitcherActivity extends RxAppCompatActivity implements InstallEmoj
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (BuildConfig.DEBUG) {
RootTools.debugMode = true;
RootShell.debugMode = true;
}

ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm.getActiveNetworkInfo() == null || !cm.getActiveNetworkInfo().isConnected()) {
Toast.makeText(this, "This app needs internet access to work.", Toast.LENGTH_LONG).show();
Expand Down
2 changes: 1 addition & 1 deletion Emoji Switcher/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ It\'s a different process for each device.\n\nDoes this app have root permission
<string name="failed_to_get_root">Impossibile ottenere root!</string>
<string name="switch_emojis_to">Passa a emoji…</string>
<string name="set_emojis_to_">Emoji impostate</string>
<string name="about">Font originali di gonsa da XDA. App di Steven Schoen.</string>
<string name="about">App di Steven Schoen.</string>
<string name="reboot_question">Riavvio?</string>
<string name="restore_default">Ripristina predefinito</string>
<string name="manage_downloads">Gestione download</string>
Expand Down
2 changes: 1 addition & 1 deletion Emoji Switcher/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ It\'s a different process for each device.\n\nDoes this app have root permission
<string name="failed_to_get_root">Failed to get root!</string>
<string name="switch_emojis_to">Switch emojis to…</string>
<string name="set_emojis_to_">Set emojis to</string>
<string name="about">Original fonts by gonsa from XDA. App by Steven Schoen.</string>
<string name="about">App by Steven Schoen.</string>
<string name="reboot_question">Reboot?</string>
<string name="restore_default">Restore default</string>
<string name="manage_downloads">Manage downloads</string>
Expand Down
1 change: 1 addition & 0 deletions Emoji Switcher/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<item name="colorButtonNormal">@color/emojiswitcher_orange_faded2</item>

<item name="android:windowBackground">@drawable/gradient_orange</item>
<item name="android:windowLightStatusBar">true</item>
<item name="autoScaleTextViewStyle">@style/EmojiSwitcher.AutoScaleTextView</item>
<item name="actionBarStyle">@style/EmojiSwitcher.ActionBar</item>
<item name="alertDialogTheme">@style/EmojiSwitcher.AlertDialog</item>
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.13.0'
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Apr 12 23:25:35 EDT 2015
#Tue Sep 20 17:50:48 EDT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

0 comments on commit 111b467

Please sign in to comment.