Enable system installer directly on first start if FDroid is a system-app
This commit is contained in:
parent
dbbad1c95c
commit
c27d8f6287
@ -48,6 +48,7 @@ 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.installer.Installer;
|
||||
import org.fdroid.fdroid.views.AppListFragmentPagerAdapter;
|
||||
import org.fdroid.fdroid.views.ManageReposActivity;
|
||||
import org.fdroid.fdroid.views.swap.ConnectSwapActivity;
|
||||
@ -104,9 +105,14 @@ public class FDroid extends ActionBarActivity {
|
||||
getContentResolver().registerContentObserver(uri, true, new AppObserver());
|
||||
|
||||
if (Preferences.get().isFirstTime()) {
|
||||
Intent installIntent = new Intent(this, InstallIntoSystemDialogActivity.class);
|
||||
installIntent.setAction(InstallIntoSystemDialogActivity.ACTION_FIRST_TIME);
|
||||
startActivity(installIntent);
|
||||
if (Installer.hasSystemPermissions(this, this.getPackageManager())) {
|
||||
Preferences.get().setSystemInstallerEnabled(true);
|
||||
Preferences.get().setFirstTime(false);
|
||||
} else {
|
||||
Intent installIntent = new Intent(this, InstallIntoSystemDialogActivity.class);
|
||||
installIntent.setAction(InstallIntoSystemDialogActivity.ACTION_FIRST_TIME);
|
||||
startActivity(installIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,15 +181,14 @@ abstract public class Installer {
|
||||
}
|
||||
|
||||
public static boolean hasSystemPermissions(Context context, PackageManager pm) {
|
||||
int checkInstallPermission =
|
||||
pm.checkPermission(permission.INSTALL_PACKAGES, context.getPackageName());
|
||||
int checkDeletePermission =
|
||||
pm.checkPermission(permission.DELETE_PACKAGES, context.getPackageName());
|
||||
boolean permissionsGranted =
|
||||
(checkInstallPermission == PackageManager.PERMISSION_GRANTED
|
||||
&& checkDeletePermission == PackageManager.PERMISSION_GRANTED);
|
||||
boolean hasInstallPermission =
|
||||
(pm.checkPermission(permission.INSTALL_PACKAGES, context.getPackageName())
|
||||
== PackageManager.PERMISSION_GRANTED);
|
||||
boolean hasDeletePermission =
|
||||
(pm.checkPermission(permission.DELETE_PACKAGES, context.getPackageName())
|
||||
== PackageManager.PERMISSION_GRANTED);
|
||||
|
||||
return permissionsGranted;
|
||||
return (hasInstallPermission && hasDeletePermission);
|
||||
}
|
||||
|
||||
public void installPackage(File apkFile) throws AndroidNotCompatibleException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user