Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ android {

defaultConfig {
applicationId = "app.attestation.auditor"
minSdk = 31
minSdk = 33
targetSdk = 35
versionCode = 89
versionName = versionCode.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.widget.LinearLayout;

import androidx.activity.EdgeToEdge;
Expand Down Expand Up @@ -331,18 +332,36 @@ public boolean onPreDraw() {
} else {
binding.content.imageview.setImageBitmap(createQrCode(data));
}
setMaxBrightness();
return true;
}
});
}

private void setMaxBrightness() {
setBrightness(WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL);
}

private void resetToOriginalBrightness() {
setBrightness(WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE);
}

private void setBrightness(float value) {
WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
layoutParams.screenBrightness = value;
getWindow().setAttributes(layoutParams);
}

private void runAuditor() {
if (auditorChallenge == null) {
auditorChallenge = AttestationProtocol.getChallengeMessage(this);
}
binding.content.textview.setText(R.string.qr_code_scan_hint_auditor);
chooseBestLayout(auditorChallenge);
binding.content.imageview.setOnClickListener(view -> startQrScanner());
binding.content.imageview.setOnClickListener(view -> {
startQrScanner();
resetToOriginalBrightness();
});
}

private void handleAttestation(final byte[] serialized) {
Expand Down
14 changes: 4 additions & 10 deletions app/src/main/java/app/attestation/auditor/AttestationProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.ApplicationInfoFlags;
import android.os.Build;
import android.os.UserManager;
import android.provider.Settings;
Expand Down Expand Up @@ -1295,15 +1296,6 @@ static Certificate[] getCertificateChain(final KeyStore keyStore, final String a
return result;
}

@SuppressWarnings("deprecation")
static ApplicationInfo getApplicationInfo(final PackageManager pm, final String packageName,
final int flags) throws PackageManager.NameNotFoundException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
return pm.getApplicationInfo(packageName, flags);
}
return pm.getApplicationInfo(packageName, PackageManager.ApplicationInfoFlags.of(flags));
}

static AttestationResult generateSerialized(final Context context, final byte[] challengeMessage,
String index, final String statePrefix) throws GeneralSecurityException, IOException {
if (challengeMessage.length < CHALLENGE_MESSAGE_LENGTH) {
Expand Down Expand Up @@ -1406,7 +1398,9 @@ static AttestationResult generateSerialized(final Context context, final byte[]
if (activeAdmins != null) {
for (final ComponentName name : activeAdmins) {
try {
final ApplicationInfo info = getApplicationInfo(pm, name.getPackageName(), 0);
final String packageName = name.getPackageName();
final ApplicationInfo info =
pm.getApplicationInfo(packageName, ApplicationInfoFlags.of(0));
if ((info.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
deviceAdminNonSystem = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ static void schedule(final Context context, int interval) {
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.setEstimatedNetworkBytes(ESTIMATED_DOWNLOAD_BYTES, ESTIMATED_UPLOAD_BYTES);
builder.setExpedited(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
builder.setPriority(JobInfo.PRIORITY_MAX);
}
builder.setPriority(JobInfo.PRIORITY_MAX);
if (scheduler.schedule(builder.build()) == JobScheduler.RESULT_FAILURE) {
throw new RuntimeException("job schedule failed");
}
Expand Down