diff --git a/app/src/main/java/org/fdroid/fdroid/FDroid.java b/app/src/main/java/org/fdroid/fdroid/FDroid.java index 5e0be9cf9..519424ba6 100644 --- a/app/src/main/java/org/fdroid/fdroid/FDroid.java +++ b/app/src/main/java/org/fdroid/fdroid/FDroid.java @@ -48,7 +48,6 @@ import org.fdroid.fdroid.compat.TabManager; import org.fdroid.fdroid.compat.UriCompat; import org.fdroid.fdroid.data.AppProvider; import org.fdroid.fdroid.data.NewRepoConfig; -import org.fdroid.fdroid.privileged.install.InstallExtensionDialogActivity; import org.fdroid.fdroid.views.AppListFragmentPagerAdapter; import org.fdroid.fdroid.views.ManageReposActivity; import org.fdroid.fdroid.views.swap.SwapWorkflowActivity; @@ -112,8 +111,6 @@ public class FDroid extends AppCompatActivity implements SearchView.OnQueryTextL Uri uri = AppProvider.getContentUri(); getContentResolver().registerContentObserver(uri, true, new AppObserver()); - InstallExtensionDialogActivity.firstTime(this); - // Re-enable once it can be disabled via a setting // See https://gitlab.com/fdroid/fdroidclient/issues/435 // diff --git a/app/src/main/java/org/fdroid/fdroid/Preferences.java b/app/src/main/java/org/fdroid/fdroid/Preferences.java index 20144be5f..cd24e5043 100644 --- a/app/src/main/java/org/fdroid/fdroid/Preferences.java +++ b/app/src/main/java/org/fdroid/fdroid/Preferences.java @@ -66,7 +66,6 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh public static final String PREF_PROXY_HOST = "proxyHost"; public static final String PREF_PROXY_PORT = "proxyPort"; public static final String PREF_SHOW_NFC_DURING_SWAP = "showNfcDuringSwap"; - public static final String PREF_FIRST_TIME = "firstTime"; public static final String PREF_POST_PRIVILEGED_INSTALL = "postPrivilegedInstall"; private static final boolean DEFAULT_ROOTED = true; @@ -84,7 +83,6 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh public static final String DEFAULT_PROXY_HOST = "127.0.0.1"; public static final int DEFAULT_PROXY_PORT = 8118; private static final boolean DEFAULT_SHOW_NFC_DURING_SWAP = true; - private static final boolean DEFAULT_FIRST_TIME = true; private static final boolean DEFAULT_POST_PRIVILEGED_INSTALL = false; public enum Theme { @@ -124,14 +122,6 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh preferences.edit().putBoolean(PREF_PRIVILEGED_INSTALLER, enable).apply(); } - public boolean isFirstTime() { - return preferences.getBoolean(PREF_FIRST_TIME, DEFAULT_FIRST_TIME); - } - - public void setFirstTime(boolean firstTime) { - preferences.edit().putBoolean(PREF_FIRST_TIME, firstTime).apply(); - } - public boolean isPostPrivilegedInstall() { return preferences.getBoolean(PREF_POST_PRIVILEGED_INSTALL, DEFAULT_POST_PRIVILEGED_INSTALL); } diff --git a/app/src/main/java/org/fdroid/fdroid/privileged/install/InstallExtensionDialogActivity.java b/app/src/main/java/org/fdroid/fdroid/privileged/install/InstallExtensionDialogActivity.java index 02d4cf6be..7260a4d55 100644 --- a/app/src/main/java/org/fdroid/fdroid/privileged/install/InstallExtensionDialogActivity.java +++ b/app/src/main/java/org/fdroid/fdroid/privileged/install/InstallExtensionDialogActivity.java @@ -20,24 +20,18 @@ package org.fdroid.fdroid.privileged.install; import android.app.Activity; -import android.app.Notification; -import android.app.NotificationManager; -import android.app.PendingIntent; import android.app.ProgressDialog; -import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.FragmentActivity; -import android.support.v4.app.NotificationCompat; import android.support.v7.app.AlertDialog; import android.text.Html; import android.util.Log; import android.view.ContextThemeWrapper; -import org.fdroid.fdroid.AppDetails; import org.fdroid.fdroid.FDroid; import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.Preferences; @@ -59,7 +53,6 @@ public class InstallExtensionDialogActivity extends FragmentActivity { public static final String ACTION_UNINSTALL = "uninstall"; public static final String ACTION_POST_INSTALL = "post_install"; - public static final String ACTION_FIRST_TIME = "first_time"; private String apkPath; @@ -88,125 +81,12 @@ public class InstallExtensionDialogActivity extends FragmentActivity { case ACTION_INSTALL: askBeforeInstall(); break; - case ACTION_FIRST_TIME: - checkRootTask.execute(); - break; case ACTION_POST_INSTALL: postInstall(); break; } } - public static void firstTime(final Context context) { - if (Preferences.get().isFirstTime()) { - Preferences.get().setFirstTime(false); - - int isInstalledCorrectly = PrivilegedInstaller.isExtensionInstalledCorrectly(context); - switch (isInstalledCorrectly) { - case PrivilegedInstaller.IS_EXTENSION_INSTALLED_YES: - Preferences.get().setPrivilegedInstallerEnabled(true); - break; - - case PrivilegedInstaller.IS_EXTENSION_INSTALLED_NO: - runFirstTime(context); - break; - - case PrivilegedInstaller.IS_EXTENSION_INSTALLED_SIGNATURE_PROBLEM: - default: - // do nothing - } - } - } - - private static void runFirstTime(final Context context) { - // don't do a "real" root access, just look up if "su" is present and has a version! - // a real check would annoy the user - AsyncTask checkRoot = new AsyncTask() { - - @Override - protected Boolean doInBackground(Void... params) { - return Shell.SU.version(true) != null; - } - - @Override - protected void onPostExecute(Boolean probablyRoot) { - super.onPostExecute(probablyRoot); - - // TODO: remove false condition once the install into system - // process is stable - #294, #346, #347, #348 - if (false && probablyRoot) { - // looks like we have root, at least su has a version number and is present - - Intent installIntent = new Intent(context, InstallExtensionDialogActivity.class); - installIntent.setAction(InstallExtensionDialogActivity.ACTION_FIRST_TIME); - installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - - PendingIntent resultPendingIntent = - PendingIntent.getActivity( - context, - 0, - installIntent, - PendingIntent.FLAG_UPDATE_CURRENT - ); - - NotificationCompat.Builder builder = - new NotificationCompat.Builder(context) - .setContentIntent(resultPendingIntent) - .setSmallIcon(R.drawable.ic_stat_notify) - .setContentTitle(context.getString(R.string.system_install_first_time_notification)) - .setContentText(context.getString(R.string.system_install_first_time_notification_message_short)) - .setDefaults(Notification.DEFAULT_LIGHTS) - .setAutoCancel(true) - /* - * Sets the big view "big text" style and supplies the - * text (the user's reminder message) that will be displayed - * in the detail area of the expanded notification. - * These calls are ignored by the support library for - * pre-4.1 devices. - */ - .setStyle(new NotificationCompat.BigTextStyle() - .bigText(context.getString(R.string.system_install_first_time_notification_message))); - - NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - nm.notify(42, builder.build()); - } - } - }; - checkRoot.execute(); - } - - /** - * first time - */ - private void firstTime() { - // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay - ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId()); - - String message = getString(R.string.system_install_first_time_message) + "

