Permalink
Browse files

WIP

  • Loading branch information...
koush committed Jul 7, 2014
1 parent 3a25d68 commit 5291f21e9ce5224a20b25a80d8978afbaa19bb66
@@ -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.

Show comment
Hide comment
@lexa76
@lexa76

This comment has been minimized.

Show comment
Hide comment
@lexa76
@lexa76
xmlns:tools="http://schemas.android.com/tools"
package="com.koushikdutta.superuser"
android:versionCode="1030"
android:versionName="1.0.3.0" >
@@ -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.
@@ -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
@@ -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;
@@ -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);
@@ -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
@@ -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>
@@ -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,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,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,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;
@@ -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);
@@ -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);
}
@@ -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);
@@ -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.