Skip to content

Instantly share code, notes, and snippets.

View Malinskiy's full-sized avatar

Anton Malinski Malinskiy

View GitHub Profile
@Malinskiy
Malinskiy / permissions.xml
Last active August 29, 2017 14:46
test-butler permissions
<!-- Required for adding a custom IActivityController class -->
<uses-permission android:name="android.permission.SET_ACTIVITY_WATCHER"/>
<!-- Required for granting permissions to the app under test -->
<uses-permission android:name="android.permission.GRANT_REVOKE_PERMISSIONS"/>
<!-- Restricted permissions -->
<uses-permission android:name="android.permission.SET_ANIMATION_SCALE"/>
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
@Malinskiy
Malinskiy / permissions-declaration.xml
Last active August 29, 2017 15:37
test-butler permissions declaration
<!-- Allows an application to watch and control how activities are started globally in the system. -->
<permission android:name="android.permission.SET_ACTIVITY_WATCHER" android:protectionLevel="signature" />
<!-- Allows an application to grant specific permissions. -->
<permission android:name="android.permission.GRANT_RUNTIME_PERMISSIONS" android:protectionLevel="signature|installer|verifier" />
<!-- Modify the global animation scaling factor. -->
<permission android:name="android.permission.SET_ANIMATION_SCALE" android:protectionLevel="signature|privileged|development" />
<!-- Allows an application to modify the current configuration, such as locale. -->
@Malinskiy
Malinskiy / PackageManagerService.java
Created August 29, 2017 14:54
PackageManagerService.java#locationIsPrivileged
static boolean locationIsPrivileged(File path) {
try {
final String privilegedAppDir = new File(Environment.getRootDirectory(), "priv-app")
.getCanonicalPath();
return path.getCanonicalPath().startsWith(privilegedAppDir);
} catch (IOException e) {
Slog.e(TAG, "Unable to access code path " + path);
}
return false;
}
@Malinskiy
Malinskiy / manifest.xml
Created August 29, 2017 15:02
test-butler system uid
<manifest
...
android:sharedUserId="android.uid.system"
...
>
private boolean grantSignaturePermission(String perm, PackageParser.Package pkg,
BasePermission bp, PermissionsState origPermissions) {
boolean allowed;
...
return allowed;
}
@Malinskiy
Malinskiy / grantSignaturePermission.smali
Created August 29, 2017 15:22
always grant permissions
.method private grantSignaturePermission(Ljava/lang/String;Landroid/content/pm/PackageParser$Package;Lcom/android/server/pm/BasePermission;Lcom/android/server/pm/PermissionsState;)Z
.locals 1
const/4 v0, 0x1
return v0
.end method
public Content get(final Context context) throws IOException {
Content content = maybeGetCachedContent(context);
Request request = context.getRequest();
if (request != null && request.getHeaders() != null && request.getHeaders().get("User-Agent") != null &&
request.getHeaders().get("User-Agent").startsWith("Nexus/")) {
request.getAttributes().set("DisableNegativeCache", true);
return null;
}
maven2:
- name: maven-public
proxy:
- name: release-hosted
url: http://nexus-boss.local/maven-release
- name: release-brother-2
url: http://nexus-2.local/release-hosted
- name: mvnrepository-broter-2
url: http://nexus-2.local/mvnrepository-proxy
- name: mvnrepository-proxy
import org.yaml.snakeyaml.Yaml
import org.sonatype.nexus.blobstore.api.BlobStoreException
import org.sonatype.nexus.repository.maven.VersionPolicy
import org.sonatype.nexus.repository.maven.LayoutPolicy
log.info(args)
Yaml yaml = new Yaml()
def config = yaml.load(args)
log.info(config.toString())
nexusScriptsClient = new ResteasyClientBuilder().build() 
.register(new BasicAuthentication(nexusUsername, nexusPassword)) 
.target("$proxyInstanceHost/service/rest") 
.proxy(ScriptClient)  
void uploadAndRunScript(String remoteConfig) { 
// Look to see if a script with this name already exists so we can update if necessary
 
boolean newScript = true 
try {