" - + getString(R.string.system_install_question); - - AlertDialog.Builder builder = new AlertDialog.Builder(theme) - .setMessage(Html.fromHtml(message)) - .setPositiveButton(R.string.system_install_button_open, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - // Open details of F-Droid Privileged - Intent intent = new Intent(InstallExtensionDialogActivity.this, AppDetails.class); - intent.putExtra(AppDetails.EXTRA_APPID, - PrivilegedInstaller.PRIVILEGED_EXTENSION_PACKAGE_NAME); - startActivity(intent); - } - }) - .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - InstallExtensionDialogActivity.this.setResult(Activity.RESULT_CANCELED); - InstallExtensionDialogActivity.this.finish(); - } - }); - builder.create().show(); - } - private void askBeforeInstall() { // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId()); @@ -288,30 +168,24 @@ public class InstallExtensionDialogActivity extends FragmentActivity { case ACTION_INSTALL: installTask.execute(); break; - case ACTION_FIRST_TIME: - firstTime(); - break; } } else { // root access denied + // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay + ContextThemeWrapper theme = new ContextThemeWrapper(InstallExtensionDialogActivity.this, + FDroidApp.getCurThemeResId()); - if (!ACTION_FIRST_TIME.equals(getIntent().getAction())) { - // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay - ContextThemeWrapper theme = new ContextThemeWrapper(InstallExtensionDialogActivity.this, - FDroidApp.getCurThemeResId()); - - AlertDialog.Builder alertBuilder = new AlertDialog.Builder(theme) - .setTitle(R.string.root_access_denied_title) - .setMessage(getString(R.string.root_access_denied_body)) - .setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - InstallExtensionDialogActivity.this.setResult(Activity.RESULT_CANCELED); - InstallExtensionDialogActivity.this.finish(); - } - }); - alertBuilder.create().show(); - } + AlertDialog.Builder alertBuilder = new AlertDialog.Builder(theme) + .setTitle(R.string.root_access_denied_title) + .setMessage(getString(R.string.root_access_denied_body)) + .setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + InstallExtensionDialogActivity.this.setResult(Activity.RESULT_CANCELED); + InstallExtensionDialogActivity.this.finish(); + } + }); + alertBuilder.create().show(); } } }; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 26f985b7c..9dcb6f0bd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -275,9 +275,6 @@ The privileged permissions have not been granted to the extension! Please create a bug report! Install Open Extension - Install F-Droid Privileged Extension? - Touch for more information. - Touch to install F-Droid Privileged Extension, tightly coupled with the Android operating system. This allows F-Droid to install, upgrade and uninstall apps on its own.\nYou can also do this later from F-Droid\'s settings. Successfully installed F-Droid Privileged Extension Installation of F-Droid Privileged Extension failed F-Droid Privileged Extension has been successfully installed. This allows F-Droid to install, upgrade and uninstall apps on its own. @@ -288,7 +285,6 @@ Do you want to install F-Droid Privileged Extension? This takes up to 10 seconds. This takes up to 10 seconds and the device will be <b>rebooted</b> afterwards. - Looks like you have root access on your device. You can now install F-Droid Privileged Extension, tightly coupled with the Android operating system. This allows F-Droid to install, upgrade and uninstall apps on its own. Do you want to uninstall F-Droid Privileged Extension? Uninstall Installation of F-Droid Privileged Extension is currently not supported on Android 5.1 or later.