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

Unverified Commit 3c1ffe13 authored by Adam Mills's avatar Adam Mills
Browse files

Merge remote-tracking branch 'origin/master' into cast-mvp

parents 7627d8ae a787b52c
Loading
Loading
Loading
Loading
+88 −0
Original line number Diff line number Diff line
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 66c497e9977..c1b2e703109 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2341,6 +2341,13 @@
         android:description="@string/permdesc_getPackageSize"
         android:protectionLevel="normal" />
 
+    <!-- @hide Allows an application to change the package signature as
+	 seen by applications -->
+    <permission android:name="android.permission.FAKE_PACKAGE_SIGNATURE"
+        android:protectionLevel="dangerous"
+        android:label="@string/permlab_fakePackageSignature"
+        android:description="@string/permdesc_fakePackageSignature" />
+
     <!-- @deprecated No longer useful, see
          {@link android.content.pm.PackageManager#addPackageToPreferred}
          for details. -->
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 0b5dd7e70e8..bbdba64f2ba 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -1650,6 +1650,8 @@
     <string-array name="config_locationProviderPackageNames" translatable="false">
         <!-- The standard AOSP fused location provider -->
         <item>com.android.location.fused</item>
+        <!-- The (faked) microg fused location provider (a free reimplementation) -->
+        <item>com.google.android.gms</item>
     </string-array>
 
     <!-- This string array can be overriden to enable test location providers initially. -->
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 3c5159c89bf..7583f1c567f 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -786,6 +786,11 @@
     <!--  Permissions -->
 
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permlab_fakePackageSignature">Spoof package signature</string>
+    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permdesc_fakePackageSignature">Allows the app to pretend to be a different app. Malicious applications might be able to use this to access private application data. Legitimate uses include an emulator pretending to be what it emulates. Grant this permission with caution only!</string>
+
+    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permlab_statusBar">disable or modify status bar</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permdesc_statusBar">Allows the app to disable the status bar or add and remove system icons.</string>
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 9ed2b9c1854..4c5ce24cfa7 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -3937,8 +3937,9 @@ public class PackageManagerService extends IPackageManager.Stub
             final Set<String> permissions = ArrayUtils.isEmpty(p.requestedPermissions)
                     ? Collections.<String>emptySet() : permissionsState.getPermissions(userId);
 
-            PackageInfo packageInfo = PackageParser.generatePackageInfo(p, gids, flags,
-                    ps.firstInstallTime, ps.lastUpdateTime, permissions, state, userId);
+            PackageInfo packageInfo = mayFakeSignature(p, PackageParser.generatePackageInfo(p, gids, flags,
+                ps.firstInstallTime, ps.lastUpdateTime, permissions, state, userId),
+                permissions);
 
             if (packageInfo == null) {
                 return null;
@@ -3974,6 +3975,24 @@ public class PackageManagerService extends IPackageManager.Stub
         }
     }
 
