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

Commit 7d058d62 authored by Svet Ganov's avatar Svet Ganov Committed by Svetoslav Ganov
Browse files

Addressing comments from commit:8d2ed5

bug:158792096
bug:180647319
bug:184051153
bug:184027531

Test:atest CtsPermissionTestCases
     atest CtsPermission2TestCases
     atest CtsPermission3TestCases
     atest CtsPermission4TestCases
     atest CtsPermission5TestCases
     atest CtsAppOpsTestCases
     atest CtsAppOps2TestCases
     atest CtsAlarmManagerTestCases

Change-Id: Id324ed0e2a653dface6ba273bba27e92bea14f99
parent 65645292
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -10684,7 +10684,7 @@ package android.content {
    ctor public ContextParams.Builder(@NonNull android.content.ContextParams);
    ctor public ContextParams.Builder(@NonNull android.content.ContextParams);
    method @NonNull public android.content.ContextParams build();
    method @NonNull public android.content.ContextParams build();
    method @NonNull public android.content.ContextParams.Builder setAttributionTag(@Nullable String);
    method @NonNull public android.content.ContextParams.Builder setAttributionTag(@Nullable String);
    method @NonNull public android.content.ContextParams.Builder setNextAttributionSource(@NonNull android.content.AttributionSource);
    method @NonNull public android.content.ContextParams.Builder setNextAttributionSource(@Nullable android.content.AttributionSource);
  }
  }
  public class ContextWrapper extends android.content.Context {
  public class ContextWrapper extends android.content.Context {
+1 −1
Original line number Original line Diff line number Diff line
@@ -2315,7 +2315,7 @@ package android.content {
  }
  }
  public static final class ContextParams.Builder {
  public static final class ContextParams.Builder {
    method @NonNull @RequiresPermission(android.Manifest.permission.RENOUNCE_PERMISSIONS) public android.content.ContextParams.Builder setRenouncedPermissions(@NonNull java.util.Set<java.lang.String>);
    method @NonNull @RequiresPermission(android.Manifest.permission.RENOUNCE_PERMISSIONS) public android.content.ContextParams.Builder setRenouncedPermissions(@Nullable java.util.Set<java.lang.String>);
  }
  }
  public class ContextWrapper extends android.content.Context {
  public class ContextWrapper extends android.content.Context {
+26 −0
Original line number Original line Diff line number Diff line
@@ -7403,6 +7403,32 @@ public class AppOpsManager {
        return sOpToString[opCode];
        return sOpToString[opCode];
    }
    }


    /**
     * Resolves special UID's pakcages such as root, shell, media, etc.
     *
     * @param uid The uid to resolve.
     * @param packageName Optional package. If caller system  and null returns "android"
     * @return The resolved package name.
     *
     * @hide
     */
    public static @Nullable String resolvePackageName(int uid, @Nullable String packageName)  {
        if (uid == Process.ROOT_UID) {
            return "root";
        } else if (uid == Process.SHELL_UID) {
            return "com.android.shell";
        } else if (uid == Process.MEDIA_UID) {
            return "media";
        } else if (uid == Process.AUDIOSERVER_UID) {
            return "audioserver";
        } else if (uid == Process.CAMERASERVER_UID) {
            return "cameraserver";
        } else if (uid == Process.SYSTEM_UID && packageName == null) {
            return "android";
        }
        return packageName;
    }

    /**
    /**
     * Monitor for changes to the operating mode for the given op in the given app package.
     * Monitor for changes to the operating mode for the given op in the given app package.
     * You can watch op changes only for your UID.
     * You can watch op changes only for your UID.
+9 −8
Original line number Original line Diff line number Diff line
@@ -226,7 +226,7 @@ class ContextImpl extends Context {
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    private final String mOpPackageName;
    private final String mOpPackageName;
    private final @NonNull ContextParams mParams;
    private final @NonNull ContextParams mParams;
    private @NonNull AttributionSource mAttributionSource;
    private final @NonNull AttributionSource mAttributionSource;


    private final @NonNull ResourcesManager mResourcesManager;
    private final @NonNull ResourcesManager mResourcesManager;
    @UnsupportedAppUsage
    @UnsupportedAppUsage
@@ -3074,25 +3074,26 @@ class ContextImpl extends Context {


        mOpPackageName = overrideOpPackageName != null ? overrideOpPackageName : opPackageName;
        mOpPackageName = overrideOpPackageName != null ? overrideOpPackageName : opPackageName;
        mParams = Objects.requireNonNull(params);
        mParams = Objects.requireNonNull(params);
        initializeAttributionSource(attributionTag, nextAttributionSource);
        mAttributionSource = createAttributionSource(attributionTag, nextAttributionSource);
        mContentResolver = new ApplicationContentResolver(this, mainThread);
        mContentResolver = new ApplicationContentResolver(this, mainThread);
    }
    }


    private void initializeAttributionSource(@Nullable String attributionTag,
    private @NonNull AttributionSource createAttributionSource(@Nullable String attributionTag,
            @Nullable AttributionSource nextAttributionSource) {
            @Nullable AttributionSource nextAttributionSource) {
        mAttributionSource = new AttributionSource(Process.myUid(), mOpPackageName,
        AttributionSource attributionSource = new AttributionSource(Process.myUid(), mOpPackageName,
                attributionTag, nextAttributionSource);
                attributionTag, nextAttributionSource);
        // If we want to access protected data on behalf of another app we need to
        // If we want to access protected data on behalf of another app we need to
        // tell the OS that we opt in to participate in the attribution chain.
        // tell the OS that we opt in to participate in the attribution chain.
        if (nextAttributionSource != null) {
        if (nextAttributionSource != null) {
            // If an app happened to stub the internal OS for testing the registration method
            // If an app happened to stub the internal OS for testing the registration method
            // can return null. In this case we keep the current untrusted attribution source.
            // can return null. In this case we keep the current untrusted attribution source.
            final AttributionSource attributionSource = getSystemService(PermissionManager.class)
            final AttributionSource registeredAttributionSource = getSystemService(
                    .registerAttributionSource(mAttributionSource);
                    PermissionManager.class).registerAttributionSource(attributionSource);
            if (attributionSource != null) {
            if (registeredAttributionSource != null) {
                mAttributionSource = attributionSource;
                return registeredAttributionSource;
            }
            }
        }
        }
        return attributionSource;
    }
    }


    void setResources(Resources r) {
    void setResources(Resources r) {
+1 −0
Original line number Original line Diff line number Diff line
@@ -3884,6 +3884,7 @@ public abstract class ContentResolver implements ContentInterface {
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    private final Context mContext;
    private final Context mContext;


    @Deprecated
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    final String mPackageName;
    final String mPackageName;
    final int mTargetSdkVersion;
    final int mTargetSdkVersion;
Loading