Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Jul 7, 2014
1 parent 3a25d68 commit 5291f21
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Superuser/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"

This comment has been minimized.

Copy link
@lexa76

lexa76 Nov 23, 2014

del

This comment has been minimized.

Copy link
@lexa76

lexa76 Nov 23, 2014

del

xmlns:tools="http://schemas.android.com/tools"
package="com.koushikdutta.superuser"
android:versionCode="1030"
android:versionName="1.0.3.0" >
Expand Down
12 changes: 6 additions & 6 deletions Superuser/assets/update-binary
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ chmod 644 /system/app/Superuser.apk

# if the system is at least 4.3, and there is no su daemon built in,
# let's try to install it using install-recovery.sh
BUILD_RELEASE_VERSION="$(grep 'ro\.build\.version\.release' /system/build.prop)"
VERSION="${BUILD_RELEASE_VERSION##*=}"
MAJ=${VERSION%%.*}
MIN=${VERSION#*.}
MIN=${MIN//.*}
BUILD_VERSION_SDK="$(grep 'ro\.build\.version\.sdk' /system/build.prop)"
BUILD_VERSION_SDK="${BUILD_VERSION_SDK##*=}"

if [ "${MAJ}${MIN}" -ge 43 ]
if [ "$BUILD_VERSION_SDK" -ge 18 ]
then
# check for rom su daemon before clobbering install-recovery.sh
if [ ! -f "/system/etc/.has_su_daemon" ]
then
echo -n -e 'ui_print Installing Superuser daemon...\n' > /proc/self/fd/$2
echo -n -e 'ui_print\n' > /proc/self/fd/$2
chattr -i /system/etc/install-recovery.sh
chattr -i /system/bin/install-recovery.sh
cp install-recovery.sh /system/etc/install-recovery.sh
cp install-recovery.sh /system/bin/install-recovery.sh
chmod 755 /system/etc/install-recovery.sh
chmod 755 /system/bin/install-recovery.sh
# note that an post install su daemon was installed
# so recovery doesn't freak out and recommend you disable
# the install-recovery.sh execute bit.
Expand Down
4 changes: 2 additions & 2 deletions Superuser/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
APP_ABI := x86 armeabi mips
NDK_TOOLCHAIN_VERSION=4.8
APP_PIE = false
# NDK_TOOLCHAIN_VERSION=4.8
APP_PIE = true
6 changes: 6 additions & 0 deletions Superuser/jni/su/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ int run_daemon() {
int previous_umask = umask(027);
mkdir(REQUESTOR_DAEMON_PATH, 0777);

memset(sun.sun_path, 0, sizeof(sun.sun_path));
memcpy(sun.sun_path, "\0" "SUPERUSER", strlen("SUPERUSER") + 1);

if (bind(fd, (struct sockaddr*)&sun, sizeof(sun)) < 0) {
PLOGE("daemon bind");
goto err;
Expand Down Expand Up @@ -551,6 +554,9 @@ int connect_daemon(int argc, char *argv[], int ppid) {
sun.sun_family = AF_LOCAL;
sprintf(sun.sun_path, "%s/server", REQUESTOR_DAEMON_PATH);

memset(sun.sun_path, 0, sizeof(sun.sun_path));
memcpy(sun.sun_path, "\0" "SUPERUSER", strlen("SUPERUSER") + 1);

if (0 != connect(socketfd, (struct sockaddr*)&sun, sizeof(sun))) {
PLOGE("connect");
exit(-1);
Expand Down
2 changes: 1 addition & 1 deletion Superuser/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-19
target=android-21
android.library.reference.1=../../Widgets/Widgets
ndk.executable=ndk-build
6 changes: 6 additions & 0 deletions Superuser/res/menu-v11/app.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@
android:title="@string/about"
android:icon="@drawable/ic_action_about"
/>

<item
android:id="@+id/settings"
android:title="@string/settings"
android:icon="@drawable/ic_action_settings"
/>
</menu>
7 changes: 1 addition & 6 deletions Superuser/res/menu-v11/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,5 @@
android:icon="@drawable/ic_action_logs"
android:showAsAction="ifRoom"
/>

<item
android:id="@+id/settings"
android:title="@string/settings"
android:icon="@drawable/ic_action_settings"
/>

</menu>
4 changes: 4 additions & 0 deletions Superuser/res/menu/app.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
android:id="@+id/about"
android:icon="@drawable/ic_menu_about"
android:title="@string/about"/>
<item
android:id="@+id/settings"
android:icon="@drawable/ic_menu_settings"
android:title="@string/settings"/>

</menu>
4 changes: 0 additions & 4 deletions Superuser/res/menu/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,5 @@
android:id="@+id/logs"
android:icon="@drawable/ic_menu_logs"
android:title="@string/logs"/>
<item
android:id="@+id/settings"
android:icon="@drawable/ic_menu_settings"
android:title="@string/settings"/>

</menu>
24 changes: 19 additions & 5 deletions Superuser/src/com/koushikdutta/superuser/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
Expand All @@ -48,10 +49,6 @@ public MainActivity() {
super(PolicyFragment.class);
}

public PolicyFragment getFragment() {
return (PolicyFragment)super.getFragment();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater mi = new MenuInflater(this);
Expand All @@ -60,11 +57,28 @@ public boolean onCreateOptionsMenu(Menu menu) {
about.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
getFragment().setContent(new AboutFragment(), true, getString(R.string.about));
getSupportFragmentManager()
.beginTransaction()
.addToBackStack(getString(R.string.about))
.replace(getListContainerId(), new AboutFragment(), "content")
.commit();
return true;
}
});

MenuItem settings = menu.findItem(R.id.settings);
settings.setOnMenuItemClickListener(new OnMenuItemClickListener() {

@Override
public boolean onMenuItemClick(final MenuItem item) {
getSupportFragmentManager()
.beginTransaction()
.addToBackStack(getString(R.string.settings))
.replace(getListContainerId(), new SettingsFragment(), "content")
.commit();
return true;
}
});
return super.onCreateOptionsMenu(menu);
}

Expand Down
22 changes: 0 additions & 22 deletions Superuser/src/com/koushikdutta/superuser/PolicyFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,24 +236,12 @@ void setContent(final ListItem li, final UidPolicy up) {
setContent(l, up == null, up == null ? getString(R.string.logs) : up.getName());
}

protected SettingsFragment createSettingsFragment() {
return new SettingsFragment();
}

protected LogFragment createLogFragment() {
return new LogFragment();
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
/* When you are in LogFragmentInternal screen and you rotate the device
* you are directed to the first screen (PolicyFragment).
* Then you will notice that the trash menu icon still exists.
* This is a bug because LogFragmentInternal's menu is loaded.
* So, clear any previously loaded menu before load this one.
*/
menu.clear();

super.onCreateOptionsMenu(menu, inflater);
MenuInflater mi = new MenuInflater(getActivity());
mi.inflate(R.menu.main, menu);
Expand All @@ -265,16 +253,6 @@ public boolean onMenuItemClick(MenuItem item) {
return true;
}
});

MenuItem settings = menu.findItem(R.id.settings);
settings.setOnMenuItemClickListener(new OnMenuItemClickListener() {

@Override
public boolean onMenuItemClick(final MenuItem item) {
setContent(createSettingsFragment(), true, getString(R.string.settings));
return true;
}
});
}

}

0 comments on commit 5291f21

Please sign in to comment.