精华内容
下载资源
问答
  • 华为手机上 手机管家会监测应用间的相互启动,并根据用户之前设置的关联启动开关(默认关闭即禁止)情况判断是否进行拦截关联启动操作;但是在关联启动记录中有一个很有意思的现象,就是记录中会有多条“某App被...

    现象:

         华为手机上 手机管家会监测应用间的相互启动,并根据用户之前设置的关联启动开关(默认关闭即禁止)情况判断是否进行拦截关联启动操作;但是在关联启动记录中有一个很有意思的现象,就是记录中会有多条“某App被Android操作系统启动”的拦截。并且很多App都出现在拦击记录中。

    分析:

          针对此现象进行分析发现,每次开机后都会有几个App(抖音、百度安全卫士、宝宝知道、爱奇艺纳豆等拦截记录),刚开机App一般来不及做其他动作,怀疑监听了系统的开机广播、电量、网络广播等;以下针对抖音、酷划锁屏、好看视频的apk进行反编译发现共性是都注册了开机等系统广播;详细如下:

    //好看视频
    		<receiver
    			android:name="com.baidu.haokan.receiver.AppReceiver"
    			android:exported="true"
    			android:priority="1000"
    			>
    			<intent-filter
    				>
    				<action
    					android:name="android.intent.action.BOOT_COMPLETED"
    					>
    				</action>
    				<action
    					android:name="android.intent.action.USER_PRESENT"
    					>
    				</action>
    				<action
    					android:name="android.net.conn.CONNECTIVITY_CHANGE"
    					>
    				</action>
    			</intent-filter>
    		</receiver>
    //抖音
    		<receiver
    			android:name="com.ss.android.message.MessageReceiver"
    			android:process=":push"
    			android:priority="2147483647"
    			>
    			<intent-filter
    				>
    				<action
    					android:name="android.intent.action.BOOT_COMPLETED"
    					>
    				</action>
    				<action
    					android:name="android.net.conn.CONNECTIVITY_CHANGE"
    					>
    				</action>
    				<action
    					android:name="android.intent.action.DATE_CHANGED"
    					>
    				</action>
    				<action
    					android:name="android.intent.action.MEDIA_MOUNTED"
    					>
    				</action>
    				<action
    					android:name="android.intent.action.MEDIA_UNMOUNTED"
    					>
    				</action>
    				<action
    					android:name="android.intent.action.USER_PRESENT"
    					>
    				</action>
    				<action
    					android:name="android.intent.action.SCREEN_OFF"
    					>
    				</action>
    				<action
    					android:name="android.intent.action.SCREEN_ON"
    					>
    				</action>
    				<action
    					android:name="android.intent.action.ACTION_POWER_CONNECTED"
    					>
    				</action>
    				<action
    					android:name="android.intent.action.ACTION_POWER_DISCONNECTED"
    					>
    				</action>
    			</intent-filter>
    			<intent-filter
    				>
    				<action
    					android:name="android.intent.action.PACKAGE_ADDED"
    					>
    				</action>
    				<action
    					android:name="android.intent.action.PACKAGE_REMOVED"
    					>
    				</action>
    				<data
    					android:scheme="package"
    					>
    				</data>
    			</intent-filter>
    		</receiver>
    //酷划锁屏
    		<receiver
    			android:name="com.coohuaclient.business.lockscreen.receiver.MonitorReceiver"
    			>
    			<intent-filter
    				>
    				<action
    					android:name="android.intent.action.USER_PRESENT"
    					>
    				</action>
    				<action
    					android:name="android.intent.action.BOOT_COMPLETED"
    					>
    				</action>
    				<action
    					android:name="android.intent.action.ACTION_POWER_CONNECTED"
    					>
    				</action>
    				<action
    					android:name="android.net.conn.CONNECTIVITY_CHANGE"
    					>
    				</action>
    			</intent-filter>
    		</receiver>

     

    展开全文
  • 自启动和管理启动管理介绍 自启动管理用于管理应用的开机自启动/后台自启动/关联自启动。应用自启动的管理,以包名(应 用名)进行限制,不区分 user(用户)。 ...关联启动指不同的应用之间进...

    自启动和管理启动管理介绍

    自启动管理用于管理应用的开机自启动/后台自启动/关联自启动。应用自启动的管理,以包名(应
    用名)进行限制,不区分 user(用户)。

    (1)自启动
    指开机自启动和后台自启动。应用可以监听系统的一些开机广播,从而在系统开机后自动进行启动。
    同时应用也可以监听系统的任何广播,如网络连接的广播,从而在网络连接上的时候,进行自启动。
    (2)关联启动
    关联启动指不同的应用之间进行互起。这里指的是,该应用被其他应用后台启动。

    流程分析

    1)自启动reason

        private static final String REASON_START_SERVICE = "start-service";
        private static final String REASON_BIND_SERVICE = "bind-service";
        private static final String REASON_CONTENT_PROVIDER = "contentprovider";
        private static final String REASON_BROADCAST = "send-broadcast";
        private static final String REASON_START_ACTIVITY = "start-activity";

     

    1.1 start-activity

    在ActivityStarter.java-->startActivity()判断是否是异常启动

        private int startActivity(IApplicationThread caller, Intent intent, Intent ephemeralIntent,
                String resolvedType, ActivityInfo aInfo, ResolveInfo rInfo,
                IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor,
                IBinder resultTo, String resultWho, int requestCode, int callingPid, int callingUid,
                String callingPackage, int realCallingPid, int realCallingUid, int startFlags,
                ActivityOptions options, boolean ignoreTargetSecurity, boolean componentSpecified,
                ActivityRecord[] outActivity, TaskRecord inTask) {
                  
            .......
            String targetPkg = null;
            int targetUid = aInfo != null ? aInfo.applicationInfo.uid : 0;
            if (intent.getComponent() != null) targetPkg = intent.getComponent().getPackageName();
            if(!mService.judgeStartAllowLocked(intent, targetPkg, targetUid, callingUid, callingPackage, "start-activity")){
                return ActivityManager.START_INTENT_NOT_RESOLVED;
            }
            .......
    }

    1.2 start-service

    在ActiveServices.java-->startServiceLocked()

        ComponentName startServiceLocked(IApplicationThread caller, Intent service, String resolvedType,
                int callingPid, int callingUid, boolean fgRequired, String callingPackage, final int userId)
                throws TransactionTooLargeException {
            ......
                    int targetUid = r.appInfo != null ? r.appInfo.uid : 0 ;
            if(!mAm.judgeStartAllowLocked(service, r.packageName, targetUid, callingUid, callingPackage,"start-service")) {
                return null;
            }
            ......

    1.3 bind-service

    在ActiveServices.java-->bindServiceLocked()

        int bindServiceLocked(IApplicationThread caller, IBinder token, Intent service,
                String resolvedType, final IServiceConnection connection, int flags,
                String callingPackage, final int userId) throws TransactionTooLargeException {
              ......
                      String targetPkg = s != null ? s.packageName : null;
            int targetUid = (s != null && s.appInfo != null) ? s.appInfo.uid : 0;
            int callingUid = (callerApp != null && callerApp.info != null) ? callerApp.info.uid : 0;
            if(!mAm.judgeStartAllowLocked(service, targetPkg, targetUid, callingUid, callingPackage,"bind-service")) {
                return 0;
            }
              ......

    1.4 send-broadcast

    final void processNextBroadcast(boolean fromMsg) {
            ......
                            skip = skip || !mService.judgeStartAllowLocked(r.intent, info.activityInfo.applicationInfo.packageName,
                        info.activityInfo.applicationInfo.uid, r.callingUid, r.callerPackage,"send-broadcast");
            ......
    }

    1.5 contentprovider

    ActivityManagerService.java -->getContentProviderImpl()

    
        private ContentProviderHolder getContentProviderImpl(IApplicationThread caller,
                String name, IBinder token, boolean stable, int userId) {
            ContentProviderRecord cpr;
            ......
                            String targetPkg = (cpr != null && cpr.appInfo != null) ? cpr.appInfo.packageName : null;
                    int targetUid = (cpr != null && cpr.appInfo != null) ? cpr.appInfo.uid : 0;
                    if (r != null && r.info != null) {
                        String callingPackage = r.info.packageName;
                        int callerUid = r.info.uid;
                        if(!judgeStartAllowLocked(null, targetPkg, targetUid, callerUid, callingPackage,"contentprovider")) {
                            return null;
                        }
                    }
            ......

    可以看出自启动的拦截,就是在四大组件启动流程中进行的

    2)judgeStartAllowLocked()流程分析

    ActivityManagerServerEx.java-->judgeStartAllowLocked()

        protected boolean judgeStartAllowLocked(Intent intent, String targetPkg, int targetUid,
            int callingUid, String callingPackage, String reason) {
    
            boolean allowed = true;
            if (allowed && mPowerControllerInternal != null) {
                try {
                    allowed = mPowerControllerInternal.judgeAppLaunchAllowed(intent, targetPkg, targetUid, callingUid, callingPackage, reason);
                } catch (Exception e) {}
            }
            

    BackgroundCleanHelper.java-->judgeAppLaunchAllowed()

         boolean judgeAppLaunchAllowed(Intent intent, String targetApp, int targetUid,
                int callerUid, String callerApp, String reason) {
            mPowerHintSceneForGts.noteAppLaunched(targetApp, callerApp, callerUid);
    
            boolean ret = judgeAppLaunchAllowedInternal(intent, targetApp, targetUid, callerUid, callerApp, reason);
            if (mCurrentUserId == 0 && ret && targetApp != null) {
                if (!targetApp.equals(callerApp) && !mFirstCallerAppList.containsKey(targetApp)
                    && isInstalledApp(targetApp, 0)) {
                    mFirstCallerAppList.put(targetApp, new CallerAppInfo(callerApp, callerUid, reason));
                }
            }
            return ret;
    

    BackgroundCleanHelper.java-->judgeAppLaunchAllowedInternal()

    /*
         * Third app can not self started:
         * 1. not allow system broadcast from "systemserver" or "com.android.systemui"
         * 2. not allow start service from ""com.android.shell"
         * 3. not allow background app to launch other third party app
         * 4. not allow self started third party app to start other third party app
         * 5. not allow third party app to start other third party app during standby
         *
         * Note: This api is call from AMS in other threads and may be in variable calling context
         *  SO BE CAREFULL : avoid call other system API that may hold lock. Otherwise, a deadlock may HAPPEN
         */
         boolean judgeAppLaunchAllowedInternal(Intent intent, String targetApp, int targetUid,
                int callerUid, String callerApp, String reason) {
    
            // if this function is disabled, just return true
            if (!mEnabled) return true;
    
            if (DEBUG_MORE) Slog.d(TAG,"judgeAppLaunchAllowed : "+targetApp+"(uid:" + targetUid
                + "), callingPackage = "+callerApp+"(uid:" + callerUid + "), reason = "+reason);
            if (DEBUG_MORE && intent != null) Slog.d(TAG,"judgeAppLaunchAllowed : intent action:" + intent);
    
            if (targetApp == null) return true;
    
            // bug#768670
            if (handleStartServiceStartAction(intent, targetApp, targetUid, callerApp, callerUid, reason)) {
                return true;
            }
    
            if (handleBindServiceStartAction(intent, targetApp, targetUid, callerApp, callerUid, reason)) {
                return true;
            }
    
            if (handleContentProviderStartAction(intent, targetApp, targetUid, callerApp, callerUid, reason)) {
                return true;
            }
    
            //handle inputmethod
            if (isLaunchingIMEApp(intent, targetApp, targetUid, callerApp, reason)) {
                return true;
            }
    
            if (handleBroadcastAction(intent, targetApp, targetUid, callerApp, callerUid, reason)) {
                return true;
            }
    
            //handle speech recognition
            if (isRecognizerIntent(intent, targetApp, targetUid, callerApp, callerUid, reason)) {
                return true;
            }
    
            // allow cts app to start any other app
            // allow autotest app
            if (Util.isCts(callerApp) || isAutoTest(callerUid, callerApp, targetApp)) {
                return true;
            }
    
            // check deny for ultra saving mode
            //if (denyBecauseOfUltraSavingMode(intent, targetApp, targetUid, callerApp, callerUid, reason)) {
            //    return false;
            //}
    
            int targetUserId = UserHandle.getUserId(targetUid);
            int callUserId = UserHandle.getUserId(callerUid);
            AppState callerAppState = mAppStateInfoCollector.getAppState(callerApp, callUserId);
            AppState targetAppState = mAppStateInfoCollector.getAppState(targetApp, targetUserId);
    
            // if target app already exist
            /*if (targetAppState != null
                && targetAppState.mProcState < ActivityManager.PROCESS_STATE_CACHED_EMPTY
                && targetAppState.mProcState != ActivityManager.PROCESS_STATE_NONEXISTENT) {*/
            if (isAlreadyStarted(targetAppState)) {
                if (DEBUG_MORE) Slog.d(TAG,"Start Proc : "+targetApp+", callingPackage = "+callerApp+", reason = "+reason + ": already started!!"
                    + " (ProcState:" +  Util.ProcState2Str(targetAppState.mProcState)
                    + " mState:" + Util.AppState2Str(targetAppState.mState)
                    + ")");
                return true;
            }
    
            // check system app
            // allow to launch system app
            int launchState = checkLaunchStateByPreset(intent, targetApp, targetUid, callerApp, callerUid, reason);
            if (launchState == LAUNCH_STATE_ALLOW)
                return true;
            else if (launchState == LAUNCH_STATE_DENY)
                return false;
    
            // check user setting for third-party app(重点)
            launchState = checkLaunchStateByUserSetting(intent, targetApp, targetUid, callerApp, callerUid, reason);
            if (DEBUG_MORE) Slog.d(TAG, "launchState: " + launchState);
            if (launchState == LAUNCH_STATE_ALLOW)
                return true;
            else if (launchState == LAUNCH_STATE_DENY)
                return false;
    
            // not allow third party app that has been force stopped during standby
            // to be started again
            if (mStandbyStartTime > 0 && isForceStoppedAppDuringStandby(targetApp, targetUid)) {
                if (DEBUG) Slog.d(TAG,"Start Proc : "+targetApp+", callingPackage = "+callerApp+", reason = "+reason + ": denyed (has been force stopped)!!");
                return false;
            }
    
            // not allow system broadcast to launch third party app
            if ((callerAppState == null ||(callerApp != null && callerApp.equals("android")))
                && REASON_BROADCAST.equals(reason)) {
                if (DEBUG) Slog.d(TAG,"Start Proc : "+targetApp+", callingPackage = "+callerApp+", reason = "+reason + ": denyed!!");
                return false;
            }
    
            // not allow "com.android.systemui" broadcast to launch third party app
            if (callerApp != null && callerApp.equals("com.android.systemui")
                && REASON_BROADCAST.equals(reason)) {
                if (DEBUG) Slog.d(TAG,"Start Proc : "+targetApp+", callingPackage = "+callerApp+", reason = "+reason + ": denyed!!");
                return false;
            }
    
            // allow app to launch itself
            if (targetApp.equals(callerApp)) {
                return true;
            }
    
            // not allow non-top app to launch other app, except launched by UserActivity
            if (!launchedByUserActivity(intent, targetApp, targetUid, callerApp, callerUid, reason, true)) {
                if (DEBUG) {
                    Slog.d(TAG,"Start Proc : "+targetApp
                        +", callingPackage = "+callerApp
                        + " (ProcState:" + (callerAppState != null ? Util.ProcState2Str(callerAppState.mProcState):"none")
                        +"), reason = "+reason
                        + ": non-UserActivity denyed!!");
                }
                return false;
            }
    
            // not allow background app to launch other third party app
            if (callerAppState != null && callerAppState.mProcState > ActivityManager.PROCESS_STATE_FOREGROUND_SERVICE
                && !REASON_START_ACTIVITY.equals(reason)) {
                if (DEBUG) {
                    Slog.d(TAG,"Start Proc : "+targetApp
                        +", callingPackage = "+callerApp
                        + " (ProcState:" + (callerAppState != null ? Util.ProcState2Str(callerAppState.mProcState):"none")
                        +"), reason = "+reason
                        + ": denyed!!");
                }
                return false;
            }
    
            // not allow self started third party app to start other third party app
            if (callerAppState != null && callerAppState.mLaunchCount == 0 && !isSystemApp(callerAppState)
                && !REASON_START_ACTIVITY.equals(reason)) {
                if (DEBUG) Slog.d(TAG,"Start Proc : "+targetApp+", callingPackage = "+callerApp+", reason = "+reason + ": denyed!!");
                return false;
            }
    
            // not allow long idle third party app to start other third party app
            if (callerAppState != null && !isSystemApp(callerAppState)
                && callerAppState.mState != Event.MOVE_TO_FOREGROUND
                && callerAppState.mProcState != ActivityManager.PROCESS_STATE_TOP
                && !REASON_START_ACTIVITY.equals(reason)) {
    
                long nowELAPSED = SystemClock.elapsedRealtime();
                long idleDuration = 0;
                idleDuration = (callerAppState.mLastTimeUsed > 0 ? (nowELAPSED -callerAppState.mLastTimeUsed) : -1);
                if (idleDuration > DENY_START_APP_THRESHOLD) {
                    if (DEBUG) Slog.d(TAG,"Start Proc : "+targetApp+", callingPackage = "+callerApp+", reason = "+reason + ": denyed!! long idle");
                    return false;
                }
            }
    
    
            // not allow third party app to start other third party app during standby
            if (mStandbyStartTime > 0
                && !REASON_START_ACTIVITY.equals(reason)) {
                if (DEBUG) {
                    Slog.d(TAG,"Start Proc : "+targetApp
                        +", callingPackage = "+callerApp
                        + " (ProcState:" + (callerAppState != null ? Util.ProcState2Str(callerAppState.mProcState):"none")
                        +"), reason = "+reason
                        + ": denyed during standby!!");
                }
                return false;
            }
    
    
            return true;
    
        }

    BackgroundCleanHelper.java-->checkLaunchStateByUserSetting()

    private int checkLaunchStateByUserSetting(Intent intent, String targetApp, int targetUid,
                String callerApp, int callerUid, String reason) {
    
            if (targetApp == null || targetApp.equals(callerApp))
                return LAUNCH_STATE_AUTO;
    
            boolean launchByOther = autoLaunchByOtherApp(targetApp, targetUid, callerApp, callerUid, reason);
    
            // allow app in whitelist
            if (inSelfStartWhiteAppList(targetApp)) {
                return LAUNCH_STATE_ALLOW;
            }
    
            // if in ultrasaving mode, don't allow autostart except apps in ultrasve applist
            if (!launchByOther && (PowerManagerEx.MODE_ULTRASAVING == mPowerSaveMode)
                && (PowerManagerEx.MODE_ULTRASAVING == mNextPowerSaveMode)) {
                List<String> appList = mPowerControllerInternal.getAppList_UltraMode();
                if (!appList.contains(targetApp)) {
                    if (DEBUG) Slog.d(TAG, "app: " + targetApp + " in applist of ultramode, refuse to autostart, denyed");
                    return LAUNCH_STATE_DENY;
                }
            }
    
            int autoLaunch = mPowerControllerInternal.getAppPowerSaveConfgWithTypeInternal(targetApp,AppPowerSaveConfig.ConfigType.TYPE_AUTOLAUNCH.value);
            int secondLaunch = mPowerControllerInternal.getAppPowerSaveConfgWithTypeInternal(targetApp,AppPowerSaveConfig.ConfigType.TYPE_SECONDARYLAUNCH.value);
            if (((autoLaunch == AppPowerSaveConfig.VALUE_NO_OPTIMIZE) && !launchByOther)
                || ((secondLaunch == AppPowerSaveConfig.VALUE_NO_OPTIMIZE) && launchByOther)) {
                if (DEBUG) Slog.d(TAG, "bgclean judgeAppLaunchAllowed: "+targetApp
                    + ", callingPackage = "+callerApp+", reason = "+reason +" in my whitelist");
                return LAUNCH_STATE_ALLOW;
            }
    
            //check whether app is in black list
            boolean bInBlackList = false;
            if ((autoLaunch == AppPowerSaveConfig.VALUE_OPTIMIZE) && !launchByOther) {
                if (DEBUG_MORE) Slog.d(TAG, "in apppowerconfig autolaunch black list: " + targetApp);
                bInBlackList = true;
            }
            if ((secondLaunch == AppPowerSaveConfig.VALUE_OPTIMIZE) && launchByOther) {
                if (DEBUG_MORE) Slog.d(TAG, "in apppowerconfig 2ndlaunch black list: " + targetApp);
                bInBlackList = true;
            }
    
            // check whether blacklist app is in exception
            if (bInBlackList) {
                // not allow auto start app that in auto start black list
                // 1. in mAutoLaunch_BlackList AND is not launched by other app (that is launched by system broadcast etc)
                // 2. NOTE: Exception:
                //     1) Start reason is REASON_START_ACTIVITY  (this is alway happened in case of
                //         app use another app to do something, including launcher to launch a app)
                //     2) Self start self ( that is this app is alreadby started, and is start some activity internal)
                if (!launchByOther && !REASON_START_ACTIVITY.equals(reason)) {
                    if (DEBUG) Slog.d(TAG, "in autolaunch black list: "+targetApp
                        + ", callingPackage = "+callerApp+", reason = "+reason +" denyed!");
                    return LAUNCH_STATE_DENY;
                }
                // not allow auto start by other app that in secondary start black list
                // 1. in m2ndLaunch_BlackList AND is launched by other app
                // 2. NOTE: Exception:
                //     1) when callerApp is top AND Start reason is REASON_START_ACTIVITY  (this is alway happened in case of
                //         app use another app to do something, including launcher to launch a app)
                //     2) Self start self ( that is this app is alreadby started, and is start some activity internal)
                //     3) when callerApp is top AND targetApp is in AssociateLaunchExceptionAppList
                if (launchByOther && !launchedByUserActivity(intent, targetApp, targetUid, callerApp, callerUid, reason, true)) {
                    if (DEBUG) Slog.d(TAG, "in 2ndlaunch black list: "+targetApp
                        + ", callingPackage = "+callerApp+", reason = "+ reason + " intent:" + intent + " denyed!");
                    return LAUNCH_STATE_DENY;
                }
    
                // Although it is black list, but it start by user, so allowed to start
                return LAUNCH_STATE_ALLOW;
            }
            return LAUNCH_STATE_AUTO;
        }

    BackgroundCleanHelper.java-->checkLaunchStateByUserSetting()

    这个方法就是根据用户的设置,来判断是否拦截自启

    private int checkLaunchStateByUserSetting(Intent intent, String targetApp, int targetUid,
                String callerApp, int callerUid, String reason) {
    
            if (targetApp == null || targetApp.equals(callerApp))
                return LAUNCH_STATE_AUTO;
    
            boolean launchByOther = autoLaunchByOtherApp(targetApp, targetUid, callerApp, callerUid, reason);
    
            // allow app in whitelist
            if (inSelfStartWhiteAppList(targetApp)) {
                return LAUNCH_STATE_ALLOW;
            }
    
            // if in ultrasaving mode, don't allow autostart except apps in ultrasve applist
            if (!launchByOther && (PowerManagerEx.MODE_ULTRASAVING == mPowerSaveMode)
                && (PowerManagerEx.MODE_ULTRASAVING == mNextPowerSaveMode)) {
                List<String> appList = mPowerControllerInternal.getAppList_UltraMode();
                if (!appList.contains(targetApp)) {
                    if (DEBUG) Slog.d(TAG, "app: " + targetApp + " in applist of ultramode, refuse to autostart, denyed");
                    return LAUNCH_STATE_DENY;
                }
            }
    
            int autoLaunch = mPowerControllerInternal.getAppPowerSaveConfgWithTypeInternal(targetApp,AppPowerSaveConfig.ConfigType.TYPE_AUTOLAUNCH.value);
            int secondLaunch = mPowerControllerInternal.getAppPowerSaveConfgWithTypeInternal(targetApp,AppPowerSaveConfig.ConfigType.TYPE_SECONDARYLAUNCH.value);
            if (((autoLaunch == AppPowerSaveConfig.VALUE_NO_OPTIMIZE) && !launchByOther)
                || ((secondLaunch == AppPowerSaveConfig.VALUE_NO_OPTIMIZE) && launchByOther)) {
                if (DEBUG) Slog.d(TAG, "bgclean judgeAppLaunchAllowed: "+targetApp
                    + ", callingPackage = "+callerApp+", reason = "+reason +" in my whitelist");
                return LAUNCH_STATE_ALLOW;
            }
    
            //check whether app is in black list
            boolean bInBlackList = false;
            if ((autoLaunch == AppPowerSaveConfig.VALUE_OPTIMIZE) && !launchByOther) {
                if (DEBUG_MORE) Slog.d(TAG, "in apppowerconfig autolaunch black list: " + targetApp);
                bInBlackList = true;
            }
            if ((secondLaunch == AppPowerSaveConfig.VALUE_OPTIMIZE) && launchByOther) {
                if (DEBUG_MORE) Slog.d(TAG, "in apppowerconfig 2ndlaunch black list: " + targetApp);
                bInBlackList = true;
            }
    
            // check whether blacklist app is in exception
            if (bInBlackList) {
                // not allow auto start app that in auto start black list
                // 1. in mAutoLaunch_BlackList AND is not launched by other app (that is launched by system broadcast etc)
                // 2. NOTE: Exception:
                //     1) Start reason is REASON_START_ACTIVITY  (this is alway happened in case of
                //         app use another app to do something, including launcher to launch a app)
                //     2) Self start self ( that is this app is alreadby started, and is start some activity internal)
                if (!launchByOther && !REASON_START_ACTIVITY.equals(reason)) {
                    if (DEBUG) Slog.d(TAG, "in autolaunch black list: "+targetApp
                        + ", callingPackage = "+callerApp+", reason = "+reason +" denyed!");
                    return LAUNCH_STATE_DENY;
                }
                // not allow auto start by other app that in secondary start black list
                // 1. in m2ndLaunch_BlackList AND is launched by other app
                // 2. NOTE: Exception:
                //     1) when callerApp is top AND Start reason is REASON_START_ACTIVITY  (this is alway happened in case of
                //         app use another app to do something, including launcher to launch a app)
                //     2) Self start self ( that is this app is alreadby started, and is start some activity internal)
                //     3) when callerApp is top AND targetApp is in AssociateLaunchExceptionAppList
                if (launchByOther && !launchedByUserActivity(intent, targetApp, targetUid, callerApp, callerUid, reason, true)) {
                    if (DEBUG) Slog.d(TAG, "in 2ndlaunch black list: "+targetApp
                        + ", callingPackage = "+callerApp+", reason = "+ reason + " intent:" + intent + " denyed!");
                    return LAUNCH_STATE_DENY;
                }
    
                // Although it is black list, but it start by user, so allowed to start
                return LAUNCH_STATE_ALLOW;
            }
            return LAUNCH_STATE_AUTO;
        }

    继续逐个分析涉及到的主要方法

    BackgroundCleanHelper.java-->checkLaunchStateByUserSetting()-->autoLaunchByOtherApp()

        // return true, if app is start by system broadcast
        private boolean autoLaunchByOtherApp(String targetApp, int targetUid,
                    String callerApp, int callerUid, String reason) {
            if (callerApp == null
                ||callerApp.equals("android")
                || callerApp.equals("com.android.systemui"))
                return false;
    
            AppState callerAppState = mAppStateInfoCollector.getAppState(callerApp, UserHandle.getUserId(callerUid));
            if (callerAppState != null && callerAppState.mUid < Process.FIRST_APPLICATION_UID)
                return false;
    
            return true;
        }
    

    BackgroundCleanHelper.java-->checkLaunchStateByUserSetting()-->launchedByUserActivity()

     private boolean launchedByUserActivity(Intent intent, String targetApp, int targetUid,
                String callerApp, int callerUid, String reason, boolean ignoreTouchTime) {
            boolean userLaunched = false;
    
            long now = SystemClock.elapsedRealtime();
            long lastTouchTime = 0;
            AppState callerAppState = mAppStateInfoCollector.getAppState(callerApp, UserHandle.getUserId(callerUid));
            if (mPowerControllerInternal != null) {
                lastTouchTime = mPowerControllerInternal.getLastTouchEventTimeStamp();
            }
    
            boolean isCallerTopApp  =  false;
            if (callerAppState != null
                &&((callerAppState.mProcState == ActivityManager.PROCESS_STATE_TOP)
                    || (callerAppState.mProcState == ActivityManager.PROCESS_STATE_HOME)
                    || (callerAppState.mState == Event.MOVE_TO_FOREGROUND)
                    || (now - callerAppState.mLastTimeUsed) < 1000
                    || isLauncherApp(callerApp)) // for Bug#712736
            ) {
    
                isCallerTopApp = true;
            }
    
            // check the associated-starting because of third party push service
            if (isCallerTopApp &&
                REASON_START_ACTIVITY.equals(reason)
                && !isLauncherAction(intent)
                && intent != null
                && ThirdpartyPush.isAssociatedComponent(intent.getComponent())) {
                if (DEBUG) Slog.d(TAG,"launchedByUserActivity : Start Proc : "+targetApp
                    +", callingPackage = "+callerApp
                    + " (ProcState:" + (callerAppState != null ? Util.ProcState2Str(callerAppState.mProcState):"none")
                    +"), reason = "+reason
                    + " Associated-Starting ThirdParty Push Service");
                isCallerTopApp = false;
            }
    
            // see the caller of a launcher action as top app
            // add for bug#776461
            if (!isCallerTopApp && intent != null && isLauncherAction(intent)) {
                isCallerTopApp = true;
            }
    
            if (DEBUG_MORE) {
                Slog.d(TAG,"launchedByUserActivity : Start Proc : "+targetApp
                    +", callingPackage = "+callerApp
                    + " (ProcState:" + (callerAppState != null ? Util.ProcState2Str(callerAppState.mProcState):"none")
                    +"), reason = "+reason);
            }
    
            long lastTouchElasedTime = now - lastTouchTime;
            if (DEBUG) Slog.d(TAG, "lastTouchElasedTime: "+lastTouchElasedTime);
    
            if (isCallerTopApp
                && (REASON_START_ACTIVITY.equals(reason)
                        || (!ignoreTouchTime && lastTouchElasedTime <= (1*1000)))
                ) {
                userLaunched = true;
            }
    
            // check if this call from "android"
            if (!isCallerTopApp && REASON_START_ACTIVITY.equals(reason) && lastTouchElasedTime <= (1*1000)) {
                AppState androidState = mAppStateInfoCollector.getAppState("android", UserHandle.USER_SYSTEM);
                if (androidState != null
                    && (androidState.mState == Event.MOVE_TO_FOREGROUND)
                        || (now - androidState.mLastTimeUsed) < 1000) {
                    userLaunched = true;
                }
            }
    
            // Bug#707888 setting monkey fail --> BEG
            // for callerApp is system app, and use "start-activity", then allow
            if ((callerAppState == null || callerAppState.mUid < Process.FIRST_APPLICATION_UID)
                && REASON_START_ACTIVITY.equals(reason)) {
                userLaunched = true;
            }
            // Bug#707888 setting monkey fail <-- END
    
            return userLaunched;
        }

    BackgroundCleanHelper.java-->checkLaunchStateByUserSetting()-->launchedByUserActivity()-->isLauncherApp()

        private boolean isLauncherApp(String pkgName) {
            int index = mLauncherAppList.indexOf(pkgName);
            if (index >= 0) {
                return true;
            }
            return false;
        }

    isLauncherApp主要是通过是否有CATEGORY_HOME属性判断的

    
        private void loadLauncherApps() {
            try {
    
                Intent intent = new Intent(Intent.ACTION_MAIN);
                intent.addCategory(Intent.CATEGORY_HOME);
    
                final List<UserInfo> users = mUserManager.getUsers();
                for (int ui = users.size() - 1; ui >= 0; ui--) {
                    UserInfo user = users.get(ui);
                    if (DEBUG) Slog.d(TAG, "- loadLauncherApps() for user: " + user.id);
                    List<ResolveInfo> resolves =
                        mContext.getPackageManager().queryIntentActivitiesAsUser(intent, PackageManager.MATCH_DISABLED_COMPONENTS, user.id);
    
                    // Look for the original activity in the list...
                    final int N = resolves != null ? resolves.size() : 0;
                    for (int i=0; i<N; i++) {
                        final ResolveInfo candidate = resolves.get(i);
                        final ActivityInfo info = candidate.activityInfo;
                        if (info != null && info.packageName != null
                            && !mLauncherAppList.contains(info.packageName)) {
            ......
                /*check if contains the default launcher*/
                for(String s : mDefaultLauncherAppList) {
                    if(!mLauncherAppList.contains(s)) {
                        mLauncherAppList.add(s);
                    }
                }
            ......
                            
    }
        // default launcher app list
        private String[] mDefaultLauncherAppList = new String[] {
            "com.android.launcher3",
            "com.android.settings"
        };
    

    这一篇就分析到这里!

    展开全文
  • 如今笔者发现除了应用内置广告条、弹出通知等广告形式外,Android 平台又出现了种隐蔽性非常高的广告形式:应用静默关联启动。 何谓「应用静默关联启动」?以上图为例今天笔者在使用「爱帮...









    Android手机APP常见后台服务

    前言简述

    Android生态系统原本提供了类似于Apple iOS推送服务APNS的GCM(Google Cloud Messaging for Android),以前叫C2DM,但是由于某些原因,导致这项服务在国内不是很好使,为了弥补这个不足,并且我朝各大同胞又想使用Android推送服务,所以国内各大平台陆续推出了GCM的替代品。

    好点的推送服务如果在一台设备上安装了多款Push SDK的应用,不会为每个应用都创建PushService,而是会采用多应用共享一个PushService的模式,如果是差点的,就会每个应用都创建PushService。

    但不论是哪一种,其中一个app的PushService开启,就意味着其他应用都可能关联启动,尤其以百度、阿里、腾讯为甚。

    最糟糕的是,国内后台推送服务提供商太多了,他们的功能有不同的侧重点,有的专攻推送消息,有的可以获取大数据,有的还附带广告。

    所以很多App会使用多家公司的sdk,由于App使用的PushService不是同一家,所以安装的App越多,开启的后台服务也就越多,电量消耗的也越快。

    我们可以使用禁止服务(Disable Service)这个APP来禁用后台耗电服务。

    下载地址:http://www.coolapk.com/apk/cn.wq.disableservice

    当然,魔高一尺道高一丈,你要使用这个app需要获得root权限才能实现。但是像金山快盘app,如果被禁用服务后,会自动恢复被禁用的服务,这类病毒型App,趁早卸载为上。

     


    友盟推送
    SDK文档http://dev.umeng.com/
    com.umeng.message.UmengDownloadResourceService(负责下载推送的内容)
    com.umeng.message.UmengIntentService(负责推送的核心服务)
    com.umeng.message.UmengService(负责推送的后台务)
    com.umeng.update.net.DownloadingService(后台升级更新下载服务)
    com.umeng.common.net.DownloadingService(交换网络sdk,其实就是广告下载服务)
    小米推送
    SDK文档http://dev.xiaomi.com/doc/?p=544
    com.xiaomi.push.service.XMPushService (小米后台推送服务)
    com.xiaomi.push.service.PushMessageHandler (小米后台推送服务定义句柄)
    com.xiaomi.mipush.sdk.MessageHandleService(小米后台推送服务消息句柄服务)
    com.xiaomi.mipush.sdk.PushMessageHandler(小米后台推送服务定义句柄)
    极光推送
    SDK文档http://docs.jpush.io/guideline/android_guide/
    cn.jpush.android.service.PushService(极光推送服务)
    cn.jpush.android.ui.PushActivity(极光推送激活)
    cn.jpush.android.service.DownloadService(推送内容下载服务)
    cn.jpush.android.service.AlarmReceiver(提醒接收)
    魔桥推送
    SDK文档http://www.18ti.net/document2.jsp
    com.mobridge.MoPushService(魔桥推送服务)
    个推
    SDK技术文档 http://docs.getui.com/
    com.igexin.sdk.PushService(推送服务)
    com.igexin.download.DownloadService(资源下载服务)
    com.igexin.getuiext.service.GetuiExtService(个推执行服务)
    Bmob推送
    cn.bmob.push.lib.service.PushService(比目推送服务)
    cn.bmob.push.PushReceiver(推送接收服务)
    力美广告平台IMmob
    Cn.immob.sdk.net.DownloadService(广告资源下载服务)
    盛大云推送
    技术文档http://www.grandcloud.cn/product/push#doc
    cn.grandmobile.sdk.android.PushService
    cn.grandmobile.sdk.android.PushBroadcastReceiver
    云巴推送
    技术文档http://yunba.io/developers/
    io.yunba.android.core.YunBaService(云巴推送服务)
    原子推送
    com.atom.push.sdk.AtomPushService
    com.atom.push.sdk.AtomAlarmReceiver
    com.atom.push.sdk.AtomPushActionCustomReceiver
    魔泊网(MoPaaS)推送
    com.mopaas.pushservice.sdk.MPSPushService(推送服务)
    com.mopaas.backendmonitor.MonitorService(监视服务)
    有推推送(中国移动消息推送)
    com.cmcc.aoe.AoeService
    com.cmcc.aoe.push.AOEService
    WeCloud推送(这厮推送名称很杂乱,显得小公司)
    com.jiubang.go.push.PushServiceReceiver(九帮推送接收服务)
    com.jiubang.go.push.PushService(九帮推送服务)
    com.zihao.service.MyMsgService(子皓消息推送服务)
    AVOS Cloud推送(美味书签公司推送)
    com.avos.avoscloud.PushService(推送服务)
    com.avos.avoscloud.AVDefaultNotificationReceiver(推送消息通知栏展示服务)
    Cocos Push摩羯推送
    com.cocos.push.service.CCPushService(摩羯推送服务)
    com.cocos.push.client.CCPushClientReceiver(摩羯客户端接收服务)
    mPush魔推
    com.mrocker.push.service.PushService
    com.mrocker.push.service.PushServiceReceiver
    魔方推送
    com.imofan.android.basic.update.MFUpdateService(自动更新服务)
    爱心推
    com.ixintui.push.PushService(爱心推的推送服务)
    com.ixintui.push.MediateService(爱心推的富媒体推送)
    DDPush 任意门推送
    org.ddpush.im.v1.client.appuser.Message
    华为云推送
    技术文档http://developer.huawei.com/wiki/index.php?title=PushSDK%E4%B8%8B%E8%BD%BD
    com.huawei.deviceCloud.microKernel.push.EventReceiver(云推送事件接收器)
    com.huawei.deviceCloud.microKernel.push.PushBootReceiver(云推送接收服务)
    com.huawei.deviceCloud.microKernel.push.PushMKService(云推送富媒体服务)
    腾讯云信鸽推送
    技术文档http://www.qcloud.com/product/dove.html
    Com.tencent.android.tpush.service.XGPushService(信鸽推送服务)
    com.tencent.android.tpush.XGPushActivity(推送的展示型通知)
    Com.tencent.android.tpush.rpc.XGRemoteService(通知service,此选项有助于提高抵达率)
    大众点评推送后台
    com.dianping.base.push.pushservice.dp.DPPushService(大众点评推送服务)
    com.dianping.base.push.pushservice.dp.FakeService(大众点评伪装服务?)
    com.dianping.base.push.pushservice.PullService(推送内容的资源下载)
    百度云推送
    技术文档http://developer.baidu.com/wiki/index.php?title=docs/cplat/push/sdk/android
    Com.baidu.android.pushservice.PushService(百度云推送服务)
    百度定位SDK
    com.baidu.location.f(百度地图的定位服务),不需要定位功能的app可以禁用这个。
    支付宝推送后台
    com.alipay.pushsdk.push.NotificationService(支付宝推送通知栏服务)
    com.alipay.pushsdk.deliver.PushReportIntentService(快递推送报告网络服务)
    淘宝广告联盟后台
    com.taobao.munion.base.download.DownloadingService(淘宝广告联盟下载服务)
    agoo推送中心(这个暂时没有查到技术文档)

     



    --------------------------------------------------------------




    安卓app关联启动的问题,抱抱会自动启动好几个其他app

    2015-03-12 02:03 isurrender  |  浏览 569 次
      App
    最近下了app“抱抱”,发现启动后,后台会自动启动 喜马拉雅、暴风影音、唱吧等等,有手机开发大神知道这是为什么吗?怎么才能禁止这种关联启动?
    2015-03-12 09:14 提问者采纳
    这个是有多种原因的。
    可能是这几个软件是同一家公司开发的,启动某一个软件后会监控其他软件的服务有没有启动,没有的话则把它们都启动起来。
    也可能是这几个软件的消息推送机制采用的是同一家推送提供商,例如百度推送、友盟推送等,有推送到达时会启动相对应APP的后台服务。
    我们公司开发的软件这两种方式都有采用的,有时候启动并不一定是坏事,后台服务能让APP更好的为你服务。
    应该还有其他的原因,我想。。
    禁止关联应该很难,但是可以禁止自启,我用的安全软件就有这个功能,但不排除某些流氓软件。。你是无法禁止的。。(纯手打,\(^o^)/~)



    -----------------------------------------------------------------------------------------------------------------------------------------------------------------




    android 关联启动是什么原理?

    如题, 各种全家桶、大杂烩都是怎么个原理实现关联启动的?

    如果是单单接入相同的推送渠道,那么为什么同样接入小米推送的wps和youku,wps能启动youku youku缺没有启动wps?






    -------------------------------------



    Android教程:新型广告「应用静默关联启动」的解决方法

    穿越
    穿越
    2014-05-28

    Android 平台因其开放的特性,各种广告层出不穷,开放给用户带来自由的同时也带来了很多的问题。如今笔者发现除了应用内置广告条、弹出通知等广告形式外,Android 平台又出现了种隐蔽性非常高的广告形式:应用静默关联启动。

    Screenshot_2014-05-24-08-55-27.png
    Screenshot_2014-05-24-08-56-00.png

    何谓「应用静默关联启动」?以上图为例今天笔者在使用「爱帮公交」这个应用时突然弹出傲游浏览器窗口,而且显示的还是个游戏下载推荐页面。整个过程没有任何征兆,笔者也没有任何操作会导致启动「傲游浏览器」,打开「绿色守护」这才发现「傲游浏览器」果然是被爱帮公交唤醒的。这种唤醒无迹可寻,时间也不固定,如果没装「绿色守护」笔者也会找不着头绪,搞不清「傲游浏览器」是怎么突然启动的,隐藏性非常高。

    经过笔者的观察,以同样方式唤醒别的应用来散播广告的除了「爱帮公交」,还有「掌阅iRader」会偶尔唤醒「新浪微博」,「中华万年历」、「酷我音乐」等都出现过类似的问题,而阿里巴巴等一系列的应用就更是一个唤醒一个,基本打开一个就会都醒了,当然淘宝系的唤醒不一定会弹出广告。

    知道了问题的起因,如何解决呢?解决起来还真不是容易件的事,甚至如果手机没有ROOT权限就根本无法解决!这也体现了安卓平台权限管理的混乱。下面说下解决的方法:

    绿色守护

    9d2fc54c93ed2b1aa1cf801a71543e6d_mw_640_wm_0_wmp_3.png
    c9897ec26498e4cd79999dc0a6804904_mw_640_wm_0_wmp_3.png

    有些应用在「绿色守护」中根本没有切断唤醒路径的选项,不知其中是否有利益关系。我们可以试试「LBE安全大师」的软件权限管理功能,关闭相关应用的系统设置权限,这个方法笔者也在验证中,可能并不有效,毕竟「LBE安全大师」的软件权限管理功能稍弱了些。

    XPrivacy

    19c7f294464ea61c8576d94cb2147805_mw_640_wm_0_wmp_3.png
    81682cd68a7bfdff6ac0e22edf5f1191_mw_640_wm_0_wmp_3.png
    Android
    相关文章

    使用「XPrivacy」控制软件权限,把关于唤醒别的应用的权限都禁止即可。其实这个是最有效的方法,不过「XPrivacy」使用难度较大,适合极客类的用户。关于「XPrivacy」可参考下这篇文章: http://sspai.com/24535

    开发应用谋利是无可厚非的,但谋利却不考虑用户的感受,把莫名的广告强加给用户,这就有些过分了,笔者真心希望Android平台可以健康一些。




    ----------------------------------------------------------------------



    如何评价滴滴出行安卓版关联启动多个应用?

    …  显示全部
    按时间排序 按投票排序

    4 个回答





    ---------------------




    一、首先,我们先来说明后台软件自启动和关联启动是什么?

    “手机后台软件自启动”是指各种broadcast receiver,但具体是指的是哪个没有明确定义,经常发生的例子就是我们关闭手机360卫士进程以后它会自动唤醒程序使得360软件后台继续运行。

    “关联启动”就是一款软件在执行某一操作时能够启动另一款软件,例如,用户在淘宝选购了商品,然后付款时,可以选择登录支付宝进行付款,就会启动支付宝。有了“关联启动”功能,用户就可以更好地节约系统资源和手机电量。

    二、我们如何去管理华为P9的后台软件启动和关联启动呢?

    首先,从华为P9桌面的设置进入,找到【手机管家】里面的自启记录,就能看到哪些软件在后台启动,然后返回上一层进入【自动启动管理】关闭掉不需要自启动的软件,如图所示:

    www.jb51.net

    人民币白银
    人民币白银
    电玩打鱼
    电玩打鱼
    55电玩
    55电玩
    银子报价
    银子报价
    三国群英传
    三国群英传


    华为P9自启动管理

    管理关联启动,在上右图点击上端被其他应用启动,进入【被启动管理】,就可以管理被启动软件,建议开启支付宝,否则淘宝购物无法启动支付宝付款,如图所示:

    www.jb51.net

    金条多少钱一克
    金条多少钱一克
    今天白银价格
    今天白银价格
    搬家一般多少钱
    搬家一般多少钱
    微信二次开发
    微信二次开发


    华为P9被启动管理

    以上就是华为P9关闭自启动和关联启动方法介绍的全部内容了,希望对各位有所帮助。如果各位还有其他方面的问题,或者想要了解最新的资讯,请持续关注脚本之家!





    --------------------------------------------------------------------------------------------------------------------------------





    展开全文
  • android 关联启动第三方应用

    千次阅读 2016-09-02 16:41:36
    若是同一家公司应用,比如淘宝,支付宝,为了保持彼此存活率,通常会设置关联启动,那么该如何做呢?我们首先做个开机自启的Service: package com.example.myapplication; import android.app.Notification...

    若是同一家公司应用,比如淘宝,支付宝,为了保持彼此存活率,通常会设置关联启动,那么该如何做呢?我们首先做个开机自启的Service:


    package com.example.myapplication;
    
    import android.app.Notification;
    import android.app.NotificationManager;
    import android.app.PendingIntent;
    import android.app.Service;
    import android.content.Context;
    import android.content.Intent;
    import android.os.IBinder;
    import android.util.Log;
    
    public class MyService extends Service {
    
    
        @Override
        public IBinder onBind(Intent intent) {
            // TODO: Return the communication channel to the service.
            return null ;
        }
    
        @Override
        public void onCreate() {
            super.onCreate();
    
            NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            //Notification notification = new Notification(R.mipmap.ic_launcher, "myService", System.currentTimeMillis());
            Intent notificationIntent  = new Intent(this,MainActivity.class);
            PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0);
            Notification notify3 = new Notification.Builder(this)
                    .setSmallIcon(R.mipmap.ic_launcher)
                    .setTicker("TickerText:" + "您有新短消息,请注意查收!")
                    .setContentTitle("Notification Title")
                    .setContentText("This is the notification message")
                    .setContentIntent(pendingIntent).setNumber(1).build(); // 需要注意build()是在API
            // level16及之后增加的,API11可以使用getNotificatin()来替代
            notify3.flags |= Notification.FLAG_NO_CLEAR; // FLAG_AUTO_CANCEL表明当通知被用户点击时,通知将被清除。
           // manager.notify(1, notify3);// 步骤4:通过通知管理器来发起通知。如果id不同,则每click,在status哪里增加一个提示
            startForeground(1, notify3);
            Log.e("myService", "onCreate");
        }
    }
    

    然后注册一个开机广播,开机权限:

     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    注册:

     <receiver
                android:name=".BootReceiver"
                android:enabled="true"
                android:exported="true">
                <intent-filter>
                    <action android:name="android.intent.action.BOOT_COMPLETED" />
    
                    <category android:name="android.intent.category.HOME" />
                </intent-filter>
            </receiver>

    然后重写一个广播接收器:

    package com.example.myapplication;
    
    import android.content.BroadcastReceiver;
    import android.content.Context;
    import android.content.Intent;
    import android.util.Log;
    import android.widget.Toast;
    
    public class BootReceiver extends BroadcastReceiver {
    
        static final String action_boot="android.intent.action.BOOT_COMPLETED";
        @Override
        public void onReceive(Context context, Intent intent) {
            // TODO: This method is called when the BroadcastReceiver is receiving
            // an Intent broadcast.
    
            //
            if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){
               Toast.makeText(context,"开机了",Toast.LENGTH_LONG).show();
                Log.e("boot","开机了————————");
                Intent intentService = new Intent(context, MyService.class);
    
                context.startService(intentService);
            }
        }
    }
    
    在这里启动自己的service,这里需要在手机里打开开机自启权限。

    这个应用已经做好了,那么其他应用怎么启动它呢:首先对MyService加入Action:

    <service
                android:name=".MyService"
                android:enabled="true"
                android:exported="true">
                <intent-filter android:priority="1000" >
                    <action android:name="com.example.myapplication.myservice" />
                </intent-filter>
            </service>

    那么其它应用启动它的时候只要拿到其包名和这个Action就可:

    package com.example.myapplication;
    
    import android.content.ComponentName;
    import android.content.Intent;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    
    public class MainActivity extends AppCompatActivity {
    
        Intent intent ;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            ComponentName componet = new ComponentName("com.example.myapplication.boot","com.example.myapplication.MyService");
            intent = new Intent();
    
            intent.setAction("com.example.myapplication.myservice");
            intent.setComponent(componet);
    
           startService(intent);
        }
    }
    

    然后把打开关联启动权限,这样我们就能启动第三方应用了。

    源码1,开机自启demo:点击打开链接

    源码2,启动第三方应用demo: 点击打开链接

    展开全文
  • 1、无法调用服务端的service,不能唤起服务端进程,是因为服务端应用的“关联启动”权限没手动打开。2、貌似“关联启动”这个权限功能是6.0以后部分品牌手机有的。3、调用activity不需要“关联启动”权限,service...
  • 电信设备-应用关联启动的方法、装置及移动终端.zip
  • 电信设备-关联启动的管控方法、装置、存储介质及移动终端.zip
  • 电信设备-基于关联启动应用的内存优化方法、移动终端及存储介质.zip
  • 电信设备-关联启动的管控方法、装置、存储介质及移动终端[1].zip
  • 文件系统中打开某种类型文件时,在打开应用列表中添加自己的应用,并在应用中获取该文件的信息,做出对应的操作
  • 无法启动服务,原因可能是已被禁用或与其他关联的设备没有启动解决办法 解决办法 计算机→右键选中“管理”→选中"服务和应用程序"中"服务"→找到"Windows Update",双击→"启动类型"选择"自动"→“应用”→“确定...
  • 鸿蒙系统的启动流程,建议收藏!

    千次阅读 2021-05-31 19:22:44
    声明:严格来说本文档并非真正原创的,这是上了朱有鹏老师的免费课《想读懂鸿蒙 2.0 源码,也许你需要先懂...这里仅摘取课程中的鸿蒙系统在 HI3516DV300 平台上的启动流程部分(从 30:00 开始讲解启动过程)进行汇...
  • 在拼多多开店的商家应该都知道商品关联推荐,若可以利用好商品关联推荐,可以大大的提高商品的曝光量和销量,但商品关联也是需要技巧的,若做不好,也是会影响到店铺的权重和流量。那么如何正确的设置商品关联推荐?...
  • win10 uwp 关联文件

    千次阅读 2017-03-15 09:14:23
    打开 xaml.cs ,把app启动的file显示 protected override async void OnNavigatedTo (NavigationEventArgs e) { var file = e.Parameter as StorageFile; if (file != null ) { using ...
  • 使用关联的程序启动当前文件。 例如,如果您正在编辑HTML文件,然后键入命令LaunchAssociated ,则默认浏览器将打开它。 它可以用于任何与程序关联的文件类型,例如.xml , .html , .java甚至.png 。 Vim.org...
  • BCF关联工具修改BCF文件和启动游戏组件(BCF relational tools)
  • 启动MySQL服务 桌面上【计算机】图标上右键–点【管理】- 跳出【计算机管理】的窗口—选择【服务和应用程序】下面的【服务】–在名称中找到MySQL --选中MySQL后右键–点启动 修改MySQL为自动启动 方法一: 桌面上...
  • 问题背景(方便参考所出问题是否一致,可供参考,不需要直接看问题解决): 本人使用的系统是win10,...这里关联的应用是Microsoft Visual Stdio Web Protocal Handle Selector,当时的情况是有两个这样的程序来由你...
  • 因此,为解决链式启动,安卓官方以及各大手机商均做了不少举措,例如国产ROM很早就开始限制APP相互唤醒,安卓新版限制了不规范API的调用令链式启动难以实施,这次MIUI的照明弹也是为限制链式启动所做的努力。...
  • 转子系统启动时的稳定性对设备的寿命和精度有着重要影响。针对现有研究方法求解过程复杂、结果不准确,采用ANSYS软件综合考虑陀螺效应分析了支撑刚度、支撑阻尼和启动时间对转子系统启动时稳定性的影响;并在数据...
  • 人类DNA启动子区关联性质的复杂网络研究,赵芳翠,杨会杰,启动子序列在基因调控中起关键作用。对启动子区进行分析是认识基因调控网络的第一步。依据序列关联性质构造了人类DNA启动子区域关
  • DCOM 遇到错误“无法启动服务,原因可能是已被禁用或与其相关联的设备没有启动
  • 无法启动服务,原因可能是已被禁用或与其相关联的设备没有启动 更新了一个win10系统,安装某软件并启动后提示需要使用.NETFramework 3.5 点击下载并安装此应用后,页面显示无法安装。错误原因为:无法启动服务...
  • 易语言文件关联模块源码,文件关联模块,文件关联,启动,命令行缓冲区_
  • 1. UI-关联自启动 2. 源码走读-上层接口调用 ...关联启动&amp;lt;/string&amp;gt; &amp;lt;string name=&quot;app_as_lunch_optimization&quot;&amp;gt;关联自启动&amp;
  • 从保守区中选取M6(1)值较大的10个保守位点的六联体频数作为参数、引入伪计数构建位置权重矩阵,利用位置关联打分函数对683条sigma70启动子进行预测.负集分别从编码区和非编码区选取700条序列进行算法检验,获得很好的...
  • Windows EXE文件关联

    千次阅读 2013-05-25 13:06:39
     文件关联,是为了在Windows中实现方便的操作,将某一类数据文件与一个相关的程序建立联系,当用鼠标双击这类数据文件时,Windows操作系统就自动启动关联的程序,打开这个数据文件供操作者处理。例如,通用的ASCII...
  • Android 友盟互相唤醒问题

    千次阅读 2019-05-20 18:15:53
    如果你的设备是MIUI系统或其他定制化第三方安卓系统,则可能是应用的自启动默认被禁用了。 现在国内的设备都是定制化第三方安卓系统,也不会默认开启 应用自启动 ,测试了一下: 如果打开集成了友盟推送sdk的...
  • H5唤起android app,启动关联应用

    千次阅读 2020-05-11 22:12:04
    H5也好,用js也和行, 代码如下: (请前端同学来...启动应用程序</a> </body> </html> 说明:href里就是自己定义的schema,请android开发和H5开发一起商量定一个就好。 然后android的And...
  • myeclipse关联项目启动问题

    千次阅读 2017-10-23 10:41:18
    在我们日常开发中,在不打jar包的情况下,难免会遇到一个项目需要依赖另一个项目的对象,下面我就来给大家介绍一下在myeclipse中关联项目并启动成功的流程 1.右击项目—->点击properties 2.点击java build path 再...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 486,917
精华内容 194,766
关键字:

关联启动