rename Apk.permissions to requestedPermissions like PackageInfo
android.content.pm.PackageInfo is the Android class for representing data about an APK/package. Since Apk.permission is the same thing, we should use the same name.
This commit is contained in:
parent
43f380b6b6
commit
d7022dd498
@ -80,7 +80,7 @@ public class ApkVerifierTest {
|
||||
Apk apk = new Apk();
|
||||
apk.packageName = "org.fdroid.permissions.sdk14";
|
||||
apk.targetSdkVersion = 14;
|
||||
apk.permissions = new String[]{
|
||||
apk.requestedPermissions = new String[]{
|
||||
"AUTHENTICATE_ACCOUNTS",
|
||||
"MANAGE_ACCOUNTS",
|
||||
"READ_PROFILE",
|
||||
@ -116,7 +116,7 @@ public class ApkVerifierTest {
|
||||
Apk apk = new Apk();
|
||||
apk.packageName = "org.fdroid.permissions.sdk14";
|
||||
apk.targetSdkVersion = 14;
|
||||
apk.permissions = new String[]{
|
||||
apk.requestedPermissions = new String[]{
|
||||
"android.permission.AUTHENTICATE_ACCOUNTS",
|
||||
"android.permission.MANAGE_ACCOUNTS",
|
||||
"android.permission.READ_PROFILE",
|
||||
@ -156,7 +156,7 @@ public class ApkVerifierTest {
|
||||
Apk apk = new Apk();
|
||||
apk.packageName = "org.fdroid.permissions.sdk14";
|
||||
apk.targetSdkVersion = 14;
|
||||
apk.permissions = new String[]{
|
||||
apk.requestedPermissions = new String[]{
|
||||
"android.permission.AUTHENTICATE_ACCOUNTS",
|
||||
"android.permission.MANAGE_ACCOUNTS",
|
||||
"android.permission.READ_PROFILE",
|
||||
@ -197,7 +197,7 @@ public class ApkVerifierTest {
|
||||
Apk apk = new Apk();
|
||||
apk.packageName = "org.fdroid.permissions.sdk14";
|
||||
apk.targetSdkVersion = 14;
|
||||
apk.permissions = new String[]{
|
||||
apk.requestedPermissions = new String[]{
|
||||
//"android.permission.AUTHENTICATE_ACCOUNTS",
|
||||
"android.permission.MANAGE_ACCOUNTS",
|
||||
"android.permission.READ_PROFILE",
|
||||
|
@ -157,8 +157,8 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
case ApkTable.Cols.ADDED_DATE:
|
||||
curapk.added = Utils.parseDate(str, null);
|
||||
break;
|
||||
case ApkTable.Cols.PERMISSIONS:
|
||||
curapk.permissions = Utils.parseCommaSeparatedString(str);
|
||||
case ApkTable.Cols.REQUESTED_PERMISSIONS:
|
||||
curapk.requestedPermissions = Utils.parseCommaSeparatedString(str);
|
||||
break;
|
||||
case ApkTable.Cols.FEATURES:
|
||||
curapk.features = Utils.parseCommaSeparatedString(str);
|
||||
|
@ -36,8 +36,13 @@ public class Apk extends ValueObject implements Comparable<Apk>, Parcelable {
|
||||
public String obbPatchFile;
|
||||
public String obbPatchFileSha256;
|
||||
public Date added;
|
||||
public String[] permissions; // null if empty or
|
||||
// unknown
|
||||
/**
|
||||
* The array of the names of the permissions that this APK requests. This is the
|
||||
* same data as {@link android.content.pm.PackageInfo#requestedPermissions}. Note this
|
||||
* does not mean that all these permissions have been granted, only requested. For
|
||||
* example, a regular app can request a system permission, but it won't be granted it.
|
||||
*/
|
||||
public String[] requestedPermissions;
|
||||
public String[] features; // null if empty or unknown
|
||||
|
||||
public String[] nativecode; // null if empty or unknown
|
||||
@ -126,8 +131,8 @@ public class Apk extends ValueObject implements Comparable<Apk>, Parcelable {
|
||||
case Cols.NAME:
|
||||
apkName = cursor.getString(i);
|
||||
break;
|
||||
case Cols.PERMISSIONS:
|
||||
permissions = Utils.parseCommaSeparatedString(cursor.getString(i));
|
||||
case Cols.REQUESTED_PERMISSIONS:
|
||||
requestedPermissions = Utils.parseCommaSeparatedString(cursor.getString(i));
|
||||
break;
|
||||
case Cols.NATIVE_CODE:
|
||||
nativecode = Utils.parseCommaSeparatedString(cursor.getString(i));
|
||||
@ -231,12 +236,12 @@ public class Apk extends ValueObject implements Comparable<Apk>, Parcelable {
|
||||
}
|
||||
|
||||
public ArrayList<String> getFullPermissionList() {
|
||||
if (this.permissions == null) {
|
||||
if (this.requestedPermissions == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
ArrayList<String> permissionsFull = new ArrayList<>();
|
||||
for (String perm : this.permissions) {
|
||||
for (String perm : this.requestedPermissions) {
|
||||
permissionsFull.add(fdroidToAndroidPermission(perm));
|
||||
}
|
||||
return permissionsFull;
|
||||
@ -293,7 +298,7 @@ public class Apk extends ValueObject implements Comparable<Apk>, Parcelable {
|
||||
values.put(Cols.OBB_PATCH_FILE, obbPatchFile);
|
||||
values.put(Cols.OBB_PATCH_FILE_SHA256, obbPatchFileSha256);
|
||||
values.put(Cols.ADDED_DATE, Utils.formatDate(added, ""));
|
||||
values.put(Cols.PERMISSIONS, Utils.serializeCommaSeparatedString(permissions));
|
||||
values.put(Cols.REQUESTED_PERMISSIONS, Utils.serializeCommaSeparatedString(requestedPermissions));
|
||||
values.put(Cols.FEATURES, Utils.serializeCommaSeparatedString(features));
|
||||
values.put(Cols.NATIVE_CODE, Utils.serializeCommaSeparatedString(nativecode));
|
||||
values.put(Cols.INCOMPATIBLE_REASONS, Utils.serializeCommaSeparatedString(incompatibleReasons));
|
||||
@ -332,7 +337,7 @@ public class Apk extends ValueObject implements Comparable<Apk>, Parcelable {
|
||||
dest.writeString(this.obbPatchFile);
|
||||
dest.writeString(this.obbPatchFileSha256);
|
||||
dest.writeLong(this.added != null ? this.added.getTime() : -1);
|
||||
dest.writeStringArray(this.permissions);
|
||||
dest.writeStringArray(this.requestedPermissions);
|
||||
dest.writeStringArray(this.features);
|
||||
dest.writeStringArray(this.nativecode);
|
||||
dest.writeString(this.sig);
|
||||
@ -363,7 +368,7 @@ public class Apk extends ValueObject implements Comparable<Apk>, Parcelable {
|
||||
this.obbPatchFileSha256 = in.readString();
|
||||
long tmpAdded = in.readLong();
|
||||
this.added = tmpAdded == -1 ? null : new Date(tmpAdded);
|
||||
this.permissions = in.createStringArray();
|
||||
this.requestedPermissions = in.createStringArray();
|
||||
this.features = in.createStringArray();
|
||||
this.nativecode = in.createStringArray();
|
||||
this.sig = in.readString();
|
||||
|
@ -372,7 +372,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
||||
apk.targetSdkVersion = minTargetMax[1];
|
||||
apk.maxSdkVersion = minTargetMax[2];
|
||||
apk.packageName = this.packageName;
|
||||
apk.permissions = packageInfo.requestedPermissions;
|
||||
apk.requestedPermissions = packageInfo.requestedPermissions;
|
||||
apk.apkName = apk.packageName + "_" + apk.versionCode + ".apk";
|
||||
apk.installedFile = apkFile;
|
||||
|
||||
|
@ -96,7 +96,7 @@ class DBHelper extends SQLiteOpenHelper {
|
||||
+ ApkTable.Cols.OBB_MAIN_FILE_SHA256 + " string, "
|
||||
+ ApkTable.Cols.OBB_PATCH_FILE + " string, "
|
||||
+ ApkTable.Cols.OBB_PATCH_FILE_SHA256 + " string, "
|
||||
+ ApkTable.Cols.PERMISSIONS + " string, "
|
||||
+ ApkTable.Cols.REQUESTED_PERMISSIONS + " string, "
|
||||
+ ApkTable.Cols.FEATURES + " string, "
|
||||
+ ApkTable.Cols.NATIVE_CODE + " string, "
|
||||
+ ApkTable.Cols.HASH_TYPE + " string, "
|
||||
@ -504,7 +504,7 @@ class DBHelper extends SQLiteOpenHelper {
|
||||
+ ApkTable.Cols.MIN_SDK_VERSION + " integer, "
|
||||
+ ApkTable.Cols.TARGET_SDK_VERSION + " integer, "
|
||||
+ ApkTable.Cols.MAX_SDK_VERSION + " integer, "
|
||||
+ ApkTable.Cols.PERMISSIONS + " string, "
|
||||
+ ApkTable.Cols.REQUESTED_PERMISSIONS + " string, "
|
||||
+ ApkTable.Cols.FEATURES + " string, "
|
||||
+ ApkTable.Cols.NATIVE_CODE + " string, "
|
||||
+ ApkTable.Cols.HASH_TYPE + " string, "
|
||||
@ -529,7 +529,7 @@ class DBHelper extends SQLiteOpenHelper {
|
||||
ApkTable.Cols.MIN_SDK_VERSION,
|
||||
ApkTable.Cols.TARGET_SDK_VERSION,
|
||||
ApkTable.Cols.MAX_SDK_VERSION,
|
||||
ApkTable.Cols.PERMISSIONS,
|
||||
ApkTable.Cols.REQUESTED_PERMISSIONS,
|
||||
ApkTable.Cols.FEATURES,
|
||||
ApkTable.Cols.NATIVE_CODE,
|
||||
ApkTable.Cols.HASH_TYPE,
|
||||
|
@ -169,7 +169,7 @@ public interface Schema {
|
||||
String OBB_MAIN_FILE_SHA256 = "obbMainFileSha256";
|
||||
String OBB_PATCH_FILE = "obbPatchFile";
|
||||
String OBB_PATCH_FILE_SHA256 = "obbPatchFileSha256";
|
||||
String PERMISSIONS = "permissions";
|
||||
String REQUESTED_PERMISSIONS = "permissions";
|
||||
String FEATURES = "features";
|
||||
String NATIVE_CODE = "nativecode";
|
||||
String HASH_TYPE = "hashType";
|
||||
@ -193,7 +193,7 @@ public interface Schema {
|
||||
APP_ID, VERSION_NAME, REPO_ID, HASH, VERSION_CODE, NAME,
|
||||
SIZE, SIGNATURE, SOURCE_NAME, MIN_SDK_VERSION, TARGET_SDK_VERSION, MAX_SDK_VERSION,
|
||||
OBB_MAIN_FILE, OBB_MAIN_FILE_SHA256, OBB_PATCH_FILE, OBB_PATCH_FILE_SHA256,
|
||||
PERMISSIONS, FEATURES, NATIVE_CODE, HASH_TYPE, ADDED_DATE,
|
||||
REQUESTED_PERMISSIONS, FEATURES, NATIVE_CODE, HASH_TYPE, ADDED_DATE,
|
||||
IS_COMPATIBLE, INCOMPATIBLE_REASONS,
|
||||
};
|
||||
|
||||
@ -204,7 +204,7 @@ public interface Schema {
|
||||
_ID, APP_ID, Package.PACKAGE_NAME, VERSION_NAME, REPO_ID, HASH, VERSION_CODE, NAME,
|
||||
SIZE, SIGNATURE, SOURCE_NAME, MIN_SDK_VERSION, TARGET_SDK_VERSION, MAX_SDK_VERSION,
|
||||
OBB_MAIN_FILE, OBB_MAIN_FILE_SHA256, OBB_PATCH_FILE, OBB_PATCH_FILE_SHA256,
|
||||
PERMISSIONS, FEATURES, NATIVE_CODE, HASH_TYPE, ADDED_DATE,
|
||||
REQUESTED_PERMISSIONS, FEATURES, NATIVE_CODE, HASH_TYPE, ADDED_DATE,
|
||||
IS_COMPATIBLE, Repo.VERSION, Repo.ADDRESS, INCOMPATIBLE_REASONS,
|
||||
};
|
||||
}
|
||||
|
@ -436,10 +436,10 @@ public final class LocalRepoManager {
|
||||
|
||||
private void tagPermissions(App app) throws IOException {
|
||||
serializer.startTag("", "permissions");
|
||||
if (app.installedApk.permissions != null) {
|
||||
if (app.installedApk.requestedPermissions != null) {
|
||||
StringBuilder buff = new StringBuilder();
|
||||
|
||||
for (String permission : app.installedApk.permissions) {
|
||||
for (String permission : app.installedApk.requestedPermissions) {
|
||||
buff.append(permission.replace("android.permission.", ""));
|
||||
buff.append(',');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user