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

Commit b97b5ef0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Check for protected jar path when using injected jar."

parents 20561837 abd6c63d
Loading
Loading
Loading
Loading
+18 −7
Original line number Diff line number Diff line
@@ -24,6 +24,10 @@ import android.os.Handler;
import android.os.IDeviceIdleController;
import android.os.Looper;
import android.os.ServiceManager;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
import android.system.StructStatVfs;
import android.telephony.Rlog;

import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager;
@@ -80,11 +84,18 @@ public class TelephonyComponentFactory {

        private void makeInjectedInstance() {
            if (isInjected()) {
                try {
                    StructStatVfs vfs = Os.statvfs(mJarPath);
                    if ((vfs.f_flag & OsConstants.ST_RDONLY) != 0) {
                        PathClassLoader classLoader = new PathClassLoader(mJarPath,
                                ClassLoader.getSystemClassLoader());
                try {
                        Class<?> cls = classLoader.loadClass(mPackageName);
                        mInjectedInstance = (TelephonyComponentFactory) cls.newInstance();
                    } else {
                        Rlog.w(TAG, "Injection jar is not protected");
                    }
                } catch (ErrnoException e) {
                    Rlog.e(TAG, "failed file mount, " + e.getMessage());
                } catch (ClassNotFoundException e) {
                    Rlog.e(TAG, "failed: " + e.getMessage());
                } catch (IllegalAccessException | InstantiationException e) {
@@ -203,7 +214,7 @@ public class TelephonyComponentFactory {
     */
    public void injectTheComponentFactory(XmlResourceParser parser) {
        if (mInjectedComponents != null) {
            Rlog.i(TAG, "Already injected.");
            Rlog.d(TAG, "Already injected.");
            return;
        }

@@ -211,8 +222,8 @@ public class TelephonyComponentFactory {
            mInjectedComponents = new InjectedComponents();
            mInjectedComponents.parseXml(parser);
            mInjectedComponents.makeInjectedInstance();
            Rlog.i(TAG, "Total components injected: "
                    + mInjectedComponents.mComponentNames.size());
            Rlog.d(TAG, "Total components injected: " + (mInjectedComponents.isInjected()
                    ? mInjectedComponents.mComponentNames.size() : 0));
        }
    }