Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01dd3efc authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

Add Activity to grant fake signature permission

parent c845689b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ Requires the FAKE_PACKAGE_SIGNATURE patch to be functional.

License
-------
    Copyright 2014 μg Project Team
    Copyright 2013-2016 microG Project Team

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
+26 −2
Original line number Diff line number Diff line
@@ -19,15 +19,39 @@ buildscript {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
        classpath 'com.android.tools.build:gradle:1.5.0'
    }
}

apply plugin: 'com.android.application'

String getMyVersionName() {
    def stdout = new ByteArrayOutputStream()
    exec {
        commandLine 'git', 'describe', '--tags', '--always', '--dirty'
        standardOutput = stdout
    }
    return stdout.toString().trim()
}

int getMyVersionCode() {
    def stdout = new ByteArrayOutputStream()
    exec {
        commandLine 'git', 'rev-list', '--count', "HEAD"
        standardOutput = stdout
    }
    return Integer.parseInt(stdout.toString().trim())
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    buildToolsVersion "23.0.2"

    defaultConfig {
        versionName getMyVersionName()
        versionCode getMyVersionCode()
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
    }
+12 −7
Original line number Diff line number Diff line
@@ -15,10 +15,8 @@
  ~ limitations under the License.
  -->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.vending"
    android:versionCode="1"
    android:versionName="0.0.1">
<manifest package="com.android.vending"
          xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-sdk
        android:minSdkVersion="10"
@@ -28,6 +26,13 @@
    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name">
        <meta-data android:name="fake-signature" android:value="@string/fake_signature" />
        <meta-data
            android:name="fake-signature"
            android:value="@string/fake_signature"/>

        <activity
            android:name=".GrantFakeSignaturePermissionActivity"
            android:exported="true"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
    </application>
</manifest>
+45 −0
Original line number Diff line number Diff line
/*
 * Copyright 2013-2016 microG Project Team
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.vending;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;

@TargetApi(Build.VERSION_CODES.M)
public class GrantFakeSignaturePermissionActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (checkSelfPermission("android.permission.FAKE_PACKAGE_SIGNATURE") != PackageManager.PERMISSION_GRANTED) {
            requestPermissions(new String[]{"android.permission.FAKE_PACKAGE_SIGNATURE"}, 1);
        } else {
            setResult(RESULT_OK);
            finish();
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        if (requestCode == 1 && grantResults.length == 1) {
            setResult(grantResults[0] == PackageManager.PERMISSION_GRANTED ? RESULT_OK : RESULT_CANCELED);
            finish();
        }
    }
}