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

Commit abd6c63d authored by Youming Ye's avatar Youming Ye Committed by paulye
Browse files

Check for protected jar path when using injected jar.

Test: Manual
Bug: 120040975
Change-Id: I5458d1f758dda885094068d65f223288ba332a26
parent 198d1baf
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));
        }
    }