Expert mode - currently just displays md5 of signature for installed apps
This commit is contained in:
parent
a5d4399e28
commit
df6a37a705
@ -28,6 +28,10 @@
|
|||||||
android:textSize="12sp" android:layout_height="wrap_content"
|
android:textSize="12sp" android:layout_height="wrap_content"
|
||||||
android:layout_width="fill_parent" />
|
android:layout_width="fill_parent" />
|
||||||
|
|
||||||
|
<TextView android:id="@+id/signature" android:layout_below="@id/status"
|
||||||
|
android:layout_alignParentLeft="true" android:textSize="12sp"
|
||||||
|
android:layout_height="wrap_content" android:layout_width="fill_parent" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -115,4 +115,7 @@
|
|||||||
<string name="antinonfreenet">Network Services</string>
|
<string name="antinonfreenet">Network Services</string>
|
||||||
<string name="antinonfreenetlong">Show apps that promote non-free network services</string>
|
<string name="antinonfreenetlong">Show apps that promote non-free network services</string>
|
||||||
|
|
||||||
|
<string name="expert">Expert</string>
|
||||||
|
<string name="expert_mode">Enabled expert mode</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/updates">
|
<PreferenceCategory android:title="@string/updates">
|
||||||
<ListPreference android:title="@string/automatic_repo_scan"
|
<ListPreference android:title="@string/automatic_repo_scan"
|
||||||
android:summary="@string/update_apps_list"
|
android:summary="@string/update_apps_list" android:key="updateInterval"
|
||||||
android:key="updateInterval" android:defaultValue="0"
|
android:defaultValue="0" android:entries="@array/updateIntervalNames"
|
||||||
android:entries="@array/updateIntervalNames" android:entryValues="@array/updateIntervalValues" />
|
android:entryValues="@array/updateIntervalValues" />
|
||||||
<CheckBoxPreference android:title="@string/notify"
|
<CheckBoxPreference android:title="@string/notify"
|
||||||
android:defaultValue="false" android:summary="@string/notify_updates_available"
|
android:defaultValue="false" android:summary="@string/notify_updates_available"
|
||||||
android:key="updateNotify" />
|
android:key="updateNotify" />
|
||||||
@ -29,9 +29,10 @@
|
|||||||
android:key="cacheDownloaded" />
|
android:key="cacheDownloaded" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/maintenance">
|
<PreferenceCategory android:title="@string/maintenance">
|
||||||
<Preference
|
<Preference android:title="@string/reset" android:summary="@string/clear_all_cached_data"
|
||||||
android:title="@string/reset"
|
android:key="reset" />
|
||||||
android:summary="@string/clear_all_cached_data"
|
<CheckBoxPreference android:title="@string/expert"
|
||||||
android:key="reset" />
|
android:defaultValue="false" android:summary="@string/expert_mode"
|
||||||
</PreferenceCategory>
|
android:key="expert" />
|
||||||
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@ -22,7 +22,10 @@ import java.io.BufferedInputStream;
|
|||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.math.BigInteger;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -43,6 +46,7 @@ import android.widget.TextView;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.Signature;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
@ -162,8 +166,12 @@ public class AppDetails extends ListActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean pref_cacheDownloaded;
|
private boolean pref_cacheDownloaded;
|
||||||
|
private boolean pref_expert;
|
||||||
private boolean viewResetRequired;
|
private boolean viewResetRequired;
|
||||||
|
|
||||||
|
// The signature of the installed version.
|
||||||
|
private Signature mInstalledSignature;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
@ -174,6 +182,7 @@ public class AppDetails extends ListActivity {
|
|||||||
SharedPreferences prefs = PreferenceManager
|
SharedPreferences prefs = PreferenceManager
|
||||||
.getDefaultSharedPreferences(getBaseContext());
|
.getDefaultSharedPreferences(getBaseContext());
|
||||||
pref_cacheDownloaded = prefs.getBoolean("cacheDownloaded", true);
|
pref_cacheDownloaded = prefs.getBoolean("cacheDownloaded", true);
|
||||||
|
pref_expert = prefs.getBoolean("expert", false);
|
||||||
viewResetRequired = true;
|
viewResetRequired = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -204,6 +213,19 @@ public class AppDetails extends ListActivity {
|
|||||||
DB.Apk curver = app.getCurrentVersion();
|
DB.Apk curver = app.getCurrentVersion();
|
||||||
app_currentvercode = curver == null ? 0 : curver.vercode;
|
app_currentvercode = curver == null ? 0 : curver.vercode;
|
||||||
|
|
||||||
|
// Get the signature of the installed package...
|
||||||
|
mInstalledSignature = null;
|
||||||
|
if (curver != null) {
|
||||||
|
PackageManager pm = getBaseContext().getPackageManager();
|
||||||
|
try {
|
||||||
|
PackageInfo pi = pm.getPackageInfo(appid,
|
||||||
|
PackageManager.GET_SIGNATURES);
|
||||||
|
mInstalledSignature = pi.signatures[0];
|
||||||
|
} catch (NameNotFoundException e) {
|
||||||
|
Log.d("FDroid", "Failed to get installed signature");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set the icon...
|
// Set the icon...
|
||||||
ImageView iv = (ImageView) findViewById(R.id.icon);
|
ImageView iv = (ImageView) findViewById(R.id.icon);
|
||||||
String icon_path = DB.getIconsPath() + app.icon;
|
String icon_path = DB.getIconsPath() + app.icon;
|
||||||
@ -229,6 +251,23 @@ public class AppDetails extends ListActivity {
|
|||||||
app.installedVersion));
|
app.installedVersion));
|
||||||
tv = (TextView) findViewById(R.id.description);
|
tv = (TextView) findViewById(R.id.description);
|
||||||
tv.setText(app.description);
|
tv.setText(app.description);
|
||||||
|
if (pref_expert && mInstalledSignature != null) {
|
||||||
|
try {
|
||||||
|
tv = (TextView) findViewById(R.id.signature);
|
||||||
|
byte[] sig = mInstalledSignature.toByteArray();
|
||||||
|
MessageDigest md;
|
||||||
|
md = MessageDigest.getInstance("MD5");
|
||||||
|
byte[] md5sum = new byte[32];
|
||||||
|
md.update(sig, 0, sig.length);
|
||||||
|
md5sum = md.digest();
|
||||||
|
BigInteger bigInt = new BigInteger(1, md5sum);
|
||||||
|
String md5hash = bigInt.toString(16);
|
||||||
|
while (md5hash.length() < 32)
|
||||||
|
md5hash = "0" + md5hash;
|
||||||
|
tv.setText("Signed: " + md5hash);
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set up the list...
|
// Set up the list...
|
||||||
ApkListAdapter la = new ApkListAdapter(this);
|
ApkListAdapter la = new ApkListAdapter(this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user