AndroidManifest.xml:
<permission>
Declares a security permission that can be used to limit access to specific components or features of this or other applications.
<permission android:description="string resource"
android:icon="drawable resource"
android:label="string resource"
android:name="string"
android:permissionGroup="string"
android:protectionLevel=["normal" | "dangerous" |
"signature" | "signatureOrSystem"] />
就是用 <permission> 定义了一个权限:这样权限的level是signatureOrSystem,需要这个权限的就要signatureOrSystem
<permission
android:name="com.xx.klo.bugreport.permission.FEEDBACK_SERVICE"
android:protectionLevel="signatureOrSystem" />
<service> 中使用了定义的权限,意思是说该service需要该权限
<service
android:name=".service.FeedbackBackgroundService"
android:exported="true"
android:permission="com.xx.klo.bugreport.permission.FEEDBACK_SERVICE"
>
<uses-permission>:
<uses-permission android:name="string"
android:maxSdkVersion="integer" />
请求应用正确运行所必须获取的权限。权限在安装应用时(在运行 Android 5.1 和更低版本的设备上)
或者在应用运行时(在运行 Android 6.0 和更高版本的设备上)由用户授予。
klobugreport_FeedbackBackgroundService这个service是怎样启动的?
04-20 01:25:28.987 1611 1611 I PreinstallApp: Copy com.xx.klo.bugreport[/system/data-app/klobugreport/klobugreport.apk,10050] for first boot
04-20 01:33:50.014 4820 4820 D klobugreport_FeedbackBackgroundService: D onCreate
04-20 01:33:50.038 4820 4820 D klobugreport_FeedbackBackgroundService: D onStartCommand
04-20 01:33:50.038 4820 4820 D klobugreport_t: D isPackageInstalled NameNotFoundException e:com.xx.klorobot
04-20 01:33:50.039 4820 4820 D klobugreport_t: D isPackageInstalled NameNotFoundException e:com.xx.klorobotrelease
04-20 01:33:52.224 4820 4820 I klobugreport_FeedbackBackgroundService: I start AutomaticDebugService to enable ADB
04-20 01:33:52.237 4820 4820 I klobugreport_t: I isUploadLogAllowed() userExperienceAllow:true,uploadDebugLogAllow:true
04-20 01:33:52.237 4820 4820 I klobugreport_FeedbackBackgroundService: I onStartCommand sc_allow_conn false return
04-20 01:33:52.237 4820 4908 D klobugreport_FeedbackBackgroundService: D handleMessage
04-20 01:33:52.237 4820 4908 D klobugreport_FeedbackBackgroundService: D handleMessage stopSelf
是通过另一个模块启动的:
Whetstone/app/whetstone/src/com/xx/whetstone/wtstrategy/PersistManager.java
public WtStrategyManager(Context context, IWtPackageControl strategy, IActivityManagerWrapper am) {
initStrategy(context, strategy, am);
mPersistManager = new PersistManager(context, strategy);
}
PersistManager(Context context, IWtPackageControl strategy) {
startAll();
}
private void startAll() {
Iterator<Entry<String, PackageInfo>> it = mPersistPackage.entrySet().iterator();
while(it.hasNext()) {
String pk = it.next().getKey();
if (pk != null) {
startService(pk);
}
}
}
private boolean startService(String packageName) {
Utils.logD(TAG, "startService serviceName:" + packageName);
PackageInfo info = mPersistPackage.get(packageName);
if (info != null) {
ComponentName name = info.compName;
if (name != null) {
try {
Intent service = new Intent();
service.setComponent(name);
service.setAction(Intent.ACTION_MAIN);
mContext.startService(service);
//start some persist service do not unbind service
if (info.conn == null) {
info.conn = new MyServiceConnection();
} else {
try {
mContext.unbindService(info.conn);
} catch (Exception e) {
e.printStackTrace();
}
}
boolean ret = mContext.bindService(service, info.conn, 0);
return ret;
} catch (Exception e) {
e.printStackTrace();
}
}
}
return true;
}
persist service是个啥?
/**********************************************************************************/
同一个包内可以定义多 receiver接收BOOT_COMPLETED
<receiver android:name="com.xx.bill.alarm.RepayAlarmReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver android:name="com.xx.bill.BillReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
/***************************************************************************************/
<permission>
Declares a security permission that can be used to limit access to specific components or features of this or other applications.
<permission android:description="string resource"
android:icon="drawable resource"
android:label="string resource"
android:name="string"
android:permissionGroup="string"
android:protectionLevel=["normal" | "dangerous" |
"signature" | "signatureOrSystem"] />
就是用 <permission> 定义了一个权限:这样权限的level是signatureOrSystem,需要这个权限的就要signatureOrSystem
<permission
android:name="com.xx.klo.bugreport.permission.FEEDBACK_SERVICE"
android:protectionLevel="signatureOrSystem" />
<service> 中使用了定义的权限,意思是说该service需要该权限
<service
android:name=".service.FeedbackBackgroundService"
android:exported="true"
android:permission="com.xx.klo.bugreport.permission.FEEDBACK_SERVICE"
>
<uses-permission>:
<uses-permission android:name="string"
android:maxSdkVersion="integer" />
请求应用正确运行所必须获取的权限。权限在安装应用时(在运行 Android 5.1 和更低版本的设备上)
或者在应用运行时(在运行 Android 6.0 和更高版本的设备上)由用户授予。
klobugreport_FeedbackBackgroundService这个service是怎样启动的?
04-20 01:25:28.987 1611 1611 I PreinstallApp: Copy com.xx.klo.bugreport[/system/data-app/klobugreport/klobugreport.apk,10050] for first boot
04-20 01:33:50.014 4820 4820 D klobugreport_FeedbackBackgroundService: D onCreate
04-20 01:33:50.038 4820 4820 D klobugreport_FeedbackBackgroundService: D onStartCommand
04-20 01:33:50.038 4820 4820 D klobugreport_t: D isPackageInstalled NameNotFoundException e:com.xx.klorobot
04-20 01:33:50.039 4820 4820 D klobugreport_t: D isPackageInstalled NameNotFoundException e:com.xx.klorobotrelease
04-20 01:33:52.224 4820 4820 I klobugreport_FeedbackBackgroundService: I start AutomaticDebugService to enable ADB
04-20 01:33:52.237 4820 4820 I klobugreport_t: I isUploadLogAllowed() userExperienceAllow:true,uploadDebugLogAllow:true
04-20 01:33:52.237 4820 4820 I klobugreport_FeedbackBackgroundService: I onStartCommand sc_allow_conn false return
04-20 01:33:52.237 4820 4908 D klobugreport_FeedbackBackgroundService: D handleMessage
04-20 01:33:52.237 4820 4908 D klobugreport_FeedbackBackgroundService: D handleMessage stopSelf
是通过另一个模块启动的:
Whetstone/app/whetstone/src/com/xx/whetstone/wtstrategy/PersistManager.java
public WtStrategyManager(Context context, IWtPackageControl strategy, IActivityManagerWrapper am) {
initStrategy(context, strategy, am);
mPersistManager = new PersistManager(context, strategy);
}
PersistManager(Context context, IWtPackageControl strategy) {
startAll();
}
private void startAll() {
Iterator<Entry<String, PackageInfo>> it = mPersistPackage.entrySet().iterator();
while(it.hasNext()) {
String pk = it.next().getKey();
if (pk != null) {
startService(pk);
}
}
}
private boolean startService(String packageName) {
Utils.logD(TAG, "startService serviceName:" + packageName);
PackageInfo info = mPersistPackage.get(packageName);
if (info != null) {
ComponentName name = info.compName;
if (name != null) {
try {
Intent service = new Intent();
service.setComponent(name);
service.setAction(Intent.ACTION_MAIN);
mContext.startService(service);
//start some persist service do not unbind service
if (info.conn == null) {
info.conn = new MyServiceConnection();
} else {
try {
mContext.unbindService(info.conn);
} catch (Exception e) {
e.printStackTrace();
}
}
boolean ret = mContext.bindService(service, info.conn, 0);
return ret;
} catch (Exception e) {
e.printStackTrace();
}
}
}
return true;
}
persist service是个啥?
/**********************************************************************************/
同一个包内可以定义多 receiver接收BOOT_COMPLETED
<receiver android:name="com.xx.bill.alarm.RepayAlarmReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver android:name="com.xx.bill.BillReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
/***************************************************************************************/