am c6a04240: Merge "Change Configure structure to List<PersistableBundle>" into lmp-mr1-dev automerge: 5292069
* commit 'c6a042401a740b360790f71884b66fd3a2a09447': Change Configure structure to List<PersistableBundle>
This commit is contained in:
@@ -93,31 +93,6 @@ public class TrustAgentService extends Service {
|
|||||||
private static final int MSG_CONFIGURE = 2;
|
private static final int MSG_CONFIGURE = 2;
|
||||||
private static final int MSG_TRUST_TIMEOUT = 3;
|
private static final int MSG_TRUST_TIMEOUT = 3;
|
||||||
|
|
||||||
/**
|
|
||||||
* Container class for a list of configuration options and helper methods
|
|
||||||
*/
|
|
||||||
public static final class Configuration {
|
|
||||||
public final List<PersistableBundle> options;
|
|
||||||
public Configuration(List<PersistableBundle> opts) {
|
|
||||||
options = opts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Very basic method to determine if all bundles have the given feature, regardless
|
|
||||||
* of type.
|
|
||||||
* @param option String to search for.
|
|
||||||
* @return true if found in all bundles.
|
|
||||||
*/
|
|
||||||
public boolean hasOption(String option) {
|
|
||||||
if (options == null || options.size() == 0) return false;
|
|
||||||
final int N = options.size();
|
|
||||||
for (int i = 0; i < N; i++) {
|
|
||||||
if (!options.get(i).containsKey(option)) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class containing raw data for a given configuration request.
|
* Class containing raw data for a given configuration request.
|
||||||
*/
|
*/
|
||||||
@@ -147,7 +122,7 @@ public class TrustAgentService extends Service {
|
|||||||
break;
|
break;
|
||||||
case MSG_CONFIGURE:
|
case MSG_CONFIGURE:
|
||||||
ConfigurationData data = (ConfigurationData) msg.obj;
|
ConfigurationData data = (ConfigurationData) msg.obj;
|
||||||
boolean result = onConfigure(new Configuration(data.options));
|
boolean result = onConfigure(data.options);
|
||||||
try {
|
try {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
mCallback.onConfigureCompleted(result, data.token);
|
mCallback.onConfigureCompleted(result, data.token);
|
||||||
@@ -212,7 +187,7 @@ public class TrustAgentService extends Service {
|
|||||||
* @param options bundle containing all options or null if none.
|
* @param options bundle containing all options or null if none.
|
||||||
* @return true if the {@link TrustAgentService} supports configuration options.
|
* @return true if the {@link TrustAgentService} supports configuration options.
|
||||||
*/
|
*/
|
||||||
public boolean onConfigure(Configuration options) {
|
public boolean onConfigure(List<PersistableBundle> options) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import android.support.v4.content.LocalBroadcastManager;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SampleTrustAgent extends TrustAgentService
|
public class SampleTrustAgent extends TrustAgentService
|
||||||
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
@@ -90,11 +92,10 @@ public class SampleTrustAgent extends TrustAgentService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onConfigure(Configuration config) {
|
public boolean onConfigure(List<PersistableBundle> options) {
|
||||||
if (config != null && config.options != null) {
|
if (options != null) {
|
||||||
for (int i = 0; i < config.options.size(); i++) {
|
for (int i = 0; i < options.size(); i++) {
|
||||||
PersistableBundle options = config.options.get(i);
|
Log.v(TAG, "Policy options received: " + options.get(i));
|
||||||
Log.v(TAG, "Policy options received: " + options.toString());
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "onConfigure() called with no options");
|
Log.w(TAG, "onConfigure() called with no options");
|
||||||
|
|||||||
Reference in New Issue
Block a user