| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.content.integrity; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.SystemApi; |
| 21 |
import android.annotation.SystemService; |
| 22 |
import android.annotation.TestApi; |
| 23 |
import android.content.Context; |
| 24 |
import android.content.IntentSender; |
| 25 |
import android.content.pm.ParceledListSlice; |
| 26 |
import android.os.RemoteException; |
| 27 |
|
| 28 |
import java.util.List; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
@SystemApi |
| 40 |
@SystemService(Context.APP_INTEGRITY_SERVICE) |
| 41 |
public class AppIntegrityManager { |
| 42 |
|
| 43 |
|
| 44 |
public static final int STATUS_SUCCESS = 0; |
| 45 |
|
| 46 |
|
| 47 |
public static final int STATUS_FAILURE = 1; |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public static final String EXTRA_STATUS = "android.content.integrity.extra.STATUS"; |
| 59 |
|
| 60 |
IAppIntegrityManager mManager; |
| 61 |
|
| 62 |
|
| 63 |
public AppIntegrityManager(IAppIntegrityManager manager) { |
| 64 |
mManager = manager; |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
public void updateRuleSet( |
| 76 |
@NonNull RuleSet updateRequest, @NonNull IntentSender statusReceiver) { |
| 77 |
try { |
| 78 |
mManager.updateRuleSet( |
| 79 |
updateRequest.getVersion(), |
| 80 |
new ParceledListSlice<>(updateRequest.getRules()), |
| 81 |
statusReceiver); |
| 82 |
} catch (RemoteException e) { |
| 83 |
throw e.rethrowAsRuntimeException(); |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
@NonNull |
| 89 |
public String getCurrentRuleSetVersion() { |
| 90 |
try { |
| 91 |
return mManager.getCurrentRuleSetVersion(); |
| 92 |
} catch (RemoteException e) { |
| 93 |
throw e.rethrowAsRuntimeException(); |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
@NonNull |
| 99 |
public String getCurrentRuleSetProvider() { |
| 100 |
try { |
| 101 |
return mManager.getCurrentRuleSetProvider(); |
| 102 |
} catch (RemoteException e) { |
| 103 |
throw e.rethrowAsRuntimeException(); |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
@TestApi |
| 115 |
@NonNull |
| 116 |
public RuleSet getCurrentRuleSet() { |
| 117 |
try { |
| 118 |
ParceledListSlice<Rule> rules = mManager.getCurrentRules(); |
| 119 |
String version = mManager.getCurrentRuleSetVersion(); |
| 120 |
return new RuleSet.Builder().setVersion(version).addRules(rules.getList()).build(); |
| 121 |
} catch (RemoteException e) { |
| 122 |
throw e.rethrowAsRuntimeException(); |
| 123 |
} |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
@TestApi |
| 134 |
@NonNull |
| 135 |
public List<String> getWhitelistedRuleProviders() { |
| 136 |
try { |
| 137 |
return mManager.getWhitelistedRuleProviders(); |
| 138 |
} catch (RemoteException e) { |
| 139 |
throw e.rethrowAsRuntimeException(); |
| 140 |
} |
| 141 |
} |
| 142 |
} |