Below is the shortened content of AndroidManifest.xml of the app Keyguard of Lollipop located at: $(AOSP_Root_Dir)/frameworks/base/packages/Keyguard/
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.keyguard"
android:sharedUserId="android.uid.systemui"
coreApp="true">
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17"/>
<application android:label="#string/app_name"
android:process="com.android.systemui"
android:persistent="true"
android:supportsRtl="true">
</application>
</manifest>
What's weird is: There is NO any components such activity, service, etc. in AndroidManifest.xml!
How does it get started?
I'm not sure what you intended to take out when you edited this to a shortened form, but looking at the version you link to it certainly does include a service thus:
<service android:name=".KeyguardService"
android:exported="true" />
EDIT: In the version you now link to, that service was removed by the checkin:
https://github.com/android/platform_frameworks_base/commit/380ecb81db52a9d0197ca969951d07b91c20d2b9
which did the following:
Let Keyguard be a library, so we can use it in SystemUI.
Implement a new KeyguardService in SystemUI, and bind that service
from PhoneWindowManager.
Related
I am working on an AAOS (Android Automotive OS) platform. The OS version is 10.
I included "DirectRenderingCluster" in my car_product/build/car.mk as
PRODUCT_PACKAGES += DirectRenderingCluster.
In this App, there is a ClusterRenderingService, which implements InstrumentClusterRenderingService.
In InstrumentClusterRenderingService, it will try to gather some information of the suitable navigation App from the PackageManager. Originally, it will pick the FakeClusterNavigationActivity in EmbeddedKitchenSinkApp.
I want to replace the FakeClusterNavigationActivity with my own navigation App.
I mimicked it and made a similar activity.
However, I am getting error messages printed at line 153 and 299 of InstrumentClusterRenderingService.
What do I miss? What should I do to make the Car service recognize my App is an eligible navigation App for cluster? Thank you.
My AndroidManifest.xml looks like as follows. The targetSdkVersion is 29.
<manifest
package="com.mytest.android"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionName="1.0"
android:versionCode="1"
android:installLocation="auto"
android:sharedUserId="android.uid.system">
<application
android:hardwareAccelerated="true"
android:directBootAware="true"
android:persistent="false"
android:name="com.mytest.android.NaviApp"
android:label="#string/application_label"
android:icon="#drawable/icon">
<!-- Activity for cluster. Note that this is not the only activity in this App. -->
<activity android:process=":map_surface"
android:name=".MapSurfaceActivity"
android:label="MapSurfaceActivity"
android:screenOrientation="landscape"
android:launchMode="singleInstance"
android:allowEmbedded="true"
android:exported="true"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.car.cluster.NAVIGATION"/>
</intent-filter>
</activity>
<!-- Content provider for images (fake, not functional) -->
<provider android:name=".cluster.ClusterContentProvider"
android:authorities="com.mytest.android.cluster.clustercontentprovider"
android:grantUriPermissions="true"
android:exported="true"/>
It turns out to be Google's bug and has been fixed in the later code.
If the navigation app is launched as non-system user and is not installed for system user, this bug will occur.
In the original code, it uses system user's PackageManager to call getPackageInfo() and queryIntentActivities(). However, the navigation app is not installed for system user (maybe being put in the blacklist), so it won't be found.
To fix, PackageManager.MATCH_ANY_USER flag should be used in getPackageInfo(), and queryIntentActivitiesAsUser() should be used in stead of queryIntentActivities().
I don't know what commits fixed them but they are shown in the master branch.
https://android.googlesource.com/platform/packages/services/Car/+/master/car-lib/src/android/car/cluster/renderer/InstrumentClusterRenderingService.java
I am trying make my own permission for android application.
For this my android manifest file looks like this.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hp.happybirthday" >
<permission
android:name="com.example.hp.happybirthday.PERM"
android:description="#string/pdesc"
android:label="#string/CAREFUL"
/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:permission="com.example.hp.happybirthday.PERM">
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
The problem that I am facing is that I want to have my own permission associated with this application and hence i have added the following line as shown above under the application tag, so that only those activities have access to this app which possess my defined permission.
android:permission="com.example.hp.happybirthday.PERM"
But the problem is that when I try to run my app, the app whose manifest file I have declared, it shows the error app is not installed.
But when I remove the above mentioned line, it works, but then any activity will have access to this app which I do not want.
when I try to run my app, the app whose manifest file I have declared, it shows the error app is not installed
That is because the home screen is an app, and the home screen does not hold your custom permission. Hence, the home screen cannot start your launcher activity.
then any activity will have access to this app which I do not want
First, custom permissions do not work all that well.
Second, permissions are usually applied at a finer granularity than "this app". You only secure those components that need the security, and you leave public other components, like the launcher activity.
It looks like you've defined the permission, and set it to be required... but you haven't actually granted it to your own app. Add a uses-permission tag
One of my Android applications needs some features that are "dangerous" when it comes to permissions. They require some permissions such as "Internet access" which are critical in combination with private data.
This is why I want to create a separate "Add-on", i.e. a second app that provides these permission-critical features. So if users want them, they can install the add-on, but the main app will still work without those permissions.
Using a sharedUserId would obviously be the easiest solution, but adding this afterwards, when lots of users use the app already, could cause serious problems. Wouldn't this mean that the app can't access its own data any longer?
So I have to choose another approach. ContentProviders are something that I try to avoid, because they're too complex for this simple need in my opinion.
I thought custom permissions could solve the issue. Can they? I've added the following permission declaration to both the main app as well as the add-on as a child to the manifest tag in AndroidManifest.xml:
<permission
android:name="com.my.package.ADDON"
android:label="#string/permission_title"
android:description="#string/permission_description"
android:permissionGroup="android.permission-group.PERSONAL_INFO"
android:protectionLevel="signature" />
Furthermore, both manifest files have got this part now:
<uses-permission android:name="com.my.package.ADDON"></uses-permission>
The add-on app includes an IntentService that has the following attribute now:
android:permission="com.my.package.ADDON"
Shouldn't this do the job so that I can call the add-on's IntentService from my main app via this code?
Intent addonIntent = new Intent();
addonIntent.setClassName("com.my.package", "com.my.package.MyService");
startService(addonIntent);
Unfortunately, this call always fails with the following exception:
E/AndroidRuntime(16721): java.lang.SecurityException: Not allowed to start service Intent { cmp=com.mypackage.addon/.MyService } without permission com.mypackage.permission.ADDON
What did I do wrong? Thank you very much in advance!
Addition #1 - Add-on manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0"
package="com.mypackage.addon">
<uses-sdk android:minSdkVersion="8" />
<permission
android:name="com.mypackage.permission.ADDON"
android:label="#string/permission_title"
android:description="#string/permission_description"
android:permissionGroup="android.permission-group.PERSONAL_INFO"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:permission="com.mypackage.permission.ADDON"
android:exported="true">
<service
android:enabled="true"
android:name=".MyService" />
</application>
</manifest>
Addition #2 - main app manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0"
package="com.mypackage.mainapp">
<uses-sdk android:minSdkVersion="8" />
<permission
android:name="com.mypackage.permission.ADDON"
android:label="#string/permission_title"
android:description="#string/permission_description"
android:permissionGroup="android.permission-group.PERSONAL_INFO"
android:protectionLevel="signature" />
<uses-permission android:name="com.mypackage.permission.ADDON"></uses-permission>
<application android:icon="#drawable/ic_launcher" android:label="#string/app_name" android:name="MyApp">
<activity android:name=".MainActivity" android:launchMode="singleTask" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Wouldn't this mean that the app can't access its own data any longer?
Correct.
I've added the following permission
I would dump the permission-group, as that should not be necessary.
Furthermore, both manifest files have got this part now
Only the one calling your IntentService might need that.
Shouldn't this do the job so that I can call the add-on's IntentService from my main app via this code?
Not if that IntentService is not exported. Make sure that your IntentService either has an <intent-filter> or android:exported="true". I would recommend going the <intent-filter> route, so you can declare and use a custom action string, so you get away from hard-coding package and class names in the client app.
Here is a directory with two sample projects using this basic approach, though in my case the communications are based on a secured ContentProvider rather than a secured IntentService. The concept is the same, though, and so with these minor tweaks, I would expect what you are doing to work just fine.
I know similar questions have been asked but none have been helpful to me. If I were pointed to a link that has a solution I would be more than pleased. Anyway, I am getting an error every time I install a widget I am developing on my Android Emulator.
The error states
ERROR/AndroidRuntime(866): java.lang.RuntimeException: Unable to instantiate receiver com.ifractal.firstwidget.FirstWidget: java.lang.NullPointerException
Here is the relevant code
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ifractal.firstwidget"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<receiver android:name=".FirstWidget" android:label="#string/app_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="android.appwidget.action.APPWIGET_ENABLE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/provider"
/>
</receiver>
</application>
and here is my project layout in eclipse (to show that files are there)
I have tried recreating the project with a different name, cleaning/building, and a few other things but nothing has worked. I appreciate any help that you can give me and am willing to provide additional info if needed. Thanks.
The manifest looks fine to me. You get a NPE in FirstWidget, so you need to look into that class. Check the stack trace and see where exactly the exception is thrown. Could it be the constructor?
Check that your app widget class is not abstract.
Below is a typical app widget class declaration:
public class AppWidget extends AppWidgetProvider{
// ...
}
I am writing an Android app which must always be running in the background until the user exits it from the app's menu. But now I notice that in Android after some time my app is stopped by itself without user intervention.
Any idea how to make sure my app will always be running in the background?
You need to run a Service of your own.
http://developer.android.com/reference/android/app/Service.html
If you need to run at all times, look into a Service and startForeground. If you can let your Service die but get restarted, look into onStartCommand and START_STICKY.
AndroidMainfest.xml looks like this with presistent=true:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="7" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" android:persistent="true">
<activity
android:name="com.example.test.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
“While the app development documentation does explain the role of
android:persistent, the use of that attribute is reserved for apps that
are built within the AOSP.”
– Embedded Android
For your application, in the manifest xml, put:
android:persistent="true"