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

Commit 2d628b73 authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Support feature context in TelephonyManager

...Managers are supposed to use the passed in context to support e.g.
alternate user or package contexts. Not sure why this is not the case
for TelephonyManager.

Hence special case the support for feature-contexts.

Test: atest CtsAppOpsTestCases:android.app.appops.cts.AppOpsLoggingTest#getCellInfo
Bug: 136595429
Change-Id: I7f498e282a34e39da6a1f6c129eff09674dce795
parent 38936c1d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.content;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.TestApi;
@@ -927,6 +928,11 @@ public class ContextWrapper extends Context {
        return mBase.createDisplayContext(display);
    }

    @Override
    public @NonNull Context createFeatureContext(@Nullable String featureId) {
        return mBase.createFeatureContext(featureId);
    }

    @Override
    public boolean isRestricted() {
        return mBase.isRestricted();
+6 −1
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
@@ -325,7 +326,11 @@ public class TelephonyManager {
        mSubId = subId;
        Context appContext = context.getApplicationContext();
        if (appContext != null) {
            if (Objects.equals(context.getFeatureId(), appContext.getFeatureId())) {
                mContext = appContext;
            } else {
                mContext = appContext.createFeatureContext(context.getFeatureId());
            }
        } else {
            mContext = context;
        }