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

Commit a2b5dab5 authored by Romain Guy's avatar Romain Guy Committed by The Android Open Source Project
Browse files

am 870e09fc: Fixes #1963229. Introduces Context#isRestricted().

Merge commit '870e09fc'

* commit '870e09fc':
  Fixes #1963229. Introduces Context#isRestricted().
parents 4fad469b 870e09fc
Loading
Loading
Loading
Loading
+22 −0
Original line number Original line Diff line number Diff line
@@ -31051,6 +31051,17 @@
<parameter name="modeFlags" type="int">
<parameter name="modeFlags" type="int">
</parameter>
</parameter>
</method>
</method>
<method name="isRestricted"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="obtainStyledAttributes"
<method name="obtainStyledAttributes"
 return="android.content.res.TypedArray"
 return="android.content.res.TypedArray"
 abstract="false"
 abstract="false"
@@ -31575,6 +31586,17 @@
 visibility="public"
 visibility="public"
>
>
</field>
</field>
<field name="CONTEXT_RESTRICTED"
 type="int"
 transient="false"
 volatile="false"
 value="4"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="INPUT_METHOD_SERVICE"
<field name="INPUT_METHOD_SERVICE"
 type="java.lang.String"
 type="java.lang.String"
 transient="false"
 transient="false"
+7 −0
Original line number Original line Diff line number Diff line
@@ -187,6 +187,7 @@ class ApplicationContext extends Context {
    private StatusBarManager mStatusBarManager = null;
    private StatusBarManager mStatusBarManager = null;
    private TelephonyManager mTelephonyManager = null;
    private TelephonyManager mTelephonyManager = null;
    private ClipboardManager mClipboardManager = null;
    private ClipboardManager mClipboardManager = null;
    private boolean mRestricted;


    private final Object mSync = new Object();
    private final Object mSync = new Object();


@@ -1352,6 +1353,7 @@ class ApplicationContext extends Context {
            mMainThread.getPackageInfo(packageName, flags);
            mMainThread.getPackageInfo(packageName, flags);
        if (pi != null) {
        if (pi != null) {
            ApplicationContext c = new ApplicationContext();
            ApplicationContext c = new ApplicationContext();
            c.mRestricted = (flags & CONTEXT_RESTRICTED) == CONTEXT_RESTRICTED;
            c.init(pi, null, mMainThread);
            c.init(pi, null, mMainThread);
            if (c.mResources != null) {
            if (c.mResources != null) {
                return c;
                return c;
@@ -1363,6 +1365,11 @@ class ApplicationContext extends Context {
            "Application package " + packageName + " not found");
            "Application package " + packageName + " not found");
    }
    }


    @Override
    public boolean isRestricted() {
        return mRestricted;
    }

    private File getDataDirFile() {
    private File getDataDirFile() {
        if (mPackageInfo != null) {
        if (mPackageInfo != null) {
            return mPackageInfo.getDataDirFile();
            return mPackageInfo.getDataDirFile();
+1 −1
Original line number Original line Diff line number Diff line
@@ -269,7 +269,7 @@ public class AppWidgetHostView extends FrameLayout {
        try {
        try {
            if (mInfo != null) {
            if (mInfo != null) {
                Context theirContext = mContext.createPackageContext(
                Context theirContext = mContext.createPackageContext(
                        mInfo.provider.getPackageName(), 0 /* no flags */);
                        mInfo.provider.getPackageName(), Context.CONTEXT_RESTRICTED);
                LayoutInflater inflater = (LayoutInflater)
                LayoutInflater inflater = (LayoutInflater)
                        theirContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                        theirContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                inflater = inflater.cloneInContext(theirContext);
                inflater = inflater.cloneInContext(theirContext);
+18 −0
Original line number Original line Diff line number Diff line
@@ -1665,6 +1665,13 @@ public abstract class Context {
     */
     */
    public static final int CONTEXT_IGNORE_SECURITY = 0x00000002;
    public static final int CONTEXT_IGNORE_SECURITY = 0x00000002;
    
    
    /**
     * Flag for use with {@link #createPackageContext}: a restricted context may
     * disable specific features. For instance, a View associated with a restricted
     * context would ignore particular XML attributes.
     */
    public static final int CONTEXT_RESTRICTED = 0x00000004;

    /**
    /**
     * Return a new Context object for the given application name.  This
     * Return a new Context object for the given application name.  This
     * Context is the same as what the named application gets when it is
     * Context is the same as what the named application gets when it is
@@ -1692,4 +1699,15 @@ public abstract class Context {
     */
     */
    public abstract Context createPackageContext(String packageName,
    public abstract Context createPackageContext(String packageName,
            int flags) throws PackageManager.NameNotFoundException;
            int flags) throws PackageManager.NameNotFoundException;

    /**
     * Indicates whether this Context is restricted.
     * 
     * @return True if this Context is restricted, false otherwise.
     * 
     * @see #CONTEXT_RESTRICTED
     */
    public boolean isRestricted() {
        return false;
    }
}
}
+5 −0
Original line number Original line Diff line number Diff line
@@ -430,4 +430,9 @@ public class ContextWrapper extends Context {
        throws PackageManager.NameNotFoundException {
        throws PackageManager.NameNotFoundException {
        return mBase.createPackageContext(packageName, flags);
        return mBase.createPackageContext(packageName, flags);
    }
    }

    @Override
    public boolean isRestricted() {
        return mBase.isRestricted();
    }
}
}
Loading