Search in sources :

Example 26 with App

use of org.fdroid.fdroid.data.App in project fdroidclient by f-droid.

the class RepoXMLHandler method startElement.

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    super.startElement(uri, localName, qName, attributes);
    if ("repo".equals(localName)) {
        repoSigningCert = attributes.getValue("", "pubkey");
        repoMaxAge = Utils.parseInt(attributes.getValue("", "maxage"), -1);
        repoVersion = Utils.parseInt(attributes.getValue("", "version"), -1);
        repoName = cleanWhiteSpace(attributes.getValue("", "name"));
        repoDescription = cleanWhiteSpace(attributes.getValue("", "description"));
        repoTimestamp = parseLong(attributes.getValue("", "timestamp"), 0);
        repoIcon = attributes.getValue("", "icon");
    } else if (RepoPushRequest.INSTALL.equals(localName) || RepoPushRequest.UNINSTALL.equals(localName)) {
        if (repo.pushRequests == Repo.PUSH_REQUEST_ACCEPT_ALWAYS) {
            RepoPushRequest r = new RepoPushRequest(localName, attributes.getValue("packageName"), attributes.getValue("versionCode"));
            onRepoPushRequestParsed(r);
        }
    } else if ("application".equals(localName) && curapp == null) {
        curapp = new App();
        curapp.repoId = repo.getId();
        curapp.packageName = attributes.getValue("", "id");
        // To appease the NON NULL constraint in the DB. Usually there is a description, and it
        // is quite difficult to get an app to _not_ have a description when using fdroidserver.
        // However, it shouldn't crash the client when this happens.
        curapp.description = "";
    } else if ("package".equals(localName) && curapp != null && curapk == null) {
        curapk = new Apk();
        curapk.packageName = curapp.packageName;
        curapk.repoId = repo.getId();
        currentApkHashType = null;
    } else if ("hash".equals(localName) && curapk != null) {
        currentApkHashType = attributes.getValue("", "type");
    } else if ("uses-permission".equals(localName) && curapk != null) {
        String maxSdkVersion = attributes.getValue("maxSdkVersion");
        if (maxSdkVersion == null || Build.VERSION.SDK_INT <= Integer.valueOf(maxSdkVersion)) {
            addRequestedPermission(attributes.getValue("name"));
        } else {
            removeRequestedPermission(attributes.getValue("name"));
        }
    } else if ("uses-permission-sdk-23".equals(localName) && curapk != null) {
        String maxSdkVersion = attributes.getValue("maxSdkVersion");
        if (Build.VERSION.SDK_INT >= 23 && (maxSdkVersion == null || Build.VERSION.SDK_INT <= Integer.valueOf(maxSdkVersion))) {
            addRequestedPermission(attributes.getValue("name"));
        } else {
            removeRequestedPermission(attributes.getValue("name"));
        }
    }
    curchars.setLength(0);
}
Also used : App(org.fdroid.fdroid.data.App) RepoPushRequest(org.fdroid.fdroid.data.RepoPushRequest) Apk(org.fdroid.fdroid.data.Apk)

Example 27 with App

use of org.fdroid.fdroid.data.App in project fdroidclient by f-droid.

the class AppDetails2 method reset.

/**
 * Reset the display and list contents. Used when entering the activity, and
 * also when something has been installed/uninstalled.
 * Return true if the app was found, false otherwise.
 */
private boolean reset(String packageName) {
    Utils.debugLog(TAG, "Getting application details for " + packageName);
    App newApp = null;
    if (!TextUtils.isEmpty(packageName)) {
        newApp = AppProvider.Helper.findHighestPriorityMetadata(getContentResolver(), packageName);
    }
    setApp(newApp);
    return this.app != null;
}
Also used : App(org.fdroid.fdroid.data.App)

Example 28 with App

use of org.fdroid.fdroid.data.App in project fdroidclient by f-droid.

the class LocalRepoManager method addApp.

public void addApp(Context context, String packageName) {
    App app;
    try {
        app = SwapService.getAppFromCache(packageName);
        if (app == null) {
            app = new App(context.getApplicationContext(), pm, packageName);
        }
        if (!app.isValid()) {
            return;
        }
    } catch (PackageManager.NameNotFoundException | CertificateEncodingException | IOException e) {
        Log.e(TAG, "Error adding app to local repo", e);
        return;
    }
    Utils.debugLog(TAG, "apps.put: " + packageName);
    apps.put(packageName, app);
}
Also used : FDroidApp(org.fdroid.fdroid.FDroidApp) App(org.fdroid.fdroid.data.App) CertificateEncodingException(java.security.cert.CertificateEncodingException) IOException(java.io.IOException)

Example 29 with App

use of org.fdroid.fdroid.data.App in project fdroidclient by f-droid.

the class ProperMultiRepoUpdaterTest method assert2048Metadata.

private void assert2048Metadata(Repo repo, @RepoIdentifier String id) {
    App a2048 = AppProvider.Helper.findSpecificApp(context.getContentResolver(), "com.uberspot.a2048", repo.getId(), AppMetadataTable.Cols.ALL);
    assert2048Metadata(a2048, id);
}
Also used : App(org.fdroid.fdroid.data.App)

Example 30 with App

use of org.fdroid.fdroid.data.App in project fdroidclient by f-droid.

the class ProperMultiRepoUpdaterTest method assertAdbMetadata.

private void assertAdbMetadata(Repo repo, @RepoIdentifier String id) {
    App adb = AppProvider.Helper.findSpecificApp(context.getContentResolver(), "siir.es.adbWireless", repo.getId(), AppMetadataTable.Cols.ALL);
    assertAdbMetadata(adb, id);
}
Also used : App(org.fdroid.fdroid.data.App)

Aggregations

App (org.fdroid.fdroid.data.App)53 FDroidApp (org.fdroid.fdroid.FDroidApp)10 Apk (org.fdroid.fdroid.data.Apk)10 Test (org.junit.Test)6 Intent (android.content.Intent)5 PackageInfo (android.content.pm.PackageInfo)5 PackageManager (android.content.pm.PackageManager)5 ArrayList (java.util.ArrayList)5 FDroidProviderTest (org.fdroid.fdroid.data.FDroidProviderTest)5 PendingIntent (android.app.PendingIntent)4 SpannableStringBuilder (android.text.SpannableStringBuilder)4 NotificationCompat (androidx.core.app.NotificationCompat)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 IOException (java.io.IOException)4 Repo (org.fdroid.fdroid.data.Repo)4 RepoXMLHandlerTest (org.fdroid.fdroid.data.RepoXMLHandlerTest)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 ContentResolver (android.content.ContentResolver)3 ContentValues (android.content.ContentValues)3 JsonFactory (com.fasterxml.jackson.core.JsonFactory)3