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

Commit 4e0e339f authored by Rohit Sekhar's avatar Rohit Sekhar
Browse files

hacky adapt

parent 89ec26c3
Loading
Loading
Loading
Loading
+13 −73
Original line number Diff line number Diff line
@@ -65,79 +65,19 @@ public class AppStateController {
        mPm = pm;
        mUserId = Process.myUserHandle().myUserId();
        registerReceiver();
        initCarrierAppList();
        boolean islock = SystemProperties.getBoolean(DSDLOCKED_CARRIERID, false);
        if(!islock){
            setPreInstallCarrierApkState();
            //setPreInstallCarrierApkState();
        }
        Log.d(TAG, "AppStateController init");
    }

    private void initCarrierAppList() {
        for (String pkg : CARRIER_PREINSTALL_ARRAY) {
            AppState appState = new AppState();
            appState.installState = false;
            appState.pkgName = pkg;
            mAppStateArrayList.add(appState);
        }
    }

    private void updateCarrierAppState() {
        CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        //PersistableBundle config = configManager.getConfig();
        PersistableBundle config = configManager.getConfigLocked();
        if (config != null) {
            Log.d(TAG, "config != null");
            String[] preInstallApps = config.getStringArray(KEY_CARRIER_PREINSTALL);
            if (preInstallApps != null && preInstallApps.length > 0) { //dsd lock carrier_install is not null
                Log.d(TAG, "get carrier config preintall count = " + preInstallApps.length);
                for (String app : preInstallApps) {
                    Log.d(TAG, "get carrier config preintall " + app);
                    for (AppState appState : mAppStateArrayList) {
                        if (appState.pkgName.equals(app)) {
                            appState.installState = true;
                            if (!mIsCarrierConfigLoaded) {
                                Log.d(TAG, "mIsCarrierConfigLoaded = true");
                                mIsCarrierConfigLoaded = true;
                            }
                        }
                    }
                }
            } else {  //dsd lock carrier_install is null

                config = configManager.getConfig();
                preInstallApps = config.getStringArray(KEY_CARRIER_PREINSTALL);

                if (preInstallApps != null && preInstallApps.length > 0) { //dsd lock carrier_install is not null
                    Log.d(TAG, "else get carrier config preintall count = " + preInstallApps.length);
                    if("com.gohappy.mobileapp".equals(preInstallApps[0])){
                        for (String app : preInstallApps) {
                            Log.d(TAG, "else get carrier config preintall " + app);
                            for (AppState appState : mAppStateArrayList) {
                                if (appState.pkgName.equals(app)) {
                                    appState.installState = true;
                                    if (!mIsCarrierConfigLoaded) {
                                        Log.d(TAG, "mIsCarrierConfigLoaded = true");
                                        mIsCarrierConfigLoaded = true;
                                    }
                                }
                            }
                        }
                    }

                }

            }
        }
    }

    private void registerReceiver() {
        IntentFilter mIntentFilter = new IntentFilter();
        mIntentFilter.addAction(TelephonyManager.ACTION_SIM_APPLICATION_STATE_CHANGED);
        //mIntentFilter.addAction(Intent.ACTION_BOOT_COMPLETED);
        mIntentFilter.addAction(Intent.ACTION_LOCKED_BOOT_COMPLETED);
        mIntentFilter.addAction(Intent.ACTION_BOOT_COMPLETED);
        mIntentFilter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
        mIntentFilter.addAction(Intent.ACTION_USER_SWITCHED);
        mIntentFilter.addAction(Intent.ACTION_USER_REMOVED);
        mIntentFilter.addAction(Intent.ACTION_USER_ADDED);
@@ -149,8 +89,8 @@ public class AppStateController {
                    Log.d(TAG,"ACTION_USER_SWITCHED userId = " + userId);
                    Log.d(TAG,"ACTION_USER_SWITCHED getActiveLauncherPackageName = " + mPm.getActiveLauncherPackageName(userId));
                    if(mPm.getActiveLauncherPackageName(userId) == null || 
                       "com.google.android.setupwizard".equals(mPm.getActiveLauncherPackageName(userId))){
                        mPm.setActiveLauncherPackage("com.android.launcher3",userId,successful -> {
                       "org.lineageos.setupwizard".equals(mPm.getActiveLauncherPackageName(userId))){
                        mPm.setActiveLauncherPackage("foundation.e.blisslauncher",userId,successful -> {
                            if (successful) {
                                 Log.d(TAG,"default launcher set success for userId " + userId);
                            }else{
@@ -161,8 +101,8 @@ public class AppStateController {
                    if (userId != mUserId) {
                        Log.d(TAG, "ACTION_USER_SWITCHED" + " old user id = " + userId + " new user id = " + mUserId);
                        mUserId = userId;
                        updateCarrierAppState();
                        setPreInstallCarrierApkState();
                        //updateCarrierAppState();
                        //setPreInstallCarrierApkState();
                    }

                }
@@ -172,8 +112,8 @@ public class AppStateController {
                    Log.d(TAG,"ACTION_USER_ADDED userId = " + userId);
                    Log.d(TAG,"ACTION_USER_ADDED getActiveLauncherPackageName = " + mPm.getActiveLauncherPackageName(userId));
                    if(mPm.getActiveLauncherPackageName(userId) == null || 
                       "com.google.android.setupwizard".equals(mPm.getActiveLauncherPackageName(userId))){
                        mPm.setActiveLauncherPackage("com.android.launcher3",userId,successful -> {
                       "org.lineageos.setupwizard".equals(mPm.getActiveLauncherPackageName(userId))){
                        mPm.setActiveLauncherPackage("foundation.e.blisslauncher",userId,successful -> {
                            if (successful) {
                                 Log.d(TAG,"default launcher set success for userId " + userId);
                            }else{
@@ -187,8 +127,8 @@ public class AppStateController {
                    if (userId != mUserId) {
                        Log.d(TAG, "ACTION_USER_ADDED" + " old user id = " + userId + " new user id = " + mUserId);
                        mUserId = userId;
                        updateCarrierAppState();
                        setPreInstallCarrierApkState_forOtherUser();
                        //updateCarrierAppState();
                        //setPreInstallCarrierApkState_forOtherUser();
                    }
                }

@@ -213,8 +153,8 @@ public class AppStateController {
                        if (uid != UserHandle.USER_SYSTEM){
                            mUserId = uid;
                            Log.d(TAG, "disable preload app on user " + mUserId);
                            updateCarrierAppState();
                            setPreInstallCarrierApkState_forOtherUser();
                            //updateCarrierAppState();
                            //setPreInstallCarrierApkState_forOtherUser();
                            mUserId = 0;
                        }
                    }
@@ -222,7 +162,7 @@ public class AppStateController {

                if (CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED.equals(intent.getAction())) {
                    Log.d(TAG, "ACTION_CARRIER_CONFIG_CHANGED");
                    updateCarrierAppState();
                    //updateCarrierAppState();
                    mHandler.postDelayed(() -> judgeAndFireSetAppState(),200);

                }
@@ -247,7 +187,7 @@ public class AppStateController {
            Log.d(TAG, " judgeAndFireSetAppState mIsCarrierConfigLoaded  " + mIsCarrierConfigLoaded + " mHasSetAppState = " + mHasSetAppState);
            return;
        }
        setPreInstallCarrierApkState();
        //setPreInstallCarrierApkState();
        mHasSetAppState = true;
        SystemProperties.set(DSDLOCKED_HASENABLEAPP, "1");
    }
+1 −1
Original line number Diff line number Diff line
@@ -4210,7 +4210,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService

        for (int userId : UserManagerService.getInstance().getUserIds()) {
            if(getActiveLauncherPackageName(userId) == null){
                setActiveLauncherPackage("com.android.launcher3",userId,successful -> {
                setActiveLauncherPackage("foundation.e.blisslauncher",userId,successful -> {
                    if (successful) {
                         Log.d(TAG,"default launcher set success for userId " + userId);
                    }else{