Merge "Add getApplicationConfigForPackage" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
abe85d3886
@@ -17,7 +17,10 @@
|
||||
package android.security;
|
||||
|
||||
import android.annotation.TestApi;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.security.net.config.ApplicationConfig;
|
||||
import android.security.net.config.ManifestConfigSource;
|
||||
|
||||
/**
|
||||
* Network security policy.
|
||||
@@ -98,4 +101,16 @@ public class NetworkSecurityPolicy {
|
||||
public void handleTrustStorageUpdate() {
|
||||
ApplicationConfig.getDefaultInstance().handleTrustStorageUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an {@link ApplicationConfig} based on the configuration for {@code packageName}.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static ApplicationConfig getApplicationConfigForPackage(Context context,
|
||||
String packageName) throws PackageManager.NameNotFoundException {
|
||||
Context appContext = context.createPackageContext(packageName, 0);
|
||||
ManifestConfigSource source = new ManifestConfigSource(appContext);
|
||||
return new ApplicationConfig(source);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user