Use a boolean Consumer instead of RoleManagerCallback.

And use RemoteCallback for it under the hood. This removes one AIDL
interface and allows using lambda, while aligning with what
PermissionControllerService does.

Bug: 127691087
Test: manual
Change-Id: I7af28be2df5f84ffcd040a80884efe7c08e2d067
This commit is contained in:
Hai Zhang
2019-03-06 20:39:35 -08:00
parent a51b5f8756
commit 93cfd2e28e
2 changed files with 9 additions and 22 deletions

View File

@@ -17,9 +17,7 @@
package com.android.settings.applications.defaultapps;
import android.app.role.RoleManager;
import android.app.role.RoleManagerCallback;
import android.app.settings.SettingsEnums;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
@@ -27,7 +25,6 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.AsyncTask;
import android.os.Process;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
@@ -100,18 +97,13 @@ public class DefaultEmergencyPicker extends DefaultAppPickerFragment {
final String previousValue = getDefaultKey();
if (!TextUtils.isEmpty(key) && !TextUtils.equals(key, previousValue)) {
getContext().getSystemService(RoleManager.class)
.addRoleHolderAsUser(
RoleManager.ROLE_EMERGENCY, key, 0, Process.myUserHandle(),
AsyncTask.THREAD_POOL_EXECUTOR, new RoleManagerCallback() {
@Override
public void onSuccess() {}
@Override
public void onFailure() {
Log.e(TAG, "Failed to set emergency default app.");
}
});
getContext().getSystemService(RoleManager.class).addRoleHolderAsUser(
RoleManager.ROLE_EMERGENCY, key, 0, Process.myUserHandle(),
AsyncTask.THREAD_POOL_EXECUTOR, successful -> {
if (!successful) {
Log.e(TAG, "Failed to set emergency default app.");
}
});
return true;
}
return false;