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

Commit 1565a1e1 authored by Youming Ye's avatar Youming Ye Committed by android-build-merger
Browse files

Merge "Restrict inject jar path under system" am: e10bda63 am: bc768d8e

am: e56515ec

Change-Id: I2133e32a40d13cf2d2f9af5b00f4c24c46968243
parents c820c807 e56515ec
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.system.Os;
import android.system.OsConstants;
import android.system.StructStatVfs;
import android.telephony.Rlog;
import android.text.TextUtils;

import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager;
import com.android.internal.telephony.cdma.EriManager;
@@ -72,18 +73,25 @@ public class TelephonyComponentFactory {
        private static final String TAG_INJECTION = "injection";
        private static final String TAG_COMPONENTS = "components";
        private static final String TAG_COMPONENT = "component";
        private static final String SYSTEM = "/system/";

        private final Set<String> mComponentNames = new HashSet<>();
        private TelephonyComponentFactory mInjectedInstance;
        private String mPackageName;
        private String mJarPath;

        private boolean isInjected() {
            return mPackageName != null && mJarPath != null;
        /**
         * @return if jar path is correctly configured to inject.
         * 1) PackageName and JarPath mustn't be empty.
         * 2) JarPath is restricted under /system only
         */
        private boolean isConfigValid() {
            return !TextUtils.isEmpty(mPackageName) && !TextUtils.isEmpty(mJarPath)
                    && mJarPath.startsWith(SYSTEM);
        }

        private void makeInjectedInstance() {
            if (isInjected()) {
            if (isConfigValid()) {
                try {
                    StructStatVfs vfs = Os.statvfs(mJarPath);
                    if ((vfs.f_flag & OsConstants.ST_RDONLY) != 0) {
@@ -222,7 +230,7 @@ public class TelephonyComponentFactory {
            mInjectedComponents = new InjectedComponents();
            mInjectedComponents.parseXml(parser);
            mInjectedComponents.makeInjectedInstance();
            Rlog.d(TAG, "Total components injected: " + (mInjectedComponents.isInjected()
            Rlog.d(TAG, "Total components injected: " + (mInjectedComponents.isConfigValid()
                    ? mInjectedComponents.mComponentNames.size() : 0));
        }
    }