+    private PackageInfo mayFakeSignature(PackageParser.Package p, PackageInfo pi,
+            Set<String> permissions) {
+        try {
+            if (permissions.contains("android.permission.FAKE_PACKAGE_SIGNATURE")
+                    && p.applicationInfo.targetSdkVersion > Build.VERSION_CODES.LOLLIPOP_MR1
+                    && p.mAppMetaData != null) {
+                String sig = p.mAppMetaData.getString("fake-signature");
+                if (sig != null) {
+                    pi.signatures = new Signature[] {new Signature(sig)};
+                }
+            }
+        } catch (Throwable t) {
+            // We should never die because of any failures, this is system code!
+            Log.w("PackageManagerService.FAKE_PACKAGE_SIGNATURE", t);
+	}
+        return pi;
+    }
+
     @Override
     public void checkPackageStartable(String packageName, int userId) {
         final int callingUid = Binder.getCallingUid();
+4 −3
Original line number Diff line number Diff line
@@ -57,15 +57,16 @@ def execResult(...args) {
    return stdout.toString().trim()
}

def gmsVersion = "12.8.79"
def gmsVersion = "13.2.80"
def gmsVersionCode = Integer.parseInt(gmsVersion.replaceAll('\\.', ''))
def gitVersionBase = execResult('git', 'describe', '--tags', '--abbrev=0').substring(1)
def gitCommitCount = Integer.parseInt(execResult('git', 'rev-list', '--count', "v$gitVersionBase..HEAD"))
def gitCommitId = execResult('git', 'show-ref', '--abbrev=7', '--head', 'HEAD').split(' ')[0]
def gitDirty = execResult('git', 'status', '--porcelain').size() > 0
def ourVersionBase = gitVersionBase.substring(0, gitVersionBase.lastIndexOf('.'))
def ourVersionCode = gmsVersionCode * 1000 + gitCommitCount + (gitDirty ? 1 : 0)
def ourVersionName = "$ourVersionBase.$gmsVersionCode" + (gitCommitCount > 0 ? "-$gitCommitCount-$gitCommitId" : "") + (gitDirty ? "-dirty" : "")
def ourVersionMinor = Integer.parseInt(ourVersionBase.substring(ourVersionBase.lastIndexOf('.') + 1))
def ourVersionCode = gmsVersionCode * 1000 + ourVersionMinor * 2  + (gitCommitCount > 0 || gitDirty ? 1 : 0)
def ourVersionName = "$ourVersionBase.$gmsVersionCode" + (gitCommitCount > 0 && !gitDirty ? "-$gitCommitCount" : "") + (gitDirty ? "-dirty" : "") + (gitCommitCount > 0 && !gitDirty ? " ($gitCommitId)" : "")
logger.lifecycle('Starting build for version {} ({})...', ourVersionName, ourVersionCode)

android {
+27 −4
Original line number Diff line number Diff line
@@ -213,16 +213,18 @@
            android:permission="com.google.android.c2dm.permission.RECEIVE">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.REGISTER"/>

                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.UNREGISTER"/>

                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </service>

        <receiver android:name="org.microg.gms.gcm.PushRegisterReceiver">
            <intent-filter>
                <action android:name="com.google.iid.TOKEN_REQUEST"/>
            </intent-filter>
        </receiver>

        <service android:name="org.microg.gms.gcm.McsService"/>

        <receiver
@@ -419,9 +421,11 @@

        <!-- microG custom UI -->

        <!-- microG Settings shown in Launcher -->
        <activity
            android:name="org.microg.gms.ui.SettingsActivity"
            android:icon="@mipmap/ic_microg_settings"
            android:roundIcon="@mipmap/ic_microg_settings"
            android:label="@string/gms_settings_name"
            android:theme="@style/Theme.AppCompat.Settings.Dashboard">
            <intent-filter>
@@ -429,8 +433,27 @@

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.APPLICATION_PREFERENCES"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>

        <!-- microG Settings embedded in System Settings on SDK 23 and newer -->
        <activity-alias
            android:name="org.microg.gms.ui.SettingsActivityLink"
            android:targetActivity="org.microg.gms.ui.SettingsActivity"
            android:icon="@drawable/microg_light_color_24"
            android:label="@string/gms_settings_name"
            android:theme="@style/Theme.AppCompat.Settings.Dashboard">
            <intent-filter>
                <action android:name="com.android.settings.action.EXTRA_SETTINGS"/>
            </intent-filter>
            <meta-data android:name="com.android.settings.category" android:value="com.android.settings.category.device"/>
            <meta-data android:name="com.android.settings.icon" android:resource="@drawable/microg_light_color_24"/>
            <meta-data android:name="com.android.settings.summary" android:resource="@string/gms_settings_summary"/>
        </activity-alias>

        <activity
            android:name="org.microg.gms.ui.AskPushPermission"
            android:excludeFromRecents="true"
+3 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import static android.view.View.VISIBLE;
import static android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT;
import static org.microg.gms.common.Constants.GMS_PACKAGE_NAME;
import static org.microg.gms.common.Constants.MAX_REFERENCE_VERSION;
import android.os.Build;

public class LoginActivity extends AssistantActivity {
    public static final String TMPL_NEW_ACCOUNT = "new_account";
@@ -131,6 +132,8 @@ public class LoginActivity extends AssistantActivity {
            } else {
                retrieveRtToken(getIntent().getStringExtra(EXTRA_TOKEN));
            }
        } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            init();
        } else {
            setMessage(R.string.auth_before_connect);
            setBackButtonText(android.R.string.cancel);
+7 −1
Original line number Diff line number Diff line
@@ -81,7 +81,13 @@ public class HttpFormClient {
        os.close();

        if (connection.getResponseCode() != 200) {
            throw new IOException(connection.getResponseMessage());
            String error = connection.getResponseMessage();
            try {
                error = new String(Utils.readStreamToEnd(connection.getErrorStream()));
            } catch (IOException e) {
                // Ignore
            }
            throw new IOException(error);
        }

        String result = new String(Utils.readStreamToEnd(connection.getInputStream()));
Loading