Restructure installer packages

This commit is contained in:
Dominik Schürmann 2015-08-26 15:44:41 +02:00
parent 50cd629d7d
commit d530a1cf56
20 changed files with 72 additions and 167 deletions

View File

@ -302,7 +302,7 @@
android:value=".SearchResults" />
</activity>
<activity
android:name=".installer.InstallConfirmActivity"
android:name=".privileged.views.InstallConfirmActivity"
android:label="@string/menu_install"
android:parentActivityName=".FDroid">
<meta-data
@ -390,10 +390,10 @@
</activity>
<!-- Note: Theme.NoDisplay, this activity shows dialogs only -->
<activity
android:name=".installer.InstallIntoSystemDialogActivity"
android:name=".privileged.install.InstallPrivilegedDialogActivity"
android:theme="@android:style/Theme.NoDisplay" />
<receiver
android:name=".installer.InstallIntoSystemBootReceiver" >
android:name=".privileged.install.InstallPrivilegedBootReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>

View File

@ -18,7 +18,7 @@
Defines the layout of a single permission item.
-->
<view class="org.fdroid.fdroid.installer.AppSecurityPermissions$PermissionItemView"
<view class="org.fdroid.fdroid.privileged.views.AppSecurityPermissions$PermissionItemView"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -18,7 +18,7 @@
Defines the layout of a single permission item.
-->
<view class="org.fdroid.fdroid.installer.AppSecurityPermissions$PermissionItemView"
<view class="org.fdroid.fdroid.privileged.views.AppSecurityPermissions$PermissionItemView"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -18,7 +18,7 @@
Defines the layout of a single permission item that costs money.
-->
<view class="org.fdroid.fdroid.installer.AppSecurityPermissions$PermissionItemView"
<view class="org.fdroid.fdroid.privileged.views.AppSecurityPermissions$PermissionItemView"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -17,7 +17,7 @@
<!--
This is the structure for the list of all permissions.
-->
<org.fdroid.fdroid.installer.CaffeinatedScrollView
<org.fdroid.fdroid.privileged.views.CaffeinatedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollview"
android:fillViewport="true">
@ -50,4 +50,4 @@ This is the structure for the list of all permissions.
android:text="@string/devicePerms" />
</LinearLayout>
</LinearLayout>
</org.fdroid.fdroid.installer.CaffeinatedScrollView>
</org.fdroid.fdroid.privileged.views.CaffeinatedScrollView>

View File

@ -1,49 +0,0 @@
/*
* Copyright (C) 2013 Dominik Schürmann <dominik@dominikschuermann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package android.content.pm;
/**
* Just a non-working implementation of this Stub to satisfy compiler!
*/
public interface IPackageDeleteObserver extends android.os.IInterface {
abstract class Stub extends android.os.Binder implements
android.content.pm.IPackageDeleteObserver {
public Stub() {
throw new RuntimeException("Stub!");
}
public static android.content.pm.IPackageDeleteObserver asInterface(android.os.IBinder obj) {
throw new RuntimeException("Stub!");
}
public android.os.IBinder asBinder() {
throw new RuntimeException("Stub!");
}
public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply,
int flags) throws android.os.RemoteException {
throw new RuntimeException("Stub!");
}
}
void packageDeleted(java.lang.String packageName, int returnCode)
throws android.os.RemoteException;
}

View File

@ -1,49 +0,0 @@
/*
* Copyright (C) 2013 Dominik Schürmann <dominik@dominikschuermann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package android.content.pm;
/**
* Just a non-working implementation of this Stub to satisfy compiler!
*/
public interface IPackageInstallObserver extends android.os.IInterface {
abstract class Stub extends android.os.Binder implements
android.content.pm.IPackageInstallObserver {
public Stub() {
throw new RuntimeException("Stub!");
}
public static android.content.pm.IPackageInstallObserver asInterface(android.os.IBinder obj) {
throw new RuntimeException("Stub!");
}
public android.os.IBinder asBinder() {
throw new RuntimeException("Stub!");
}
public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply,
int flags) throws android.os.RemoteException {
throw new RuntimeException("Stub!");
}
}
void packageInstalled(java.lang.String packageName, int returnCode)
throws android.os.RemoteException;
}

