Commit 01b9564d authored by Nihar Thakkar's avatar Nihar Thakkar

Don't build with system UID, check for permission instead of system app

parent abd5e6d8
Pipeline #13324 passed with stage
in 3 minutes and 9 seconds
......@@ -12,17 +12,11 @@ cache:
paths:
- .gradle/
build-without-auto-install:
build:
stage: build
script:
- ./gradlew build
artifacts:
paths:
- app/build/outputs/apk/
build:
extends: build-without-auto-install
script:
- git apply auto-install.patch
- ./gradlew build
\ No newline at end of file
......@@ -17,13 +17,15 @@
package foundation.e.apps.application.model
import android.Manifest
import android.app.PendingIntent
import android.content.*
import android.content.pm.PackageInstaller
import android.content.pm.PackageManager
import android.net.Uri
import android.support.v4.content.ContextCompat
import android.support.v4.content.FileProvider
import android.util.Log
import foundation.e.apps.utils.Common
import java.io.File
import java.io.IOException
import java.io.InputStream
......@@ -37,7 +39,8 @@ class Installer(private val packageName: String,
fun install(context: Context) {
try {
Log.i(TAG, "Installing $packageName")
if (Common.isSystemApp(context.packageManager, context.packageName)) {
if (ContextCompat.checkSelfPermission(context, Manifest.permission.INSTALL_PACKAGES)
== PackageManager.PERMISSION_GRANTED) {
val inputStream = File(apk.absolutePath).inputStream()
Log.i(TAG, "Opened input stream to $packageName APK")
installApplication(context, inputStream)
......
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e3d84c2..a1a0c47 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -20,7 +20,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="foundation.e.apps"
- android:installLocation="internalOnly">
+ android:installLocation="internalOnly"
+ android:sharedUserId="android.uid.system">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment