Update to gradle build structure

This commit is contained in:
mar-v-in 2015-03-13 16:19:59 +01:00
parent 4ee1acc738
commit b2e10a10e4
81 changed files with 228 additions and 145 deletions

4
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "UnifiedNlpApi"]
path = UnifiedNlpApi
[submodule "extern/UnifiedNlpApi"]
path = extern/UnifiedNlpApi
url = https://github.com/microg/android_external_UnifiedNlpApi.git

@ -1 +0,0 @@
Subproject commit 06d1132344b4600ae00bda63d4da0acff7de42f0

View File

@ -1,73 +1 @@
/*
Copyright 2013-2015 µg Project Team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
final boolean buildNlpAsLib = name.equals('UnifiedNlpLib')
if (buildNlpAsLib) {
apply plugin: 'com.android.library'
} else {
apply plugin: 'com.android.application'
}
dependencies {
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':UnifiedNlpApi')
provided project('compat')
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
lintOptions.abortOnError false
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
res.srcDirs = ['res']
}
}
if (!buildNlpAsLib) {
productFlavors {
NetworkLocation {
applicationId = 'com.google.android.gms'
minSdkVersion 19
}
LegacyNetworkLocation {
applicationId = 'com.google.android.location'
}
UnifiedNlp {
applicationId = 'org.microg.nlp'
}
}
}
}
if (file('user.gradle').exists()) {
apply from: 'user.gradle'
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.

1
extern/UnifiedNlpApi vendored Submodule

@ -0,0 +1 @@
Subproject commit caa1b952b320c21e34357a1442c858ac775a1e15

View File

@ -1 +1,4 @@
include ':compat', ':UnifiedNlpApi'
include ':unifiednlp-compat'
include ':unifiednlp-api'
include ':unifiednlp-base'
include ':unifiednlp-app'

View File

@ -1,30 +0,0 @@
/*
* Copyright 2013-2015 µg Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.microg.nlp.ui;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class SettingsLauncherActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startActivity(new Intent(this, SettingsActivity.class));
finish();
}
}

1
unifiednlp-api Symbolic link
View File

@ -0,0 +1 @@
extern/UnifiedNlpApi/unifiednlp-api

View File

@ -0,0 +1,52 @@
/*
Copyright 2013-2015 µg Project Team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
}
}
apply plugin: 'com.android.application'
dependencies {
compile project(':unifiednlp-base')
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
productFlavors {
NetworkLocation {
applicationId = 'com.google.android.gms'
minSdkVersion 19
}
LegacyNetworkLocation {
applicationId = 'com.google.android.location'
}
UnifiedNlp {
applicationId = 'org.microg.nlp'
}
}
}
if (file('user.gradle').exists()) {
apply from: 'user.gradle'
}

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2013-2015 µg Project Team
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.microg.nlp.app"
android:versionName="1.4"
android:versionCode="10400">
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="21" />
<application
android:icon="@drawable/ic_nlp_app"
android:allowBackup="true"
android:label="@string/nlp_app_name">
<activity
android:name="org.microg.nlp.ui.SettingsLauncherActivity"
android:icon="@drawable/ic_nlp_settings"
android:label="@string/nlp_app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,55 @@
/*
* Copyright 2013-2015 µg Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.microg.nlp.ui;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
import static android.content.pm.PackageManager.DONT_KILL_APP;
public class SettingsLauncherActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startActivity(new Intent(this, SettingsActivity.class));
finish();
}
public static void setLauncherIconEnabled(Context context, boolean enabled) {
PackageManager pm = context.getPackageManager();
pm.setComponentEnabledSetting(new ComponentName(context, SettingsLauncherActivity.class),
enabled ? COMPONENT_ENABLED_STATE_ENABLED : COMPONENT_ENABLED_STATE_DISABLED,
DONT_KILL_APP);
}
public static void updateLauncherIcon(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (SettingInjectorService.settingsInjectionPossible(context)) {
setLauncherIconEnabled(context, false);
} else {
setLauncherIconEnabled(context, true);
}
}
}
}

View File

@ -0,0 +1,38 @@
/*
Copyright 2013-2015 µg Project Team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
}
}
apply plugin: 'com.android.library'
dependencies {
compile 'com.android.support:support-v4:22.0.0'
compile 'com.android.support:appcompat-v7:22.0.0'
compile project(':unifiednlp-api')
provided project(':unifiednlp-compat')
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
}

View File

@ -15,13 +15,9 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.microg.nlp"
android:versionName="1.3.1"
android:versionCode="10301">
package="org.microg.nlp">
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="21" />
<uses-sdk android:minSdkVersion="9" />
<permission
android:permissionGroup="android.permission-group.LOCATION"
@ -36,10 +32,7 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="org.microg.permission.FORCE_COARSE_LOCATION" />
<application
android:icon="@drawable/ic_nlp_app"
android:allowBackup="true"
android:label="@string/nlp_app_name">
<application>
<uses-library android:name="com.android.location.provider" />
<!-- Gingerbread / Ice Cream Sandwich -->
@ -110,16 +103,6 @@
android:icon="@drawable/ic_nlp_settings"
android:label="@string/nlp_settings_label" />
<activity
android:name=".ui.SettingsLauncherActivity"
android:icon="@drawable/ic_nlp_settings"
android:label="@string/nlp_app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="org.microg.nlp.PackageReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_CHANGED" />

View File

@ -26,6 +26,8 @@ import android.os.IBinder;
import org.microg.nlp.AbstractProviderService;
import org.microg.nlp.ui.SettingInjectorService;
import java.lang.reflect.Method;
import static org.microg.nlp.api.Constants.ACTION_FORCE_LOCATION;
import static org.microg.nlp.api.Constants.ACTION_RELOAD_SETTINGS;
import static org.microg.nlp.api.Constants.INTENT_EXTRA_LOCATION;
@ -91,12 +93,12 @@ public abstract class AbstractLocationService extends AbstractProviderService<Lo
}
private void updateLauncherIcon() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (SettingInjectorService.settingsInjectionPossible(this)) {
SettingInjectorService.setLauncherIconEnabled(this, false);
} else {
SettingInjectorService.setLauncherIconEnabled(this, true);
}
try {
Class cls = Class.forName("org.microg.nlp.ui.SettingsLauncherActivity");
Method updateLauncherIcon = cls.getDeclaredMethod("updateLauncherIcon", Context.class);
updateLauncherIcon.invoke(null, this);
} catch (Exception ignored) {
// This package does not come with a settings launcher icon
}
}
}

View File

@ -23,6 +23,7 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Build;
import android.os.UserHandle;
import android.util.Log;
import java.lang.reflect.InvocationTargetException;
@ -52,25 +53,34 @@ public class SettingInjectorService extends android.location.SettingInjectorServ
return true;
}
public static void setLauncherIconEnabled(Context context, boolean enabled) {
PackageManager pm = context.getPackageManager();
pm.setComponentEnabledSetting(new ComponentName(context, SettingsLauncherActivity.class),
enabled ? COMPONENT_ENABLED_STATE_ENABLED : COMPONENT_ENABLED_STATE_DISABLED,
DONT_KILL_APP);
}
/**
* Dirty method to check whether settings injection is possible on the currently used system
*/
public static boolean settingsInjectionPossible(Context context) {
try {
Context settingsContext = context.createPackageContext("com.android.settings", CONTEXT_INCLUDE_CODE);
ClassLoader cl = settingsContext.getClassLoader();
Class cls = cl.loadClass("com.android.settings.location.SettingsInjector");
Method pSi = cls.getDeclaredMethod("parseServiceInfo", ResolveInfo.class, PackageManager.class);
int pSiVersion;
Method pSi;
try {
pSi = cls.getDeclaredMethod("parseServiceInfo", ResolveInfo.class, PackageManager.class);
pSiVersion = 1;
} catch (NoSuchMethodException e) {
pSi = cls.getDeclaredMethod("parseServiceInfo", ResolveInfo.class, UserHandle.class, PackageManager.class);
pSiVersion = 2;
}
pSi.setAccessible(true);
PackageManager pm = context.getPackageManager();
Intent intent = new Intent(context, SettingInjectorService.class);
List<ResolveInfo> ris = pm.queryIntentServices(intent, GET_META_DATA);
ResolveInfo ri = ris.get(0);
Object result = pSi.invoke(null, ri, pm);
Object result = null;
if (pSiVersion == 1) {
result = pSi.invoke(null, ri, pm);
} else if (pSiVersion == 2) {
result = pSi.invoke(null, ri, android.os.Process.myUserHandle(), pm);
}
if (result != null) {
Log.d(TAG, "Setting injection possible!");
return true;
@ -78,7 +88,7 @@ public class SettingInjectorService extends android.location.SettingInjectorServ
} catch (InvocationTargetException e) {
Log.d(TAG, "settings injection not possible: " + e.getMessage());
} catch (Exception e) {
Log.d(TAG, "Can't determine if settings injection is possible");
Log.w(TAG, "Can't determine if settings injection is possible", e);
}
return false;
}

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 616 B

After

Width:  |  Height:  |  Size: 616 B

View File

Before

Width:  |  Height:  |  Size: 608 B

After

Width:  |  Height:  |  Size: 608 B

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 445 B

After

Width:  |  Height:  |  Size: 445 B

View File

Before

Width:  |  Height:  |  Size: 451 B

After

Width:  |  Height:  |  Size: 451 B

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

Before

Width:  |  Height:  |  Size: 775 B

After

Width:  |  Height:  |  Size: 775 B

View File

Before

Width:  |  Height:  |  Size: 725 B

After

Width:  |  Height:  |  Size: 725 B

View File

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -21,6 +21,6 @@ properties.load(project.rootProject.file('local.properties').newDataInputStream(
def sdkDir = properties.getProperty('sdk.dir')
sourceSets.main {
java.srcDirs = ['current/src', 'v9/src']
compileClasspath += project.rootProject.files("$sdkDir/platforms/android-21/android.jar")
java.srcDirs = ['src/current', 'src/v9']
compileClasspath += project.rootProject.files("$sdkDir/platforms/android-22/android.jar")
}