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

Commit d69cb696 authored by Abhishek Aggarwal's avatar Abhishek Aggarwal
Browse files

Merge branch 'epic13-s-bringup' into 'v1-s'

base: Setup CI to update from upstream

See merge request e/os/android_frameworks_base!117
parents 3a190757 b9bd2cc2
Loading
Loading
Loading
Loading

.gitlab-ci.yml

0 → 100644
+7 −0
Original line number Diff line number Diff line
stages:
  - update-from-upstream

include:
  - project: 'e/templates'
    ref: master
    file: '/gitlab-ci/.gitlab-ci-import-updates-from-upstream.yml'
+2 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ package android {
    field public static final String DUMP = "android.permission.DUMP";
    field public static final String EXPAND_STATUS_BAR = "android.permission.EXPAND_STATUS_BAR";
    field public static final String FACTORY_TEST = "android.permission.FACTORY_TEST";
    field public static final String FAKE_PACKAGE_SIGNATURE = "android.permission.FAKE_PACKAGE_SIGNATURE";
    field public static final String FOREGROUND_SERVICE = "android.permission.FOREGROUND_SERVICE";
    field public static final String GET_ACCOUNTS = "android.permission.GET_ACCOUNTS";
    field public static final String GET_ACCOUNTS_PRIVILEGED = "android.permission.GET_ACCOUNTS_PRIVILEGED";
@@ -200,6 +201,7 @@ package android {
    field public static final String CALL_LOG = "android.permission-group.CALL_LOG";
    field public static final String CAMERA = "android.permission-group.CAMERA";
    field public static final String CONTACTS = "android.permission-group.CONTACTS";
    field public static final String FAKE_PACKAGE = "android.permission-group.FAKE_PACKAGE";
    field public static final String LOCATION = "android.permission-group.LOCATION";
    field public static final String MICROPHONE = "android.permission-group.MICROPHONE";
    field public static final String NEARBY_DEVICES = "android.permission-group.NEARBY_DEVICES";
+4 −0
Original line number Diff line number Diff line
@@ -64,6 +64,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeoutException;

import com.android.internal.safetynet.SafetyNetHooks;

/**
 * Base class for implementing application instrumentation code.  When running
 * with instrumentation turned on, this class will be instantiated for you
@@ -1188,6 +1190,7 @@ public class Instrumentation {
        Application app = getFactory(context.getPackageName())
                .instantiateApplication(cl, className);
        app.attach(context);
        SafetyNetHooks.init(app);
        return app;
    }
    
@@ -1205,6 +1208,7 @@ public class Instrumentation {
            ClassNotFoundException {
        Application app = (Application)clazz.newInstance();
        app.attach(context);
        SafetyNetHooks.init(app);
        return app;
    }

+62 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * 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.internal.safetynet;

import java.lang.reflect.Field;
import java.util.Arrays;

import android.app.Application;
import android.os.Build;
import android.util.Log;

public final class SafetyNetHooks {

    private static final String TAG = "SafetyNetHooks";
    private static final String GMS_PACKAGE_NAME = "com.google.android.gms";

    private static volatile boolean sIsGms = false;

    private static void setBuildField(String key, String value) {
        try {
            Field field = Build.class.getDeclaredField(key);
            field.setAccessible(true);
            field.set(null, value);
            field.setAccessible(false);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            Log.e(TAG, "Failed to fake Build." + key, e);
        }
    }

    public static void init(Application app) {
        if (GMS_PACKAGE_NAME.equals(app.getPackageName())) {
            sIsGms = true;
            setBuildField("MODEL", Build.MODEL + " ");
        }
    }

    private static boolean isCallerSafetyNet() {
        return Arrays.stream(Thread.currentThread().getStackTrace())
                .anyMatch(elem -> elem.getClassName().contains("DroidGuard"));
    }

    public static void onEngineGetCertificateChain() {
        // Check stack for SafetyNet
        if (sIsGms && isCallerSafetyNet()) {
            throw new UnsupportedOperationException();
        }
    }
}
+15 −0
Original line number Diff line number Diff line
@@ -3203,6 +3203,21 @@
        android:description="@string/permdesc_getPackageSize"
        android:protectionLevel="normal" />

    <!-- Dummy user-facing group for faking package signature -->
    <permission-group android:name="android.permission-group.FAKE_PACKAGE"
        android:label="@string/permgrouplab_fake_package_signature"
        android:description="@string/permgroupdesc_fake_package_signature"
        android:request="@string/permgrouprequest_fake_package_signature"
        android:priority="100" />

    <!-- Allows an application to change the package signature as
         seen by applications -->
    <permission android:name="android.permission.FAKE_PACKAGE_SIGNATURE"
        android:permissionGroup="android.permission-group.UNDEFINED"
        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. -->
Loading