View File

@ -34,7 +34,6 @@ import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AlertDialog;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@ -45,7 +44,7 @@ import android.widget.Toast;
import org.fdroid.fdroid.compat.TabManager;
import org.fdroid.fdroid.data.AppProvider;
import org.fdroid.fdroid.data.NewRepoConfig;
import org.fdroid.fdroid.installer.InstallIntoSystemDialogActivity;
import org.fdroid.fdroid.privileged.install.InstallPrivilegedDialogActivity;
import org.fdroid.fdroid.views.AppListFragmentPagerAdapter;
import org.fdroid.fdroid.views.ManageReposActivity;
import org.fdroid.fdroid.views.swap.SwapWorkflowActivity;
@ -99,7 +98,7 @@ public class FDroid extends ActionBarActivity {
Uri uri = AppProvider.getContentUri();
getContentResolver().registerContentObserver(uri, true, new AppObserver());
InstallIntoSystemDialogActivity.firstTime(this);
InstallPrivilegedDialogActivity.firstTime(this);
}
@Override

View File

@ -39,10 +39,10 @@ import java.util.List;
* unattended installations.
*/
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public class DefaultInstallerSdk14 extends Installer {
public class DefaultSdk14Installer extends Installer {
private final Activity mActivity;
public DefaultInstallerSdk14(Activity activity, PackageManager pm, InstallerCallback callback)
public DefaultSdk14Installer(Activity activity, PackageManager pm, InstallerCallback callback)
throws AndroidNotCompatibleException {
super(activity, pm, callback);
this.mActivity = activity;

View File

@ -113,7 +113,7 @@ abstract public class Installer {
Utils.DebugLog(TAG, "system permissions -> SystemInstaller");
try {
return new SystemInstaller(activity, pm, callback);
return new PrivilegedInstaller(activity, pm, callback);
} catch (AndroidNotCompatibleException e) {
Log.e(TAG, "Android not compatible with SystemInstaller!", e);
}
@ -128,7 +128,7 @@ abstract public class Installer {
try {
Utils.DebugLog(TAG, "try default installer for Android >= 4");
return new DefaultInstallerSdk14(activity, pm, callback);
return new DefaultSdk14Installer(activity, pm, callback);
} catch (AndroidNotCompatibleException e) {
Log.e(TAG, "Android not compatible with DefaultInstallerSdk14!", e);
}

View File

@ -34,6 +34,9 @@ import android.util.Log;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.privileged.views.AppDiff;
import org.fdroid.fdroid.privileged.views.AppSecurityPermissions;
import org.fdroid.fdroid.privileged.views.InstallConfirmActivity;
import java.io.File;
import java.lang.reflect.Method;
@ -63,19 +66,19 @@ import java.util.List;
* https://android.googlesource.com/platform
* /frameworks/base/+/ccbf84f44c9e6a5ed3c08673614826bb237afc54
*/
public class SystemInstaller extends Installer {
public class PrivilegedInstaller extends Installer {
private static final String TAG = "SystemInstaller";
private static final String TAG = "PrivilegedInstaller";
private Activity mActivity;
private final PackageInstallObserver mInstallObserver;
private final PackageDeleteObserver mDeleteObserver;
private Method mInstallMethod;
private Method mDeleteMethod;
// private final PackageInstallObserver mInstallObserver;
// private final PackageDeleteObserver mDeleteObserver;
// private Method mInstallMethod;
// private Method mDeleteMethod;
public static final int REQUEST_CONFIRM_PERMS = 0;
public SystemInstaller(Activity activity, PackageManager pm,
public PrivilegedInstaller(Activity activity, PackageManager pm,
InstallerCallback callback) throws AndroidNotCompatibleException {
super(activity, pm, callback);
this.mActivity = activity;

View File

@ -17,7 +17,7 @@
* MA 02110-1301, USA.
*/
package org.fdroid.fdroid.installer;
package org.fdroid.fdroid.privileged.install;
import android.content.Context;
import android.os.Build;
@ -35,15 +35,15 @@ import eu.chainfire.libsuperuser.Shell;
* http://omerjerk.in/2014/08/how-to-install-an-app-to-system-partition/
* https://github.com/omerjerk/RemoteDroid/blob/master/app/src/main/java/in/omerjerk/remotedroid/app/MainActivity.java
*/
abstract class InstallIntoSystem {
abstract class InstallPrivileged {
protected final Context context;
public InstallIntoSystem(final Context context) {
public InstallPrivileged(final Context context) {
this.context = context;
}
public static InstallIntoSystem create(final Context context) {
public static InstallPrivileged create(final Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return new LollipopImpl(context);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
@ -112,7 +112,7 @@ abstract class InstallIntoSystem {
return commands;
}
private static class PreKitKatImpl extends InstallIntoSystem {
private static class PreKitKatImpl extends InstallPrivileged {
public PreKitKatImpl(Context context) {
super(context);
@ -125,7 +125,7 @@ abstract class InstallIntoSystem {
}
private static class KitKatToLollipopImpl extends InstallIntoSystem {
private static class KitKatToLollipopImpl extends InstallPrivileged {
public KitKatToLollipopImpl(Context context) {
super(context);
@ -146,7 +146,7 @@ abstract class InstallIntoSystem {
* History of PackageManagerService in Lollipop:
* https://github.com/android/platform_frameworks_base/commits/lollipop-release/services/core/java/com/android/server/pm/PackageManagerService.java
*/
private static class LollipopImpl extends InstallIntoSystem {
private static class LollipopImpl extends InstallPrivileged {
public LollipopImpl(Context context) {
super(context);

View File

@ -17,7 +17,7 @@
* MA 02110-1301, USA.
*/
package org.fdroid.fdroid.installer;
package org.fdroid.fdroid.privileged.install;
import android.content.BroadcastReceiver;
import android.content.Context;
@ -25,7 +25,7 @@ import android.content.Intent;
import org.fdroid.fdroid.Preferences;
public class InstallIntoSystemBootReceiver extends BroadcastReceiver {
public class InstallPrivilegedBootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
@ -33,8 +33,8 @@ public class InstallIntoSystemBootReceiver extends BroadcastReceiver {
if (Preferences.get().isPostSystemInstall()) {
Preferences.get().setPostSystemInstall(false);
Intent postInstall = new Intent(context.getApplicationContext(), InstallIntoSystemDialogActivity.class);
postInstall.setAction(InstallIntoSystemDialogActivity.ACTION_POST_INSTALL);
Intent postInstall = new Intent(context.getApplicationContext(), InstallPrivilegedDialogActivity.class);
postInstall.setAction(InstallPrivilegedDialogActivity.ACTION_POST_INSTALL);
postInstall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(postInstall);
}

View File

@ -17,7 +17,7 @@
* MA 02110-1301, USA.
*/
package org.fdroid.fdroid.installer;
package org.fdroid.fdroid.privileged.install;
import android.app.Activity;
import android.app.Notification;
@ -40,13 +40,14 @@ import org.fdroid.fdroid.FDroid;
import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.installer.Installer;
import eu.chainfire.libsuperuser.Shell;
/**
* Note: This activity has no view on its own, it displays consecutive dialogs.
*/
public class InstallIntoSystemDialogActivity extends FragmentActivity {
public class InstallPrivilegedDialogActivity extends FragmentActivity {
private static final String TAG = "InstallIntoSystem";
@ -112,8 +113,8 @@ public class InstallIntoSystemDialogActivity extends FragmentActivity {
if (false && probablyRoot) {
// looks like we have root, at least su has a version number and is present
Intent installIntent = new Intent(context, InstallIntoSystemDialogActivity.class);
installIntent.setAction(InstallIntoSystemDialogActivity.ACTION_FIRST_TIME);
Intent installIntent = new Intent(context, InstallPrivilegedDialogActivity.class);
installIntent.setAction(InstallPrivilegedDialogActivity.ACTION_FIRST_TIME);
installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent resultPendingIntent =
@ -157,7 +158,7 @@ public class InstallIntoSystemDialogActivity extends FragmentActivity {
// hack to get holo design (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) + "<br/><br/>" + InstallIntoSystem.create(getApplicationContext()).getWarningInfo();
String message = getString(R.string.system_install_first_time_message) + "<br/><br/>" + InstallPrivileged.create(getApplicationContext()).getWarningInfo();
AlertDialog.Builder builder = new AlertDialog.Builder(theme)
.setMessage(Html.fromHtml(message))
@ -170,8 +171,8 @@ public class InstallIntoSystemDialogActivity extends FragmentActivity {
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
InstallIntoSystemDialogActivity.this.setResult(Activity.RESULT_CANCELED);
InstallIntoSystemDialogActivity.this.finish();
InstallPrivilegedDialogActivity.this.setResult(Activity.RESULT_CANCELED);
InstallPrivilegedDialogActivity.this.finish();
}
});
builder.create().show();
@ -188,7 +189,7 @@ public class InstallIntoSystemDialogActivity extends FragmentActivity {
super.onPreExecute();
// hack to get holo design (which is not automatically applied due to activity's Theme.NoDisplay
ContextThemeWrapper theme = new ContextThemeWrapper(InstallIntoSystemDialogActivity.this,
ContextThemeWrapper theme = new ContextThemeWrapper(InstallPrivilegedDialogActivity.this,
FDroidApp.getCurThemeResId());
mProgressDialog = new ProgressDialog(theme);
@ -224,7 +225,7 @@ public class InstallIntoSystemDialogActivity extends FragmentActivity {
if (!ACTION_FIRST_TIME.equals(action)) {
// hack to get holo design (which is not automatically applied due to activity's Theme.NoDisplay
ContextThemeWrapper theme = new ContextThemeWrapper(InstallIntoSystemDialogActivity.this,
ContextThemeWrapper theme = new ContextThemeWrapper(InstallPrivilegedDialogActivity.this,
FDroidApp.getCurThemeResId());
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(theme)
@ -233,8 +234,8 @@ public class InstallIntoSystemDialogActivity extends FragmentActivity {
.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
InstallIntoSystemDialogActivity.this.setResult(Activity.RESULT_CANCELED);
InstallIntoSystemDialogActivity.this.finish();
InstallPrivilegedDialogActivity.this.setResult(Activity.RESULT_CANCELED);
InstallPrivilegedDialogActivity.this.finish();
}
});
alertBuilder.create().show();
@ -254,7 +255,7 @@ public class InstallIntoSystemDialogActivity extends FragmentActivity {
super.onPreExecute();
// hack to get holo design (which is not automatically applied due to activity's Theme.NoDisplay
ContextThemeWrapper theme = new ContextThemeWrapper(InstallIntoSystemDialogActivity.this,
ContextThemeWrapper theme = new ContextThemeWrapper(InstallPrivilegedDialogActivity.this,
FDroidApp.getCurThemeResId());
mProgressDialog = new ProgressDialog(theme);
@ -266,7 +267,7 @@ public class InstallIntoSystemDialogActivity extends FragmentActivity {
@Override
protected Void doInBackground(Void... voids) {
InstallIntoSystem.create(getApplicationContext()).runInstall();
InstallPrivileged.create(getApplicationContext()).runInstall();
return null;
}
};
@ -289,9 +290,9 @@ public class InstallIntoSystemDialogActivity extends FragmentActivity {
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
InstallIntoSystemDialogActivity.this.setResult(success ? Activity.RESULT_OK : Activity.RESULT_CANCELED);
InstallIntoSystemDialogActivity.this.finish();
startActivity(new Intent(InstallIntoSystemDialogActivity.this, FDroid.class));
InstallPrivilegedDialogActivity.this.setResult(success ? Activity.RESULT_OK : Activity.RESULT_CANCELED);
InstallPrivilegedDialogActivity.this.finish();
startActivity(new Intent(InstallPrivilegedDialogActivity.this, FDroid.class));
}
})
.setCancelable(false);
@ -317,8 +318,8 @@ public class InstallIntoSystemDialogActivity extends FragmentActivity {
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
InstallIntoSystemDialogActivity.this.setResult(Activity.RESULT_CANCELED);
InstallIntoSystemDialogActivity.this.finish();
InstallPrivilegedDialogActivity.this.setResult(Activity.RESULT_CANCELED);
InstallPrivilegedDialogActivity.this.finish();
}
});
builder.create().show();
@ -329,8 +330,8 @@ public class InstallIntoSystemDialogActivity extends FragmentActivity {
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
InstallIntoSystemDialogActivity.this.setResult(Activity.RESULT_CANCELED);
InstallIntoSystemDialogActivity.this.finish();
InstallPrivilegedDialogActivity.this.setResult(Activity.RESULT_CANCELED);
InstallPrivilegedDialogActivity.this.finish();
}
});
builder.create().show();
@ -345,7 +346,7 @@ public class InstallIntoSystemDialogActivity extends FragmentActivity {
super.onPreExecute();
// hack to get holo design (which is not automatically applied due to activity's Theme.NoDisplay
ContextThemeWrapper theme = new ContextThemeWrapper(InstallIntoSystemDialogActivity.this,
ContextThemeWrapper theme = new ContextThemeWrapper(InstallPrivilegedDialogActivity.this,
FDroidApp.getCurThemeResId());
mProgressDialog = new ProgressDialog(theme);
@ -357,7 +358,7 @@ public class InstallIntoSystemDialogActivity extends FragmentActivity {
@Override
protected Void doInBackground(Void... voids) {
InstallIntoSystem.create(getApplicationContext()).runUninstall();
InstallPrivileged.create(getApplicationContext()).runUninstall();
return null;
}

View File

@ -16,7 +16,7 @@
** limitations under the License.
*/
package org.fdroid.fdroid.installer;
package org.fdroid.fdroid.privileged.views;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
@ -25,10 +25,10 @@ import android.net.Uri;
public class AppDiff {
final PackageManager mPm;
final PackageInfo mPkgInfo;
public final PackageManager mPm;
public final PackageInfo mPkgInfo;
ApplicationInfo mInstalledAppInfo = null;
public ApplicationInfo mInstalledAppInfo = null;
public AppDiff(PackageManager mPm, Uri mPackageURI) {
this.mPm = mPm;

View File

@ -15,7 +15,7 @@
** See the License for the specific language governing permissions and
** limitations under the License.
*/
package org.fdroid.fdroid.installer;
package org.fdroid.fdroid.privileged.views;
import android.annotation.TargetApi;
import android.content.Context;

View File

@ -15,7 +15,7 @@
** limitations under the License.
*/
package org.fdroid.fdroid.installer;
package org.fdroid.fdroid.privileged.views;
import android.content.Context;
import android.graphics.Canvas;

View File

@ -16,7 +16,7 @@
** limitations under the License.
*/
package org.fdroid.fdroid.installer;
package org.fdroid.fdroid.privileged.views;
import android.app.Activity;
import android.content.Context;

View File

@ -14,7 +14,7 @@
** See the License for the specific language governing permissions and
** limitations under the License.
*/
package org.fdroid.fdroid.installer;
package org.fdroid.fdroid.privileged.views;
import android.app.Activity;
import android.content.Context;

View File

@ -19,7 +19,7 @@ import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.PreferencesActivity;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.installer.InstallIntoSystemDialogActivity;
import org.fdroid.fdroid.privileged.install.InstallPrivilegedDialogActivity;
import org.fdroid.fdroid.installer.Installer;
import java.util.Locale;
@ -221,8 +221,8 @@ public class PreferencesFragment extends PreferenceFragment
alertBuilder.setPositiveButton(R.string.system_permission_install_via_root, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent installIntent = new Intent(getActivity(), InstallIntoSystemDialogActivity.class);
installIntent.setAction(InstallIntoSystemDialogActivity.ACTION_INSTALL);
Intent installIntent = new Intent(getActivity(), InstallPrivilegedDialogActivity.class);
installIntent.setAction(InstallPrivilegedDialogActivity.ACTION_INSTALL);
startActivity(installIntent);
}
});
@ -249,8 +249,8 @@ public class PreferencesFragment extends PreferenceFragment
@Override
public boolean onPreferenceClick(Preference preference) {
Intent uninstallIntent = new Intent(getActivity(), InstallIntoSystemDialogActivity.class);
uninstallIntent.setAction(InstallIntoSystemDialogActivity.ACTION_UNINSTALL);
Intent uninstallIntent = new Intent(getActivity(), InstallPrivilegedDialogActivity.class);
uninstallIntent.setAction(InstallPrivilegedDialogActivity.ACTION_UNINSTALL);
startActivity(uninstallIntent);
return true;