Debug: list all permissions

pull/194/merge
M66B 3 years ago
parent 345d55b908
commit ac834e755f

@ -26,6 +26,7 @@ import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;
import android.content.res.Resources;
import android.database.sqlite.SQLiteDatabaseCorruptException;
@ -175,6 +176,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private Button btnFontMap;
private Button btnCiphers;
private Button btnFiles;
private Button btnAllPermissions;
private TextView tvPermissions;
private Group grpUpdates;
@ -327,6 +329,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
btnFontMap = view.findViewById(R.id.btnFontMap);
btnCiphers = view.findViewById(R.id.btnCiphers);
btnFiles = view.findViewById(R.id.btnFiles);
btnAllPermissions = view.findViewById(R.id.btnAllPermissions);
tvPermissions = view.findViewById(R.id.tvPermissions);
grpUpdates = view.findViewById(R.id.grpUpdates);
@ -1275,6 +1278,66 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
btnAllPermissions.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new SimpleTask<Spanned>() {
@Override
protected Spanned onExecute(Context context, Bundle args) throws Throwable {
SpannableStringBuilder ssb = new SpannableStringBuilderEx();
PackageManager pm = context.getPackageManager();
List<PermissionGroupInfo> groups = pm.getAllPermissionGroups(0);
groups.add(0, null); // Ungrouped
for (PermissionGroupInfo group : groups) {
String name = (group == null ? null : group.name);
int start = ssb.length();
ssb.append(name == null ? "Ungrouped" : name);
ssb.setSpan(new StyleSpan(Typeface.BOLD), start, ssb.length(), 0);
ssb.append("\n\n");
try {
for (PermissionInfo permission : pm.queryPermissionsByGroup(name, 0)) {
start = ssb.length();
ssb.append(permission.name);
ssb.setSpan(new RelativeSizeSpan(HtmlHelper.FONT_SMALL), start, ssb.length(), 0);
ssb.append("\n");
}
} catch (PackageManager.NameNotFoundException ex) {
ssb.append(ex.toString()).append("\n")
.append(android.util.Log.getStackTraceString(ex)).append("\n");
}
ssb.append("\n");
}
return ssb;
}
@Override
protected void onExecuted(Bundle args, Spanned ssb) {
new AlertDialog.Builder(v.getContext())
.setIcon(R.drawable.twotone_info_24)
.setTitle(R.string.title_advanced_all_permissions)
.setMessage(ssb)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Do nothing
}
})
.show();
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(FragmentOptionsMisc.this, new Bundle(), "misc:permissions");
}
});
// Initialize
FragmentDialogTheme.setBackground(getContext(), view, false);

@ -1417,6 +1417,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnCiphers" />
<Button
android:id="@+id/btnAllPermissions"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_all_permissions"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnFiles" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvPermissions"
android:layout_width="0dp"
@ -1427,7 +1437,7 @@
android:textIsSelectable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnFiles" />
app:layout_constraintTop_toBottomOf="@id/btnAllPermissions" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -737,6 +737,7 @@
<string name="title_advanced_font_map" translatable="false">Font map</string>
<string name="title_advanced_ciphers" translatable="false">Ciphers</string>
<string name="title_advanced_files" translatable="false">Files &gt;%1$s</string>
<string name="title_advanced_all_permissions" translatable="false">All permissions</string>
<string name="title_advanced_manual_hint">If receiving messages is disabled, it is still possible to manually receive messages by pulling down the message list</string>
<string name="title_advanced_poll_battery">This can cause high battery usage!</string>

Loading…
Cancel
Save